Getting TLE in second test case

My code looks fine, but I’m getting TLE in second test case. I’m unable to optimize it further, please help!
my code: https://ide.codingblocks.com/s/235797

Your code is fine! use fast I/O
just add this in your main()
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

It didn’t work, still getting TLE!

@devaman1729 I manually checked your code and it worked fine on hackerblocks!
Furthermore I don’t see any possible way to further optimize your code, so don’t worry

Ok, Thanks.
:blush: :blush: