my sol to contest of codeforces