Sample output is correct but not getting output while submitting
Prateek loves Candy
@rhythm9 When the number of test cases is less, your code is working fine.
The problem with your code is that for large number of test cases you are running the prime sieve again and again which is making the process inefficient and exceeding the time limit.
So instead follow this approach:(I have commented out the steps)
Hope this helps
Thanx alot for ur efforts…it worked