Swapping loops makes code performance better!!
Difference between en2 and en3, changed 17 character(s)
Recently i was trying to solve a problem ([ Little Pony and Harmony Chest](http://mirror.codeforces.com/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 to 
messtinker 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://mirror.codeforces.com/contest/453/submission/29219535)↵

[TLE](http://mirror.codeforces.com/contest/453/submission/29219236)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Xahandd 2017-08-05 16:36:35 17
en2 English Xahandd 2017-08-05 16:33:57 23 Tiny change: 'thing.\n\nThe problem was that at first i ' -> 'thing.\n\nAt first i '
en1 English Xahandd 2017-08-05 16:33:32 739 Initial revision (published)