we have two accepted code for 596C:
http://codeforces.me/contest/596/submission/14293038
http://codeforces.me/contest/596/submission/14278646
and a test case:
11 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 3 0 3 1 0 1 -1 2 0 -2 1 -1 0 -2 -3
and two answer :)
NO
YES 0 0 0 1 1 0 0 2 1 1 2 0 1 2 2 1 2 2 3 1 3 0
I have nothing to say.