Trying to solve tasks from codeforces.ru