Niyaz Nigmatullin's submission of ATM | CodeChef