I often run into NZEC errors with SPOJ because of "real world" input data. Most common are empty lines.
And trying to apply int() on empty strings or malformed strings raises an exception. So your code as posted above will raise an error even on ideone:
Traceback (most recent call last):
File "prog.py", line 5, in <module>
a = int(sys.stdin.readline())
ValueError: invalid literal for int() with base 10: '4 2\n'
You are aware of the result of sys.input.readline()? It is a string containing a complete line of input, e.g. '4 2\n'