"Are the conditions 'if(sum%2)' and 'if(sum%2==1)' the same? If not, could you please clarify the matter? If they are the same, I have two submissions, one is accepted (AC) and the other is rejected (WA), but the only difference between them is the use of the two aforementioned conditions. I would be grateful if someone could help me with this." https://codeforces.com/contest/1807/submission/199213689 (Accepted). https://codeforces.com/contest/1807/submission/199213510 (Wrong Answer).

Auto comment: topic has been updated by The..Atomic..Flea (previous revision, new revision, compare).It is possible that the value sum is becoming negative and hence its mod 2 is -1 instead of 1. So if you want to test for even or odd, either check for sum % 2 == -1 or 1, or take mod with absolute value of sum.

PS : I submitted your code with the above changes and it got accepted. This

Hope it Helps.

Yes, I understand the matter. Thank you for such a helpful response.