Help needed

my solution:- https://codeforces.com/contest/1358/submission/81584313
problem Code https://codeforces.com/contest/1358/problem/D

Can anyone help me with this?? I am getting runtime error in testcase 12.