This is the error I am getting while I am submitting the code for this problem , and I am not able to figure out the problem as it is giving correct answer on my computer's compiler (GNU GCC) . If someone can identify the cause of the issue please look after it. Here is the link to my solution: https://codeforces.com/contest/230/submission/98808853
Rewrite
if(soe[t.first] && t.second)
asif(t.second && soe[t.first])
Initialise res value in sqrt_binary function. If the while loop doesn't execute you will have the uninitialized value usage because res was never assigned any value.
The sieve is wrong
Take a look at this line
for(ll j = (ll)i*i ; j <= maxN ; j += i)
, you are starting at $$$i^2$$$ instead of $$$2i$$$.