Python Code Giving NZEC

My code for the Problem : CodeChef: Practical coding for everyone :

is repeatedly giving (NZEC) for the following
solution :
CodeChef: Practical coding for everyone :

Please suggest any optimizations.

This is a live contest question. please ask after contest is over.

oohh!! crap extremely sorry for that!!