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 SPOJ.com - Problem PRIME1 my solution link fNK7GR - Online C++ Compiler & Debugging Tool - Ideone.com

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]