Giving TLE, Please Tell the mistake?

Problem: Prateek Loves Candy

i have many modification in your code
you can check them in modified Code

  1. use bool instead of int in p array
  2. use long long int instead of int
  3. also make size of array= 7400000
    because The 500,000th prime is 7,368,787.

Modified Code

1 Like

Thank you so much for the help, It Worked