time limit exceeded

i am getting time limit exceeded when i try to run my python code for the question https://www.codechef.com/problems/MUFFINS3
my code is https://www.codechef.com/viewsolution/20969843

//