Since I recently started competitive programming, I have summarized the unexpectedly annoying standard input. I will fix the output and other processing later.
Speeding up
import sys
input = sys.stdin.readline
input
apple
orange
10
12.5
a = input()
b = str(input())
c = int(input())
d = float(input())
input
1
2
3
4
5
X = [int(input()) for i in range(5)]
print(X)
output
[1, 2, 3, 4, 5]
input
1 2 3 4 5
A = list(map(int,input().split()))
print(A)
output
[1, 2, 3, 4, 5]
List in 〇〇
List in tuple
l = []
n = int(input())
for i in range(n):
a,b=input().split()
l.append((int(a), b))
List in list(int)
n = int(input())
arr = []
for i in range(n):
arr.append(list(map(int, input().rstrip().split())))
List in list(str)
N = int(input())
arr = [list(map(str, input().split())) for i in range(N)]
Recommended Posts