Please check why my code is giving TLE for test case 0 but passing all the rest
TLE for only testcase 0
Your code can be optimized as 
1.after using prime sieve, simply collect all primes into another array or vector, so now for all test cases you just have to print n-1th index of that array!
eg prime_numbers [ ] = {2,3,5,11,13…}
its working now
Thanks a lot for your help