https://codeforces.com/contest/961/problem/C

Can anyone help me solve this question.