Recently i was trying to solve a problem ([ Little Pony and Harmony Chest](http://codeforces.me/problemset/problem/453/B)) and i encountered a weird thing.↵
↵
At first i tried to solve it and i got TLE and then after some debugging(that came to no conclusion) i just tried tomesstinker with the code to see what happens and then so i swapped two of my loop and MAGICALY the code got AC.↵
↵
Has anyone encountered something like this before? and can anyone explain to me why?↵
↵
these are the codes (you can compare them to see what is their difference):↵
↵
[AC](http://codeforces.me/contest/453/submission/29219535)↵
↵
[TLE](http://codeforces.me/contest/453/submission/29219236)
↵
At first i tried to solve it and i got TLE and then after some debugging(that came to no conclusion) i just tried to
↵
Has anyone encountered something like this before? and can anyone explain to me why?↵
↵
these are the codes (you can compare them to see what is their difference):↵
↵
[AC](http://codeforces.me/contest/453/submission/29219535)↵
↵
[TLE](http://codeforces.me/contest/453/submission/29219236)