i am getting one case wrong :https://ide.codingblocks.com/s/225083
Parteek loves candy
you are getting TLE in the one case because your approach is not efficient, you should make an array of primes while constructing seive such that ith index represents i+1 th prime and then answer each query in O(1)
your code changed accordingly: