I have this code here: https://codeforces.net/contest/444/submission/310588587. It is really weird that:
On custom invocation, it sometimes output 6, then after that it just do -1
The res[id][i] value never seems to be written to the correct value (2), even though I have checked for overflow and the value is correct
On my machine, it output 2 as normal.
Putting res as a global variable fixes the above.
Can anyone explains why this happen, is it a bug in my code or a bug on Codeforces?