Prateek Loves Candies

code Link : https://pastebin.com/dNdufyis
I am getting a tle , please suggest how can I optimise it.

Divya, you are supposed to use the prime seive optimisation technique given in online video lecture under the number theory section of your course, and also make sure that you call the primeseive function that you will make before the test cases only to prevent tle…

CODE LINK : https://pastebin.com/QL3bWP3V
is it ok???

thanks it runs well , I have resloved this doubt.