I recently tried to solve Div 3 D problem and keep on getting Runtime error on 5th case. Not able to figure out the reason behind it.
https://codeforces.net/contest/999/submission/39512943 (link for the submission)
https://codeforces.net/contest/999/problem/D (link for the problem)