Standard input reception & int conversion for paiza and competitive programming.
It is assumed that the input value has a space between them, such as 1 2 3
.
I don't like to use input, so I use sys
. I wonder if it's okay because the execution speed is also faster using sys.
The comparison of execution time is in a separate article. Which is better, python standard input input () or sys.stdin?
For one line.py
data = [int(s) for s in sys.stdin.readline().split()]
For multiple lines.py
data = list()
for l in sys.stdin:
data.append([int(i) for i in l.split()])
#If you write in one line ↓
data = [ [int(s) for s in line.split()] for line in sys.stdin ]