Python 3 - too slow on ACM14KP1 problem

Hello, I have been trying to compare my solution CodeChef: Practical coding for everyone to other python solutions posted for problem CodeChef: Practical coding for everyone but I can’t figure out what is so slow in my program. Any suggestion?
Thanks