I've been solving a few problems on SPOJ.pl using python 3.1.2 and some peoples fast result on simple problems makes me wonder if there is a faster way to handle input and output.
I've tried using
input()
print()
and
sys.stdin.readline()
sys.stdout.write()
or rather
for line in sys.stdin:
#Handle input
sys.stdout.write(output)
to process each line. I've also tried to collect all output in lists and print all at once when everything is processed.
But all of these produce similar execution times.
Is there any faster way to handle input and output from stdin/out?
See Question&Answers more detail:os