The doubt is in the IDE
Hello @Ak07,
The reason of this is written in your code only i.e.
the statement int j = number*number;
the value of number = 1000000(approx), the value of the product will be very large i.e. greater then the range of int and thus the value would be rounded of to a negative number. Thus, leading to segmentation error as you would access a memory address that is not allocated while executing the statement p[j].
Thus, using ll is solving this issue.
Hope, this would help.
Give a like if you are satisfied.