simple prime number generator question on spoj

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

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]