My solution on Codeforces