Getting wrong answer for my code, but test cases approve it. Whats the problem? and any changes that i should make to correct it.

problem link

my solution link

Actually bro in this problem constraints are from 1 ≤ N ≤ 100000. So N can be 1 .

1 is not a prime number( Debatable topic some consider it is prime ).However most of the times constraints for prime number is starts from 2 due to this reason but in this problem 1 is included. Your program is wrong because it is showing 1 as a prime number and producing “yes” in output and also it is time consuming.

link for right solution which can be further optimized I just improved your solution https://www.codechef.com/viewsolution/55468340

Your codewrong output

Your code is too slow. If it will be produced right output then also it will give TLE.

However I am checking for errors in it.