simple prime number generator question on spoj

easy
runtime-error

#1

my solution is correct n efficient but it is showing runtime error whenever i submit any solution on spoj it happens with me. promlem link http://www.spoj.com/problems/PRIME1/ my solution link https://ideone.com/fNK7GR


#2

You have declared long long a[m] but you are accessing the index which is wrong because 0 to m-1 will be available so just make long long a[m+1]