Prateek loves Candy Testcase TLE

I am getting tle in testcase-0, What is wrong with my code:
Here is my code: https://ide.codingblocks.com/s/253119

@gods_eye running a sieve for every test case is not an efficient approach, instead run sieve outside while loop and store your prime numbers in a vector and directly print the required prime number inside while loop.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.