TLE in all but the code works well on Sublime and other IDE

Hi there I tried the same code for Deepak and Primes and the code works there but here it is giving TLE in all testcases.

Could you please check the code below. Thanks

since u need to have the 500000th prime hence the array should be of size 10000001

rest of the code is fine

1<=n<=500000

Greetings of the day @chhavibansal ma’am I tried increasing the size but no success. Could you please help :slight_smile:

Yes @chhavibansal ma’am it was resolved. Was my problem in 'n' in a[n]?

image trying to access the last index as well of the array
and try makinf a[n]

Or @chhavibansal ma’am I feel it’s due to repeated creating sieve in every test case. I think because of it runtime occured.

this + repeated creation of sieve