Prateek loves candy

i have written the code and i am also getting the correct output but still hackerblock sis showing wrong answer i think it is because i am taking input inside the for loop .
kindly tell me the code is : https://ide.codingblocks.com/s/192937

You have to use Prime Sieve in this question.Only then it will pass all the cases. If you do not know about prime sieve, refer to the prime sieve video which must be there in the number theory section of your course.
You can refer this:

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.