I was working on problem D on Round 166 Div 2.
This is my submission which got TLE.
The interesting thing is that I copied the solution above and submitted exactly the same code again, and I got AC.
I submitted the TLE code multiple times, and all of them got AC.
More interestingly, my code outputted the correct solution, but I got TLE. (You can see it by comparing the output for test 8 on those two codes)
Could someone help me figure out how this happened?