python runtime error

I have never coded for such online competitions before.
This code works fine locally.
It works on the test case correctly.
Can you please tell me why am I getting a runtime error on submission?

Here is the problem -

here is my attempt -

You have a Non Zero Return Value for your function (see NZEC error in FAQs)
Try removing the function main() and running it directly in the body of the script or add a return statement.

tried but it didnt help. Same ugly runtime error.