Time limit exceeds

In :bulb: Prateek Loves Candy problem, the outputs are as desired but the time limit is getting exceeded.

The code link is Prateek Loves Candy.

You are getting TLE because you might be constructing sieve(creating array for primes ) for each test case, you are supposed to create sieve once and then use it for every test case.
- Pre-Compute the array i.e - Create the array once and print the answer for each testcase in O(1)