Get all standard inputs used in paiza and competitive programming with int (python)

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 ]

Recommended Posts

Get all standard inputs used in paiza and competitive programming with int (python)
Competitive programming with python
Get standard output in real time with Python subprocess
Get in touch with functional programming in JavaScript or Python 3
Programming with Python and Tkinter
Compare HTTP GET / POST with cURL (command) and Python (programming)
Python3 standard input for competitive programming
Get started with Python in Blender
Get additional data in LDAP with python
Calculate and display standard weight with python
Competitive programming with python Local environment settings
How to get the date and time difference in seconds with python
Dealing with "years and months" in Python
I installed and used Numba with Python3.5
Get and convert the current time in the system local timezone with python
Get Started with TopCoder in Python (2020 Edition)
Competitive Pro with Python and VSCode-Simplification of standard input and automation of sample case judgment-
[Python] Get the files in a folder with Python
Get git branch name and tag name with python
Get Gmail subject and body with Python and Gmail API
Standard .py file used in Python trials (template)-2020
Programming in python
[Python] Building an environment for competitive programming with Atom (input () can be used!) [Mac]
Get media timeline images and videos with Python + Tweepy
Calculation of standard deviation and correlation coefficient in Python
Japanese can be used with Python in Docker environment
Get the result in dict format with Python psycopg2
Get comments on youtube Live with [python] and [pytchat]!
Output log in JSON format with Python standard logging
Get your current location and user agent in Python
Can be used in competition pros! Python standard library
Get mail from Gmail and label it with Python3
Start numerical calculation in Python (with Homebrew and pip)
Tips you should know when programming competitive programming with Python2
Get stock prices and create candlestick charts in Python
[Python] Get user information and article information with Qiita API
Private memos used for list operations and competitive programming
[Redash] Standard library cannot be used in python function
Recursively get the Excel list in a specific folder with python and write it to Excel.
3. 3. AI programming with Python
Competitive programming diary python 20201213
Python programming with Atom
Competitive programming diary python 20201220
Get date in Python
Get date with python
Python programming in Excel
About __all__ in python
Competitive programming diary python
Programming with Python Flask
Design and test Verilog in Python only with Veriloggen and cocotb.
Solving with Ruby and Python AtCoder ABC178 D Dynamic programming
Knowledge you need to know when programming competitive programming with Python2
[For beginners] Summary of standard input in Python (with explanation)
Get the MIME type in Python and determine the file format
Consider If Programming Was An Anime in Python and C
Get rid of dirty data with Python and regular expressions
A standard way to develop and distribute packages in Python
I tried programming the chi-square test in Python and Java.
How to get all the keys and values in the dictionary
Solving with Ruby and Python AtCoder ABC011 C Dynamic programming
Solving with Ruby and Python AtCoder ABC153 E Dynamic programming