So I was giving Codeforces Round #790 Div 4. I solved B (not efficiently) however my code gave wrong ans. After the contest was over I looked for the test case and ran in my personal ide. It worked fine there. It was also running on onliegdb.com
Link to my solution: https://codeforces.com/contest/1676/submission/156648104
I want to know why isn't my code running as intended? Thanks for any help!