Runtime error in segmented seive

I have matched the whole code as given in tutorial of prateek bhaiya for qn Prime generator https://www.spoj.com/problems/PRIME1/

but my submission is giving runtime error .
Please , comment the error in the code

solution link

@Sus
the size of your sieve array p[N] should be N+1 because the loop is till i=N.
Rest code is fine.
Also please mark the doubt as resolved if you don’t have any further query in it.