Pawel Kacprzak's submission of ATM | CodeChef