Whats wrong in my solution

image
beyond integer range
also prime sieve is wrongly written
like u need to first make the entire prime array as 1 ( assume all are prime)
then update the array acc to if they are prime or not
line 16 needs to be p[j] = 0
refer to this code

but i have used long long so no problem of integer range and we can also set all bits as 0 first and for prime no we change it into 1. Is i am wrong??

max size of array u can declare globally is 10^7- 10^8 not beyond that
also the max permissible size within a function is lower hence declare it globally

its fine but u got error in lin e 16 it should be p[j] = 0

updated ur code and added comments