Codeforces Question

Please help me …how to solve this question