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 my solution link


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]