somebody pls explain the gennady approach masha and minions

link for code CodeChef: Practical coding for everyone

didn’t getting his approach , someone pls explain the logic

help @soham1234