Wrong Answer with last subtasks

My code works on 2 subtasks but gives wrong answer on only the last subtask, I cannot post the question itself, since its from a live contest, but I was wondering whether someone with such experiences might give me tips or general mistakes to check for in such a situation.

P.S. I dont think this question violates the rules, but if it does, tell me and I’ll take down the question ASAP.

Sometimes, there is an overflow for large input values and hence some sub-tasks (generally those with larger constraints) might show wrong answer even when your logic is correct.

Taking care of overflow will help prevent WA in many cases! :smiley:

Same is the case with me… Overflow cannot be there because of modulo… Don’t know what I am missing :frowning:

Same with me … Works for all tasks of subtask #1 …but WA for only one task of subtask #2 ??? What to do ?

I have already taken care of overflow by taking modulo, any other suggestions?