Dinesh Goyal's submission of ATM | CodeChef