I was solving a question Weird Sum, I wrote a solution and according to me it was within the constraints. It passed sample test cases on VS code but when I submitted it on the codeforces it gave TLE on the sample test case only. I tried changing the version of G++ and it worked. It got accepted on G++17. However, I cannot understand what my mistake was and what the improvements could be.
(Here's my submission: https://codeforces.me/contest/1648/submission/300963112)