it is showing timelimit in the testcase
Candy problem timelimit
Brother Mention Problem Name
Problem Link
Paste your code on coding blocks IDE and share the link here.
Learn Sieve from here and precompute all primes upto n=1000000 and show the nth prime in the query