node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
85,
2
],
[
88,
8
],
[
88,
17
],
[
20,
19
],
[
86,
23
],
[
79,
26
],
[
79,
35
],
[
82,
37
],
[
74,
43
],
[
71,
43
],
[
77,
44
],
[
77,
46
],
[
89,
50
],
[
92,
50
],
[
80,
51
],
[
80,
53
],
[
70,
55
],
[
83,
57
],
[
77,
58
],
[
91,
60
],
[
83,
62
],
[
80,
63
],
[
71,
67
],
[
74,
67
],
[
92,
68
],
[
89,
68
],
[
70,
71
],
[
88,
74
],
[
79,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
]
] | [
"N = int(input())\nA, B = map(int, input().split())\n\nfor _ in range(N-1):\n T, S = map(int, input().split())\n x = max((A+T-1)//T, (B+S-1)//S)\n A = x*T\n B = x*S\n\nprint(A+B)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A, B = map(int, input().split())",
"A",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"B",
"for _ in range(N-1):\n T, S = map(int, input().split())\n x = max((A+T-1)//T, (B+S-1)//S)\n A = x*T\n B = x*S",
"_",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"T, S = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"S",
"x = max((A+T-1)//T, (B+S-1)//S)",
"x",
"max((A+T-1)//T, (B+S-1)//S)",
"max",
"(A+T-1)//T",
"A+T-1",
"A+T",
"A",
"T",
"1",
"T",
"(B+S-1)//S",
"B+S-1",
"B+S",
"B",
"S",
"1",
"S",
"A = x*T",
"A",
"x*T",
"x",
"T",
"B = x*S",
"B",
"x*S",
"x",
"S",
"print(A+B)",
"print",
"A+B",
"A",
"B",
"A = x*T",
"x*T",
"A",
"A, B = map(int, input().split())",
"map(int, input().split())",
"A",
"T, S = map(int, input().split())",
"map(int, input().split())",
"T",
"S = map(int, input().split())",
"map(int, input().split())",
"S",
"x = max((A+T-1)//T, (B+S-1)//S)",
"max((A+T-1)//T, (B+S-1)//S)",
"x",
"N = int(input())",
"int(input())",
"N",
"B = map(int, input().split())",
"map(int, input().split())",
"B",
"B = x*S",
"x*S",
"B"
] | N = int(input())
A, B = map(int, input().split())
for _ in range(N-1):
T, S = map(int, input().split())
x = max((A+T-1)//T, (B+S-1)//S)
A = x*T
B = x*S
print(A+B)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
28,
13,
4,
13,
17,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
4,
13,
2,
2,
13,
13,
40,
2,
13,
13,
17,
2,
2,
13,
13,
40,
2,
13,
13,
17,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13
] | [
[
94,
2
],
[
10,
9
],
[
9,
18
],
[
91,
20
],
[
91,
22
],
[
25,
24
],
[
95,
28
],
[
32,
31
],
[
31,
40
],
[
100,
42
],
[
100,
44
],
[
97,
46
],
[
89,
51
],
[
104,
51
],
[
101,
52
],
[
89,
55
],
[
104,
55
],
[
101,
56
],
[
92,
60
],
[
86,
60
],
[
83,
61
],
[
92,
64
],
[
86,
64
],
[
83,
65
],
[
103,
68
],
[
101,
70
],
[
98,
71
],
[
85,
72
],
[
83,
74
],
[
98,
75
],
[
104,
79
],
[
89,
79
],
[
86,
80
],
[
92,
80
],
[
100,
83
],
[
85,
86
],
[
91,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
]
] | [
"N = int(input())\nTNow,ANow = (int(T) for T in input().split())\nfor TN in range(1,N):\n TNext,ANext = (int(T) for T in input().split())\n Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))\n TNow,ANow = TNext*Magn,ANext*Magn\nprint(TNow+ANow)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"int(T) for T in input().split()",
"for T in input().split()",
"T",
"input().split()",
"().split",
"()",
"input",
"split",
"for T in input().split()",
"int(T)",
"int",
"T",
"TNow,ANow = (int(T) for T in input().split())",
"TNow",
"(int(T) for T in input().split())",
"ANow",
"for TN in range(1,N):\n TNext,ANext = (int(T) for T in input().split())\n Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))\n TNow,ANow = TNext*Magn,ANext*Magn",
"TN",
"range(1,N)",
"range",
"1",
"N",
"int(T) for T in input().split()",
"for T in input().split()",
"T",
"input().split()",
"().split",
"()",
"input",
"split",
"for T in input().split()",
"int(T)",
"int",
"T",
"TNext,ANext = (int(T) for T in input().split())",
"TNext",
"(int(T) for T in input().split())",
"ANext",
"Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))",
"Magn",
"max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))",
"max",
"TNow//TNext+(TNow%TNext!=0)",
"TNow//TNext",
"TNow",
"TNext",
"TNow%TNext!=0",
"TNow%TNext",
"TNow",
"TNext",
"0",
"ANow//ANext+(ANow%ANext!=0)",
"ANow//ANext",
"ANow",
"ANext",
"ANow%ANext!=0",
"ANow%ANext",
"ANow",
"ANext",
"0",
"TNow,ANow = TNext*Magn,ANext*Magn",
"TNow",
"TNext*Magn",
"TNext",
"Magn",
"ANow",
"ANext*Magn",
"ANext",
"Magn",
"print(TNow+ANow)",
"print",
"TNow+ANow",
"TNow",
"ANow",
"ANext = (int(T) for T in input().split())",
"(int(T) for T in input().split())",
"ANext",
"ANow = TNext*Magn,ANext*Magn",
"ANext*Magn",
"ANow",
"TNow,ANow = (int(T) for T in input().split())",
"(int(T) for T in input().split())",
"TNow",
"ANow = (int(T) for T in input().split())",
"(int(T) for T in input().split())",
"ANow",
"N = int(input())",
"int(input())",
"N",
"Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))",
"max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))",
"Magn",
"TNext,ANext = (int(T) for T in input().split())",
"(int(T) for T in input().split())",
"TNext",
"TNow,ANow = TNext*Magn,ANext*Magn",
"TNext*Magn",
"TNow"
] | N = int(input())
TNow,ANow = (int(T) for T in input().split())
for TN in range(1,N):
TNext,ANext = (int(T) for T in input().split())
Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))
TNow,ANow = TNext*Magn,ANext*Magn
print(TNow+ANow) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
13,
2,
13,
13,
13,
0,
13,
2,
2,
2,
2,
13,
13,
13,
13,
13,
14,
40,
13,
17,
0,
13,
13,
0,
13,
13,
0,
13,
40,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
0,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
40,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13
] | [
[
121,
2
],
[
100,
8
],
[
100,
17
],
[
20,
19
],
[
122,
23
],
[
124,
26
],
[
124,
35
],
[
127,
37
],
[
95,
40
],
[
101,
42
],
[
119,
42
],
[
134,
42
],
[
95,
43
],
[
95,
44
],
[
103,
46
],
[
101,
51
],
[
119,
51
],
[
134,
51
],
[
128,
52
],
[
113,
52
],
[
125,
53
],
[
95,
54
],
[
98,
55
],
[
116,
55
],
[
131,
55
],
[
104,
58
],
[
107,
58
],
[
133,
61
],
[
128,
62
],
[
113,
62
],
[
130,
64
],
[
104,
65
],
[
107,
65
],
[
109,
67
],
[
104,
70
],
[
107,
70
],
[
125,
71
],
[
112,
73
],
[
110,
75
],
[
19,
75
],
[
95,
76
],
[
106,
78
],
[
110,
80
],
[
19,
80
],
[
125,
81
],
[
118,
83
],
[
113,
84
],
[
128,
84
],
[
115,
86
],
[
107,
87
],
[
104,
87
],
[
116,
91
],
[
131,
91
],
[
98,
91
],
[
119,
92
],
[
134,
92
],
[
101,
92
],
[
124,
95
],
[
100,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
107,
115
],
[
104,
115
],
[
115,
116
],
[
113,
118
],
[
128,
118
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
],
[
104,
130
],
[
107,
130
],
[
130,
131
],
[
128,
133
],
[
113,
133
],
[
133,
134
]
] | [
"N = int(input())\n\nT, A = map(int, input().split())\n\nfor i in range(N-1):\n t, a = map(int, input().split())\n da = (a - A%a)%a\n dt = (A + da)*t//a - T\n if dt >= 0:\n A += da\n T += dt\n else:\n i = -(dt // t)\n da += i*a\n dt += i*t\n A += da\n T += dt\n\nprint(T + A)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T, A = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"for i in range(N-1):\n t, a = map(int, input().split())\n da = (a - A%a)%a\n dt = (A + da)*t//a - T\n if dt >= 0:\n A += da\n T += dt\n else:\n i = -(dt // t)\n da += i*a\n dt += i*t\n A += da\n T += dt",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"da = (a - A%a)%a",
"da",
"(a - A%a)%a",
"a - A%a",
"a",
"A%a",
"A",
"a",
"a",
"dt = (A + da)*t//a - T",
"dt",
"(A + da)*t//a - T",
"(A + da)*t//a",
"(A + da)*t",
"A + da",
"A",
"da",
"t",
"a",
"T",
"if dt >= 0:\n A += da\n T += dt\n else:\n i = -(dt // t)\n da += i*a\n dt += i*t\n A += da\n T += dt",
"dt >= 0",
"dt",
"0",
"A += da",
"A",
"da",
"T += dt",
"T",
"dt",
"i = -(dt // t)",
"i",
"-(dt // t)",
"dt // t",
"dt",
"t",
"da += i*a",
"da",
"i*a",
"i",
"a",
"dt += i*t",
"dt",
"i*t",
"i",
"t",
"A += da",
"A",
"da",
"T += dt",
"T",
"dt",
"print(T + A)",
"print",
"T + A",
"T",
"A",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"T, A = map(int, input().split())",
"map(int, input().split())",
"T",
"A = map(int, input().split())",
"map(int, input().split())",
"A",
"dt = (A + da)*t//a - T",
"(A + da)*t//a - T",
"dt",
"dt += i*t",
"i*t",
"dt",
"i = -(dt // t)",
"-(dt // t)",
"i",
"da += i*a",
"i*a",
"da",
"T += dt",
"dt",
"T",
"A += da",
"da",
"A",
"N = int(input())",
"int(input())",
"N",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"da = (a - A%a)%a",
"(a - A%a)%a",
"da",
"T += dt",
"dt",
"T",
"A += da",
"da",
"A"
] | N = int(input())
T, A = map(int, input().split())
for i in range(N-1):
t, a = map(int, input().split())
da = (a - A%a)%a
dt = (A + da)*t//a - T
if dt >= 0:
A += da
T += dt
else:
i = -(dt // t)
da += i*a
dt += i*t
A += da
T += dt
print(T + A) |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
4,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13
] | [
[
94,
4
],
[
88,
10
],
[
95,
14
],
[
109,
16
],
[
95,
20
],
[
23,
22
],
[
95,
25
],
[
30,
27
],
[
89,
28
],
[
22,
29
],
[
30,
38
],
[
110,
39
],
[
22,
40
],
[
103,
42
],
[
106,
45
],
[
89,
52
],
[
110,
53
],
[
91,
55
],
[
104,
61
],
[
98,
61
],
[
107,
68
],
[
101,
68
],
[
97,
73
],
[
92,
75
],
[
95,
75
],
[
100,
78
],
[
92,
80
],
[
95,
80
],
[
98,
85
],
[
104,
85
],
[
101,
86
],
[
107,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
]
] | [
"import math\nn = int(input())\nT = [0]*n\nA = [0]*n\nfor i in range(n):\n T[i], A[i] = map(int,input().split())\n\na = 1\nb = 1\nfor ti, ai in zip(T,A):\n #n = max(math.ceil(a/ti),math.ceil(b/ai))\n n = max((a+ti-1)//ti,(b+ai-1)//ai)\n a = n*ti\n b = n*ai\n #print(a,b)\nprint(a+b)",
"import math",
"math",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"T = [0]*n",
"T",
"[0]*n",
"[0]",
"0",
"n",
"A = [0]*n",
"A",
"[0]*n",
"[0]",
"0",
"n",
"for i in range(n):\n T[i], A[i] = map(int,input().split())",
"i",
"range(n)",
"range",
"n",
"T[i], A[i] = map(int,input().split())",
"T[i]",
"T",
"i",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A[i]",
"A",
"i",
"a = 1",
"a",
"1",
"b = 1",
"b",
"1",
"for ti, ai in zip(T,A):\n #n = max(math.ceil(a/ti),math.ceil(b/ai))\n n = max((a+ti-1)//ti,(b+ai-1)//ai)\n a = n*ti\n b = n*ai\n #print(a,b)",
"ti",
"ai",
"zip(T,A)",
"zip",
"T",
"A",
"n = max((a+ti-1)//ti,(b+ai-1)//ai)",
"n",
"max((a+ti-1)//ti,(b+ai-1)//ai)",
"max",
"(a+ti-1)//ti",
"a+ti-1",
"a+ti",
"a",
"ti",
"1",
"ti",
"(b+ai-1)//ai",
"b+ai-1",
"b+ai",
"b",
"ai",
"1",
"ai",
"a = n*ti",
"a",
"n*ti",
"n",
"ti",
"b = n*ai",
"b",
"n*ai",
"n",
"ai",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"T = [0]*n",
"[0]*n",
"T",
"n = max((a+ti-1)//ti,(b+ai-1)//ai)",
"max((a+ti-1)//ti,(b+ai-1)//ai)",
"n",
"n = int(input())",
"int(input())",
"n",
"a = n*ti",
"n*ti",
"a",
"b = n*ai",
"n*ai",
"b",
"a = 1",
"1",
"a",
"b = 1",
"1",
"b",
"A = [0]*n",
"[0]*n",
"A"
] | import math
n = int(input())
T = [0]*n
A = [0]*n
for i in range(n):
T[i], A[i] = map(int,input().split())
a = 1
b = 1
for ti, ai in zip(T,A):
#n = max(math.ceil(a/ti),math.ceil(b/ai))
n = max((a+ti-1)//ti,(b+ai-1)//ai)
a = n*ti
b = n*ai
#print(a,b)
print(a+b) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
2,
13,
2,
13,
17,
13,
13,
0,
13,
2,
2,
2,
13,
2,
13,
17,
13,
13,
14,
2,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
13,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13
] | [
[
81,
2
],
[
93,
8
],
[
90,
10
],
[
14,
13
],
[
82,
16
],
[
87,
18
],
[
87,
27
],
[
99,
29
],
[
94,
33
],
[
79,
33
],
[
100,
33
],
[
88,
35
],
[
88,
37
],
[
88,
38
],
[
102,
40
],
[
91,
44
],
[
97,
44
],
[
103,
44
],
[
85,
46
],
[
85,
48
],
[
85,
49
],
[
103,
52
],
[
91,
52
],
[
97,
52
],
[
100,
55
],
[
94,
55
],
[
79,
55
],
[
85,
56
],
[
88,
57
],
[
96,
59
],
[
100,
62
],
[
94,
62
],
[
79,
62
],
[
85,
63
],
[
88,
64
],
[
78,
66
],
[
103,
69
],
[
91,
69
],
[
97,
69
],
[
88,
70
],
[
85,
71
],
[
97,
75
],
[
103,
75
],
[
91,
75
],
[
79,
76
],
[
100,
76
],
[
94,
76
],
[
78,
79
],
[
81,
82
],
[
87,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
]
] | [
"N = int(input())\n\nt, a = 1, 1\nfor _ in range(N):\n T, A = map(int, input().split())\n t = (t + (T - 1)) // T * T\n a = (a + (A - 1)) // A * A\n if a < t * A // T:\n a = t * A // T\n else:\n t = a * T // A\nprint(a + t)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"t, a = 1, 1",
"t",
"1",
"a",
"1",
"for _ in range(N):\n T, A = map(int, input().split())\n t = (t + (T - 1)) // T * T\n a = (a + (A - 1)) // A * A\n if a < t * A // T:\n a = t * A // T\n else:\n t = a * T // A",
"_",
"range(N)",
"range",
"N",
"T, A = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"t = (t + (T - 1)) // T * T",
"t",
"(t + (T - 1)) // T * T",
"(t + (T - 1)) // T",
"t + (T - 1)",
"t",
"T - 1",
"T",
"1",
"T",
"T",
"a = (a + (A - 1)) // A * A",
"a",
"(a + (A - 1)) // A * A",
"(a + (A - 1)) // A",
"a + (A - 1)",
"a",
"A - 1",
"A",
"1",
"A",
"A",
"if a < t * A // T:\n a = t * A // T\n else:\n t = a * T // A",
"a < t * A // T",
"a",
"t * A // T",
"t * A",
"t",
"A",
"T",
"a = t * A // T",
"a",
"t * A // T",
"t * A",
"t",
"A",
"T",
"t = a * T // A",
"t",
"a * T // A",
"a * T",
"a",
"T",
"A",
"print(a + t)",
"print",
"a + t",
"a",
"t",
"t = a * T // A",
"a * T // A",
"t",
"N = int(input())",
"int(input())",
"N",
"A = map(int, input().split())",
"map(int, input().split())",
"A",
"T, A = map(int, input().split())",
"map(int, input().split())",
"T",
"a = 1, 1",
"1",
"a",
"t, a = 1, 1",
"1",
"t",
"a = t * A // T",
"t * A // T",
"a",
"t = (t + (T - 1)) // T * T",
"(t + (T - 1)) // T * T",
"t",
"a = (a + (A - 1)) // A * A",
"(a + (A - 1)) // A * A",
"a"
] | N = int(input())
t, a = 1, 1
for _ in range(N):
T, A = map(int, input().split())
t = (t + (T - 1)) // T * T
a = (a + (A - 1)) // A * A
if a < t * A // T:
a = t * A // T
else:
t = a * T // A
print(a + t) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
2,
17,
2,
2,
17,
13,
18,
13,
17,
2,
17,
2,
2,
17,
13,
18,
13,
17,
0,
13,
2,
18,
13,
17,
13,
13,
2,
18,
13,
17,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
76,
2
],
[
70,
8
],
[
79,
10
],
[
14,
13
],
[
77,
16
],
[
73,
18
],
[
82,
30
],
[
71,
38
],
[
86,
38
],
[
74,
40
],
[
80,
47
],
[
89,
47
],
[
74,
49
],
[
85,
52
],
[
74,
55
],
[
83,
57
],
[
88,
58
],
[
74,
61
],
[
83,
63
],
[
86,
67
],
[
71,
67
],
[
89,
68
],
[
80,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
]
] | [
"N=int(input())\nA,B=1,1\nfor i in range(N):\n tmpl=list(map(int,input().split()))\n tmp=max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))\n A,B=tmpl[0]*tmp,tmpl[1]*tmp\nprint(A+B)",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A,B=1,1",
"A",
"1",
"B",
"1",
"for i in range(N):\n tmpl=list(map(int,input().split()))\n tmp=max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))\n A,B=tmpl[0]*tmp,tmpl[1]*tmp",
"i",
"range(N)",
"range",
"N",
"tmpl=list(map(int,input().split()))",
"tmpl",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"tmp=max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))",
"tmp",
"max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))",
"max",
"-1*(-1*A//tmpl[0])",
"-1",
"-1*A//tmpl[0]",
"-1*A",
"-1",
"A",
"tmpl[0]",
"tmpl",
"0",
"-1*(-1*B//tmpl[1])",
"-1",
"-1*B//tmpl[1]",
"-1*B",
"-1",
"B",
"tmpl[1]",
"tmpl",
"1",
"A,B=tmpl[0]*tmp,tmpl[1]*tmp",
"A",
"tmpl[0]*tmp",
"tmpl[0]",
"tmpl",
"0",
"tmp",
"B",
"tmpl[1]*tmp",
"tmpl[1]",
"tmpl",
"1",
"tmp",
"print(A+B)",
"print",
"A+B",
"A",
"B",
"A,B=1,1",
"1",
"A",
"tmpl=list(map(int,input().split()))",
"list(map(int,input().split()))",
"tmpl",
"N=int(input())",
"int(input())",
"N",
"B=1,1",
"1",
"B",
"tmp=max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))",
"max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))",
"tmp",
"A,B=tmpl[0]*tmp,tmpl[1]*tmp",
"tmpl[0]*tmp",
"A",
"B=tmpl[0]*tmp,tmpl[1]*tmp",
"tmpl[1]*tmp",
"B"
] | N=int(input())
A,B=1,1
for i in range(N):
tmpl=list(map(int,input().split()))
tmp=max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))
A,B=tmpl[0]*tmp,tmpl[1]*tmp
print(A+B) |
[
7,
15,
0,
13,
4,
13,
4,
18,
4,
18,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
13,
13,
13,
13,
0,
13,
13,
0,
13,
18,
18,
13,
17,
17,
13,
18,
18,
13,
17,
17,
28,
13,
4,
13,
17,
13,
0,
13,
18,
18,
13,
13,
17,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
18,
13,
10,
18,
13,
10,
18,
13,
10,
2,
13,
10,
18,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
121,
3
],
[
16,
15
],
[
122,
18
],
[
115,
36
],
[
106,
39
],
[
116,
42
],
[
100,
45
],
[
116,
48
],
[
53,
52
],
[
122,
56
],
[
112,
58
],
[
116,
61
],
[
52,
62
],
[
103,
64
],
[
116,
67
],
[
52,
68
],
[
124,
71
],
[
107,
77
],
[
110,
77
],
[
113,
78
],
[
101,
82
],
[
119,
82
],
[
104,
83
],
[
109,
85
],
[
125,
87
],
[
113,
88
],
[
118,
90
],
[
125,
92
],
[
104,
93
],
[
110,
97
],
[
107,
97
],
[
119,
98
],
[
101,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
]
] | [
"from sys import stdin\n\nn = int(stdin.readline().rstrip())\nli = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]\nA,B = li[0][0],li[0][1]\nfor i in range(1,n):\n a,b = li[i][0],li[i][1]\n bai = max(-(-A//a),-(-B//b))\n A = bai*a\n B = bai*b\nprint(A+B)",
"from sys import stdin",
"n = int(stdin.readline().rstrip())",
"n",
"int(stdin.readline().rstrip())",
"int",
"stdin.readline().rstrip()",
"stdin.readline().rstrip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"rstrip",
"list(map(int,stdin.readline().rstrip().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int,stdin.readline().rstrip().split()))",
"list",
"map(int,stdin.readline().rstrip().split())",
"map",
"int",
"stdin.readline().rstrip().split()",
"stdin.readline().rstrip().split",
"stdin.readline().rstrip()",
"stdin.readline().rstrip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"rstrip",
"split",
"li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]",
"li",
"[list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]",
"A,B = li[0][0],li[0][1]",
"A",
"li[0][0]",
"[0]",
"li",
"0",
"0",
"B",
"li[0][1]",
"[0]",
"li",
"0",
"1",
"for i in range(1,n):\n a,b = li[i][0],li[i][1]\n bai = max(-(-A//a),-(-B//b))\n A = bai*a\n B = bai*b",
"i",
"range(1,n)",
"range",
"1",
"n",
"a,b = li[i][0],li[i][1]",
"a",
"li[i][0]",
"[i]",
"li",
"i",
"0",
"b",
"li[i][1]",
"[i]",
"li",
"i",
"1",
"bai = max(-(-A//a),-(-B//b))",
"bai",
"max(-(-A//a),-(-B//b))",
"max",
"-(-A//a)",
"-A//a",
"-A",
"A",
"a",
"-(-B//b)",
"-B//b",
"-B",
"B",
"b",
"A = bai*a",
"A",
"bai*a",
"bai",
"a",
"B = bai*b",
"B",
"bai*b",
"bai",
"b",
"print(A+B)",
"print",
"A+B",
"A",
"B",
"B = li[0][0],li[0][1]",
"li[0][1]",
"B",
"b = li[i][0],li[i][1]",
"li[i][1]",
"b",
"A,B = li[0][0],li[0][1]",
"li[0][0]",
"A",
"A = bai*a",
"bai*a",
"A",
"a,b = li[i][0],li[i][1]",
"li[i][0]",
"a",
"li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]",
"[list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]",
"li",
"B = bai*b",
"bai*b",
"B",
"n = int(stdin.readline().rstrip())",
"int(stdin.readline().rstrip())",
"n",
"bai = max(-(-A//a),-(-B//b))",
"max(-(-A//a),-(-B//b))",
"bai"
] | from sys import stdin
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
A,B = li[0][0],li[0][1]
for i in range(1,n):
a,b = li[i][0],li[i][1]
bai = max(-(-A//a),-(-B//b))
A = bai*a
B = bai*b
print(A+B) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
18,
13,
17,
17,
0,
13,
18,
18,
13,
17,
17,
28,
13,
4,
13,
17,
13,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13,
10,
13,
13,
10,
18,
13,
10,
18,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13
] | [
[
95,
2
],
[
10,
9
],
[
96,
12
],
[
104,
25
],
[
98,
28
],
[
105,
31
],
[
101,
35
],
[
105,
38
],
[
43,
42
],
[
96,
46
],
[
107,
48
],
[
105,
51
],
[
42,
52
],
[
110,
55
],
[
105,
58
],
[
42,
59
],
[
116,
62
],
[
108,
68
],
[
99,
69
],
[
120,
69
],
[
108,
71
],
[
111,
75
],
[
102,
76
],
[
114,
76
],
[
111,
78
],
[
119,
80
],
[
117,
82
],
[
108,
83
],
[
113,
85
],
[
117,
87
],
[
111,
88
],
[
120,
92
],
[
99,
92
],
[
114,
93
],
[
102,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
]
] | [
"N = int(input())\nTA = [list(map(int, input().split())) for i in range(N)]\n\n\nt_votes = TA[0][0]\na_votes = TA[0][1]\nfor n in range(1, N):\n t_ratio = TA[n][0]\n a_ratio = TA[n][1]\n # coeff = 1\n # while TA[n][0] * coeff < t_votes or TA[n][1] * coeff < a_votes:\n # coeff += 1\n # ↓\n coeff = max((t_ratio + t_votes - 1) // t_ratio,\n (a_ratio + a_votes - 1) // a_ratio)\n\n t_votes = coeff * t_ratio\n a_votes = coeff * a_ratio\n\nprint(t_votes + a_votes)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for i in range(N)]",
"TA",
"[list(map(int, input().split())) for i in range(N)]",
"t_votes = TA[0][0]",
"t_votes",
"TA[0][0]",
"[0]",
"TA",
"0",
"0",
"a_votes = TA[0][1]",
"a_votes",
"TA[0][1]",
"[0]",
"TA",
"0",
"1",
"for n in range(1, N):\n t_ratio = TA[n][0]\n a_ratio = TA[n][1]\n # coeff = 1\n # while TA[n][0] * coeff < t_votes or TA[n][1] * coeff < a_votes:\n # coeff += 1\n # ↓\n coeff = max((t_ratio + t_votes - 1) // t_ratio,\n (a_ratio + a_votes - 1) // a_ratio)\n\n t_votes = coeff * t_ratio\n a_votes = coeff * a_ratio",
"n",
"range(1, N)",
"range",
"1",
"N",
"t_ratio = TA[n][0]",
"t_ratio",
"TA[n][0]",
"[n]",
"TA",
"n",
"0",
"a_ratio = TA[n][1]",
"a_ratio",
"TA[n][1]",
"[n]",
"TA",
"n",
"1",
"coeff = max((t_ratio + t_votes - 1) // t_ratio,\n (a_ratio + a_votes - 1) // a_ratio)",
"coeff",
"max((t_ratio + t_votes - 1) // t_ratio,\n (a_ratio + a_votes - 1) // a_ratio)",
"max",
"(t_ratio + t_votes - 1) // t_ratio",
"t_ratio + t_votes - 1",
"t_ratio + t_votes",
"t_ratio",
"t_votes",
"1",
"t_ratio",
"(a_ratio + a_votes - 1) // a_ratio",
"a_ratio + a_votes - 1",
"a_ratio + a_votes",
"a_ratio",
"a_votes",
"1",
"a_ratio",
"t_votes = coeff * t_ratio",
"t_votes",
"coeff * t_ratio",
"coeff",
"t_ratio",
"a_votes = coeff * a_ratio",
"a_votes",
"coeff * a_ratio",
"coeff",
"a_ratio",
"print(t_votes + a_votes)",
"print",
"t_votes + a_votes",
"t_votes",
"a_votes",
"N = int(input())",
"int(input())",
"N",
"t_votes = TA[0][0]",
"TA[0][0]",
"t_votes",
"a_votes = TA[0][1]",
"TA[0][1]",
"a_votes",
"TA = [list(map(int, input().split())) for i in range(N)]",
"[list(map(int, input().split())) for i in range(N)]",
"TA",
"t_ratio = TA[n][0]",
"TA[n][0]",
"t_ratio",
"a_ratio = TA[n][1]",
"TA[n][1]",
"a_ratio",
"a_votes = coeff * a_ratio",
"coeff * a_ratio",
"a_votes",
"coeff = max((t_ratio + t_votes - 1) // t_ratio,\n (a_ratio + a_votes - 1) // a_ratio)",
"max((t_ratio + t_votes - 1) // t_ratio,\n (a_ratio + a_votes - 1) // a_ratio)",
"coeff",
"t_votes = coeff * t_ratio",
"coeff * t_ratio",
"t_votes"
] | N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]
t_votes = TA[0][0]
a_votes = TA[0][1]
for n in range(1, N):
t_ratio = TA[n][0]
a_ratio = TA[n][1]
# coeff = 1
# while TA[n][0] * coeff < t_votes or TA[n][1] * coeff < a_votes:
# coeff += 1
# ↓
coeff = max((t_ratio + t_votes - 1) // t_ratio,
(a_ratio + a_votes - 1) // a_ratio)
t_votes = coeff * t_ratio
a_votes = coeff * a_ratio
print(t_votes + a_votes) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
13,
18,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
18,
13,
10,
39,
13,
10,
17,
13,
10,
17,
13,
10,
39,
13
] | [
[
91,
2
],
[
124,
8
],
[
115,
10
],
[
14,
13
],
[
92,
16
],
[
109,
18
],
[
109,
27
],
[
125,
30
],
[
104,
32
],
[
116,
35
],
[
110,
37
],
[
118,
39
],
[
121,
41
],
[
45,
44
],
[
92,
47
],
[
94,
49
],
[
125,
51
],
[
44,
52
],
[
112,
53
],
[
116,
55
],
[
44,
56
],
[
100,
58
],
[
119,
64
],
[
98,
64
],
[
95,
65
],
[
104,
65
],
[
95,
67
],
[
104,
67
],
[
122,
71
],
[
107,
71
],
[
113,
72
],
[
110,
72
],
[
113,
74
],
[
110,
74
],
[
97,
76
],
[
101,
78
],
[
92,
78
],
[
95,
79
],
[
104,
79
],
[
106,
81
],
[
101,
83
],
[
92,
83
],
[
113,
84
],
[
110,
84
],
[
98,
88
],
[
119,
88
],
[
107,
89
],
[
122,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
109,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
]
] | [
"n = int(input())\nt_lst, a_lst = [], []\nfor i in range(n):\n ti, ai = map(int, input().split())\n t_lst.append(ti)\n a_lst.append(ai)\n\nt, a = 1, 1\nfor i in range(n):\n ti, ai = t_lst[i], a_lst[i]\n n = max((t+ti-1)//ti, (a+ai-1)//ai)\n t = n*ti\n a = n*ai\nprint(t+a)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"t_lst, a_lst = [], []",
"t_lst",
"[]",
"a_lst",
"[]",
"for i in range(n):\n ti, ai = map(int, input().split())\n t_lst.append(ti)\n a_lst.append(ai)",
"i",
"range(n)",
"range",
"n",
"ti, ai = map(int, input().split())",
"ti",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ai",
"t_lst.append(ti)",
"t_lst.append",
"t_lst",
"append",
"ti",
"a_lst.append(ai)",
"a_lst.append",
"a_lst",
"append",
"ai",
"t, a = 1, 1",
"t",
"1",
"a",
"1",
"for i in range(n):\n ti, ai = t_lst[i], a_lst[i]\n n = max((t+ti-1)//ti, (a+ai-1)//ai)\n t = n*ti\n a = n*ai",
"i",
"range(n)",
"range",
"n",
"ti, ai = t_lst[i], a_lst[i]",
"ti",
"t_lst[i]",
"t_lst",
"i",
"ai",
"a_lst[i]",
"a_lst",
"i",
"n = max((t+ti-1)//ti, (a+ai-1)//ai)",
"n",
"max((t+ti-1)//ti, (a+ai-1)//ai)",
"max",
"(t+ti-1)//ti",
"t+ti-1",
"t+ti",
"t",
"ti",
"1",
"ti",
"(a+ai-1)//ai",
"a+ai-1",
"a+ai",
"a",
"ai",
"1",
"ai",
"t = n*ti",
"t",
"n*ti",
"n",
"ti",
"a = n*ai",
"a",
"n*ai",
"n",
"ai",
"print(t+a)",
"print",
"t+a",
"t",
"a",
"n = int(input())",
"int(input())",
"n",
"ti, ai = t_lst[i], a_lst[i]",
"t_lst[i]",
"ti",
"t = n*ti",
"n*ti",
"t",
"n = max((t+ti-1)//ti, (a+ai-1)//ai)",
"max((t+ti-1)//ti, (a+ai-1)//ai)",
"n",
"ti, ai = map(int, input().split())",
"map(int, input().split())",
"ti",
"a = n*ai",
"n*ai",
"a",
"ai = map(int, input().split())",
"map(int, input().split())",
"ai",
"ai = t_lst[i], a_lst[i]",
"a_lst[i]",
"ai",
"a_lst = [], []",
"[]",
"a_lst",
"t, a = 1, 1",
"1",
"t",
"a = 1, 1",
"1",
"a",
"t_lst, a_lst = [], []",
"[]",
"t_lst"
] | n = int(input())
t_lst, a_lst = [], []
for i in range(n):
ti, ai = map(int, input().split())
t_lst.append(ti)
a_lst.append(ai)
t, a = 1, 1
for i in range(n):
ti, ai = t_lst[i], a_lst[i]
n = max((t+ti-1)//ti, (a+ai-1)//ai)
t = n*ti
a = n*ai
print(t+a) |
[
7,
12,
13,
15,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
12,
11
],
[
14,
13
],
[
17,
16
],
[
5,
19
],
[
22,
21
],
[
22,
30
],
[
33,
32
],
[
11,
38
],
[
50,
38
],
[
21,
39
],
[
21,
41
],
[
13,
45
],
[
54,
45
],
[
30,
46
],
[
30,
48
],
[
51,
50
],
[
32,
52
],
[
21,
53
],
[
55,
54
],
[
32,
56
],
[
30,
57
],
[
50,
61
],
[
11,
61
],
[
54,
62
],
[
13,
62
],
[
71,
68
]
] | [
"def main():\n from math import ceil\n n = int(input())\n a, b = 1, 1\n for _ in range(n):\n i, j = map(int, input().split())\n x = max((a + i - 1) // i, (b + j - 1) // j)\n a, b = x * i, x * j\n print(a + b)\n\n\nif __name__ == '__main__':\n main()",
"def main():\n from math import ceil\n n = int(input())\n a, b = 1, 1\n for _ in range(n):\n i, j = map(int, input().split())\n x = max((a + i - 1) // i, (b + j - 1) // j)\n a, b = x * i, x * j\n print(a + b)",
"main",
"from math import ceil",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a, b = 1, 1",
"a",
"1",
"b",
"1",
"for _ in range(n):\n i, j = map(int, input().split())\n x = max((a + i - 1) // i, (b + j - 1) // j)\n a, b = x * i, x * j\n ",
"_",
"range(n)",
"range",
"n",
"i, j = map(int, input().split())",
"i",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"j",
"x = max((a + i - 1) // i, (b + j - 1) // j)",
"x",
"max((a + i - 1) // i, (b + j - 1) // j)",
"max",
"(a + i - 1) // i",
"a + i - 1",
"a + i",
"a",
"i",
"1",
"i",
"(b + j - 1) // j",
"b + j - 1",
"b + j",
"b",
"j",
"1",
"j",
"a, b = x * i, x * j",
"a",
"x * i",
"x",
"i",
"b",
"x * j",
"x",
"j",
"print(a + b)",
"print",
"a + b",
"a",
"b",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n from math import ceil\n n = int(input())\n a, b = 1, 1\n for _ in range(n):\n i, j = map(int, input().split())\n x = max((a + i - 1) // i, (b + j - 1) // j)\n a, b = x * i, x * j\n print(a + b)",
"def main():\n from math import ceil\n n = int(input())\n a, b = 1, 1\n for _ in range(n):\n i, j = map(int, input().split())\n x = max((a + i - 1) // i, (b + j - 1) // j)\n a, b = x * i, x * j\n print(a + b)",
"main"
] | def main():
from math import ceil
n = int(input())
a, b = 1, 1
for _ in range(n):
i, j = map(int, input().split())
x = max((a + i - 1) // i, (b + j - 1) // j)
a, b = x * i, x * j
print(a + b)
if __name__ == '__main__':
main()
|
[
7,
15,
0,
13,
4,
13,
4,
13,
0,
13,
39,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
40,
18,
13,
13,
13,
40,
18,
13,
13,
13,
0,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
18,
13,
13,
18,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
13,
0,
13,
40,
2,
40,
13,
18,
13,
13,
0,
13,
40,
2,
40,
13,
18,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
18,
13,
13,
13,
0,
13,
2,
18,
13,
13,
13,
0,
13,
4,
13,
2,
13,
13,
4,
13,
13,
10,
4,
13,
10,
13,
13,
10,
39,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
40,
13,
10,
2,
13,
10,
18,
13,
10,
40,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
138,
3
],
[
147,
9
],
[
144,
11
],
[
15,
14
],
[
139,
17
],
[
186,
19
],
[
186,
28
],
[
148,
31
],
[
187,
33
],
[
145,
36
],
[
154,
38
],
[
150,
40
],
[
159,
43
],
[
47,
46
],
[
139,
49
],
[
148,
54
],
[
46,
55
],
[
151,
56
],
[
166,
56
],
[
184,
56
],
[
181,
56
],
[
145,
59
],
[
46,
60
],
[
160,
61
],
[
157,
61
],
[
142,
61
],
[
169,
61
],
[
180,
63
],
[
148,
65
],
[
46,
66
],
[
168,
68
],
[
145,
70
],
[
46,
71
],
[
148,
75
],
[
46,
76
],
[
145,
78
],
[
46,
79
],
[
183,
81
],
[
151,
84
],
[
166,
84
],
[
184,
84
],
[
181,
84
],
[
160,
85
],
[
157,
85
],
[
142,
85
],
[
169,
85
],
[
141,
87
],
[
184,
88
],
[
151,
88
],
[
166,
88
],
[
181,
88
],
[
162,
90
],
[
151,
94
],
[
166,
94
],
[
184,
94
],
[
181,
94
],
[
148,
96
],
[
46,
97
],
[
171,
99
],
[
160,
103
],
[
157,
103
],
[
142,
103
],
[
169,
103
],
[
145,
105
],
[
46,
106
],
[
174,
108
],
[
163,
111
],
[
172,
112
],
[
165,
114
],
[
148,
117
],
[
46,
118
],
[
175,
119
],
[
156,
121
],
[
145,
124
],
[
46,
125
],
[
175,
126
],
[
177,
128
],
[
166,
132
],
[
184,
132
],
[
181,
132
],
[
151,
132
],
[
157,
133
],
[
142,
133
],
[
169,
133
],
[
160,
133
],
[
178,
136
],
[
138,
139
],
[
184,
141
],
[
151,
141
],
[
166,
141
],
[
181,
141
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
186,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
],
[
165,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
186,
187
]
] | [
"from decimal import *\n\nn = int(input())\nT, A = [], []\nfor _ in range(n):\n t, a = map(int, input().split())\n T.append(t)\n A.append(a)\n\nTaka = 0\nAoki = 0\n\nfor i in range(n):\n\n if (T[i] >= Taka) and (A[i] >= Aoki):\n Taka = T[i]\n Aoki = A[i]\n elif T[i] == A[i]:\n Taka = max(Taka, Aoki)\n Aoki = Taka\n else:\n Taka_up = -(-Taka//T[i])\n Aoki_up = -(-Aoki//A[i])\n multi = max(Taka_up, Aoki_up)\n Taka = T[i] * multi\n Aoki = A[i] * multi \n\nans = int(Taka + Aoki)\nprint(ans)",
"from decimal import *",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"T, A = [], []",
"T",
"[]",
"A",
"[]",
"for _ in range(n):\n t, a = map(int, input().split())\n T.append(t)\n A.append(a)",
"_",
"range(n)",
"range",
"n",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"T.append(t)",
"T.append",
"T",
"append",
"t",
"A.append(a)",
"A.append",
"A",
"append",
"a",
"Taka = 0",
"Taka",
"0",
"Aoki = 0",
"Aoki",
"0",
"for i in range(n):\n\n if (T[i] >= Taka) and (A[i] >= Aoki):\n Taka = T[i]\n Aoki = A[i]\n elif T[i] == A[i]:\n Taka = max(Taka, Aoki)\n Aoki = Taka\n else:\n Taka_up = -(-Taka//T[i])\n Aoki_up = -(-Aoki//A[i])\n multi = max(Taka_up, Aoki_up)\n Taka = T[i] * multi\n Aoki = A[i] * multi ",
"i",
"range(n)",
"range",
"n",
"if (T[i] >= Taka) and (A[i] >= Aoki):\n Taka = T[i]\n Aoki = A[i]\n elif T[i] == A[i]:\n Taka = max(Taka, Aoki)\n Aoki = Taka\n else:\n Taka_up = -(-Taka//T[i])\n Aoki_up = -(-Aoki//A[i])\n multi = max(Taka_up, Aoki_up)\n Taka = T[i] * multi\n Aoki = A[i] * multi ",
"(T[i] >= Taka) and (A[i] >= Aoki)",
"T[i] >= Taka",
"T[i]",
"T",
"i",
"Taka",
"A[i] >= Aoki",
"A[i]",
"A",
"i",
"Aoki",
"Taka = T[i]",
"Taka",
"T[i]",
"T",
"i",
"Aoki = A[i]",
"Aoki",
"A[i]",
"A",
"i",
"elif T[i] == A[i]:\n Taka = max(Taka, Aoki)\n Aoki = Taka\n ",
"T[i] == A[i]",
"T[i]",
"T",
"i",
"A[i]",
"A",
"i",
"Taka = max(Taka, Aoki)",
"Taka",
"max(Taka, Aoki)",
"max",
"Taka",
"Aoki",
"Aoki = Taka",
"Aoki",
"Taka",
"Taka_up = -(-Taka//T[i])",
"Taka_up",
"-(-Taka//T[i])",
"-Taka//T[i]",
"-Taka",
"Taka",
"T[i]",
"T",
"i",
"Aoki_up = -(-Aoki//A[i])",
"Aoki_up",
"-(-Aoki//A[i])",
"-Aoki//A[i]",
"-Aoki",
"Aoki",
"A[i]",
"A",
"i",
"multi = max(Taka_up, Aoki_up)",
"multi",
"max(Taka_up, Aoki_up)",
"max",
"Taka_up",
"Aoki_up",
"Taka = T[i] * multi",
"Taka",
"T[i] * multi",
"T[i]",
"T",
"i",
"multi",
"Aoki = A[i] * multi",
"Aoki",
"A[i] * multi",
"A[i]",
"A",
"i",
"multi",
"ans = int(Taka + Aoki)",
"ans",
"int(Taka + Aoki)",
"int",
"Taka + Aoki",
"Taka",
"Aoki",
"print(ans)",
"print",
"ans",
"n = int(input())",
"int(input())",
"n",
"Aoki = Taka",
"Taka",
"Aoki",
"A = [], []",
"[]",
"A",
"T, A = [], []",
"[]",
"T",
"Taka = 0",
"0",
"Taka",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"Aoki = A[i] * multi",
"A[i] * multi",
"Aoki",
"Aoki = 0",
"0",
"Aoki",
"Taka_up = -(-Taka//T[i])",
"-(-Taka//T[i])",
"Taka_up",
"Taka = T[i] * multi",
"T[i] * multi",
"Taka",
"Aoki = A[i]",
"A[i]",
"Aoki",
"Aoki_up = -(-Aoki//A[i])",
"-(-Aoki//A[i])",
"Aoki_up",
"multi = max(Taka_up, Aoki_up)",
"max(Taka_up, Aoki_up)",
"multi",
"ans = int(Taka + Aoki)",
"int(Taka + Aoki)",
"ans",
"Taka = T[i]",
"T[i]",
"Taka",
"Taka = max(Taka, Aoki)",
"max(Taka, Aoki)",
"Taka",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t"
] | from decimal import *
n = int(input())
T, A = [], []
for _ in range(n):
t, a = map(int, input().split())
T.append(t)
A.append(a)
Taka = 0
Aoki = 0
for i in range(n):
if (T[i] >= Taka) and (A[i] >= Aoki):
Taka = T[i]
Aoki = A[i]
elif T[i] == A[i]:
Taka = max(Taka, Aoki)
Aoki = Taka
else:
Taka_up = -(-Taka//T[i])
Aoki_up = -(-Aoki//A[i])
multi = max(Taka_up, Aoki_up)
Taka = T[i] * multi
Aoki = A[i] * multi
ans = int(Taka + Aoki)
print(ans) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
18,
13,
17,
4,
18,
13,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
14,
2,
40,
18,
13,
2,
13,
17,
18,
13,
13,
40,
18,
13,
2,
13,
17,
18,
13,
13,
9,
0,
13,
40,
2,
40,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
40,
2,
40,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
4,
13,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
2,
13,
17,
4,
13,
13,
10,
40,
13,
10,
2,
13,
10,
39,
13,
10,
4,
13,
10,
40,
13,
10,
18,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13
] | [
[
154,
4
],
[
163,
11
],
[
155,
15
],
[
145,
17
],
[
160,
20
],
[
24,
23
],
[
164,
26
],
[
148,
28
],
[
155,
37
],
[
146,
41
],
[
149,
44
],
[
161,
48
],
[
149,
51
],
[
55,
54
],
[
164,
58
],
[
146,
63
],
[
54,
65
],
[
113,
67
],
[
146,
68
],
[
54,
69
],
[
161,
72
],
[
54,
74
],
[
118,
76
],
[
161,
77
],
[
54,
78
],
[
139,
81
],
[
146,
86
],
[
54,
88
],
[
113,
90
],
[
146,
91
],
[
54,
92
],
[
151,
94
],
[
161,
99
],
[
54,
101
],
[
118,
103
],
[
161,
104
],
[
54,
105
],
[
157,
107
],
[
140,
110
],
[
152,
111
],
[
116,
113
],
[
146,
114
],
[
54,
115
],
[
158,
116
],
[
149,
116
],
[
121,
118
],
[
161,
119
],
[
54,
120
],
[
158,
121
],
[
149,
121
],
[
142,
123
],
[
146,
126
],
[
164,
128
],
[
161,
131
],
[
164,
133
],
[
143,
137
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
148,
149
],
[
151,
152
],
[
154,
155
],
[
157,
158
],
[
160,
161
],
[
163,
164
]
] | [
"# import numpy as np\n# import math\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\n\nT = []\nA = []\n\nfor i in range(N):\n temp = list(map(int,input().split()))\n T.append(temp[0])\n A.append(temp[1])\n\nfor i in range(1,N):\n if (T[i-1] <= T[i]) & (A[i-1] <= A[i]):\n # print(T[i],A[i])\n continue\n else:\n rT = - ( - T[i-1] // T[i])\n rA = - ( - A[i-1] // A[i])\n temp = max(rT,rA)\n T[i] *= temp\n A[i] *= temp\n # print(T[i],A[i])\n\nres = T[N-1] + A[N-1]\n\nprint(res)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T = []",
"T",
"[]",
"A = []",
"A",
"[]",
"for i in range(N):\n temp = list(map(int,input().split()))\n T.append(temp[0])\n A.append(temp[1])",
"i",
"range(N)",
"range",
"N",
"temp = list(map(int,input().split()))",
"temp",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T.append(temp[0])",
"T.append",
"T",
"append",
"temp[0]",
"temp",
"0",
"A.append(temp[1])",
"A.append",
"A",
"append",
"temp[1]",
"temp",
"1",
"for i in range(1,N):\n if (T[i-1] <= T[i]) & (A[i-1] <= A[i]):\n # print(T[i],A[i])\n continue\n else:\n rT = - ( - T[i-1] // T[i])\n rA = - ( - A[i-1] // A[i])\n temp = max(rT,rA)\n T[i] *= temp\n A[i] *= temp\n # print(T[i],A[i])",
"i",
"range(1,N)",
"range",
"1",
"N",
"if (T[i-1] <= T[i]) & (A[i-1] <= A[i]):\n # print(T[i],A[i])\n continue\n else:\n rT = - ( - T[i-1] // T[i])\n rA = - ( - A[i-1] // A[i])\n temp = max(rT,rA)\n T[i] *= temp\n A[i] *= temp\n # print(T[i],A[i])",
"(T[i-1] <= T[i]) & (A[i-1] <= A[i])",
"T[i-1] <= T[i]",
"T[i-1]",
"T",
"i-1",
"i",
"1",
"T[i]",
"T",
"i",
"A[i-1] <= A[i]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"continue",
"rT = - ( - T[i-1] // T[i])",
"rT",
"- ( - T[i-1] // T[i])",
"- T[i-1] // T[i]",
"- T[i-1]",
"T[i-1]",
"T",
"i-1",
"i",
"1",
"T[i]",
"T",
"i",
"rA = - ( - A[i-1] // A[i])",
"rA",
"- ( - A[i-1] // A[i])",
"- A[i-1] // A[i]",
"- A[i-1]",
"A[i-1]",
"A",
"i-1",
"i",
"1",
"A[i]",
"A",
"i",
"temp = max(rT,rA)",
"temp",
"max(rT,rA)",
"max",
"rT",
"rA",
"T[i] *= temp",
"T[i]",
"T",
"i",
"temp",
"A[i] *= temp",
"A[i]",
"A",
"i",
"temp",
"res = T[N-1] + A[N-1]",
"res",
"T[N-1] + A[N-1]",
"T[N-1]",
"T",
"N-1",
"N",
"1",
"A[N-1]",
"A",
"N-1",
"N",
"1",
"print(res)",
"print",
"res",
"rT = - ( - T[i-1] // T[i])",
"- ( - T[i-1] // T[i])",
"rT",
"res = T[N-1] + A[N-1]",
"T[N-1] + A[N-1]",
"res",
"T = []",
"[]",
"T",
"temp = list(map(int,input().split()))",
"list(map(int,input().split()))",
"temp",
"rA = - ( - A[i-1] // A[i])",
"- ( - A[i-1] // A[i])",
"rA",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"temp = max(rT,rA)",
"max(rT,rA)",
"temp",
"A = []",
"[]",
"A",
"N = int(input())",
"int(input())",
"N"
] | # import numpy as np
# import math
import sys
input = sys.stdin.readline
N = int(input())
T = []
A = []
for i in range(N):
temp = list(map(int,input().split()))
T.append(temp[0])
A.append(temp[1])
for i in range(1,N):
if (T[i-1] <= T[i]) & (A[i-1] <= A[i]):
# print(T[i],A[i])
continue
else:
rT = - ( - T[i-1] // T[i])
rA = - ( - A[i-1] // A[i])
temp = max(rT,rA)
T[i] *= temp
A[i] *= temp
# print(T[i],A[i])
res = T[N-1] + A[N-1]
print(res)
|
[
7,
15,
15,
13,
15,
13,
12,
13,
29,
4,
13,
4,
18,
4,
18,
13,
13,
13,
12,
13,
29,
4,
13,
4,
18,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
18,
13,
13,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
18,
13,
13,
13,
12,
13,
4,
18,
13,
13,
2,
4,
13,
13,
17,
23,
13,
12,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
39,
28,
13,
4,
13,
17,
2,
13,
17,
14,
18,
13,
13,
28,
13,
4,
13,
2,
13,
13,
2,
13,
17,
13,
0,
18,
13,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
18,
13,
13,
4,
18,
13,
13,
13,
29,
13,
23,
13,
12,
13,
0,
13,
2,
4,
13,
2,
13,
17,
17,
0,
13,
4,
13,
13,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
4,
13,
13,
0,
13,
2,
2,
13,
18,
13,
13,
18,
13,
13,
14,
2,
13,
13,
0,
13,
18,
13,
13,
14,
2,
13,
18,
13,
13,
0,
13,
18,
13,
13,
28,
13,
4,
13,
13,
2,
13,
17,
18,
13,
13,
0,
18,
13,
2,
13,
13,
17,
28,
13,
4,
13,
13,
2,
13,
17,
14,
40,
18,
13,
2,
13,
13,
14,
40,
13,
17,
4,
13,
13,
23,
13,
23,
13,
12,
13,
42,
13,
0,
13,
13,
13,
2,
13,
13,
29,
13,
23,
13,
23,
13,
12,
13,
0,
13,
17,
42,
13,
14,
2,
13,
17,
0,
13,
2,
13,
13,
0,
13,
13,
0,
13,
2,
13,
17,
29,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
28,
13,
4,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
67,
64
],
[
67,
67
],
[
72,
71
],
[
129,
76
],
[
80,
79
],
[
83,
82
],
[
129,
87
],
[
71,
91
],
[
82,
92
],
[
95,
94
],
[
82,
98
],
[
82,
99
],
[
129,
101
],
[
82,
103
],
[
108,
105
],
[
71,
106
],
[
94,
107
],
[
111,
110
],
[
129,
115
],
[
71,
119
],
[
110,
120
],
[
79,
123
],
[
110,
125
],
[
79,
127
],
[
129,
129
],
[
134,
133
],
[
242,
138
],
[
143,
142
],
[
377,
144
],
[
133,
145
],
[
148,
147
],
[
242,
150
],
[
240,
151
],
[
155,
154
],
[
147,
159
],
[
163,
162
],
[
142,
167
],
[
170,
169
],
[
240,
172
],
[
142,
174
],
[
162,
175
],
[
142,
177
],
[
162,
178
],
[
169,
181
],
[
195,
181
],
[
184,
181
],
[
240,
182
],
[
185,
184
],
[
142,
186
],
[
162,
187
],
[
184,
190
],
[
169,
190
],
[
195,
190
],
[
142,
192
],
[
162,
193
],
[
196,
195
],
[
142,
197
],
[
162,
198
],
[
201,
200
],
[
195,
203
],
[
184,
203
],
[
169,
203
],
[
242,
205
],
[
142,
208
],
[
162,
209
],
[
216,
211
],
[
154,
212
],
[
200,
214
],
[
240,
215
],
[
219,
218
],
[
240,
221
],
[
242,
223
],
[
154,
228
],
[
218,
230
],
[
240,
231
],
[
218,
234
],
[
218,
238
],
[
240,
240
],
[
242,
242
],
[
249,
248
],
[
259,
249
],
[
250,
249
],
[
251,
250
],
[
248,
252
],
[
257,
252
],
[
259,
253
],
[
250,
253
],
[
248,
255
],
[
257,
255
],
[
257,
257
],
[
259,
259
],
[
264,
263
],
[
289,
269
],
[
280,
269
],
[
273,
272
],
[
263,
274
],
[
272,
274
],
[
287,
275
],
[
277,
275
],
[
278,
277
],
[
277,
278
],
[
287,
278
],
[
281,
280
],
[
289,
282
],
[
280,
282
],
[
272,
285
],
[
263,
285
],
[
287,
287
],
[
289,
289
],
[
294,
293
],
[
368,
295
],
[
298,
297
],
[
300,
299
],
[
303,
302
],
[
293,
305
],
[
308,
307
],
[
374,
309
],
[
308,
310
],
[
313,
312
],
[
307,
318
],
[
297,
319
],
[
330,
319
],
[
307,
321
],
[
310,
325
],
[
299,
326
],
[
335,
326
],
[
310,
328
],
[
331,
330
],
[
312,
332
],
[
307,
333
],
[
336,
335
],
[
312,
337
],
[
310,
338
],
[
353,
340
],
[
330,
342
],
[
297,
342
],
[
335,
343
],
[
299,
343
],
[
346,
345
],
[
365,
350
]
] | [
"from sys import stdin,stdout\n\nimport bisect\n\nimport math\n\ndef st():\n return list(stdin.readline().strip())\n\ndef inp():\n return int(stdin.readline())\n\ndef li():\n return list(map(int,stdin.readline().split()))\n\ndef mp():\n return map(int,stdin.readline().split())\n\ndef pr(n):\n stdout.write(str(n)+\"\\n\")\n\ndef soe(limit):\n l=[1]*(limit+1)\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime\n\ndef segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n \ndef gcd(a,b):\n while b:\n a,b=b,a%b\n return a\n\ndef power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n\n \ndef solve():\n n=inp()\n a,b=1,1\n for _ in range(n):\n x,y=mp()\n d=max((x+a-1)//x,(y+b-1)//y)\n a=d*x\n b=d*y\n pr(a+b)\nfor _ in range(1):\n solve()\n ",
"from sys import stdin,stdout",
"import bisect",
"bisect",
"import math",
"math",
"def st():\n return list(stdin.readline().strip())",
"st",
"return list(stdin.readline().strip())",
"list(stdin.readline().strip())",
"list",
"stdin.readline().strip()",
"stdin.readline().strip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"strip",
"def inp():\n return int(stdin.readline())",
"inp",
"return int(stdin.readline())",
"int(stdin.readline())",
"int",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"def li():\n return list(map(int,stdin.readline().split()))",
"li",
"return list(map(int,stdin.readline().split()))",
"list(map(int,stdin.readline().split()))",
"list",
"map(int,stdin.readline().split())",
"map",
"int",
"stdin.readline().split()",
"stdin.readline().split",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"split",
"def mp():\n return map(int,stdin.readline().split())",
"mp",
"return map(int,stdin.readline().split())",
"map(int,stdin.readline().split())",
"map",
"int",
"stdin.readline().split()",
"stdin.readline().split",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"split",
"def pr(n):\n stdout.write(str(n)+\"\\n\")",
"pr",
"stdout.write(str(n)+\"\\n\")",
"stdout.write",
"stdout",
"write",
"str(n)+\"\\n\"",
"str(n)",
"str",
"n",
"\"\\n\"",
"n",
"n",
"def soe(limit):\n l=[1]*(limit+1)\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime",
"soe",
"l=[1]*(limit+1)",
"l",
"[1]*(limit+1)",
"[1]",
"1",
"limit+1",
"limit",
"1",
"prime=[]",
"prime",
"[]",
"for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n ",
"i",
"range(2,limit+1)",
"range",
"2",
"limit+1",
"limit",
"1",
"if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n ",
"l[i]",
"l",
"i",
"for j in range(i*i,limit+1,i):\n l[j]=0\n\n ",
"j",
"range(i*i,limit+1,i)",
"range",
"i*i",
"i",
"i",
"limit+1",
"limit",
"1",
"i",
"l[j]=0",
"l[j]",
"l",
"j",
"0",
"for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n ",
"i",
"range(2,limit+1)",
"range",
"2",
"limit+1",
"limit",
"1",
"if l[i]:\n prime.append(i)\n ",
"l[i]",
"l",
"i",
"prime.append(i)",
"prime.append",
"prime",
"append",
"i",
"return prime",
"prime",
"limit",
"limit",
"def segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n ",
"segsoe",
"limit=int(high**0.5)+1",
"limit",
"int(high**0.5)+1",
"int(high**0.5)",
"int",
"high**0.5",
"high",
"0.5",
"1",
"prime=soe(limit)",
"prime",
"soe(limit)",
"soe",
"limit",
"n=high-low+1",
"n",
"high-low+1",
"high-low",
"high",
"low",
"1",
"l=[0]*(n+1)",
"l",
"[0]*(n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n ",
"i",
"range(len(prime))",
"range",
"len(prime)",
"len",
"prime",
"lowlimit=(low//prime[i])*prime[i]",
"lowlimit",
"(low//prime[i])*prime[i]",
"low//prime[i]",
"low",
"prime[i]",
"prime",
"i",
"prime[i]",
"prime",
"i",
"if lowlimit<low:\n lowlimit+=prime[i]\n ",
"lowlimit<low",
"lowlimit",
"low",
"lowlimit+=prime[i]",
"lowlimit",
"prime[i]",
"prime",
"i",
"if lowlimit==prime[i]:\n lowlimit+=prime[i]\n ",
"lowlimit==prime[i]",
"lowlimit",
"prime[i]",
"prime",
"i",
"lowlimit+=prime[i]",
"lowlimit",
"prime[i]",
"prime",
"i",
"for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n ",
"j",
"range(lowlimit,high+1,prime[i])",
"range",
"lowlimit",
"high+1",
"high",
"1",
"prime[i]",
"prime",
"i",
"l[j-low]=1",
"l[j-low]",
"l",
"j-low",
"j",
"low",
"1",
"for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n ",
"i",
"range(low,high+1)",
"range",
"low",
"high+1",
"high",
"1",
"if not l[i-low]:\n if i!=1:\n print(i)\n ",
"not l[i-low]",
"l[i-low]",
"l",
"i-low",
"i",
"low",
"if i!=1:\n print(i)\n ",
"i!=1",
"i",
"1",
"print(i)",
"print",
"i",
"low",
"low",
"high",
"high",
"def gcd(a,b):\n while b:\n a,b=b,a%b\n return a",
"gcd",
"while b:\n a,b=b,a%b\n ",
"b",
"a,b=b,a%b",
"a",
"b",
"b",
"a%b",
"a",
"b",
"return a",
"a",
"a",
"a",
"b",
"b",
"def power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n\n ",
"power",
"r=1",
"r",
"1",
"while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n ",
"n",
"if n&1:\n r=(r*a)\n ",
"n&1",
"n",
"1",
"r=(r*a)",
"r",
"r*a",
"r",
"a",
"a*=a",
"a",
"a",
"n=n>>1",
"n",
"n>>1",
"n",
"1",
"return r",
"r",
"a",
"a",
"n",
"n",
"def solve():\n n=inp()\n a,b=1,1\n for _ in range(n):\n x,y=mp()\n d=max((x+a-1)//x,(y+b-1)//y)\n a=d*x\n b=d*y\n pr(a+b)",
"solve",
"n=inp()",
"n",
"inp()",
"inp",
"a,b=1,1",
"a",
"1",
"b",
"1",
"for _ in range(n):\n x,y=mp()\n d=max((x+a-1)//x,(y+b-1)//y)\n a=d*x\n b=d*y\n ",
"_",
"range(n)",
"range",
"n",
"x,y=mp()",
"x",
"mp()",
"mp",
"y",
"d=max((x+a-1)//x,(y+b-1)//y)",
"d",
"max((x+a-1)//x,(y+b-1)//y)",
"max",
"(x+a-1)//x",
"x+a-1",
"x+a",
"x",
"a",
"1",
"x",
"(y+b-1)//y",
"y+b-1",
"y+b",
"y",
"b",
"1",
"y",
"a=d*x",
"a",
"d*x",
"d",
"x",
"b=d*y",
"b",
"d*y",
"d",
"y",
"pr(a+b)",
"pr",
"a+b",
"a",
"b",
"for _ in range(1):\n solve()\n ",
"_",
"range(1)",
"range",
"1",
"solve()",
"solve",
"def pr(n):\n stdout.write(str(n)+\"\\n\")",
"def pr(n):\n stdout.write(str(n)+\"\\n\")",
"pr",
"def st():\n return list(stdin.readline().strip())",
"def st():\n return list(stdin.readline().strip())",
"st",
"def li():\n return list(map(int,stdin.readline().split()))",
"def li():\n return list(map(int,stdin.readline().split()))",
"li",
"def segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n ",
"def segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n ",
"segsoe",
"def solve():\n n=inp()\n a,b=1,1\n for _ in range(n):\n x,y=mp()\n d=max((x+a-1)//x,(y+b-1)//y)\n a=d*x\n b=d*y\n pr(a+b)",
"def solve():\n n=inp()\n a,b=1,1\n for _ in range(n):\n x,y=mp()\n d=max((x+a-1)//x,(y+b-1)//y)\n a=d*x\n b=d*y\n pr(a+b)",
"solve",
"def inp():\n return int(stdin.readline())",
"def inp():\n return int(stdin.readline())",
"inp",
"def gcd(a,b):\n while b:\n a,b=b,a%b\n return a",
"def gcd(a,b):\n while b:\n a,b=b,a%b\n return a",
"gcd",
"def mp():\n return map(int,stdin.readline().split())",
"def mp():\n return map(int,stdin.readline().split())",
"mp",
"def soe(limit):\n l=[1]*(limit+1)\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime",
"def soe(limit):\n l=[1]*(limit+1)\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime",
"soe",
"def power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n\n ",
"def power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n\n ",
"power"
] | from sys import stdin,stdout
import bisect
import math
def st():
return list(stdin.readline().strip())
def inp():
return int(stdin.readline())
def li():
return list(map(int,stdin.readline().split()))
def mp():
return map(int,stdin.readline().split())
def pr(n):
stdout.write(str(n)+"\n")
def soe(limit):
l=[1]*(limit+1)
prime=[]
for i in range(2,limit+1):
if l[i]:
for j in range(i*i,limit+1,i):
l[j]=0
for i in range(2,limit+1):
if l[i]:
prime.append(i)
return prime
def segsoe(low,high):
limit=int(high**0.5)+1
prime=soe(limit)
n=high-low+1
l=[0]*(n+1)
for i in range(len(prime)):
lowlimit=(low//prime[i])*prime[i]
if lowlimit<low:
lowlimit+=prime[i]
if lowlimit==prime[i]:
lowlimit+=prime[i]
for j in range(lowlimit,high+1,prime[i]):
l[j-low]=1
for i in range(low,high+1):
if not l[i-low]:
if i!=1:
print(i)
def gcd(a,b):
while b:
a,b=b,a%b
return a
def power(a,n):
r=1
while n:
if n&1:
r=(r*a)
a*=a
n=n>>1
return r
def solve():
n=inp()
a,b=1,1
for _ in range(n):
x,y=mp()
d=max((x+a-1)//x,(y+b-1)//y)
a=d*x
b=d*y
pr(a+b)
for _ in range(1):
solve()
|
[
7,
15,
13,
12,
13,
41,
28,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
17,
4,
4,
13,
13,
29,
4,
13,
13,
0,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
13,
14,
2,
13,
13,
14,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13
] | [
[
8,
7
],
[
7,
24
],
[
116,
30
],
[
132,
32
],
[
125,
34
],
[
140,
37
],
[
41,
40
],
[
117,
43
],
[
137,
45
],
[
132,
47
],
[
137,
48
],
[
143,
50
],
[
126,
52
],
[
123,
52
],
[
141,
53
],
[
135,
53
],
[
146,
55
],
[
129,
57
],
[
138,
58
],
[
152,
60
],
[
144,
64
],
[
147,
65
],
[
147,
67
],
[
119,
69
],
[
126,
73
],
[
123,
73
],
[
129,
74
],
[
129,
76
],
[
113,
78
],
[
141,
82
],
[
135,
82
],
[
138,
83
],
[
138,
85
],
[
149,
87
],
[
153,
88
],
[
120,
91
],
[
150,
92
],
[
114,
95
],
[
150,
96
],
[
122,
98
],
[
129,
100
],
[
150,
101
],
[
134,
103
],
[
138,
105
],
[
150,
106
],
[
123,
110
],
[
126,
110
],
[
135,
111
],
[
141,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
137,
129
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
153,
149
],
[
149,
150
],
[
152,
153
]
] | [
"import sys\n\ndef read():\n\treturn tuple([int(d) for d in sys.stdin.readline().rstrip().split(\" \")])\n\nN, = read()\n\ncur_T = 1\ncur_A = 1\n\nfor i in range(N):\n\tT, A = read()\n\n\tcurrent = cur_T + cur_A\n\tsum = T + A\n\n\tmult1 = (current + sum - 1) // sum\n\tmult2 = (cur_T + T - 1) // T\n\tmult3 = (cur_A + A - 1) // A\n\n\tmult = mult1\n\tif mult2 > mult: mult = mult2\n\tif mult3 > mult: mult = mult3\n\n\tcur_T = T * mult\n\tcur_A = A * mult\n\nprint(cur_T + cur_A)",
"import sys",
"sys",
"def read():\n\treturn tuple([int(d) for d in sys.stdin.readline().rstrip().split(\" \")])",
"read",
"int(d) for d in sys.stdin.readline().rstrip().split(\" \")",
"for d in sys.stdin.readline().rstrip().split(\" \")",
"d",
"sys.stdin.readline().rstrip().split(\" \")",
"sys.stdin.readline().rstrip().split",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"split",
"\" \"",
"for d in sys.stdin.readline().rstrip().split(\" \")",
"int(d)",
"int",
"d",
"return tuple([int(d) for d in sys.stdin.readline().rstrip().split(\" \")])",
"tuple([int(d) for d in sys.stdin.readline().rstrip().split(\" \")])",
"tuple",
"[int(d) for d in sys.stdin.readline().rstrip().split(\" \")]",
"N, = read()",
"N",
"read()",
"read",
"cur_T = 1",
"cur_T",
"1",
"cur_A = 1",
"cur_A",
"1",
"for i in range(N):\n\tT, A = read()\n\n\tcurrent = cur_T + cur_A\n\tsum = T + A\n\n\tmult1 = (current + sum - 1) // sum\n\tmult2 = (cur_T + T - 1) // T\n\tmult3 = (cur_A + A - 1) // A\n\n\tmult = mult1\n\tif mult2 > mult: mult = mult2\n\tif mult3 > mult: mult = mult3\n\n\tcur_T = T * mult\n\tcur_A = A * mult",
"i",
"range(N)",
"range",
"N",
"T, A = read()",
"T",
"read()",
"read",
"A",
"current = cur_T + cur_A",
"current",
"cur_T + cur_A",
"cur_T",
"cur_A",
"sum = T + A",
"sum",
"T + A",
"T",
"A",
"mult1 = (current + sum - 1) // sum",
"mult1",
"(current + sum - 1) // sum",
"current + sum - 1",
"current + sum",
"current",
"sum",
"1",
"sum",
"mult2 = (cur_T + T - 1) // T",
"mult2",
"(cur_T + T - 1) // T",
"cur_T + T - 1",
"cur_T + T",
"cur_T",
"T",
"1",
"T",
"mult3 = (cur_A + A - 1) // A",
"mult3",
"(cur_A + A - 1) // A",
"cur_A + A - 1",
"cur_A + A",
"cur_A",
"A",
"1",
"A",
"mult = mult1",
"mult",
"mult1",
"if mult2 > mult: mult = mult2\n\t",
"mult2 > mult",
"mult2",
"mult",
"if mult3 > mult: mult = mult3\n\n\t",
"mult3 > mult",
"mult3",
"mult",
"cur_T = T * mult",
"cur_T",
"T * mult",
"T",
"mult",
"cur_A = A * mult",
"cur_A",
"A * mult",
"A",
"mult",
"print(cur_T + cur_A)",
"print",
"cur_T + cur_A",
"cur_T",
"cur_A",
"mult3 = (cur_A + A - 1) // A",
"(cur_A + A - 1) // A",
"mult3",
"N, = read()",
"read()",
"N",
"mult2 = (cur_T + T - 1) // T",
"(cur_T + T - 1) // T",
"mult2",
"cur_T = T * mult",
"T * mult",
"cur_T",
"cur_T = 1",
"1",
"cur_T",
"T, A = read()",
"read()",
"T",
"def read():\n\treturn tuple([int(d) for d in sys.stdin.readline().rstrip().split(\" \")])",
"def read():\n\treturn tuple([int(d) for d in sys.stdin.readline().rstrip().split(\" \")])",
"read",
"cur_A = A * mult",
"A * mult",
"cur_A",
"A = read()",
"read()",
"A",
"cur_A = 1",
"1",
"cur_A",
"current = cur_T + cur_A",
"cur_T + cur_A",
"current",
"sum = T + A",
"T + A",
"sum",
"mult = mult1",
"mult1",
"mult",
"mult1 = (current + sum - 1) // sum",
"(current + sum - 1) // sum",
"mult1"
] | import sys
def read():
return tuple([int(d) for d in sys.stdin.readline().rstrip().split(" ")])
N, = read()
cur_T = 1
cur_A = 1
for i in range(N):
T, A = read()
current = cur_T + cur_A
sum = T + A
mult1 = (current + sum - 1) // sum
mult2 = (cur_T + T - 1) // T
mult3 = (cur_A + A - 1) // A
mult = mult1
if mult2 > mult: mult = mult2
if mult3 > mult: mult = mult3
cur_T = T * mult
cur_A = A * mult
print(cur_T + cur_A)
|
[
7,
15,
13,
15,
15,
13,
6,
13,
12,
13,
0,
13,
18,
13,
13,
13,
18,
13,
13,
0,
18,
13,
13,
4,
13,
18,
13,
13,
4,
13,
13,
4,
13,
4,
18,
18,
13,
13,
13,
17,
0,
13,
18,
4,
18,
18,
13,
13,
13,
39,
17,
0,
18,
13,
13,
13,
18,
13,
13,
13,
4,
18,
13,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
17,
0,
13,
17,
4,
18,
13,
13,
13,
13,
23,
13,
12,
13,
0,
13,
17,
0,
13,
17,
4,
18,
13,
13,
13,
13,
23,
13,
12,
13,
0,
13,
17,
0,
13,
17,
4,
18,
13,
13,
13,
13,
23,
13,
18,
13,
13,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
18,
13,
17,
17,
0,
13,
18,
18,
13,
17,
17,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
2,
2,
2,
13,
18,
18,
13,
13,
17,
17,
18,
18,
13,
13,
17,
2,
2,
2,
13,
18,
18,
13,
13,
17,
17,
18,
18,
13,
13,
17,
0,
13,
2,
13,
18,
18,
13,
13,
17,
0,
13,
2,
13,
18,
18,
13,
13,
17,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
6,
13,
10,
12,
13
] | [
[
12,
11
],
[
16,
15
],
[
23,
20
],
[
11,
22
],
[
28,
25
],
[
15,
27
],
[
69,
30
],
[
20,
35
],
[
11,
37
],
[
42,
41
],
[
20,
45
],
[
11,
47
],
[
55,
52
],
[
11,
54
],
[
11,
55
],
[
59,
56
],
[
15,
58
],
[
15,
59
],
[
67,
62
],
[
41,
64
],
[
71,
65
],
[
67,
67
],
[
69,
69
],
[
71,
71
],
[
76,
75
],
[
79,
78
],
[
87,
82
],
[
9,
83
],
[
75,
84
],
[
78,
85
],
[
87,
87
],
[
92,
91
],
[
95,
94
],
[
103,
98
],
[
9,
99
],
[
91,
100
],
[
94,
101
],
[
103,
103
],
[
108,
107
],
[
111,
110
],
[
119,
114
],
[
9,
115
],
[
107,
116
],
[
110,
117
],
[
119,
119
],
[
127,
126
],
[
134,
133
],
[
126,
136
],
[
150,
149
],
[
153,
152
],
[
149,
155
],
[
160,
159
],
[
149,
162
],
[
167,
166
],
[
126,
170
],
[
173,
172
],
[
152,
178
],
[
206,
178
],
[
149,
181
],
[
166,
182
],
[
149,
187
],
[
166,
188
],
[
159,
193
],
[
215,
193
],
[
149,
196
],
[
166,
197
],
[
149,
202
],
[
166,
203
],
[
207,
206
],
[
172,
208
],
[
149,
211
],
[
166,
212
],
[
216,
215
],
[
172,
217
],
[
149,
220
],
[
166,
221
],
[
206,
226
],
[
152,
226
],
[
215,
227
],
[
159,
227
],
[
239,
233
]
] | [
"#\n# abc046 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = \"\"\"3\n2 3\n1 1\n3 2\"\"\"\n output = \"\"\"10\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"\n output = \"\"\"101\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"\n output = \"\"\"6930\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n R = [list(map(int, input().split())) for _ in range(N)]\n\n t = R[0][0]\n a = R[0][1]\n for i in range(1, N):\n n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])\n t = n*R[i][0]\n a = n*R[i][1]\n\n print(t+a)\n\n\nif __name__ == \"__main__\":\n # unittest.main()\n resolve()",
"import sys",
"sys",
"from io import StringIO",
"import unittest",
"unittest",
"class TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = \"\"\"3\n2 3\n1 1\n3 2\"\"\"\n output = \"\"\"10\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"\n output = \"\"\"101\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"\n output = \"\"\"6930\"\"\"\n self.assertIO(input, output)",
"TestClass",
"def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n ",
"assertIO",
"stdout, stdin = sys.stdout, sys.stdin",
"stdout",
"sys.stdout",
"sys",
"stdout",
"stdin",
"sys.stdin",
"sys",
"stdin",
"sys.stdout, sys.stdin = StringIO(), StringIO(input)",
"sys.stdout",
"sys",
"stdout",
"StringIO()",
"StringIO",
"sys.stdin",
"sys",
"stdin",
"StringIO(input)",
"StringIO",
"input",
"resolve()",
"resolve",
"sys.stdout.seek(0)",
"sys.stdout.seek",
"sys.stdout",
"sys",
"stdout",
"seek",
"0",
"out = sys.stdout.read()[:-1]",
"out",
"sys.stdout.read()[:-1]",
"sys.stdout.read()",
"sys.stdout.read",
"sys.stdout",
"sys",
"stdout",
"read",
":-1",
"-1",
"sys.stdout, sys.stdin = stdout, stdin",
"sys.stdout",
"sys",
"stdout",
"stdout",
"sys.stdin",
"sys",
"stdin",
"stdin",
"self.assertEqual(out, output)",
"self.assertEqual",
"self",
"assertEqual",
"out",
"output",
"self",
"self",
"input",
"input",
"output",
"output",
"def test_入力例_1(self):\n input = \"\"\"3\n2 3\n1 1\n3 2\"\"\"\n output = \"\"\"10\"\"\"\n self.assertIO(input, output)\n\n ",
"test_入力例_1",
"input = \"\"\"3\n2 3\n1 1\n3 2\"\"\"",
"input",
"\"\"\"3\n2 3\n1 1\n3 2\"\"\"",
"output = \"\"\"10\"\"\"",
"output",
"\"\"\"10\"\"\"",
"self.assertIO(input, output)",
"self.assertIO",
"self",
"assertIO",
"input",
"output",
"self",
"self",
"def test_入力例_2(self):\n input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"\n output = \"\"\"101\"\"\"\n self.assertIO(input, output)\n\n ",
"test_入力例_2",
"input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"",
"input",
"\"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"",
"output = \"\"\"101\"\"\"",
"output",
"\"\"\"101\"\"\"",
"self.assertIO(input, output)",
"self.assertIO",
"self",
"assertIO",
"input",
"output",
"self",
"self",
"def test_入力例_3(self):\n input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"\n output = \"\"\"6930\"\"\"\n self.assertIO(input, output)",
"test_入力例_3",
"input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"",
"input",
"\"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"",
"output = \"\"\"6930\"\"\"",
"output",
"\"\"\"6930\"\"\"",
"self.assertIO(input, output)",
"self.assertIO",
"self",
"assertIO",
"input",
"output",
"self",
"self",
"unittest.TestCase",
"unittest",
"TestCase",
"def resolve():\n N = int(input())\n R = [list(map(int, input().split())) for _ in range(N)]\n\n t = R[0][0]\n a = R[0][1]\n for i in range(1, N):\n n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])\n t = n*R[i][0]\n a = n*R[i][1]\n\n print(t+a)",
"resolve",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"R = [list(map(int, input().split())) for _ in range(N)]",
"R",
"[list(map(int, input().split())) for _ in range(N)]",
"t = R[0][0]",
"t",
"R[0][0]",
"[0]",
"R",
"0",
"0",
"a = R[0][1]",
"a",
"R[0][1]",
"[0]",
"R",
"0",
"1",
"for i in range(1, N):\n n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])\n t = n*R[i][0]\n a = n*R[i][1]\n\n ",
"i",
"range(1, N)",
"range",
"1",
"N",
"n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])",
"n",
"max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])",
"max",
"(t+R[i][0]-1)//R[i][0]",
"t+R[i][0]-1",
"t+R[i][0]",
"t",
"R[i][0]",
"[i]",
"R",
"i",
"0",
"1",
"R[i][0]",
"[i]",
"R",
"i",
"0",
"(a+R[i][1]-1)//R[i][1]",
"a+R[i][1]-1",
"a+R[i][1]",
"a",
"R[i][1]",
"[i]",
"R",
"i",
"1",
"1",
"R[i][1]",
"[i]",
"R",
"i",
"1",
"t = n*R[i][0]",
"t",
"n*R[i][0]",
"n",
"R[i][0]",
"[i]",
"R",
"i",
"0",
"a = n*R[i][1]",
"a",
"n*R[i][1]",
"n",
"R[i][1]",
"[i]",
"R",
"i",
"1",
"print(t+a)",
"print",
"t+a",
"t",
"a",
"if __name__ == \"__main__\":\n # unittest.main()\n resolve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"resolve()",
"resolve",
"class TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = \"\"\"3\n2 3\n1 1\n3 2\"\"\"\n output = \"\"\"10\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"\n output = \"\"\"101\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"\n output = \"\"\"6930\"\"\"\n self.assertIO(input, output)",
"class TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = \"\"\"3\n2 3\n1 1\n3 2\"\"\"\n output = \"\"\"10\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"\n output = \"\"\"101\"\"\"\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"\n output = \"\"\"6930\"\"\"\n self.assertIO(input, output)",
"TestClass",
"def resolve():\n N = int(input())\n R = [list(map(int, input().split())) for _ in range(N)]\n\n t = R[0][0]\n a = R[0][1]\n for i in range(1, N):\n n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])\n t = n*R[i][0]\n a = n*R[i][1]\n\n print(t+a)",
"def resolve():\n N = int(input())\n R = [list(map(int, input().split())) for _ in range(N)]\n\n t = R[0][0]\n a = R[0][1]\n for i in range(1, N):\n n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])\n t = n*R[i][0]\n a = n*R[i][1]\n\n print(t+a)",
"resolve"
] | #
# abc046 c
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3
2 3
1 1
3 2"""
output = """10"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """4
1 1
1 1
1 5
1 100"""
output = """101"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """5
3 10
48 17
31 199
231 23
3 2"""
output = """6930"""
self.assertIO(input, output)
def resolve():
N = int(input())
R = [list(map(int, input().split())) for _ in range(N)]
t = R[0][0]
a = R[0][1]
for i in range(1, N):
n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])
t = n*R[i][0]
a = n*R[i][1]
print(t+a)
if __name__ == "__main__":
# unittest.main()
resolve()
|
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
0,
13,
4,
13,
13,
28,
13,
4,
13,
17,
13,
14,
2,
2,
18,
13,
17,
18,
18,
13,
13,
17,
2,
18,
13,
17,
18,
18,
13,
13,
17,
9,
0,
13,
4,
13,
4,
18,
13,
13,
2,
2,
2,
18,
13,
17,
18,
18,
13,
13,
17,
17,
18,
18,
13,
13,
17,
4,
18,
13,
13,
2,
2,
2,
18,
13,
17,
18,
18,
13,
13,
17,
17,
18,
18,
13,
13,
17,
0,
13,
4,
13,
4,
13,
12,
2,
13,
13,
23,
18,
13,
13,
0,
13,
4,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
18,
13,
10,
4,
13
] | [
[
155,
4
],
[
12,
11
],
[
156,
14
],
[
149,
27
],
[
152,
30
],
[
150,
32
],
[
146,
35
],
[
153,
38
],
[
41,
40
],
[
156,
44
],
[
153,
49
],
[
138,
49
],
[
150,
53
],
[
40,
54
],
[
153,
58
],
[
138,
58
],
[
150,
62
],
[
40,
63
],
[
143,
67
],
[
153,
78
],
[
138,
78
],
[
150,
82
],
[
40,
83
],
[
150,
88
],
[
40,
89
],
[
153,
99
],
[
138,
99
],
[
150,
103
],
[
40,
104
],
[
150,
109
],
[
40,
110
],
[
137,
113
],
[
144,
121
],
[
150,
124
],
[
40,
125
],
[
140,
127
],
[
138,
130
],
[
153,
130
],
[
138,
135
],
[
153,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
]
] | [
"import math\n\nn = int(input())\nt_a = [tuple(map(int, input().split())) for _ in range(n)]\n\ntmp_tuple = t_a[0]\nans = sum(tmp_tuple)\n# ans = sum(tmp_tuple)\nfor i in range(1, n):\n if (tmp_tuple[0] / t_a[i][0]) == (tmp_tuple[1] / t_a[i][1]):\n continue\n else:\n # to prevent error\n factor = max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))\n\n tmp_tuple = tuple(map(lambda x: x * factor, t_a[i]))\n # print(tmp_tuple)\n # print(sum(tmp_tuple) - ans)\n ans = sum(tmp_tuple)\n \nprint(sum(tmp_tuple))",
"import math",
"math",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"tuple(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"tuple(map(int, input().split()))",
"tuple",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t_a = [tuple(map(int, input().split())) for _ in range(n)]",
"t_a",
"[tuple(map(int, input().split())) for _ in range(n)]",
"tmp_tuple = t_a[0]",
"tmp_tuple",
"t_a[0]",
"t_a",
"0",
"ans = sum(tmp_tuple)",
"ans",
"sum(tmp_tuple)",
"sum",
"tmp_tuple",
"for i in range(1, n):\n if (tmp_tuple[0] / t_a[i][0]) == (tmp_tuple[1] / t_a[i][1]):\n continue\n else:\n # to prevent error\n factor = max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))\n\n tmp_tuple = tuple(map(lambda x: x * factor, t_a[i]))\n # print(tmp_tuple)\n # print(sum(tmp_tuple) - ans)\n ans = sum(tmp_tuple)\n ",
"i",
"range(1, n)",
"range",
"1",
"n",
"if (tmp_tuple[0] / t_a[i][0]) == (tmp_tuple[1] / t_a[i][1]):\n continue\n else:\n # to prevent error\n factor = max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))\n\n ",
"(tmp_tuple[0] / t_a[i][0]) == (tmp_tuple[1] / t_a[i][1])",
"tmp_tuple[0] / t_a[i][0]",
"tmp_tuple[0]",
"tmp_tuple",
"0",
"t_a[i][0]",
"[i]",
"t_a",
"i",
"0",
"tmp_tuple[1] / t_a[i][1]",
"tmp_tuple[1]",
"tmp_tuple",
"1",
"t_a[i][1]",
"[i]",
"t_a",
"i",
"1",
"continue",
"factor = max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))",
"factor",
"max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))",
"max",
"math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0])",
"math.ceil",
"math",
"ceil",
"(tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]",
"tmp_tuple[0] + t_a[i][0] - 1",
"tmp_tuple[0] + t_a[i][0]",
"tmp_tuple[0]",
"tmp_tuple",
"0",
"t_a[i][0]",
"[i]",
"t_a",
"i",
"0",
"1",
"t_a[i][0]",
"[i]",
"t_a",
"i",
"0",
"math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1])",
"math.ceil",
"math",
"ceil",
"(tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]",
"tmp_tuple[1] + t_a[i][1] - 1",
"tmp_tuple[1] + t_a[i][1]",
"tmp_tuple[1]",
"tmp_tuple",
"1",
"t_a[i][1]",
"[i]",
"t_a",
"i",
"1",
"1",
"t_a[i][1]",
"[i]",
"t_a",
"i",
"1",
"tmp_tuple = tuple(map(lambda x: x * factor, t_a[i]))",
"tmp_tuple",
"tuple(map(lambda x: x * factor, t_a[i]))",
"tuple",
"map(lambda x: x * factor, t_a[i])",
"map",
"lambda x: x * factor",
"x * factor",
"x",
"factor",
"x",
"t_a[i]",
"t_a",
"i",
"ans = sum(tmp_tuple)",
"ans",
"sum(tmp_tuple)",
"sum",
"tmp_tuple",
"print(sum(tmp_tuple))",
"print",
"sum(tmp_tuple)",
"sum",
"tmp_tuple",
"tmp_tuple = tuple(map(lambda x: x * factor, t_a[i]))",
"tuple(map(lambda x: x * factor, t_a[i]))",
"tmp_tuple",
"ans = sum(tmp_tuple)",
"sum(tmp_tuple)",
"ans",
"factor = max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))",
"max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))",
"factor",
"ans = sum(tmp_tuple)",
"sum(tmp_tuple)",
"ans",
"t_a = [tuple(map(int, input().split())) for _ in range(n)]",
"[tuple(map(int, input().split())) for _ in range(n)]",
"t_a",
"tmp_tuple = t_a[0]",
"t_a[0]",
"tmp_tuple",
"n = int(input())",
"int(input())",
"n"
] | import math
n = int(input())
t_a = [tuple(map(int, input().split())) for _ in range(n)]
tmp_tuple = t_a[0]
ans = sum(tmp_tuple)
# ans = sum(tmp_tuple)
for i in range(1, n):
if (tmp_tuple[0] / t_a[i][0]) == (tmp_tuple[1] / t_a[i][1]):
continue
else:
# to prevent error
factor = max(math.ceil((tmp_tuple[0] + t_a[i][0] - 1) // t_a[i][0]), math.ceil((tmp_tuple[1] + t_a[i][1] - 1) // t_a[i][1]))
tmp_tuple = tuple(map(lambda x: x * factor, t_a[i]))
# print(tmp_tuple)
# print(sum(tmp_tuple) - ans)
ans = sum(tmp_tuple)
print(sum(tmp_tuple))
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
2,
13,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
13,
17,
14,
2,
2,
13,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
112,
2
],
[
100,
8
],
[
91,
10
],
[
14,
13
],
[
113,
16
],
[
115,
18
],
[
115,
27
],
[
101,
31
],
[
89,
31
],
[
116,
32
],
[
103,
35
],
[
101,
37
],
[
89,
37
],
[
116,
38
],
[
97,
40
],
[
101,
43
],
[
89,
43
],
[
116,
44
],
[
92,
49
],
[
119,
49
],
[
95,
50
],
[
85,
53
],
[
92,
55
],
[
119,
55
],
[
95,
56
],
[
106,
58
],
[
92,
61
],
[
119,
61
],
[
95,
62
],
[
109,
65
],
[
98,
68
],
[
104,
68
],
[
107,
69
],
[
86,
69
],
[
88,
71
],
[
116,
73
],
[
110,
74
],
[
118,
75
],
[
95,
77
],
[
110,
78
],
[
89,
82
],
[
101,
82
],
[
119,
83
],
[
92,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
],
[
115,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
]
] | [
"n=int(input())\nx,y=1,1\nfor i in range(n):\n a,b=map(int,input().split())\n if x%a==0:\n x1=x//a\n else:\n x1=x//a+1\n if y%b==0:\n y1=y//b\n else:\n y1=y//b+1\n z1=max(x1,y1)\n x,y=a*z1,b*z1\nprint(x+y)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"x,y=1,1",
"x",
"1",
"y",
"1",
"for i in range(n):\n a,b=map(int,input().split())\n if x%a==0:\n x1=x//a\n else:\n x1=x//a+1\n if y%b==0:\n y1=y//b\n else:\n y1=y//b+1\n z1=max(x1,y1)\n x,y=a*z1,b*z1",
"i",
"range(n)",
"range",
"n",
"a,b=map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"if x%a==0:\n x1=x//a\n else:\n x1=x//a+1\n ",
"x%a==0",
"x%a",
"x",
"a",
"0",
"x1=x//a",
"x1",
"x//a",
"x",
"a",
"x1=x//a+1",
"x1",
"x//a+1",
"x//a",
"x",
"a",
"1",
"if y%b==0:\n y1=y//b\n else:\n y1=y//b+1\n ",
"y%b==0",
"y%b",
"y",
"b",
"0",
"y1=y//b",
"y1",
"y//b",
"y",
"b",
"y1=y//b+1",
"y1",
"y//b+1",
"y//b",
"y",
"b",
"1",
"z1=max(x1,y1)",
"z1",
"max(x1,y1)",
"max",
"x1",
"y1",
"x,y=a*z1,b*z1",
"x",
"a*z1",
"a",
"z1",
"y",
"b*z1",
"b",
"z1",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"y1=y//b",
"y//b",
"y1",
"x,y=a*z1,b*z1",
"a*z1",
"x",
"y=1,1",
"1",
"y",
"b=map(int,input().split())",
"map(int,input().split())",
"b",
"x1=x//a+1",
"x//a+1",
"x1",
"x,y=1,1",
"1",
"x",
"x1=x//a",
"x//a",
"x1",
"y1=y//b+1",
"y//b+1",
"y1",
"z1=max(x1,y1)",
"max(x1,y1)",
"z1",
"n=int(input())",
"int(input())",
"n",
"a,b=map(int,input().split())",
"map(int,input().split())",
"a",
"y=a*z1,b*z1",
"b*z1",
"y"
] | n=int(input())
x,y=1,1
for i in range(n):
a,b=map(int,input().split())
if x%a==0:
x1=x//a
else:
x1=x//a+1
if y%b==0:
y1=y//b
else:
y1=y//b+1
z1=max(x1,y1)
x,y=a*z1,b*z1
print(x+y) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
29,
40,
2,
40,
13,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13
] | [
[
96,
4
],
[
19,
16
],
[
21,
17
],
[
19,
19
],
[
21,
21
],
[
26,
25
],
[
97,
29
],
[
33,
32
],
[
25,
35
],
[
97,
47
],
[
52,
51
],
[
55,
54
],
[
57,
56
],
[
64,
63
],
[
103,
67
],
[
54,
68
],
[
75,
68
],
[
103,
71
],
[
56,
72
],
[
80,
72
],
[
76,
75
],
[
63,
77
],
[
81,
80
],
[
63,
82
],
[
75,
87
],
[
54,
87
],
[
80,
88
],
[
56,
88
],
[
100,
94
],
[
96,
97
]
] | [
"import sys\nreadline = sys.stdin.readline\n\ndef ceil(a, b):\n return -(-a//b)\n\ndef main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 1, 1\n for t, a in inp:\n n = max(ceil(scr_t, t), ceil(scr_a, a))\n scr_t = n * t\n scr_a = n * a\n\n print(scr_t + scr_a)\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"readline = sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def ceil(a, b):\n return -(-a//b)",
"ceil",
"return -(-a//b)",
"-(-a//b)",
"-a//b",
"-a",
"a",
"b",
"a",
"a",
"b",
"b",
"def main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 1, 1\n for t, a in inp:\n n = max(ceil(scr_t, t), ceil(scr_a, a))\n scr_t = n * t\n scr_a = n * a\n\n print(scr_t + scr_a)",
"main",
"N = int(readline())",
"N",
"int(readline())",
"int",
"readline()",
"readline",
"tuple(map(int, readline().rstrip().split())) for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"tuple(map(int, readline().rstrip().split()))",
"tuple",
"map(int, readline().rstrip().split())",
"map",
"int",
"readline().rstrip().split()",
"().rstrip().split",
"().rstrip()",
"().rstrip",
"()",
"readline",
"rstrip",
"split",
"inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]",
"inp",
"[tuple(map(int, readline().rstrip().split())) for _ in range(N)]",
"scr_t, scr_a = 1, 1",
"scr_t",
"1",
"scr_a",
"1",
"for t, a in inp:\n n = max(ceil(scr_t, t), ceil(scr_a, a))\n scr_t = n * t\n scr_a = n * a\n\n ",
"t",
"a",
"inp",
"n = max(ceil(scr_t, t), ceil(scr_a, a))",
"n",
"max(ceil(scr_t, t), ceil(scr_a, a))",
"max",
"ceil(scr_t, t)",
"ceil",
"scr_t",
"t",
"ceil(scr_a, a)",
"ceil",
"scr_a",
"a",
"scr_t = n * t",
"scr_t",
"n * t",
"n",
"t",
"scr_a = n * a",
"scr_a",
"n * a",
"n",
"a",
"print(scr_t + scr_a)",
"print",
"scr_t + scr_a",
"scr_t",
"scr_a",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"readline = sys.stdin.readline",
"sys.stdin.readline",
"readline",
"def main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 1, 1\n for t, a in inp:\n n = max(ceil(scr_t, t), ceil(scr_a, a))\n scr_t = n * t\n scr_a = n * a\n\n print(scr_t + scr_a)",
"def main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 1, 1\n for t, a in inp:\n n = max(ceil(scr_t, t), ceil(scr_a, a))\n scr_t = n * t\n scr_a = n * a\n\n print(scr_t + scr_a)",
"main",
"def ceil(a, b):\n return -(-a//b)",
"def ceil(a, b):\n return -(-a//b)",
"ceil"
] | import sys
readline = sys.stdin.readline
def ceil(a, b):
return -(-a//b)
def main():
N = int(readline())
inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]
scr_t, scr_a = 1, 1
for t, a in inp:
n = max(ceil(scr_t, t), ceil(scr_a, a))
scr_t = n * t
scr_a = n * a
print(scr_t + scr_a)
if __name__ == '__main__':
main() |
[
7,
0,
13,
4,
13,
4,
13,
12,
13,
29,
2,
2,
2,
13,
13,
17,
13,
23,
13,
23,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
69,
2
],
[
18,
13
],
[
20,
14
],
[
20,
16
],
[
18,
18
],
[
20,
20
],
[
78,
22
],
[
93,
24
],
[
28,
27
],
[
70,
30
],
[
90,
32
],
[
90,
41
],
[
84,
43
],
[
73,
47
],
[
79,
48
],
[
76,
48
],
[
82,
49
],
[
73,
51
],
[
94,
52
],
[
88,
52
],
[
91,
53
],
[
75,
55
],
[
82,
57
],
[
85,
58
],
[
87,
59
],
[
91,
61
],
[
85,
62
],
[
76,
66
],
[
79,
66
],
[
88,
67
],
[
94,
67
],
[
69,
70
],
[
75,
76
],
[
78,
79
],
[
90,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
]
] | [
"N = int(input())\n\n\ndef ceil(a, b):\n return (a + b - 1) // b\n\n\nT, A = 1, 1\nfor _ in range(N):\n Tt, At = map(int, input().split())\n x = max(ceil(T , Tt), ceil(A , At))\n T, A = Tt * x, At * x\nprint(T + A)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"def ceil(a, b):\n return (a + b - 1) // b",
"ceil",
"return (a + b - 1) // b",
"(a + b - 1) // b",
"a + b - 1",
"a + b",
"a",
"b",
"1",
"b",
"a",
"a",
"b",
"b",
"T, A = 1, 1",
"T",
"1",
"A",
"1",
"for _ in range(N):\n Tt, At = map(int, input().split())\n x = max(ceil(T , Tt), ceil(A , At))\n T, A = Tt * x, At * x",
"_",
"range(N)",
"range",
"N",
"Tt, At = map(int, input().split())",
"Tt",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"At",
"x = max(ceil(T , Tt), ceil(A , At))",
"x",
"max(ceil(T , Tt), ceil(A , At))",
"max",
"ceil(T , Tt)",
"ceil",
"T",
"Tt",
"ceil(A , At)",
"ceil",
"A",
"At",
"T, A = Tt * x, At * x",
"T",
"Tt * x",
"Tt",
"x",
"A",
"At * x",
"At",
"x",
"print(T + A)",
"print",
"T + A",
"T",
"A",
"N = int(input())",
"int(input())",
"N",
"def ceil(a, b):\n return (a + b - 1) // b",
"def ceil(a, b):\n return (a + b - 1) // b",
"ceil",
"T, A = Tt * x, At * x",
"Tt * x",
"T",
"T, A = 1, 1",
"1",
"T",
"Tt, At = map(int, input().split())",
"map(int, input().split())",
"Tt",
"x = max(ceil(T , Tt), ceil(A , At))",
"max(ceil(T , Tt), ceil(A , At))",
"x",
"A = Tt * x, At * x",
"At * x",
"A",
"At = map(int, input().split())",
"map(int, input().split())",
"At",
"A = 1, 1",
"1",
"A"
] | N = int(input())
def ceil(a, b):
return (a + b - 1) // b
T, A = 1, 1
for _ in range(N):
Tt, At = map(int, input().split())
x = max(ceil(T , Tt), ceil(A , At))
T, A = Tt * x, At * x
print(T + A)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
39,
13,
13,
0,
13,
18,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
17,
0,
13,
13,
0,
13,
13,
13,
13,
28,
13,
4,
13,
17,
13,
0,
13,
18,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
4,
13,
39,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
18,
13,
10,
2,
13,
10,
18,
13,
10,
13,
13,
10,
39,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13
] | [
[
182,
2
],
[
152,
8
],
[
12,
11
],
[
183,
14
],
[
161,
16
],
[
161,
25
],
[
153,
28
],
[
185,
34
],
[
153,
36
],
[
185,
38
],
[
170,
40
],
[
165,
42
],
[
132,
42
],
[
186,
43
],
[
162,
43
],
[
176,
45
],
[
134,
48
],
[
177,
49
],
[
149,
51
],
[
165,
52
],
[
132,
52
],
[
125,
53
],
[
186,
54
],
[
162,
54
],
[
57,
56
],
[
183,
60
],
[
146,
62
],
[
153,
64
],
[
56,
65
],
[
146,
66
],
[
173,
68
],
[
141,
70
],
[
165,
70
],
[
132,
70
],
[
147,
71
],
[
186,
71
],
[
162,
71
],
[
167,
73
],
[
171,
77
],
[
138,
77
],
[
174,
78
],
[
174,
80
],
[
155,
82
],
[
150,
86
],
[
129,
86
],
[
141,
87
],
[
165,
87
],
[
132,
87
],
[
141,
89
],
[
165,
89
],
[
132,
89
],
[
143,
91
],
[
126,
95
],
[
159,
95
],
[
147,
96
],
[
186,
96
],
[
162,
96
],
[
147,
98
],
[
186,
98
],
[
162,
98
],
[
179,
100
],
[
128,
108
],
[
180,
110
],
[
168,
110
],
[
177,
110
],
[
141,
111
],
[
165,
111
],
[
132,
111
],
[
158,
112
],
[
180,
114
],
[
168,
114
],
[
177,
114
],
[
147,
115
],
[
186,
115
],
[
162,
115
],
[
137,
117
],
[
129,
119
],
[
150,
119
],
[
159,
120
],
[
126,
120
],
[
138,
123
],
[
171,
123
],
[
186,
125
],
[
162,
125
],
[
125,
126
],
[
128,
129
],
[
161,
132
],
[
177,
134
],
[
134,
135
],
[
137,
138
],
[
146,
141
],
[
143,
144
],
[
146,
147
],
[
165,
149
],
[
132,
149
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
],
[
161,
162
],
[
185,
165
],
[
167,
168
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
],
[
182,
183
],
[
185,
186
]
] | [
"N = int(input())\nTA = []\nfor i in range(N):\n T, A = map(int, input().split())\n TA.append((T, A))\n\nT, A = TA[0]\nanswer = T+A\np = 1\nprev = p\npT, pA = T, A\nfor i in range(1,N):\n # (T+A) * p >= prev\n # p >= prev/(T+A)\n T, A = TA[i]\n s = T+A\n p = (answer+s-1)//s\n p1 = (pT+T-1)//T\n p2 = (pA+A-1)//A\n p = max([p,p1,p2])\n pT, pA = p*T, p*A\n answer = pT+pA\n #print(T, A, p, answer, sep=\"\\t\")\nprint(answer)\n\n ",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"TA = []",
"TA",
"[]",
"for i in range(N):\n T, A = map(int, input().split())\n TA.append((T, A))",
"i",
"range(N)",
"range",
"N",
"T, A = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"TA.append((T, A))",
"TA.append",
"TA",
"append",
"(T, A)",
"T",
"A",
"T, A = TA[0]",
"T",
"TA[0]",
"TA",
"0",
"A",
"answer = T+A",
"answer",
"T+A",
"T",
"A",
"p = 1",
"p",
"1",
"prev = p",
"prev",
"p",
"pT, pA = T, A",
"pT",
"T",
"pA",
"A",
"for i in range(1,N):\n # (T+A) * p >= prev\n # p >= prev/(T+A)\n T, A = TA[i]\n s = T+A\n p = (answer+s-1)//s\n p1 = (pT+T-1)//T\n p2 = (pA+A-1)//A\n p = max([p,p1,p2])\n pT, pA = p*T, p*A\n answer = pT+pA\n #print(T, A, p, answer, sep=\"\\t\")",
"i",
"range(1,N)",
"range",
"1",
"N",
"T, A = TA[i]",
"T",
"TA[i]",
"TA",
"i",
"A",
"s = T+A",
"s",
"T+A",
"T",
"A",
"p = (answer+s-1)//s",
"p",
"(answer+s-1)//s",
"answer+s-1",
"answer+s",
"answer",
"s",
"1",
"s",
"p1 = (pT+T-1)//T",
"p1",
"(pT+T-1)//T",
"pT+T-1",
"pT+T",
"pT",
"T",
"1",
"T",
"p2 = (pA+A-1)//A",
"p2",
"(pA+A-1)//A",
"pA+A-1",
"pA+A",
"pA",
"A",
"1",
"A",
"p = max([p,p1,p2])",
"p",
"max([p,p1,p2])",
"max",
"[p,p1,p2]",
"p",
"p1",
"p2",
"pT, pA = p*T, p*A",
"pT",
"p*T",
"p",
"T",
"pA",
"p*A",
"p",
"A",
"answer = pT+pA",
"answer",
"pT+pA",
"pT",
"pA",
"print(answer)",
"print",
"answer",
"pA = T, A",
"A",
"pA",
"pT, pA = p*T, p*A",
"p*T",
"pT",
"T, A = map(int, input().split())",
"map(int, input().split())",
"T",
"prev = p",
"p",
"prev",
"answer = pT+pA",
"pT+pA",
"answer",
"T, A = TA[i]",
"TA[i]",
"T",
"p2 = (pA+A-1)//A",
"(pA+A-1)//A",
"p2",
"A = TA[i]",
"TA[i]",
"A",
"pT, pA = T, A",
"T",
"pT",
"TA = []",
"[]",
"TA",
"p1 = (pT+T-1)//T",
"(pT+T-1)//T",
"p1",
"pA = p*T, p*A",
"p*A",
"pA",
"A = map(int, input().split())",
"map(int, input().split())",
"A",
"T, A = TA[0]",
"TA[0]",
"T",
"p = (answer+s-1)//s",
"(answer+s-1)//s",
"p",
"answer = T+A",
"T+A",
"answer",
"s = T+A",
"T+A",
"s",
"p = 1",
"1",
"p",
"p = max([p,p1,p2])",
"max([p,p1,p2])",
"p",
"N = int(input())",
"int(input())",
"N",
"A = TA[0]",
"TA[0]",
"A"
] | N = int(input())
TA = []
for i in range(N):
T, A = map(int, input().split())
TA.append((T, A))
T, A = TA[0]
answer = T+A
p = 1
prev = p
pT, pA = T, A
for i in range(1,N):
# (T+A) * p >= prev
# p >= prev/(T+A)
T, A = TA[i]
s = T+A
p = (answer+s-1)//s
p1 = (pT+T-1)//T
p2 = (pA+A-1)//A
p = max([p,p1,p2])
pT, pA = p*T, p*A
answer = pT+pA
#print(T, A, p, answer, sep="\t")
print(answer)
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
0,
13,
2,
2,
2,
13,
18,
13,
13,
17,
18,
13,
13,
0,
13,
2,
2,
2,
13,
18,
13,
13,
17,
18,
13,
13,
0,
13,
2,
18,
13,
13,
4,
13,
13,
13,
0,
13,
2,
18,
13,
13,
4,
13,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
18,
13,
10,
39,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
39,
13,
10,
18,
13
] | [
[
128,
4
],
[
137,
11
],
[
129,
15
],
[
146,
17
],
[
131,
20
],
[
24,
23
],
[
138,
26
],
[
119,
28
],
[
129,
35
],
[
119,
37
],
[
147,
40
],
[
117,
42
],
[
132,
45
],
[
120,
47
],
[
149,
49
],
[
147,
51
],
[
134,
54
],
[
132,
56
],
[
60,
59
],
[
138,
63
],
[
122,
65
],
[
150,
69
],
[
126,
69
],
[
147,
71
],
[
59,
72
],
[
147,
75
],
[
59,
76
],
[
143,
78
],
[
135,
82
],
[
141,
82
],
[
132,
84
],
[
59,
85
],
[
132,
88
],
[
59,
89
],
[
125,
91
],
[
147,
94
],
[
59,
95
],
[
123,
98
],
[
144,
99
],
[
140,
101
],
[
132,
104
],
[
59,
105
],
[
123,
108
],
[
144,
109
],
[
126,
113
],
[
150,
113
],
[
141,
114
],
[
135,
114
],
[
119,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
]
] | [
"import sys\ninput = sys.stdin.readline\nN = int(input())\nT = []\nA = []\nfor i in range(N) :\n p, q = map(int,input().split())\n T.append(p)\n A.append(q)\n\nTak = T[0]\nAok = A[0]\nfor i in range(1, N) :\n Tb = (Tak + T[i] - 1) // T[i]\n Ab = (Aok + A[i] - 1) // A[i]\n Tak = T[i] * max(Tb, Ab)\n Aok = A[i] * max(Tb, Ab)\n\nprint(Tak + Aok)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T = []",
"T",
"[]",
"A = []",
"A",
"[]",
"for i in range(N) :\n p, q = map(int,input().split())\n T.append(p)\n A.append(q)",
"i",
"range(N)",
"range",
"N",
"p, q = map(int,input().split())",
"p",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"q",
"T.append(p)",
"T.append",
"T",
"append",
"p",
"A.append(q)",
"A.append",
"A",
"append",
"q",
"Tak = T[0]",
"Tak",
"T[0]",
"T",
"0",
"Aok = A[0]",
"Aok",
"A[0]",
"A",
"0",
"for i in range(1, N) :\n Tb = (Tak + T[i] - 1) // T[i]\n Ab = (Aok + A[i] - 1) // A[i]\n Tak = T[i] * max(Tb, Ab)\n Aok = A[i] * max(Tb, Ab)",
"i",
"range(1, N)",
"range",
"1",
"N",
"Tb = (Tak + T[i] - 1) // T[i]",
"Tb",
"(Tak + T[i] - 1) // T[i]",
"Tak + T[i] - 1",
"Tak + T[i]",
"Tak",
"T[i]",
"T",
"i",
"1",
"T[i]",
"T",
"i",
"Ab = (Aok + A[i] - 1) // A[i]",
"Ab",
"(Aok + A[i] - 1) // A[i]",
"Aok + A[i] - 1",
"Aok + A[i]",
"Aok",
"A[i]",
"A",
"i",
"1",
"A[i]",
"A",
"i",
"Tak = T[i] * max(Tb, Ab)",
"Tak",
"T[i] * max(Tb, Ab)",
"T[i]",
"T",
"i",
"max(Tb, Ab)",
"max",
"Tb",
"Ab",
"Aok = A[i] * max(Tb, Ab)",
"Aok",
"A[i] * max(Tb, Ab)",
"A[i]",
"A",
"i",
"max(Tb, Ab)",
"max",
"Tb",
"Ab",
"print(Tak + Aok)",
"print",
"Tak + Aok",
"Tak",
"Aok",
"p, q = map(int,input().split())",
"map(int,input().split())",
"p",
"q = map(int,input().split())",
"map(int,input().split())",
"q",
"Tb = (Tak + T[i] - 1) // T[i]",
"(Tak + T[i] - 1) // T[i]",
"Tb",
"Tak = T[i] * max(Tb, Ab)",
"T[i] * max(Tb, Ab)",
"Tak",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"A = []",
"[]",
"A",
"Aok = A[0]",
"A[0]",
"Aok",
"N = int(input())",
"int(input())",
"N",
"Aok = A[i] * max(Tb, Ab)",
"A[i] * max(Tb, Ab)",
"Aok",
"Ab = (Aok + A[i] - 1) // A[i]",
"(Aok + A[i] - 1) // A[i]",
"Ab",
"T = []",
"[]",
"T",
"Tak = T[0]",
"T[0]",
"Tak"
] | import sys
input = sys.stdin.readline
N = int(input())
T = []
A = []
for i in range(N) :
p, q = map(int,input().split())
T.append(p)
A.append(q)
Tak = T[0]
Aok = A[0]
for i in range(1, N) :
Tb = (Tak + T[i] - 1) // T[i]
Ab = (Aok + A[i] - 1) // A[i]
Tak = T[i] * max(Tb, Ab)
Aok = A[i] * max(Tb, Ab)
print(Tak + Aok)
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
4,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
40,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13
] | [
[
131,
4
],
[
113,
11
],
[
132,
15
],
[
146,
17
],
[
149,
19
],
[
23,
22
],
[
114,
25
],
[
122,
27
],
[
132,
34
],
[
122,
36
],
[
123,
39
],
[
120,
40
],
[
125,
42
],
[
147,
45
],
[
105,
45
],
[
117,
45
],
[
111,
45
],
[
150,
46
],
[
144,
46
],
[
141,
46
],
[
126,
46
],
[
125,
48
],
[
137,
51
],
[
147,
55
],
[
117,
55
],
[
111,
55
],
[
105,
55
],
[
123,
56
],
[
123,
58
],
[
107,
60
],
[
138,
62
],
[
129,
62
],
[
123,
63
],
[
134,
65
],
[
138,
67
],
[
129,
67
],
[
120,
68
],
[
135,
71
],
[
150,
72
],
[
144,
72
],
[
141,
72
],
[
126,
72
],
[
110,
74
],
[
108,
75
],
[
140,
77
],
[
135,
78
],
[
128,
80
],
[
150,
84
],
[
144,
84
],
[
141,
84
],
[
126,
84
],
[
120,
85
],
[
120,
87
],
[
116,
89
],
[
129,
91
],
[
138,
91
],
[
123,
92
],
[
143,
94
],
[
129,
96
],
[
138,
96
],
[
120,
97
],
[
117,
101
],
[
111,
101
],
[
105,
101
],
[
147,
101
],
[
144,
102
],
[
141,
102
],
[
126,
102
],
[
150,
102
],
[
125,
105
],
[
107,
108
],
[
108,
110
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
122,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
],
[
135,
140
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
]
] | [
"import sys\ninput = sys.stdin.readline\n\nN = int(input())\ntak, aok = 1, 1\nfor _ in range(N):\n T, A = map(int, input().split())\n if T == A:\n tak = aok = max(tak, aok)\n else:\n f = (tak + T - 1) // T\n t = f * T\n a = f * A\n if a >= aok:\n tak = t\n aok = a\n else:\n f = (aok + A - 1) // A\n tak = f * T\n aok = f * A\nprint(tak + aok)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"tak, aok = 1, 1",
"tak",
"1",
"aok",
"1",
"for _ in range(N):\n T, A = map(int, input().split())\n if T == A:\n tak = aok = max(tak, aok)\n else:\n f = (tak + T - 1) // T\n t = f * T\n a = f * A\n if a >= aok:\n tak = t\n aok = a\n else:\n f = (aok + A - 1) // A\n tak = f * T\n aok = f * A",
"_",
"range(N)",
"range",
"N",
"T, A = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"if T == A:\n tak = aok = max(tak, aok)\n else:\n f = (tak + T - 1) // T\n t = f * T\n a = f * A\n if a >= aok:\n tak = t\n aok = a\n else:\n f = (aok + A - 1) // A\n tak = f * T\n aok = f * A",
"T == A",
"T",
"A",
"tak = aok = max(tak, aok)",
"tak",
"max(tak, aok)",
"max",
"tak",
"aok",
"= aok = max(tak, aok)",
"aok",
"max(tak, aok)",
"f = (tak + T - 1) // T",
"f",
"(tak + T - 1) // T",
"tak + T - 1",
"tak + T",
"tak",
"T",
"1",
"T",
"t = f * T",
"t",
"f * T",
"f",
"T",
"a = f * A",
"a",
"f * A",
"f",
"A",
"if a >= aok:\n tak = t\n aok = a\n else:\n f = (aok + A - 1) // A\n tak = f * T\n aok = f * A",
"a >= aok",
"a",
"aok",
"tak = t",
"tak",
"t",
"aok = a",
"aok",
"a",
"f = (aok + A - 1) // A",
"f",
"(aok + A - 1) // A",
"aok + A - 1",
"aok + A",
"aok",
"A",
"1",
"A",
"tak = f * T",
"tak",
"f * T",
"f",
"T",
"aok = f * A",
"aok",
"f * A",
"f",
"A",
"print(tak + aok)",
"print",
"tak + aok",
"tak",
"aok",
"tak = aok = max(tak, aok)",
"max(tak, aok)",
"tak",
"t = f * T",
"f * T",
"t",
"tak = t",
"t",
"tak",
"N = int(input())",
"int(input())",
"N",
"tak = f * T",
"f * T",
"tak",
"A = map(int, input().split())",
"map(int, input().split())",
"A",
"T, A = map(int, input().split())",
"map(int, input().split())",
"T",
"aok = max(tak, aok)",
"max(tak, aok)",
"aok",
"f = (aok + A - 1) // A",
"(aok + A - 1) // A",
"f",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"a = f * A",
"f * A",
"a",
"f = (tak + T - 1) // T",
"(tak + T - 1) // T",
"f",
"aok = a",
"a",
"aok",
"aok = f * A",
"f * A",
"aok",
"tak, aok = 1, 1",
"1",
"tak",
"aok = 1, 1",
"1",
"aok"
] | import sys
input = sys.stdin.readline
N = int(input())
tak, aok = 1, 1
for _ in range(N):
T, A = map(int, input().split())
if T == A:
tak = aok = max(tak, aok)
else:
f = (tak + T - 1) // T
t = f * T
a = f * A
if a >= aok:
tak = t
aok = a
else:
f = (aok + A - 1) // A
tak = f * T
aok = f * A
print(tak + aok)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
14,
2,
13,
13,
0,
13,
13,
0,
13,
13,
14,
2,
2,
13,
13,
2,
13,
13,
14,
40,
2,
13,
13,
17,
0,
13,
2,
13,
2,
13,
13,
0,
13,
13,
0,
13,
2,
2,
13,
13,
13,
14,
40,
2,
13,
13,
17,
0,
13,
2,
13,
2,
13,
13,
0,
13,
13,
0,
13,
2,
2,
13,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
134,
2
],
[
146,
8
],
[
146,
17
],
[
20,
19
],
[
135,
23
],
[
143,
26
],
[
143,
35
],
[
123,
38
],
[
144,
39
],
[
117,
42
],
[
141,
42
],
[
120,
42
],
[
132,
42
],
[
147,
43
],
[
114,
43
],
[
126,
43
],
[
138,
43
],
[
131,
45
],
[
147,
46
],
[
114,
46
],
[
126,
46
],
[
138,
46
],
[
137,
48
],
[
117,
49
],
[
141,
49
],
[
120,
49
],
[
132,
49
],
[
123,
53
],
[
144,
54
],
[
117,
56
],
[
141,
56
],
[
120,
56
],
[
132,
56
],
[
147,
57
],
[
114,
57
],
[
126,
57
],
[
138,
57
],
[
147,
61
],
[
114,
61
],
[
126,
61
],
[
138,
61
],
[
144,
62
],
[
128,
65
],
[
144,
67
],
[
147,
69
],
[
114,
69
],
[
126,
69
],
[
138,
69
],
[
144,
70
],
[
125,
72
],
[
129,
73
],
[
111,
73
],
[
119,
75
],
[
126,
78
],
[
138,
78
],
[
147,
78
],
[
114,
78
],
[
123,
79
],
[
144,
80
],
[
117,
84
],
[
141,
84
],
[
120,
84
],
[
132,
84
],
[
123,
85
],
[
110,
88
],
[
123,
90
],
[
117,
92
],
[
141,
92
],
[
120,
92
],
[
132,
92
],
[
123,
93
],
[
140,
95
],
[
111,
96
],
[
129,
96
],
[
113,
98
],
[
141,
101
],
[
120,
101
],
[
132,
101
],
[
117,
101
],
[
144,
102
],
[
123,
103
],
[
141,
107
],
[
120,
107
],
[
132,
107
],
[
117,
107
],
[
114,
108
],
[
126,
108
],
[
138,
108
],
[
147,
108
],
[
110,
111
],
[
113,
114
],
[
146,
117
],
[
119,
120
],
[
143,
123
],
[
129,
125
],
[
111,
125
],
[
125,
126
],
[
128,
129
],
[
147,
131
],
[
114,
131
],
[
126,
131
],
[
138,
131
],
[
131,
132
],
[
134,
135
],
[
117,
137
],
[
141,
137
],
[
120,
137
],
[
132,
137
],
[
137,
138
],
[
111,
140
],
[
129,
140
],
[
140,
141
],
[
143,
144
],
[
146,
147
]
] | [
"N=int(input())\nA,B=map(int,input().split())\nfor i in range(N-1):\n a,b=map(int,input().split())\n if a==b:\n if A<B:\n A=B\n else:\n B=A\n \n else:\n if a/b > A/B:\n # Bに対していく\n if B%b!=0:\n plus=b-(B%b)\n B+=plus\n A=(B*a)//b\n else:\n # Aに足していく\n if A%a!=0:\n plus=a-(A%a)\n A+=plus\n B=(A*b)//a\n\nprint(A+B) ",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"A,B=map(int,input().split())",
"A",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"B",
"for i in range(N-1):\n a,b=map(int,input().split())\n if a==b:\n if A<B:\n A=B\n else:\n B=A\n \n else:\n if a/b > A/B:\n # Bに対していく\n if B%b!=0:\n plus=b-(B%b)\n B+=plus\n A=(B*a)//b\n else:\n # Aに足していく\n if A%a!=0:\n plus=a-(A%a)\n A+=plus\n B=(A*b)//a",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"a,b=map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"if a==b:\n if A<B:\n A=B\n else:\n B=A\n \n else:\n if a/b > A/B:\n # Bに対していく\n if B%b!=0:\n plus=b-(B%b)\n B+=plus\n A=(B*a)//b\n else:\n # Aに足していく\n if A%a!=0:\n plus=a-(A%a)\n A+=plus\n B=(A*b)//a",
"a==b",
"a",
"b",
"if A<B:\n A=B\n else:\n B=A\n \n ",
"A<B",
"A",
"B",
"A=B",
"A",
"B",
"B=A",
"B",
"A",
"if a/b > A/B:\n # Bに対していく\n if B%b!=0:\n plus=b-(B%b)\n B+=plus\n A=(B*a)//b\n else:\n # Aに足していく\n if A%a!=0:\n plus=a-(A%a)\n A+=plus\n B=(A*b)//a",
"a/b > A/B",
"a/b",
"a",
"b",
"A/B",
"A",
"B",
"if B%b!=0:\n plus=b-(B%b)\n B+=plus\n ",
"B%b!=0",
"B%b",
"B",
"b",
"0",
"plus=b-(B%b)",
"plus",
"b-(B%b)",
"b",
"B%b",
"B",
"b",
"B+=plus",
"B",
"plus",
"A=(B*a)//b",
"A",
"(B*a)//b",
"B*a",
"B",
"a",
"b",
"if A%a!=0:\n plus=a-(A%a)\n A+=plus\n ",
"A%a!=0",
"A%a",
"A",
"a",
"0",
"plus=a-(A%a)",
"plus",
"a-(A%a)",
"a",
"A%a",
"A",
"a",
"A+=plus",
"A",
"plus",
"B=(A*b)//a",
"B",
"(A*b)//a",
"A*b",
"A",
"b",
"a",
"print(A+B)",
"print",
"A+B",
"A",
"B",
"plus=a-(A%a)",
"a-(A%a)",
"plus",
"B=(A*b)//a",
"(A*b)//a",
"B",
"A,B=map(int,input().split())",
"map(int,input().split())",
"A",
"A=(B*a)//b",
"(B*a)//b",
"A",
"a,b=map(int,input().split())",
"map(int,input().split())",
"a",
"B+=plus",
"plus",
"B",
"plus=b-(B%b)",
"b-(B%b)",
"plus",
"A=B",
"B",
"A",
"N=int(input())",
"int(input())",
"N",
"B=A",
"A",
"B",
"A+=plus",
"plus",
"A",
"b=map(int,input().split())",
"map(int,input().split())",
"b",
"B=map(int,input().split())",
"map(int,input().split())",
"B"
] | N=int(input())
A,B=map(int,input().split())
for i in range(N-1):
a,b=map(int,input().split())
if a==b:
if A<B:
A=B
else:
B=A
else:
if a/b > A/B:
# Bに対していく
if B%b!=0:
plus=b-(B%b)
B+=plus
A=(B*a)//b
else:
# Aに足していく
if A%a!=0:
plus=a-(A%a)
A+=plus
B=(A*b)//a
print(A+B) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13
] | [
[
85,
2
],
[
76,
8
],
[
76,
11
],
[
15,
14
],
[
86,
17
],
[
21,
20
],
[
20,
29
],
[
82,
31
],
[
82,
33
],
[
73,
35
],
[
77,
41
],
[
71,
41
],
[
83,
42
],
[
83,
44
],
[
68,
48
],
[
89,
48
],
[
80,
49
],
[
80,
51
],
[
70,
53
],
[
74,
55
],
[
83,
56
],
[
88,
57
],
[
74,
59
],
[
80,
60
],
[
71,
64
],
[
77,
64
],
[
89,
65
],
[
68,
65
],
[
76,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
82,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
]
] | [
"n = int(input())\nt_v = a_v = 1\nfor _ in range(n):\n t, a = [int(x) for x in input().split()]\n r = max((t_v + t - 1) // t, (a_v + a - 1) // a)\n t_v, a_v = r * t, r * a\nprint(t_v + a_v)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"t_v = a_v = 1",
"t_v",
"1",
"= a_v = 1",
"a_v",
"1",
"for _ in range(n):\n t, a = [int(x) for x in input().split()]\n r = max((t_v + t - 1) // t, (a_v + a - 1) // a)\n t_v, a_v = r * t, r * a",
"_",
"range(n)",
"range",
"n",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"t, a = [int(x) for x in input().split()]",
"t",
"[int(x) for x in input().split()]",
"a",
"r = max((t_v + t - 1) // t, (a_v + a - 1) // a)",
"r",
"max((t_v + t - 1) // t, (a_v + a - 1) // a)",
"max",
"(t_v + t - 1) // t",
"t_v + t - 1",
"t_v + t",
"t_v",
"t",
"1",
"t",
"(a_v + a - 1) // a",
"a_v + a - 1",
"a_v + a",
"a_v",
"a",
"1",
"a",
"t_v, a_v = r * t, r * a",
"t_v",
"r * t",
"r",
"t",
"a_v",
"r * a",
"r",
"a",
"print(t_v + a_v)",
"print",
"t_v + a_v",
"t_v",
"a_v",
"a_v = 1",
"1",
"a_v",
"t_v, a_v = r * t, r * a",
"r * t",
"t_v",
"r = max((t_v + t - 1) // t, (a_v + a - 1) // a)",
"max((t_v + t - 1) // t, (a_v + a - 1) // a)",
"r",
"t_v = a_v = 1",
"1",
"t_v",
"a = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"a",
"t, a = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"t",
"n = int(input())",
"int(input())",
"n",
"a_v = r * t, r * a",
"r * a",
"a_v"
] | n = int(input())
t_v = a_v = 1
for _ in range(n):
t, a = [int(x) for x in input().split()]
r = max((t_v + t - 1) // t, (a_v + a - 1) // a)
t_v, a_v = r * t, r * a
print(t_v + a_v) |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
39,
13,
13,
0,
13,
18,
13,
17,
13,
28,
13,
4,
13,
17,
13,
0,
13,
18,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
39,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
39,
13,
10,
2,
13,
10,
18,
13,
10,
18,
13
] | [
[
119,
4
],
[
152,
13
],
[
140,
22
],
[
113,
31
],
[
153,
35
],
[
146,
37
],
[
116,
40
],
[
44,
43
],
[
114,
46
],
[
143,
48
],
[
153,
55
],
[
143,
57
],
[
147,
60
],
[
137,
66
],
[
147,
68
],
[
137,
70
],
[
73,
72
],
[
114,
76
],
[
155,
78
],
[
147,
80
],
[
72,
81
],
[
155,
82
],
[
128,
84
],
[
138,
90
],
[
150,
90
],
[
132,
91
],
[
126,
91
],
[
123,
95
],
[
135,
95
],
[
156,
96
],
[
144,
96
],
[
149,
98
],
[
129,
100
],
[
132,
101
],
[
126,
101
],
[
134,
103
],
[
129,
105
],
[
156,
106
],
[
144,
106
],
[
150,
110
],
[
138,
110
],
[
135,
111
],
[
123,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
137,
123
],
[
143,
126
],
[
128,
129
],
[
155,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
]
] | [
"# -*- coding: utf-8 -*-\nimport sys \nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nN = int(readline())\ndata = []\nX = []\nfor i in range(N):\n T, A = map(int, readline().split())\n data.append((T,A))\n\nT_pre,A_pre = data[0] \nfor i in range(1,N):\n T,A = data[i]\n n = max(-(-T_pre//T),-(-A_pre//A))\n T_pre = n*T\n A_pre = n*A\nprint(T_pre+A_pre) ",
"import sys",
"sys",
"read = sys.stdin.buffer.read",
"read",
"sys.stdin.buffer.read",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"read",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"readlines = sys.stdin.buffer.readlines",
"readlines",
"sys.stdin.buffer.readlines",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readlines",
"N = int(readline())",
"N",
"int(readline())",
"int",
"readline()",
"readline",
"data = []",
"data",
"[]",
"X = []",
"X",
"[]",
"for i in range(N):\n T, A = map(int, readline().split())\n data.append((T,A))",
"i",
"range(N)",
"range",
"N",
"T, A = map(int, readline().split())",
"T",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"A",
"data.append((T,A))",
"data.append",
"data",
"append",
"(T,A)",
"T",
"A",
"T_pre,A_pre = data[0]",
"T_pre",
"data[0]",
"data",
"0",
"A_pre",
"for i in range(1,N):\n T,A = data[i]\n n = max(-(-T_pre//T),-(-A_pre//A))\n T_pre = n*T\n A_pre = n*A",
"i",
"range(1,N)",
"range",
"1",
"N",
"T,A = data[i]",
"T",
"data[i]",
"data",
"i",
"A",
"n = max(-(-T_pre//T),-(-A_pre//A))",
"n",
"max(-(-T_pre//T),-(-A_pre//A))",
"max",
"-(-T_pre//T)",
"-T_pre//T",
"-T_pre",
"T_pre",
"T",
"-(-A_pre//A)",
"-A_pre//A",
"-A_pre",
"A_pre",
"A",
"T_pre = n*T",
"T_pre",
"n*T",
"n",
"T",
"A_pre = n*A",
"A_pre",
"n*A",
"n",
"A",
"print(T_pre+A_pre)",
"print",
"T_pre+A_pre",
"T_pre",
"A_pre",
"N = int(readline())",
"int(readline())",
"N",
"X = []",
"[]",
"X",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"A_pre = data[0]",
"data[0]",
"A_pre",
"T, A = map(int, readline().split())",
"map(int, readline().split())",
"T",
"n = max(-(-T_pre//T),-(-A_pre//A))",
"max(-(-T_pre//T),-(-A_pre//A))",
"n",
"T,A = data[i]",
"data[i]",
"T",
"A_pre = n*A",
"n*A",
"A_pre",
"T_pre,A_pre = data[0]",
"data[0]",
"T_pre",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"A = map(int, readline().split())",
"map(int, readline().split())",
"A",
"data = []",
"[]",
"data",
"T_pre = n*T",
"n*T",
"T_pre",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"A = data[i]",
"data[i]",
"A"
] | # -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
data = []
X = []
for i in range(N):
T, A = map(int, readline().split())
data.append((T,A))
T_pre,A_pre = data[0]
for i in range(1,N):
T,A = data[i]
n = max(-(-T_pre//T),-(-A_pre//A))
T_pre = n*T
A_pre = n*A
print(T_pre+A_pre) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
31,
13,
0,
13,
17,
13,
17,
28,
13,
13,
4,
13,
31,
2,
39,
4,
13,
13,
17,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
29,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
2,
13,
10,
17,
13,
10,
18,
13,
10,
18,
13,
10,
12,
13
] | [
[
116,
4
],
[
125,
11
],
[
128,
18
],
[
119,
32
],
[
122,
37
],
[
43,
42
],
[
117,
49
],
[
43,
51
],
[
55,
54
],
[
57,
56
],
[
72,
71
],
[
54,
75
],
[
95,
75
],
[
81,
80
],
[
56,
84
],
[
99,
84
],
[
90,
89
],
[
71,
92
],
[
80,
93
],
[
96,
95
],
[
89,
98
],
[
100,
99
],
[
89,
102
],
[
95,
106
],
[
54,
106
],
[
99,
107
],
[
56,
107
],
[
132,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
]
] | [
"import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n N, *TA = map(int, read().split())\n\n x, y = 1, 1\n\n for t, a in zip(*[iter(TA)] * 2):\n m1 = (x + t - 1) // t\n m2 = (y + a - 1) // a\n m = max(m1, m2)\n x, y = t * m, a * m\n\n print(x + y)\n return\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"read = sys.stdin.read",
"read",
"sys.stdin.read",
"sys.stdin",
"sys",
"stdin",
"read",
"readline = sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"readlines = sys.stdin.readlines",
"readlines",
"sys.stdin.readlines",
"sys.stdin",
"sys",
"stdin",
"readlines",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"INF = 1 << 60",
"INF",
"1 << 60",
"1",
"60",
"MOD = 1000000007",
"MOD",
"1000000007",
"def main():\n N, *TA = map(int, read().split())\n\n x, y = 1, 1\n\n for t, a in zip(*[iter(TA)] * 2):\n m1 = (x + t - 1) // t\n m2 = (y + a - 1) // a\n m = max(m1, m2)\n x, y = t * m, a * m\n\n print(x + y)\n return",
"main",
"N, *TA = map(int, read().split())",
"N",
"map(int, read().split())",
"map",
"int",
"read().split()",
"().split",
"()",
"read",
"split",
"*TA",
"TA",
"x, y = 1, 1",
"x",
"1",
"y",
"1",
"for t, a in zip(*[iter(TA)] * 2):\n m1 = (x + t - 1) // t\n m2 = (y + a - 1) // a\n m = max(m1, m2)\n x, y = t * m, a * m\n\n ",
"t",
"a",
"zip(*[iter(TA)] * 2)",
"zip",
"*[iter(TA)] * 2",
"[iter(TA)] * 2",
"[iter(TA)]",
"iter(TA)",
"iter",
"TA",
"2",
"m1 = (x + t - 1) // t",
"m1",
"(x + t - 1) // t",
"x + t - 1",
"x + t",
"x",
"t",
"1",
"t",
"m2 = (y + a - 1) // a",
"m2",
"(y + a - 1) // a",
"y + a - 1",
"y + a",
"y",
"a",
"1",
"a",
"m = max(m1, m2)",
"m",
"max(m1, m2)",
"max",
"m1",
"m2",
"x, y = t * m, a * m",
"x",
"t * m",
"t",
"m",
"y",
"a * m",
"a",
"m",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"return",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"read = sys.stdin.read",
"sys.stdin.read",
"read",
"INF = 1 << 60",
"1 << 60",
"INF",
"MOD = 1000000007",
"1000000007",
"MOD",
"readline = sys.stdin.readline",
"sys.stdin.readline",
"readline",
"readlines = sys.stdin.readlines",
"sys.stdin.readlines",
"readlines",
"def main():\n N, *TA = map(int, read().split())\n\n x, y = 1, 1\n\n for t, a in zip(*[iter(TA)] * 2):\n m1 = (x + t - 1) // t\n m2 = (y + a - 1) // a\n m = max(m1, m2)\n x, y = t * m, a * m\n\n print(x + y)\n return",
"def main():\n N, *TA = map(int, read().split())\n\n x, y = 1, 1\n\n for t, a in zip(*[iter(TA)] * 2):\n m1 = (x + t - 1) // t\n m2 = (y + a - 1) // a\n m = max(m1, m2)\n x, y = t * m, a * m\n\n print(x + y)\n return",
"main"
] | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *TA = map(int, read().split())
x, y = 1, 1
for t, a in zip(*[iter(TA)] * 2):
m1 = (x + t - 1) // t
m2 = (y + a - 1) // a
m = max(m1, m2)
x, y = t * m, a * m
print(x + y)
return
if __name__ == '__main__':
main()
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
0,
13,
18,
18,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
0,
13,
18,
13,
17,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
13,
13,
0,
13,
17,
0,
13,
17,
0,
13,
2,
2,
2,
17,
17,
13,
17,
0,
13,
17,
42,
40,
13,
13,
0,
13,
13,
14,
2,
2,
2,
18,
13,
13,
13,
13,
2,
2,
18,
13,
13,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
17,
0,
13,
2,
18,
13,
13,
13,
13,
2,
18,
13,
13,
13,
4,
13,
2,
13,
13,
10,
18,
13,
10,
2,
13,
10,
18,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
18,
13,
10,
13,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13
] | [
[
168,
18
],
[
219,
25
],
[
189,
32
],
[
169,
36
],
[
171,
38
],
[
190,
42
],
[
198,
44
],
[
190,
48
],
[
51,
50
],
[
190,
53
],
[
58,
55
],
[
172,
56
],
[
50,
57
],
[
169,
64
],
[
58,
66
],
[
199,
67
],
[
50,
68
],
[
204,
70
],
[
172,
72
],
[
174,
74
],
[
199,
76
],
[
80,
79
],
[
190,
83
],
[
210,
85
],
[
55,
87
],
[
172,
88
],
[
79,
89
],
[
66,
90
],
[
199,
91
],
[
79,
92
],
[
177,
94
],
[
213,
97
],
[
195,
100
],
[
211,
106
],
[
216,
109
],
[
178,
113
],
[
193,
113
],
[
217,
114
],
[
208,
114
],
[
207,
116
],
[
178,
117
],
[
193,
117
],
[
55,
122
],
[
172,
123
],
[
79,
124
],
[
178,
125
],
[
193,
125
],
[
205,
126
],
[
187,
126
],
[
66,
129
],
[
199,
130
],
[
79,
131
],
[
178,
132
],
[
193,
132
],
[
175,
133
],
[
202,
133
],
[
180,
135
],
[
178,
136
],
[
193,
136
],
[
183,
138
],
[
178,
139
],
[
193,
139
],
[
192,
141
],
[
181,
145
],
[
214,
145
],
[
184,
146
],
[
196,
146
],
[
186,
150
],
[
55,
152
],
[
172,
153
],
[
79,
154
],
[
193,
155
],
[
178,
155
],
[
201,
156
],
[
66,
158
],
[
199,
159
],
[
79,
160
],
[
193,
161
],
[
178,
161
],
[
187,
165
],
[
205,
165
],
[
202,
166
],
[
175,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
],
[
177,
178
],
[
178,
180
],
[
193,
180
],
[
180,
181
],
[
178,
183
],
[
193,
183
],
[
183,
184
],
[
186,
187
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
198,
199
],
[
201,
202
],
[
204,
205
],
[
178,
207
],
[
193,
207
],
[
207,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
],
[
219,
220
]
] | [
"import bisect\nimport collections\nimport copy\nimport functools\nimport heapq\nimport math\nimport sys\nfrom collections import deque\nfrom collections import defaultdict\ninput = sys.stdin.readline\nMOD = 10**9+7\n\nN = int(input())\nT = [0]*N\nA = [0]*N\nfor i in range(N):\n T[i],A[i] = map(int,(input().split()))\n\nt,a = T[0],A[0]\n\nfor i in range(1,N):\n s = T[i] + A[i]\n now = 1\n l = 1\n r = 10**18//s + 1\n mae = -1\n while now != mae:\n mae = now\n if T[i]*now < t or A[i]*now < a:\n l = now\n else:\n r = now\n now = (l+r+1)//2\n t,a = T[i]*now,A[i]*now\nprint(t+a)",
"import bisect",
"bisect",
"import collections",
"collections",
"import copy",
"copy",
"import functools",
"functools",
"import heapq",
"heapq",
"import math",
"math",
"import sys",
"sys",
"from collections import deque",
"from collections import defaultdict",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"MOD = 10**9+7",
"MOD",
"10**9+7",
"10**9",
"10",
"9",
"7",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T = [0]*N",
"T",
"[0]*N",
"[0]",
"0",
"N",
"A = [0]*N",
"A",
"[0]*N",
"[0]",
"0",
"N",
"for i in range(N):\n T[i],A[i] = map(int,(input().split()))",
"i",
"range(N)",
"range",
"N",
"T[i],A[i] = map(int,(input().split()))",
"T[i]",
"T",
"i",
"map(int,(input().split()))",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A[i]",
"A",
"i",
"t,a = T[0],A[0]",
"t",
"T[0]",
"T",
"0",
"a",
"A[0]",
"A",
"0",
"for i in range(1,N):\n s = T[i] + A[i]\n now = 1\n l = 1\n r = 10**18//s + 1\n mae = -1\n while now != mae:\n mae = now\n if T[i]*now < t or A[i]*now < a:\n l = now\n else:\n r = now\n now = (l+r+1)//2\n t,a = T[i]*now,A[i]*now",
"i",
"range(1,N)",
"range",
"1",
"N",
"s = T[i] + A[i]",
"s",
"T[i] + A[i]",
"T[i]",
"T",
"i",
"A[i]",
"A",
"i",
"now = 1",
"now",
"1",
"l = 1",
"l",
"1",
"r = 10**18//s + 1",
"r",
"10**18//s + 1",
"10**18//s",
"10**18",
"10",
"18",
"s",
"1",
"mae = -1",
"mae",
"-1",
"while now != mae:\n mae = now\n if T[i]*now < t or A[i]*now < a:\n l = now\n else:\n r = now\n now = (l+r+1)//2\n ",
"now != mae",
"now",
"mae",
"mae = now",
"mae",
"now",
"if T[i]*now < t or A[i]*now < a:\n l = now\n else:\n r = now\n ",
"T[i]*now < t or A[i]*now < a",
"T[i]*now < t",
"T[i]*now",
"T[i]",
"T",
"i",
"now",
"t",
"A[i]*now < a",
"A[i]*now",
"A[i]",
"A",
"i",
"now",
"a",
"l = now",
"l",
"now",
"r = now",
"r",
"now",
"now = (l+r+1)//2",
"now",
"(l+r+1)//2",
"l+r+1",
"l+r",
"l",
"r",
"1",
"2",
"t,a = T[i]*now,A[i]*now",
"t",
"T[i]*now",
"T[i]",
"T",
"i",
"now",
"a",
"A[i]*now",
"A[i]",
"A",
"i",
"now",
"print(t+a)",
"print",
"t+a",
"t",
"a",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"T = [0]*N",
"[0]*N",
"T",
"a = T[0],A[0]",
"A[0]",
"a",
"now = 1",
"1",
"now",
"l = now",
"now",
"l",
"r = now",
"now",
"r",
"t,a = T[i]*now,A[i]*now",
"T[i]*now",
"t",
"N = int(input())",
"int(input())",
"N",
"now = (l+r+1)//2",
"(l+r+1)//2",
"now",
"r = 10**18//s + 1",
"10**18//s + 1",
"r",
"A = [0]*N",
"[0]*N",
"A",
"a = T[i]*now,A[i]*now",
"A[i]*now",
"a",
"t,a = T[0],A[0]",
"T[0]",
"t",
"mae = now",
"now",
"mae",
"s = T[i] + A[i]",
"T[i] + A[i]",
"s",
"l = 1",
"1",
"l",
"mae = -1",
"-1",
"mae",
"MOD = 10**9+7",
"10**9+7",
"MOD"
] | import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7
N = int(input())
T = [0]*N
A = [0]*N
for i in range(N):
T[i],A[i] = map(int,(input().split()))
t,a = T[0],A[0]
for i in range(1,N):
s = T[i] + A[i]
now = 1
l = 1
r = 10**18//s + 1
mae = -1
while now != mae:
mae = now
if T[i]*now < t or A[i]*now < a:
l = now
else:
r = now
now = (l+r+1)//2
t,a = T[i]*now,A[i]*now
print(t+a) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
13,
28,
13,
13,
18,
13,
39,
17,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
18,
13,
10,
13,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
85,
2
],
[
10,
9
],
[
86,
12
],
[
76,
25
],
[
82,
28
],
[
77,
30
],
[
82,
32
],
[
77,
37
],
[
79,
41
],
[
74,
47
],
[
92,
47
],
[
83,
54
],
[
89,
54
],
[
91,
59
],
[
80,
61
],
[
88,
63
],
[
80,
65
],
[
92,
70
],
[
74,
70
],
[
89,
71
],
[
83,
71
],
[
82,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
]
] | [
"n = int(input())\nls = [list(map(int, input().split())) for _ in range(n)]\nx, y = ls[0]\nfor a, b in ls[1:]:\n k = max((x + a - 1) // a, (y + b - 1) // b)\n x, y = k * a, k * b\nprint(x + y)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ls = [list(map(int, input().split())) for _ in range(n)]",
"ls",
"[list(map(int, input().split())) for _ in range(n)]",
"x, y = ls[0]",
"x",
"ls[0]",
"ls",
"0",
"y",
"for a, b in ls[1:]:\n k = max((x + a - 1) // a, (y + b - 1) // b)\n x, y = k * a, k * b",
"a",
"b",
"ls[1:]",
"ls",
"1:",
"1",
"k = max((x + a - 1) // a, (y + b - 1) // b)",
"k",
"max((x + a - 1) // a, (y + b - 1) // b)",
"max",
"(x + a - 1) // a",
"x + a - 1",
"x + a",
"x",
"a",
"1",
"a",
"(y + b - 1) // b",
"y + b - 1",
"y + b",
"y",
"b",
"1",
"b",
"x, y = k * a, k * b",
"x",
"k * a",
"k",
"a",
"y",
"k * b",
"k",
"b",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"x, y = ls[0]",
"ls[0]",
"x",
"ls = [list(map(int, input().split())) for _ in range(n)]",
"[list(map(int, input().split())) for _ in range(n)]",
"ls",
"k = max((x + a - 1) // a, (y + b - 1) // b)",
"max((x + a - 1) // a, (y + b - 1) // b)",
"k",
"y = ls[0]",
"ls[0]",
"y",
"n = int(input())",
"int(input())",
"n",
"y = k * a, k * b",
"k * b",
"y",
"x, y = k * a, k * b",
"k * a",
"x"
] | n = int(input())
ls = [list(map(int, input().split())) for _ in range(n)]
x, y = ls[0]
for a, b in ls[1:]:
k = max((x + a - 1) // a, (y + b - 1) // b)
x, y = k * a, k * b
print(x + y) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
0,
13,
13,
14,
2,
2,
13,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
4,
13,
13,
13,
42,
2,
2,
2,
13,
13,
13,
2,
2,
13,
13,
13,
0,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13
] | [
[
98,
2
],
[
113,
8
],
[
116,
11
],
[
15,
14
],
[
99,
17
],
[
104,
19
],
[
104,
28
],
[
105,
32
],
[
114,
33
],
[
111,
33
],
[
126,
33
],
[
102,
35
],
[
117,
36
],
[
135,
36
],
[
120,
36
],
[
125,
38
],
[
105,
39
],
[
119,
41
],
[
102,
42
],
[
105,
46
],
[
114,
47
],
[
111,
47
],
[
126,
47
],
[
102,
49
],
[
117,
50
],
[
135,
50
],
[
120,
50
],
[
128,
52
],
[
114,
54
],
[
111,
54
],
[
126,
54
],
[
105,
55
],
[
122,
57
],
[
117,
59
],
[
135,
59
],
[
120,
59
],
[
102,
60
],
[
131,
62
],
[
129,
65
],
[
123,
66
],
[
105,
71
],
[
132,
72
],
[
108,
72
],
[
114,
73
],
[
111,
73
],
[
126,
73
],
[
102,
76
],
[
132,
77
],
[
108,
77
],
[
117,
78
],
[
135,
78
],
[
120,
78
],
[
107,
80
],
[
110,
83
],
[
105,
85
],
[
108,
86
],
[
132,
86
],
[
134,
88
],
[
102,
90
],
[
108,
91
],
[
132,
91
],
[
111,
95
],
[
126,
95
],
[
114,
95
],
[
135,
96
],
[
120,
96
],
[
117,
96
],
[
98,
99
],
[
104,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
102,
119
],
[
119,
120
],
[
122,
123
],
[
105,
125
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
]
] | [
"n = int(input())\nmt = 0\nma = 0\nfor i in range(n):\n t , a = map(int, input().split())\n if t>=mt and a>=ma:\n mt = t\n ma = a\n elif t<mt or a<ma:\n k1 = mt//t\n k2 = ma//a\n k=max(k1,k2)\n while t*k < mt or a*k <ma:\n k+=1\n mt=t*k\n ma=a*k\nprint(mt+ma)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"mt = 0",
"mt",
"0",
"ma = 0",
"ma",
"0",
"for i in range(n):\n t , a = map(int, input().split())\n if t>=mt and a>=ma:\n mt = t\n ma = a\n elif t<mt or a<ma:\n k1 = mt//t\n k2 = ma//a\n k=max(k1,k2)\n while t*k < mt or a*k <ma:\n k+=1\n mt=t*k\n ma=a*k",
"i",
"range(n)",
"range",
"n",
"t , a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"if t>=mt and a>=ma:\n mt = t\n ma = a\n elif t<mt or a<ma:\n k1 = mt//t\n k2 = ma//a\n k=max(k1,k2)\n while t*k < mt or a*k <ma:\n k+=1\n mt=t*k\n ma=a*k",
"t>=mt and a>=ma",
"t>=mt",
"t",
"mt",
"a>=ma",
"a",
"ma",
"mt = t",
"mt",
"t",
"ma = a",
"ma",
"a",
"elif t<mt or a<ma:\n k1 = mt//t\n k2 = ma//a\n k=max(k1,k2)\n while t*k < mt or a*k <ma:\n k+=1\n mt=t*k\n ma=a*k",
"t<mt or a<ma",
"t<mt",
"t",
"mt",
"a<ma",
"a",
"ma",
"k1 = mt//t",
"k1",
"mt//t",
"mt",
"t",
"k2 = ma//a",
"k2",
"ma//a",
"ma",
"a",
"k=max(k1,k2)",
"k",
"max(k1,k2)",
"max",
"k1",
"k2",
"while t*k < mt or a*k <ma:\n k+=1\n ",
"t*k < mt or a*k <ma",
"t*k < mt",
"t*k",
"t",
"k",
"mt",
"a*k <ma",
"a*k",
"a",
"k",
"ma",
"k+=1",
"k",
"1",
"mt=t*k",
"mt",
"t*k",
"t",
"k",
"ma=a*k",
"ma",
"a*k",
"a",
"k",
"print(mt+ma)",
"print",
"mt+ma",
"mt",
"ma",
"n = int(input())",
"int(input())",
"n",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"t , a = map(int, input().split())",
"map(int, input().split())",
"t",
"k+=1",
"1",
"k",
"mt=t*k",
"t*k",
"mt",
"mt = 0",
"0",
"mt",
"ma = 0",
"0",
"ma",
"ma = a",
"a",
"ma",
"k2 = ma//a",
"ma//a",
"k2",
"mt = t",
"t",
"mt",
"k1 = mt//t",
"mt//t",
"k1",
"k=max(k1,k2)",
"max(k1,k2)",
"k",
"ma=a*k",
"a*k",
"ma"
] | n = int(input())
mt = 0
ma = 0
for i in range(n):
t , a = map(int, input().split())
if t>=mt and a>=ma:
mt = t
ma = a
elif t<mt or a<ma:
k1 = mt//t
k2 = ma//a
k=max(k1,k2)
while t*k < mt or a*k <ma:
k+=1
mt=t*k
ma=a*k
print(mt+ma)
|
[
7,
15,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
2,
13,
13,
2,
13,
13,
14,
2,
2,
2,
13,
13,
13,
2,
2,
13,
13,
13,
0,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
18,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13
] | [
[
104,
3
],
[
11,
10
],
[
105,
13
],
[
107,
26
],
[
110,
29
],
[
98,
31
],
[
35,
34
],
[
105,
37
],
[
101,
39
],
[
108,
42
],
[
34,
43
],
[
119,
45
],
[
108,
48
],
[
34,
49
],
[
113,
52
],
[
111,
56
],
[
117,
56
],
[
102,
57
],
[
99,
59
],
[
93,
59
],
[
120,
60
],
[
102,
65
],
[
114,
66
],
[
96,
66
],
[
111,
67
],
[
117,
67
],
[
120,
70
],
[
114,
71
],
[
96,
71
],
[
99,
72
],
[
93,
72
],
[
95,
74
],
[
116,
77
],
[
102,
79
],
[
96,
80
],
[
114,
80
],
[
92,
82
],
[
120,
84
],
[
96,
85
],
[
114,
85
],
[
117,
89
],
[
111,
89
],
[
93,
90
],
[
99,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
]
] | [
"from math import ceil\nN = int(input())\nL = [list(map(int,input().split())) for k in range(N)]\nA, T = 1, 1\nfor k in range(N):\n a, t = L[k][0], L[k][1]\n m = max(A//a,T//t)\n if a*m < A or t*m < T:\n m += 1\n A = a*m\n T = t*m\nprint(A+T)",
"from math import ceil",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int,input().split())) for k in range(N)",
"for k in range(N)",
"k",
"range(N)",
"range",
"N",
"for k in range(N)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L = [list(map(int,input().split())) for k in range(N)]",
"L",
"[list(map(int,input().split())) for k in range(N)]",
"A, T = 1, 1",
"A",
"1",
"T",
"1",
"for k in range(N):\n a, t = L[k][0], L[k][1]\n m = max(A//a,T//t)\n if a*m < A or t*m < T:\n m += 1\n A = a*m\n T = t*m",
"k",
"range(N)",
"range",
"N",
"a, t = L[k][0], L[k][1]",
"a",
"L[k][0]",
"[k]",
"L",
"k",
"0",
"t",
"L[k][1]",
"[k]",
"L",
"k",
"1",
"m = max(A//a,T//t)",
"m",
"max(A//a,T//t)",
"max",
"A//a",
"A",
"a",
"T//t",
"T",
"t",
"if a*m < A or t*m < T:\n m += 1\n ",
"a*m < A or t*m < T",
"a*m < A",
"a*m",
"a",
"m",
"A",
"t*m < T",
"t*m",
"t",
"m",
"T",
"m += 1",
"m",
"1",
"A = a*m",
"A",
"a*m",
"a",
"m",
"T = t*m",
"T",
"t*m",
"t",
"m",
"print(A+T)",
"print",
"A+T",
"A",
"T",
"T = t*m",
"t*m",
"T",
"m += 1",
"1",
"m",
"T = 1, 1",
"1",
"T",
"a, t = L[k][0], L[k][1]",
"L[k][0]",
"a",
"N = int(input())",
"int(input())",
"N",
"L = [list(map(int,input().split())) for k in range(N)]",
"[list(map(int,input().split())) for k in range(N)]",
"L",
"A, T = 1, 1",
"1",
"A",
"m = max(A//a,T//t)",
"max(A//a,T//t)",
"m",
"A = a*m",
"a*m",
"A",
"t = L[k][0], L[k][1]",
"L[k][1]",
"t"
] | from math import ceil
N = int(input())
L = [list(map(int,input().split())) for k in range(N)]
A, T = 1, 1
for k in range(N):
a, t = L[k][0], L[k][1]
m = max(A//a,T//t)
if a*m < A or t*m < T:
m += 1
A = a*m
T = t*m
print(A+T)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
2,
4,
13,
2,
2,
13,
17,
13,
17,
2,
4,
13,
2,
2,
13,
17,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13
] | [
[
76,
2
],
[
85,
8
],
[
70,
11
],
[
15,
14
],
[
77,
17
],
[
88,
19
],
[
88,
28
],
[
67,
30
],
[
86,
38
],
[
83,
38
],
[
74,
40
],
[
71,
47
],
[
80,
47
],
[
89,
49
],
[
82,
52
],
[
68,
54
],
[
74,
55
],
[
79,
57
],
[
68,
59
],
[
89,
60
],
[
83,
64
],
[
86,
64
],
[
80,
65
],
[
71,
65
],
[
67,
68
],
[
70,
71
],
[
88,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
]
] | [
"n=int(input())\na=1\nb=1\nfor i in range(n):\n ti,ai=map(int,input().split())\n# m=max(int((a-1)/ti)+1,int((b-1)/ai)+1)\n m=max(int((a-1)//ti)+1,int((b-1)//ai)+1)\n a=m*ti\n b=m*ai\nprint(a+b)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a=1",
"a",
"1",
"b=1",
"b",
"1",
"for i in range(n):\n ti,ai=map(int,input().split())\n# m=max(int((a-1)/ti)+1,int((b-1)/ai)+1)\n m=max(int((a-1)//ti)+1,int((b-1)//ai)+1)\n a=m*ti\n b=m*ai",
"i",
"range(n)",
"range",
"n",
"ti,ai=map(int,input().split())",
"ti",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ai",
"m=max(int((a-1)//ti)+1,int((b-1)//ai)+1)",
"m",
"max(int((a-1)//ti)+1,int((b-1)//ai)+1)",
"max",
"int((a-1)//ti)+1",
"int((a-1)//ti)",
"int",
"(a-1)//ti",
"a-1",
"a",
"1",
"ti",
"1",
"int((b-1)//ai)+1",
"int((b-1)//ai)",
"int",
"(b-1)//ai",
"b-1",
"b",
"1",
"ai",
"1",
"a=m*ti",
"a",
"m*ti",
"m",
"ti",
"b=m*ai",
"b",
"m*ai",
"m",
"ai",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"m=max(int((a-1)//ti)+1,int((b-1)//ai)+1)",
"max(int((a-1)//ti)+1,int((b-1)//ai)+1)",
"m",
"b=1",
"1",
"b",
"ti,ai=map(int,input().split())",
"map(int,input().split())",
"ti",
"n=int(input())",
"int(input())",
"n",
"b=m*ai",
"m*ai",
"b",
"a=m*ti",
"m*ti",
"a",
"a=1",
"1",
"a",
"ai=map(int,input().split())",
"map(int,input().split())",
"ai"
] | n=int(input())
a=1
b=1
for i in range(n):
ti,ai=map(int,input().split())
# m=max(int((a-1)/ti)+1,int((b-1)/ai)+1)
m=max(int((a-1)//ti)+1,int((b-1)//ai)+1)
a=m*ti
b=m*ai
print(a+b) |
[
7,
15,
13,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
13,
28,
13,
4,
13,
17,
4,
13,
13,
0,
13,
18,
13,
13,
13,
0,
13,
4,
13,
2,
2,
13,
13,
40,
2,
13,
13,
17,
2,
2,
13,
13,
40,
2,
13,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
17,
13,
4,
13,
10,
12,
13
] | [
[
7,
6
],
[
14,
13
],
[
6,
16
],
[
30,
29
],
[
33,
32
],
[
29,
34
],
[
33,
36
],
[
39,
38
],
[
29,
44
],
[
47,
46
],
[
29,
48
],
[
38,
49
],
[
47,
50
],
[
53,
52
],
[
32,
57
],
[
74,
57
],
[
46,
58
],
[
32,
61
],
[
74,
61
],
[
46,
62
],
[
36,
66
],
[
79,
66
],
[
50,
67
],
[
36,
70
],
[
79,
70
],
[
50,
71
],
[
75,
74
],
[
46,
76
],
[
52,
77
],
[
80,
79
],
[
50,
81
],
[
52,
82
],
[
74,
86
],
[
32,
86
],
[
79,
87
],
[
36,
87
],
[
96,
93
]
] | [
"import math\ndef resolve():\n N = int(input())\n TA = [list(map(int, input().split())) for i in range(N)]\n t, a = TA[0]\n for i in range(1, len(TA)):\n t_next, a_next = TA[i]\n div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))\n t = t_next*div\n a = a_next*div\n print(t+a)\n\n\nif '__main__' == __name__:\n resolve()\n",
"import math",
"math",
"def resolve():\n N = int(input())\n TA = [list(map(int, input().split())) for i in range(N)]\n t, a = TA[0]\n for i in range(1, len(TA)):\n t_next, a_next = TA[i]\n div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))\n t = t_next*div\n a = a_next*div\n print(t+a)",
"resolve",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for i in range(N)]",
"TA",
"[list(map(int, input().split())) for i in range(N)]",
"t, a = TA[0]",
"t",
"TA[0]",
"TA",
"0",
"a",
"for i in range(1, len(TA)):\n t_next, a_next = TA[i]\n div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))\n t = t_next*div\n a = a_next*div\n ",
"i",
"range(1, len(TA))",
"range",
"1",
"len(TA)",
"len",
"TA",
"t_next, a_next = TA[i]",
"t_next",
"TA[i]",
"TA",
"i",
"a_next",
"div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))",
"div",
"max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))",
"max",
"(t//t_next)+(t%t_next!=0)",
"t//t_next",
"t",
"t_next",
"t%t_next!=0",
"t%t_next",
"t",
"t_next",
"0",
"(a//a_next)+(a%a_next!=0)",
"a//a_next",
"a",
"a_next",
"a%a_next!=0",
"a%a_next",
"a",
"a_next",
"0",
"t = t_next*div",
"t",
"t_next*div",
"t_next",
"div",
"a = a_next*div",
"a",
"a_next*div",
"a_next",
"div",
"print(t+a)",
"print",
"t+a",
"t",
"a",
"if '__main__' == __name__:\n resolve()",
"'__main__' == __name__",
"'__main__'",
"__name__",
"resolve()",
"resolve",
"def resolve():\n N = int(input())\n TA = [list(map(int, input().split())) for i in range(N)]\n t, a = TA[0]\n for i in range(1, len(TA)):\n t_next, a_next = TA[i]\n div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))\n t = t_next*div\n a = a_next*div\n print(t+a)",
"def resolve():\n N = int(input())\n TA = [list(map(int, input().split())) for i in range(N)]\n t, a = TA[0]\n for i in range(1, len(TA)):\n t_next, a_next = TA[i]\n div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))\n t = t_next*div\n a = a_next*div\n print(t+a)",
"resolve"
] | import math
def resolve():
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]
t, a = TA[0]
for i in range(1, len(TA)):
t_next, a_next = TA[i]
div = max((t//t_next)+(t%t_next!=0), (a//a_next)+(a%a_next!=0))
t = t_next*div
a = a_next*div
print(t+a)
if '__main__' == __name__:
resolve()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
2,
13,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
42,
2,
2,
13,
13,
2,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13
] | [
[
88,
2
],
[
103,
8
],
[
103,
17
],
[
20,
19
],
[
89,
23
],
[
115,
26
],
[
115,
35
],
[
85,
37
],
[
101,
41
],
[
98,
41
],
[
92,
42
],
[
104,
44
],
[
113,
44
],
[
116,
45
],
[
106,
47
],
[
92,
49
],
[
86,
50
],
[
82,
52
],
[
116,
54
],
[
86,
55
],
[
107,
59
],
[
95,
59
],
[
101,
60
],
[
98,
60
],
[
83,
62
],
[
110,
62
],
[
104,
63
],
[
113,
63
],
[
94,
65
],
[
92,
66
],
[
109,
68
],
[
116,
69
],
[
97,
71
],
[
95,
72
],
[
107,
72
],
[
112,
74
],
[
110,
75
],
[
83,
75
],
[
98,
79
],
[
101,
79
],
[
113,
80
],
[
104,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
115,
92
],
[
92,
94
],
[
94,
95
],
[
95,
97
],
[
107,
97
],
[
97,
98
],
[
103,
101
],
[
103,
104
],
[
106,
107
],
[
116,
109
],
[
109,
110
],
[
110,
112
],
[
83,
112
],
[
112,
113
],
[
115,
116
]
] | [
"N = int(input())\n\nt, a = map(int, input().split())\n\nfor i in range(N - 1):\n nt, na = map(int, input().split())\n p = max(t // nt, a // na)\n pt = nt * p\n pa = na * p\n while pt < t or pa < a:\n pt += nt\n pa += na\n t = pt\n a = pa\nprint(t + a)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"for i in range(N - 1):\n nt, na = map(int, input().split())\n p = max(t // nt, a // na)\n pt = nt * p\n pa = na * p\n while pt < t or pa < a:\n pt += nt\n pa += na\n t = pt\n a = pa",
"i",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"nt, na = map(int, input().split())",
"nt",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"na",
"p = max(t // nt, a // na)",
"p",
"max(t // nt, a // na)",
"max",
"t // nt",
"t",
"nt",
"a // na",
"a",
"na",
"pt = nt * p",
"pt",
"nt * p",
"nt",
"p",
"pa = na * p",
"pa",
"na * p",
"na",
"p",
"while pt < t or pa < a:\n pt += nt\n pa += na\n ",
"pt < t or pa < a",
"pt < t",
"pt",
"t",
"pa < a",
"pa",
"a",
"pt += nt",
"pt",
"nt",
"pa += na",
"pa",
"na",
"t = pt",
"t",
"pt",
"a = pa",
"a",
"pa",
"print(t + a)",
"print",
"t + a",
"t",
"a",
"pa = na * p",
"na * p",
"pa",
"p = max(t // nt, a // na)",
"max(t // nt, a // na)",
"p",
"N = int(input())",
"int(input())",
"N",
"nt, na = map(int, input().split())",
"map(int, input().split())",
"nt",
"pt += nt",
"nt",
"pt",
"t = pt",
"pt",
"t",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"pt = nt * p",
"nt * p",
"pt",
"pa += na",
"na",
"pa",
"a = pa",
"pa",
"a",
"na = map(int, input().split())",
"map(int, input().split())",
"na"
] | N = int(input())
t, a = map(int, input().split())
for i in range(N - 1):
nt, na = map(int, input().split())
p = max(t // nt, a // na)
pt = nt * p
pa = na * p
while pt < t or pa < a:
pt += nt
pa += na
t = pt
a = pa
print(t + a)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
17,
17,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
18,
13,
17,
13,
17,
13,
2,
2,
2,
18,
13,
17,
13,
17,
13,
0,
13,
4,
13,
4,
13,
12,
2,
13,
13,
23,
18,
13,
13,
4,
13,
4,
13,
13,
10,
18,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
18,
13
] | [
[
96,
2
],
[
93,
8
],
[
102,
13
],
[
17,
16
],
[
97,
19
],
[
103,
22
],
[
36,
35
],
[
97,
38
],
[
105,
40
],
[
103,
42
],
[
35,
43
],
[
105,
44
],
[
90,
46
],
[
94,
53
],
[
100,
53
],
[
88,
55
],
[
88,
57
],
[
94,
62
],
[
100,
62
],
[
106,
64
],
[
106,
66
],
[
99,
68
],
[
91,
76
],
[
103,
79
],
[
35,
80
],
[
100,
85
],
[
94,
85
],
[
105,
88
],
[
90,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
]
] | [
"\nn = int(input())\nnow = [1,1]\ndata = []\n\nfor i in range(n):\n data.append(list(map(int, input().split())))\nfor i in range(n):\n t,a = data[i]\n mul = max((now[0] + t - 1)//t, (now[1] + a - 1) //a)\n now = list(map(lambda x:x*mul, data[i]))\nprint(sum(now))",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"now = [1,1]",
"now",
"[1,1]",
"1",
"1",
"data = []",
"data",
"[]",
"for i in range(n):\n data.append(list(map(int, input().split())))",
"i",
"range(n)",
"range",
"n",
"data.append(list(map(int, input().split())))",
"data.append",
"data",
"append",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(n):\n t,a = data[i]\n mul = max((now[0] + t - 1)//t, (now[1] + a - 1) //a)\n now = list(map(lambda x:x*mul, data[i]))",
"i",
"range(n)",
"range",
"n",
"t,a = data[i]",
"t",
"data[i]",
"data",
"i",
"a",
"mul = max((now[0] + t - 1)//t, (now[1] + a - 1) //a)",
"mul",
"max((now[0] + t - 1)//t, (now[1] + a - 1) //a)",
"max",
"(now[0] + t - 1)//t",
"now[0] + t - 1",
"now[0] + t",
"now[0]",
"now",
"0",
"t",
"1",
"t",
"(now[1] + a - 1) //a",
"now[1] + a - 1",
"now[1] + a",
"now[1]",
"now",
"1",
"a",
"1",
"a",
"now = list(map(lambda x:x*mul, data[i]))",
"now",
"list(map(lambda x:x*mul, data[i]))",
"list",
"map(lambda x:x*mul, data[i])",
"map",
"lambda x:x*mul",
"x*mul",
"x",
"mul",
"x",
"data[i]",
"data",
"i",
"print(sum(now))",
"print",
"sum(now)",
"sum",
"now",
"t,a = data[i]",
"data[i]",
"t",
"mul = max((now[0] + t - 1)//t, (now[1] + a - 1) //a)",
"max((now[0] + t - 1)//t, (now[1] + a - 1) //a)",
"mul",
"now = [1,1]",
"[1,1]",
"now",
"n = int(input())",
"int(input())",
"n",
"now = list(map(lambda x:x*mul, data[i]))",
"list(map(lambda x:x*mul, data[i]))",
"now",
"data = []",
"[]",
"data",
"a = data[i]",
"data[i]",
"a"
] |
n = int(input())
now = [1,1]
data = []
for i in range(n):
data.append(list(map(int, input().split())))
for i in range(n):
t,a = data[i]
mul = max((now[0] + t - 1)//t, (now[1] + a - 1) //a)
now = list(map(lambda x:x*mul, data[i]))
print(sum(now)) |
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
13,
17,
28,
39,
13,
13,
13,
14,
2,
13,
13,
0,
13,
4,
13,
13,
4,
13,
13,
13,
0,
13,
13,
13,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
29,
2,
13,
13,
14,
2,
13,
17,
0,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
11,
10
],
[
14,
13
],
[
4,
16
],
[
10,
19
],
[
33,
32
],
[
35,
34
],
[
40,
37
],
[
10,
37
],
[
47,
46
],
[
32,
52
],
[
91,
52
],
[
68,
52
],
[
55,
52
],
[
34,
53
],
[
96,
53
],
[
70,
53
],
[
57,
53
],
[
56,
55
],
[
46,
56
],
[
58,
57
],
[
46,
58
],
[
32,
62
],
[
91,
62
],
[
68,
62
],
[
55,
62
],
[
34,
65
],
[
96,
65
],
[
70,
65
],
[
57,
65
],
[
69,
68
],
[
71,
70
],
[
74,
73
],
[
32,
79
],
[
91,
79
],
[
68,
79
],
[
55,
79
],
[
34,
86
],
[
96,
86
],
[
70,
86
],
[
57,
86
],
[
92,
91
],
[
73,
94
],
[
97,
96
],
[
73,
99
],
[
91,
102
],
[
68,
102
],
[
55,
102
],
[
32,
102
],
[
96,
103
],
[
70,
103
],
[
57,
103
],
[
34,
103
],
[
116,
109
],
[
120,
111
],
[
117,
114
],
[
116,
117
]
] | [
"def solve():\n N = int(input())\n\n LIS = []\n for _ in range(N):\n LIS.append(tuple(map(int, input().split())))\n # print(LIS)\n\n A, B = 1, 1\n for (x, y) in LIS:\n # print(\"current:\", A, B)\n # print(\"ratio :\", x, y, \"\\n\")\n if x == y:\n m = max(x, max(A, B))\n A, B = m, m\n elif A <= x and B <= y:\n A, B = x, y\n else:\n # div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる\n div = max((A + x - 1) // x, (B + y - 1) // y)\n A = x * div\n B = y * div\n\n return A + B\n\n\nif __name__ == '__main__':\n res = solve()\n print(res)",
"def solve():\n N = int(input())\n\n LIS = []\n for _ in range(N):\n LIS.append(tuple(map(int, input().split())))\n # print(LIS)\n\n A, B = 1, 1\n for (x, y) in LIS:\n # print(\"current:\", A, B)\n # print(\"ratio :\", x, y, \"\\n\")\n if x == y:\n m = max(x, max(A, B))\n A, B = m, m\n elif A <= x and B <= y:\n A, B = x, y\n else:\n # div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる\n div = max((A + x - 1) // x, (B + y - 1) // y)\n A = x * div\n B = y * div\n\n return A + B",
"solve",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"LIS = []",
"LIS",
"[]",
"for _ in range(N):\n LIS.append(tuple(map(int, input().split())))\n # print(LIS)\n\n ",
"_",
"range(N)",
"range",
"N",
"LIS.append(tuple(map(int, input().split())))",
"LIS.append",
"LIS",
"append",
"tuple(map(int, input().split()))",
"tuple",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A, B = 1, 1",
"A",
"1",
"B",
"1",
"for (x, y) in LIS:\n # print(\"current:\", A, B)\n # print(\"ratio :\", x, y, \"\\n\")\n if x == y:\n m = max(x, max(A, B))\n A, B = m, m\n elif A <= x and B <= y:\n A, B = x, y\n else:\n # div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる\n div = max((A + x - 1) // x, (B + y - 1) // y)\n A = x * div\n B = y * div\n\n ",
"(x, y)",
"x",
"y",
"LIS",
"if x == y:\n m = max(x, max(A, B))\n A, B = m, m\n elif A <= x and B <= y:\n A, B = x, y\n else:\n # div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる\n div = max((A + x - 1) // x, (B + y - 1) // y)\n A = x * div\n B = y * div\n\n ",
"x == y",
"x",
"y",
"m = max(x, max(A, B))",
"m",
"max(x, max(A, B))",
"max",
"x",
"max(A, B)",
"max",
"A",
"B",
"A, B = m, m",
"A",
"m",
"B",
"m",
"elif A <= x and B <= y:\n A, B = x, y\n ",
"A <= x and B <= y",
"A <= x",
"A",
"x",
"B <= y",
"B",
"y",
"A, B = x, y",
"A",
"x",
"B",
"y",
"div = max((A + x - 1) // x, (B + y - 1) // y)",
"div",
"max((A + x - 1) // x, (B + y - 1) // y)",
"max",
"(A + x - 1) // x",
"A + x - 1",
"A + x",
"A",
"x",
"1",
"x",
"(B + y - 1) // y",
"B + y - 1",
"B + y",
"B",
"y",
"1",
"y",
"A = x * div",
"A",
"x * div",
"x",
"div",
"B = y * div",
"B",
"y * div",
"y",
"div",
"return A + B",
"A + B",
"A",
"B",
"if __name__ == '__main__':\n res = solve()\n print(res)",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"res = solve()",
"res",
"solve()",
"solve",
"print(res)",
"print",
"res",
"res = solve()",
"solve()",
"res",
"def solve():\n N = int(input())\n\n LIS = []\n for _ in range(N):\n LIS.append(tuple(map(int, input().split())))\n # print(LIS)\n\n A, B = 1, 1\n for (x, y) in LIS:\n # print(\"current:\", A, B)\n # print(\"ratio :\", x, y, \"\\n\")\n if x == y:\n m = max(x, max(A, B))\n A, B = m, m\n elif A <= x and B <= y:\n A, B = x, y\n else:\n # div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる\n div = max((A + x - 1) // x, (B + y - 1) // y)\n A = x * div\n B = y * div\n\n return A + B",
"def solve():\n N = int(input())\n\n LIS = []\n for _ in range(N):\n LIS.append(tuple(map(int, input().split())))\n # print(LIS)\n\n A, B = 1, 1\n for (x, y) in LIS:\n # print(\"current:\", A, B)\n # print(\"ratio :\", x, y, \"\\n\")\n if x == y:\n m = max(x, max(A, B))\n A, B = m, m\n elif A <= x and B <= y:\n A, B = x, y\n else:\n # div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる\n div = max((A + x - 1) // x, (B + y - 1) // y)\n A = x * div\n B = y * div\n\n return A + B",
"solve"
] | def solve():
N = int(input())
LIS = []
for _ in range(N):
LIS.append(tuple(map(int, input().split())))
# print(LIS)
A, B = 1, 1
for (x, y) in LIS:
# print("current:", A, B)
# print("ratio :", x, y, "\n")
if x == y:
m = max(x, max(A, B))
A, B = m, m
elif A <= x and B <= y:
A, B = x, y
else:
# div = max(ceil(A / x), ceil(B / y)) 誤差でWAになる
div = max((A + x - 1) // x, (B + y - 1) // y)
A = x * div
B = y * div
return A + B
if __name__ == '__main__':
res = solve()
print(res)
|
[
7,
12,
13,
29,
2,
2,
2,
13,
13,
17,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
12,
7
],
[
14,
8
],
[
14,
10
],
[
12,
12
],
[
14,
14
],
[
19,
18
],
[
25,
24
],
[
28,
27
],
[
31,
30
],
[
18,
33
],
[
36,
35
],
[
36,
44
],
[
47,
46
],
[
83,
50
],
[
24,
51
],
[
58,
51
],
[
35,
52
],
[
83,
54
],
[
27,
55
],
[
63,
55
],
[
44,
56
],
[
59,
58
],
[
35,
60
],
[
46,
61
],
[
64,
63
],
[
44,
65
],
[
46,
66
],
[
58,
70
],
[
24,
70
],
[
63,
71
],
[
27,
71
],
[
80,
77
]
] | [
"def ceil(x, y):\n # ceil(x / y)\n return (x + y - 1) // y\n\n\ndef main():\n n = int(input())\n takahashi = 1\n aoki = 1\n for _ in range(n):\n t, a = map(int, input().split())\n diff = max(ceil(takahashi, t), ceil(aoki, a))\n takahashi = t * diff\n aoki = a * diff\n print(takahashi + aoki)\n\n\nif __name__ == '__main__':\n main()",
"def ceil(x, y):\n # ceil(x / y)\n return (x + y - 1) // y",
"ceil",
"return (x + y - 1) // y",
"(x + y - 1) // y",
"x + y - 1",
"x + y",
"x",
"y",
"1",
"y",
"x",
"x",
"y",
"y",
"def main():\n n = int(input())\n takahashi = 1\n aoki = 1\n for _ in range(n):\n t, a = map(int, input().split())\n diff = max(ceil(takahashi, t), ceil(aoki, a))\n takahashi = t * diff\n aoki = a * diff\n print(takahashi + aoki)",
"main",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"takahashi = 1",
"takahashi",
"1",
"aoki = 1",
"aoki",
"1",
"for _ in range(n):\n t, a = map(int, input().split())\n diff = max(ceil(takahashi, t), ceil(aoki, a))\n takahashi = t * diff\n aoki = a * diff\n ",
"_",
"range(n)",
"range",
"n",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"diff = max(ceil(takahashi, t), ceil(aoki, a))",
"diff",
"max(ceil(takahashi, t), ceil(aoki, a))",
"max",
"ceil(takahashi, t)",
"ceil",
"takahashi",
"t",
"ceil(aoki, a)",
"ceil",
"aoki",
"a",
"takahashi = t * diff",
"takahashi",
"t * diff",
"t",
"diff",
"aoki = a * diff",
"aoki",
"a * diff",
"a",
"diff",
"print(takahashi + aoki)",
"print",
"takahashi + aoki",
"takahashi",
"aoki",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n n = int(input())\n takahashi = 1\n aoki = 1\n for _ in range(n):\n t, a = map(int, input().split())\n diff = max(ceil(takahashi, t), ceil(aoki, a))\n takahashi = t * diff\n aoki = a * diff\n print(takahashi + aoki)",
"def main():\n n = int(input())\n takahashi = 1\n aoki = 1\n for _ in range(n):\n t, a = map(int, input().split())\n diff = max(ceil(takahashi, t), ceil(aoki, a))\n takahashi = t * diff\n aoki = a * diff\n print(takahashi + aoki)",
"main",
"def ceil(x, y):\n # ceil(x / y)\n return (x + y - 1) // y",
"def ceil(x, y):\n # ceil(x / y)\n return (x + y - 1) // y",
"ceil"
] | def ceil(x, y):
# ceil(x / y)
return (x + y - 1) // y
def main():
n = int(input())
takahashi = 1
aoki = 1
for _ in range(n):
t, a = map(int, input().split())
diff = max(ceil(takahashi, t), ceil(aoki, a))
takahashi = t * diff
aoki = a * diff
print(takahashi + aoki)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
13,
17,
14,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
13,
13,
0,
13,
17,
14,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
13,
13,
0,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13
] | [
[
114,
2
],
[
120,
8
],
[
117,
10
],
[
14,
13
],
[
115,
16
],
[
99,
18
],
[
99,
27
],
[
123,
29
],
[
102,
31
],
[
121,
35
],
[
109,
35
],
[
88,
36
],
[
126,
38
],
[
121,
40
],
[
109,
40
],
[
88,
41
],
[
121,
44
],
[
109,
44
],
[
88,
45
],
[
90,
47
],
[
118,
51
],
[
94,
51
],
[
100,
52
],
[
111,
54
],
[
118,
56
],
[
94,
56
],
[
100,
57
],
[
118,
60
],
[
94,
60
],
[
100,
61
],
[
96,
63
],
[
105,
66
],
[
91,
69
],
[
127,
69
],
[
124,
69
],
[
106,
69
],
[
97,
70
],
[
112,
70
],
[
103,
70
],
[
108,
72
],
[
88,
74
],
[
106,
75
],
[
91,
75
],
[
127,
75
],
[
124,
75
],
[
93,
77
],
[
100,
79
],
[
106,
80
],
[
91,
80
],
[
127,
80
],
[
124,
80
],
[
109,
84
],
[
121,
84
],
[
94,
85
],
[
118,
85
],
[
99,
88
],
[
90,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
126,
127
]
] | [
"n = int(input())\nca, cb = 0, 0\nfor i in range(n):\n a, b = map(int,input().split())\n x, y = 1, 1\n if ca > a:\n x = ca // a\n if ca % a:\n x += 1\n if cb > b:\n y = cb // b\n if cb % b:\n y += 1\n x = max(x, y)\n ca = a * x\n cb = b * x\nprint(ca + cb)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"ca, cb = 0, 0",
"ca",
"0",
"cb",
"0",
"for i in range(n):\n a, b = map(int,input().split())\n x, y = 1, 1\n if ca > a:\n x = ca // a\n if ca % a:\n x += 1\n if cb > b:\n y = cb // b\n if cb % b:\n y += 1\n x = max(x, y)\n ca = a * x\n cb = b * x",
"i",
"range(n)",
"range",
"n",
"a, b = map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"x, y = 1, 1",
"x",
"1",
"y",
"1",
"if ca > a:\n x = ca // a\n if ca % a:\n x += 1\n ",
"ca > a",
"ca",
"a",
"x = ca // a",
"x",
"ca // a",
"ca",
"a",
"if ca % a:\n x += 1\n ",
"ca % a",
"ca",
"a",
"x += 1",
"x",
"1",
"if cb > b:\n y = cb // b\n if cb % b:\n y += 1\n ",
"cb > b",
"cb",
"b",
"y = cb // b",
"y",
"cb // b",
"cb",
"b",
"if cb % b:\n y += 1\n ",
"cb % b",
"cb",
"b",
"y += 1",
"y",
"1",
"x = max(x, y)",
"x",
"max(x, y)",
"max",
"x",
"y",
"ca = a * x",
"ca",
"a * x",
"a",
"x",
"cb = b * x",
"cb",
"b * x",
"b",
"x",
"print(ca + cb)",
"print",
"ca + cb",
"ca",
"cb",
"a, b = map(int,input().split())",
"map(int,input().split())",
"a",
"x += 1",
"1",
"x",
"cb = b * x",
"b * x",
"cb",
"y += 1",
"1",
"y",
"b = map(int,input().split())",
"map(int,input().split())",
"b",
"y = 1, 1",
"1",
"y",
"x = max(x, y)",
"max(x, y)",
"x",
"ca = a * x",
"a * x",
"ca",
"y = cb // b",
"cb // b",
"y",
"n = int(input())",
"int(input())",
"n",
"cb = 0, 0",
"0",
"cb",
"ca, cb = 0, 0",
"0",
"ca",
"x, y = 1, 1",
"1",
"x",
"x = ca // a",
"ca // a",
"x"
] | n = int(input())
ca, cb = 0, 0
for i in range(n):
a, b = map(int,input().split())
x, y = 1, 1
if ca > a:
x = ca // a
if ca % a:
x += 1
if cb > b:
y = cb // b
if cb % b:
y += 1
x = max(x, y)
ca = a * x
cb = b * x
print(ca + cb)
|
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
39,
13,
13,
12,
13,
0,
13,
17,
28,
13,
39,
17,
17,
14,
2,
18,
13,
13,
18,
13,
13,
0,
13,
17,
29,
13,
23,
13,
23,
13,
0,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
0,
13,
4,
18,
13,
13,
18,
13,
13,
14,
4,
13,
13,
13,
0,
13,
13,
9,
0,
13,
40,
2,
40,
18,
13,
17,
18,
13,
17,
0,
13,
4,
13,
17,
14,
40,
2,
18,
13,
17,
13,
18,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
40,
2,
40,
18,
13,
17,
18,
13,
17,
14,
40,
2,
18,
13,
17,
13,
18,
13,
17,
0,
13,
4,
13,
13,
13,
0,
18,
13,
17,
13,
0,
18,
13,
17,
13,
0,
13,
13,
4,
13,
4,
13,
13,
10,
12,
13,
10,
4,
13,
10,
40,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
40,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
203,
4
],
[
12,
11
],
[
204,
14
],
[
188,
20
],
[
24,
23
],
[
204,
26
],
[
218,
28
],
[
218,
37
],
[
42,
39
],
[
189,
40
],
[
23,
41
],
[
49,
48
],
[
52,
51
],
[
69,
58
],
[
51,
59
],
[
71,
61
],
[
51,
62
],
[
65,
64
],
[
64,
67
],
[
48,
67
],
[
69,
69
],
[
71,
71
],
[
212,
73
],
[
189,
75
],
[
79,
78
],
[
204,
82
],
[
197,
84
],
[
39,
89
],
[
189,
90
],
[
78,
91
],
[
180,
94
],
[
213,
95
],
[
195,
95
],
[
192,
95
],
[
198,
96
],
[
191,
98
],
[
198,
99
],
[
185,
102
],
[
192,
107
],
[
213,
107
],
[
195,
107
],
[
198,
110
],
[
206,
113
],
[
198,
121
],
[
186,
123
],
[
192,
125
],
[
213,
125
],
[
195,
125
],
[
209,
128
],
[
207,
131
],
[
216,
131
],
[
210,
131
],
[
186,
132
],
[
200,
134
],
[
192,
139
],
[
213,
139
],
[
195,
139
],
[
198,
142
],
[
198,
148
],
[
201,
150
],
[
192,
152
],
[
213,
152
],
[
195,
152
],
[
215,
155
],
[
210,
158
],
[
207,
158
],
[
216,
158
],
[
201,
159
],
[
164,
161
],
[
198,
162
],
[
216,
164
],
[
210,
164
],
[
207,
164
],
[
169,
166
],
[
198,
167
],
[
216,
169
],
[
210,
169
],
[
207,
169
],
[
194,
171
],
[
198,
172
],
[
195,
177
],
[
192,
177
],
[
213,
177
],
[
218,
183
],
[
185,
186
],
[
188,
189
],
[
198,
191
],
[
191,
192
],
[
198,
194
],
[
194,
195
],
[
197,
198
],
[
200,
201
],
[
203,
204
],
[
206,
207
],
[
209,
210
],
[
212,
213
],
[
215,
216
],
[
218,
219
]
] | [
"import copy\nn = int(input())\nvote_ls = [[0,0] for _ in range(n)]\nfor i in range(n):\n a,b = map(int,input().split())\n vote_ls[i] = [a,b]\n\ndef check(previous,now):\n ok = True\n for j in [0,1]:\n if previous[j] > now[j]:\n ok = False\n return ok\n\nprevious = vote_ls[0]\nfor i in range(1,n):\n now = copy.copy(vote_ls[i])\n if check(previous,now):\n previous = now\n continue\n\n time_a = -(-previous[0]//now[0])\n time = float('inf')\n if now[1] * time_a >= previous[1]:\n time = min(time,time_a)\n time_b = -(-previous[1]//now[1])\n if now[0] * time_b >= previous[0]:\n time = min(time,time_b)\n now[0]*=time\n now[1]*=time\n previous = now\n\nprint(sum(previous))",
"import copy",
"copy",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"[0,0] for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"[0,0]",
"0",
"0",
"vote_ls = [[0,0] for _ in range(n)]",
"vote_ls",
"[[0,0] for _ in range(n)]",
"for i in range(n):\n a,b = map(int,input().split())\n vote_ls[i] = [a,b]",
"i",
"range(n)",
"range",
"n",
"a,b = map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"vote_ls[i] = [a,b]",
"vote_ls[i]",
"vote_ls",
"i",
"[a,b]",
"a",
"b",
"def check(previous,now):\n ok = True\n for j in [0,1]:\n if previous[j] > now[j]:\n ok = False\n return ok",
"check",
"ok = True",
"ok",
"True",
"for j in [0,1]:\n if previous[j] > now[j]:\n ok = False\n ",
"j",
"[0,1]",
"0",
"1",
"if previous[j] > now[j]:\n ok = False\n ",
"previous[j] > now[j]",
"previous[j]",
"previous",
"j",
"now[j]",
"now",
"j",
"ok = False",
"ok",
"False",
"return ok",
"ok",
"previous",
"previous",
"now",
"now",
"previous = vote_ls[0]",
"previous",
"vote_ls[0]",
"vote_ls",
"0",
"for i in range(1,n):\n now = copy.copy(vote_ls[i])\n if check(previous,now):\n previous = now\n continue\n\n time_a = -(-previous[0]//now[0])\n time = float('inf')\n if now[1] * time_a >= previous[1]:\n time = min(time,time_a)\n time_b = -(-previous[1]//now[1])\n if now[0] * time_b >= previous[0]:\n time = min(time,time_b)\n now[0]*=time\n now[1]*=time\n previous = now",
"i",
"range(1,n)",
"range",
"1",
"n",
"now = copy.copy(vote_ls[i])",
"now",
"copy.copy(vote_ls[i])",
"copy.copy",
"copy",
"copy",
"vote_ls[i]",
"vote_ls",
"i",
"if check(previous,now):\n previous = now\n continue\n\n ",
"check(previous,now)",
"check",
"previous",
"now",
"previous = now",
"previous",
"now",
"continue",
"time_a = -(-previous[0]//now[0])",
"time_a",
"-(-previous[0]//now[0])",
"-previous[0]//now[0]",
"-previous[0]",
"previous[0]",
"previous",
"0",
"now[0]",
"now",
"0",
"time = float('inf')",
"time",
"float('inf')",
"float",
"'inf'",
"if now[1] * time_a >= previous[1]:\n time = min(time,time_a)\n ",
"now[1] * time_a >= previous[1]",
"now[1] * time_a",
"now[1]",
"now",
"1",
"time_a",
"previous[1]",
"previous",
"1",
"time = min(time,time_a)",
"time",
"min(time,time_a)",
"min",
"time",
"time_a",
"time_b = -(-previous[1]//now[1])",
"time_b",
"-(-previous[1]//now[1])",
"-previous[1]//now[1]",
"-previous[1]",
"previous[1]",
"previous",
"1",
"now[1]",
"now",
"1",
"if now[0] * time_b >= previous[0]:\n time = min(time,time_b)\n ",
"now[0] * time_b >= previous[0]",
"now[0] * time_b",
"now[0]",
"now",
"0",
"time_b",
"previous[0]",
"previous",
"0",
"time = min(time,time_b)",
"time",
"min(time,time_b)",
"min",
"time",
"time_b",
"now[0]*=time",
"now[0]",
"now",
"0",
"time",
"now[1]*=time",
"now[1]",
"now",
"1",
"time",
"previous = now",
"previous",
"now",
"print(sum(previous))",
"print",
"sum(previous)",
"sum",
"previous",
"def check(previous,now):\n ok = True\n for j in [0,1]:\n if previous[j] > now[j]:\n ok = False\n return ok",
"def check(previous,now):\n ok = True\n for j in [0,1]:\n if previous[j] > now[j]:\n ok = False\n return ok",
"check",
"a,b = map(int,input().split())",
"map(int,input().split())",
"a",
"time_a = -(-previous[0]//now[0])",
"-(-previous[0]//now[0])",
"time_a",
"vote_ls = [[0,0] for _ in range(n)]",
"[[0,0] for _ in range(n)]",
"vote_ls",
"previous = now",
"now",
"previous",
"previous = now",
"now",
"previous",
"now = copy.copy(vote_ls[i])",
"copy.copy(vote_ls[i])",
"now",
"time_b = -(-previous[1]//now[1])",
"-(-previous[1]//now[1])",
"time_b",
"n = int(input())",
"int(input())",
"n",
"time = float('inf')",
"float('inf')",
"time",
"time = min(time,time_a)",
"min(time,time_a)",
"time",
"previous = vote_ls[0]",
"vote_ls[0]",
"previous",
"time = min(time,time_b)",
"min(time,time_b)",
"time",
"b = map(int,input().split())",
"map(int,input().split())",
"b"
] | import copy
n = int(input())
vote_ls = [[0,0] for _ in range(n)]
for i in range(n):
a,b = map(int,input().split())
vote_ls[i] = [a,b]
def check(previous,now):
ok = True
for j in [0,1]:
if previous[j] > now[j]:
ok = False
return ok
previous = vote_ls[0]
for i in range(1,n):
now = copy.copy(vote_ls[i])
if check(previous,now):
previous = now
continue
time_a = -(-previous[0]//now[0])
time = float('inf')
if now[1] * time_a >= previous[1]:
time = min(time,time_a)
time_b = -(-previous[1]//now[1])
if now[0] * time_b >= previous[0]:
time = min(time,time_b)
now[0]*=time
now[1]*=time
previous = now
print(sum(previous)) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
79,
2
],
[
73,
8
],
[
73,
17
],
[
20,
19
],
[
80,
23
],
[
88,
26
],
[
88,
35
],
[
91,
37
],
[
74,
43
],
[
83,
43
],
[
86,
44
],
[
86,
46
],
[
71,
50
],
[
77,
50
],
[
89,
51
],
[
89,
53
],
[
82,
55
],
[
86,
57
],
[
92,
58
],
[
76,
60
],
[
89,
62
],
[
92,
63
],
[
83,
67
],
[
74,
67
],
[
77,
68
],
[
71,
68
],
[
73,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
88,
86
],
[
88,
89
],
[
91,
92
]
] | [
"N = int(input())\n\nt, a = map(int, input().split())\n\nfor i in range(N - 1):\n nt, na = map(int, input().split())\n p = max((t + nt - 1) // nt, (a + na - 1) // na)\n t = nt * p\n a = na * p\nprint(t + a)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"for i in range(N - 1):\n nt, na = map(int, input().split())\n p = max((t + nt - 1) // nt, (a + na - 1) // na)\n t = nt * p\n a = na * p",
"i",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"nt, na = map(int, input().split())",
"nt",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"na",
"p = max((t + nt - 1) // nt, (a + na - 1) // na)",
"p",
"max((t + nt - 1) // nt, (a + na - 1) // na)",
"max",
"(t + nt - 1) // nt",
"t + nt - 1",
"t + nt",
"t",
"nt",
"1",
"nt",
"(a + na - 1) // na",
"a + na - 1",
"a + na",
"a",
"na",
"1",
"na",
"t = nt * p",
"t",
"nt * p",
"nt",
"p",
"a = na * p",
"a",
"na * p",
"na",
"p",
"print(t + a)",
"print",
"t + a",
"t",
"a",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"a = na * p",
"na * p",
"a",
"N = int(input())",
"int(input())",
"N",
"t = nt * p",
"nt * p",
"t",
"nt, na = map(int, input().split())",
"map(int, input().split())",
"nt",
"na = map(int, input().split())",
"map(int, input().split())",
"na",
"p = max((t + nt - 1) // nt, (a + na - 1) // na)",
"max((t + nt - 1) // nt, (a + na - 1) // na)",
"p"
] | N = int(input())
t, a = map(int, input().split())
for i in range(N - 1):
nt, na = map(int, input().split())
p = max((t + nt - 1) // nt, (a + na - 1) // na)
t = nt * p
a = na * p
print(t + a)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
18,
13,
17,
17,
0,
13,
18,
18,
13,
17,
17,
28,
13,
4,
13,
17,
13,
0,
13,
2,
2,
2,
13,
18,
18,
13,
13,
17,
17,
18,
18,
13,
13,
17,
0,
13,
2,
2,
2,
13,
18,
18,
13,
13,
17,
17,
18,
18,
13,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
18,
18,
13,
13,
17,
0,
13,
2,
13,
18,
18,
13,
13,
17,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13
] | [
[
111,
2
],
[
10,
9
],
[
112,
12
],
[
126,
25
],
[
132,
28
],
[
127,
31
],
[
117,
35
],
[
127,
38
],
[
43,
42
],
[
112,
46
],
[
114,
48
],
[
133,
52
],
[
136,
52
],
[
127,
55
],
[
42,
56
],
[
127,
61
],
[
42,
62
],
[
123,
65
],
[
118,
69
],
[
121,
69
],
[
127,
72
],
[
42,
73
],
[
127,
78
],
[
42,
79
],
[
129,
82
],
[
115,
85
],
[
124,
86
],
[
135,
88
],
[
130,
90
],
[
127,
93
],
[
42,
94
],
[
120,
97
],
[
130,
99
],
[
127,
102
],
[
42,
103
],
[
136,
108
],
[
133,
108
],
[
121,
109
],
[
118,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
]
] | [
"n=int(input())\nl=[list(map(int,input().split())) for _ in range(n)]\n\ntaka = l[0][0]\nao = l[0][1]\n\nfor i in range(1,n):\n rt = (taka+l[i][0]-1) // l[i][0]\n ra = (ao+l[i][1]-1) // l[i][1]\n r = max(rt,ra)\n taka = r * l[i][0]\n ao = r * l[i][1]\n\nprint(taka+ao)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int,input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l=[list(map(int,input().split())) for _ in range(n)]",
"l",
"[list(map(int,input().split())) for _ in range(n)]",
"taka = l[0][0]",
"taka",
"l[0][0]",
"[0]",
"l",
"0",
"0",
"ao = l[0][1]",
"ao",
"l[0][1]",
"[0]",
"l",
"0",
"1",
"for i in range(1,n):\n rt = (taka+l[i][0]-1) // l[i][0]\n ra = (ao+l[i][1]-1) // l[i][1]\n r = max(rt,ra)\n taka = r * l[i][0]\n ao = r * l[i][1]",
"i",
"range(1,n)",
"range",
"1",
"n",
"rt = (taka+l[i][0]-1) // l[i][0]",
"rt",
"(taka+l[i][0]-1) // l[i][0]",
"taka+l[i][0]-1",
"taka+l[i][0]",
"taka",
"l[i][0]",
"[i]",
"l",
"i",
"0",
"1",
"l[i][0]",
"[i]",
"l",
"i",
"0",
"ra = (ao+l[i][1]-1) // l[i][1]",
"ra",
"(ao+l[i][1]-1) // l[i][1]",
"ao+l[i][1]-1",
"ao+l[i][1]",
"ao",
"l[i][1]",
"[i]",
"l",
"i",
"1",
"1",
"l[i][1]",
"[i]",
"l",
"i",
"1",
"r = max(rt,ra)",
"r",
"max(rt,ra)",
"max",
"rt",
"ra",
"taka = r * l[i][0]",
"taka",
"r * l[i][0]",
"r",
"l[i][0]",
"[i]",
"l",
"i",
"0",
"ao = r * l[i][1]",
"ao",
"r * l[i][1]",
"r",
"l[i][1]",
"[i]",
"l",
"i",
"1",
"print(taka+ao)",
"print",
"taka+ao",
"taka",
"ao",
"n=int(input())",
"int(input())",
"n",
"rt = (taka+l[i][0]-1) // l[i][0]",
"(taka+l[i][0]-1) // l[i][0]",
"rt",
"ao = l[0][1]",
"l[0][1]",
"ao",
"ao = r * l[i][1]",
"r * l[i][1]",
"ao",
"ra = (ao+l[i][1]-1) // l[i][1]",
"(ao+l[i][1]-1) // l[i][1]",
"ra",
"l=[list(map(int,input().split())) for _ in range(n)]",
"[list(map(int,input().split())) for _ in range(n)]",
"l",
"r = max(rt,ra)",
"max(rt,ra)",
"r",
"taka = l[0][0]",
"l[0][0]",
"taka",
"taka = r * l[i][0]",
"r * l[i][0]",
"taka"
] | n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
taka = l[0][0]
ao = l[0][1]
for i in range(1,n):
rt = (taka+l[i][0]-1) // l[i][0]
ra = (ao+l[i][1]-1) // l[i][1]
r = max(rt,ra)
taka = r * l[i][0]
ao = r * l[i][1]
print(taka+ao)
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
12,
4,
13,
8,
13,
39,
4,
13,
17,
4,
13,
17,
23,
0,
13,
12,
4,
13,
8,
13,
39,
4,
13,
17,
4,
13,
17,
23,
0,
13,
12,
2,
4,
13,
13,
17,
23,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13
] | [
[
151,
11
],
[
160,
16
],
[
157,
23
],
[
163,
35
],
[
145,
50
],
[
154,
65
],
[
77,
76
],
[
158,
80
],
[
83,
82
],
[
158,
89
],
[
83,
91
],
[
94,
93
],
[
76,
97
],
[
101,
100
],
[
158,
107
],
[
101,
109
],
[
112,
111
],
[
82,
117
],
[
125,
117
],
[
100,
118
],
[
91,
122
],
[
129,
122
],
[
109,
123
],
[
126,
125
],
[
100,
127
],
[
111,
128
],
[
130,
129
],
[
109,
131
],
[
111,
132
],
[
125,
136
],
[
82,
136
],
[
129,
137
],
[
91,
137
],
[
149,
143
],
[
145,
146
],
[
151,
152
],
[
154,
155
],
[
157,
158
],
[
160,
161
],
[
163,
164
]
] | [
"# -*- coding: utf-8 -*-\nimport sys\nsys.setrecursionlimit(10**9)\nINF=10**18\nMOD=10**9+7\ninput=lambda: sys.stdin.readline().rstrip()\nYesNo=lambda b: bool([print('Yes')] if b else print('No'))\nYESNO=lambda b: bool([print('YES')] if b else print('NO'))\nint1=lambda x:int(x)-1\n\ndef main():\n N=int(input())\n T,A=map(int,input().split())\n for _ in range(N-1):\n t,a=map(int,input().split())\n res=max(-(-T//t),-(-A//a))\n T,A=t*res,a*res\n print(T+A)\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"sys.setrecursionlimit(10**9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**9",
"10",
"9",
"INF=10**18",
"INF",
"10**18",
"10",
"18",
"MOD=10**9+7",
"MOD",
"10**9+7",
"10**9",
"10",
"9",
"7",
"input=lambda: sys.stdin.readline().rstrip()",
"input",
"lambda: sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"YesNo=lambda b: bool([print('Yes')] if b else print('No'))",
"YesNo",
"lambda b: bool([print('Yes')] if b else print('No'))",
"bool([print('Yes')] if b else print('No'))",
"bool",
"[print('Yes')] if b else print('No')",
"b",
"[print('Yes')]",
"print('Yes')",
"print",
"'Yes'",
"print('No')",
"print",
"'No'",
"b",
"YESNO=lambda b: bool([print('YES')] if b else print('NO'))",
"YESNO",
"lambda b: bool([print('YES')] if b else print('NO'))",
"bool([print('YES')] if b else print('NO'))",
"bool",
"[print('YES')] if b else print('NO')",
"b",
"[print('YES')]",
"print('YES')",
"print",
"'YES'",
"print('NO')",
"print",
"'NO'",
"b",
"int1=lambda x:int(x)-1",
"int1",
"lambda x:int(x)-1",
"int(x)-1",
"int(x)",
"int",
"x",
"1",
"x",
"def main():\n N=int(input())\n T,A=map(int,input().split())\n for _ in range(N-1):\n t,a=map(int,input().split())\n res=max(-(-T//t),-(-A//a))\n T,A=t*res,a*res\n print(T+A)",
"main",
"N=int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T,A=map(int,input().split())",
"T",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"for _ in range(N-1):\n t,a=map(int,input().split())\n res=max(-(-T//t),-(-A//a))\n T,A=t*res,a*res\n ",
"_",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"t,a=map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"res=max(-(-T//t),-(-A//a))",
"res",
"max(-(-T//t),-(-A//a))",
"max",
"-(-T//t)",
"-T//t",
"-T",
"T",
"t",
"-(-A//a)",
"-A//a",
"-A",
"A",
"a",
"T,A=t*res,a*res",
"T",
"t*res",
"t",
"res",
"A",
"a*res",
"a",
"res",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"YESNO=lambda b: bool([print('YES')] if b else print('NO'))",
"lambda b: bool([print('YES')] if b else print('NO'))",
"YESNO",
"def main():\n N=int(input())\n T,A=map(int,input().split())\n for _ in range(N-1):\n t,a=map(int,input().split())\n res=max(-(-T//t),-(-A//a))\n T,A=t*res,a*res\n print(T+A)",
"def main():\n N=int(input())\n T,A=map(int,input().split())\n for _ in range(N-1):\n t,a=map(int,input().split())\n res=max(-(-T//t),-(-A//a))\n T,A=t*res,a*res\n print(T+A)",
"main",
"INF=10**18",
"10**18",
"INF",
"int1=lambda x:int(x)-1",
"lambda x:int(x)-1",
"int1",
"input=lambda: sys.stdin.readline().rstrip()",
"lambda: sys.stdin.readline().rstrip()",
"input",
"MOD=10**9+7",
"10**9+7",
"MOD",
"YesNo=lambda b: bool([print('Yes')] if b else print('No'))",
"lambda b: bool([print('Yes')] if b else print('No'))",
"YesNo"
] | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
def main():
N=int(input())
T,A=map(int,input().split())
for _ in range(N-1):
t,a=map(int,input().split())
res=max(-(-T//t),-(-A//a))
T,A=t*res,a*res
print(T+A)
if __name__ == '__main__':
main()
|
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
18,
13,
13,
17,
4,
17,
0,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
18,
13,
13,
17,
4,
17,
0,
18,
13,
13,
13,
28,
13,
4,
13,
17,
2,
18,
13,
13,
17,
0,
18,
18,
13,
13,
13,
2,
2,
18,
18,
13,
13,
2,
13,
17,
13,
18,
13,
13,
0,
18,
18,
13,
13,
13,
2,
2,
18,
18,
13,
13,
2,
13,
17,
4,
13,
13,
17,
18,
13,
13,
18,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
29,
2,
2,
18,
18,
13,
13,
13,
2,
2,
18,
18,
13,
13,
2,
13,
13,
18,
18,
13,
13,
13,
18,
13,
13,
18,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
14,
2,
13,
17,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
2,
2,
2,
18,
13,
17,
18,
13,
17,
17,
18,
13,
17,
0,
13,
2,
2,
2,
18,
13,
17,
18,
13,
17,
17,
18,
13,
17,
0,
13,
4,
13,
13,
13,
14,
2,
13,
17,
0,
13,
17,
0,
18,
13,
17,
13,
0,
18,
13,
17,
13,
0,
13,
13,
4,
13,
4,
13,
13,
10,
17,
13,
10,
39,
13,
10,
12,
13,
10,
2,
13,
10,
13,
13,
10,
6,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] | [
[
9,
6
],
[
104,
7
],
[
106,
8
],
[
106,
9
],
[
14,
11
],
[
104,
12
],
[
108,
13
],
[
108,
14
],
[
18,
17
],
[
6,
21
],
[
104,
22
],
[
106,
23
],
[
31,
28
],
[
104,
29
],
[
35,
34
],
[
6,
38
],
[
104,
39
],
[
106,
40
],
[
48,
45
],
[
104,
46
],
[
51,
50
],
[
6,
55
],
[
104,
56
],
[
106,
57
],
[
65,
60
],
[
28,
61
],
[
104,
62
],
[
50,
64
],
[
28,
68
],
[
104,
69
],
[
50,
72
],
[
50,
74
],
[
11,
75
],
[
104,
76
],
[
108,
77
],
[
84,
79
],
[
45,
80
],
[
104,
81
],
[
50,
83
],
[
45,
87
],
[
104,
88
],
[
50,
91
],
[
50,
95
],
[
11,
97
],
[
104,
98
],
[
108,
99
],
[
11,
100
],
[
104,
101
],
[
108,
102
],
[
104,
104
],
[
106,
106
],
[
108,
108
],
[
140,
116
],
[
142,
118
],
[
140,
123
],
[
142,
126
],
[
144,
127
],
[
140,
130
],
[
144,
132
],
[
140,
134
],
[
140,
137
],
[
140,
140
],
[
142,
142
],
[
144,
144
],
[
271,
163
],
[
247,
169
],
[
250,
172
],
[
178,
177
],
[
272,
180
],
[
268,
182
],
[
254,
184
],
[
256,
186
],
[
251,
191
],
[
260,
191
],
[
269,
194
],
[
269,
198
],
[
274,
201
],
[
251,
206
],
[
260,
206
],
[
269,
209
],
[
269,
213
],
[
277,
216
],
[
257,
219
],
[
275,
220
],
[
278,
223
],
[
266,
223
],
[
265,
226
],
[
232,
229
],
[
269,
230
],
[
266,
232
],
[
278,
232
],
[
237,
234
],
[
269,
235
],
[
266,
237
],
[
278,
237
],
[
259,
239
],
[
269,
240
],
[
260,
245
],
[
251,
245
],
[
247,
248
],
[
250,
251
],
[
256,
257
],
[
269,
259
],
[
259,
260
],
[
265,
266
],
[
268,
269
],
[
271,
272
],
[
274,
275
],
[
277,
278
]
] | [
"class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod\ndef iparse():\n return list(map(int, input().split()))\n\n\nif __name__ == \"__main__\":\n n = int(input())\n ml = 1\n last = [0,0]\n for i in range(n):\n x = iparse()\n # print(len(x))\n l = (last[0] + x[0] - 1) // x[0]\n r = (last[1] + x[1] - 1) // x[1]\n m = max(l, r)\n if m == 0:\n m = 1\n x[0] *= m\n x[1] *= m\n \n last = x\n print(sum(last))\n \n \n ",
"class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod",
"Combination",
"def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n ",
"__init__",
"self.n = n",
"self.n",
"self",
"n",
"n",
"self.mod = mod",
"self.mod",
"self",
"mod",
"mod",
"1 for i in range(self.n + 1)",
"for i in range(self.n + 1)",
"i",
"range(self.n + 1)",
"range",
"self.n + 1",
"self.n",
"self",
"n",
"1",
"for i in range(self.n + 1)",
"1",
"self.fac = [1 for i in range(self.n + 1)]",
"self.fac",
"self",
"fac",
"[1 for i in range(self.n + 1)]",
"1 for i in range(self.n + 1)",
"for i in range(self.n + 1)",
"i",
"range(self.n + 1)",
"range",
"self.n + 1",
"self.n",
"self",
"n",
"1",
"for i in range(self.n + 1)",
"1",
"self.finv = [1 for i in range(self.n + 1)]",
"self.finv",
"self",
"finv",
"[1 for i in range(self.n + 1)]",
"for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n ",
"i",
"range(2, self.n+1)",
"range",
"2",
"self.n+1",
"self.n",
"self",
"n",
"1",
"self.fac[i] = (self.fac[i - 1] * i) % self.mod",
"self.fac[i]",
"self.fac",
"self",
"fac",
"i",
"(self.fac[i - 1] * i) % self.mod",
"self.fac[i - 1] * i",
"self.fac[i - 1]",
"self.fac",
"self",
"fac",
"i - 1",
"i",
"1",
"i",
"self.mod",
"self",
"mod",
"self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod",
"self.finv[i]",
"self.finv",
"self",
"finv",
"i",
"(self.finv[i-1] * pow(i, -1, self.mod)) % self.mod",
"self.finv[i-1] * pow(i, -1, self.mod)",
"self.finv[i-1]",
"self.finv",
"self",
"finv",
"i-1",
"i",
"1",
"pow(i, -1, self.mod)",
"pow",
"i",
"-1",
"self.mod",
"self",
"mod",
"self.mod",
"self",
"mod",
"self",
"self",
"n",
"n",
"mod",
"mod",
"def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod",
"comb",
"return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod",
"self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod",
"self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod)",
"self.fac[n]",
"self.fac",
"self",
"fac",
"n",
"self.finv[n-m] * self.finv[m] % self.mod",
"self.finv[n-m] * self.finv[m]",
"self.finv[n-m]",
"self.finv",
"self",
"finv",
"n-m",
"n",
"m",
"self.finv[m]",
"self.finv",
"self",
"finv",
"m",
"self.mod",
"self",
"mod",
"self.mod",
"self",
"mod",
"self",
"self",
"n",
"n",
"m",
"m",
"def iparse():\n return list(map(int, input().split()))",
"iparse",
"return list(map(int, input().split()))",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"if __name__ == \"__main__\":\n n = int(input())\n ml = 1\n last = [0,0]\n for i in range(n):\n x = iparse()\n # print(len(x))\n l = (last[0] + x[0] - 1) // x[0]\n r = (last[1] + x[1] - 1) // x[1]\n m = max(l, r)\n if m == 0:\n m = 1\n x[0] *= m\n x[1] *= m\n \n last = x\n print(sum(last))\n \n \n ",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"ml = 1",
"ml",
"1",
"last = [0,0]",
"last",
"[0,0]",
"0",
"0",
"for i in range(n):\n x = iparse()\n # print(len(x))\n l = (last[0] + x[0] - 1) // x[0]\n r = (last[1] + x[1] - 1) // x[1]\n m = max(l, r)\n if m == 0:\n m = 1\n x[0] *= m\n x[1] *= m\n \n last = x\n ",
"i",
"range(n)",
"range",
"n",
"x = iparse()",
"x",
"iparse()",
"iparse",
"l = (last[0] + x[0] - 1) // x[0]",
"l",
"(last[0] + x[0] - 1) // x[0]",
"last[0] + x[0] - 1",
"last[0] + x[0]",
"last[0]",
"last",
"0",
"x[0]",
"x",
"0",
"1",
"x[0]",
"x",
"0",
"r = (last[1] + x[1] - 1) // x[1]",
"r",
"(last[1] + x[1] - 1) // x[1]",
"last[1] + x[1] - 1",
"last[1] + x[1]",
"last[1]",
"last",
"1",
"x[1]",
"x",
"1",
"1",
"x[1]",
"x",
"1",
"m = max(l, r)",
"m",
"max(l, r)",
"max",
"l",
"r",
"if m == 0:\n m = 1\n ",
"m == 0",
"m",
"0",
"m = 1",
"m",
"1",
"x[0] *= m",
"x[0]",
"x",
"0",
"m",
"x[1] *= m",
"x[1]",
"x",
"1",
"m",
"last = x",
"last",
"x",
"print(sum(last))",
"print",
"sum(last)",
"sum",
"last",
"ml = 1",
"1",
"ml",
"last = [0,0]",
"[0,0]",
"last",
"def iparse():\n return list(map(int, input().split()))",
"def iparse():\n return list(map(int, input().split()))",
"iparse",
"l = (last[0] + x[0] - 1) // x[0]",
"(last[0] + x[0] - 1) // x[0]",
"l",
"last = x",
"x",
"last",
"class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod",
"class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod",
"Combination",
"m = 1",
"1",
"m",
"x = iparse()",
"iparse()",
"x",
"n = int(input())",
"int(input())",
"n",
"r = (last[1] + x[1] - 1) // x[1]",
"(last[1] + x[1] - 1) // x[1]",
"r",
"m = max(l, r)",
"max(l, r)",
"m"
] | class Combination:
def __init__(self, n, mod):
self.n = n
self.mod = mod
self.fac = [1 for i in range(self.n + 1)]
self.finv = [1 for i in range(self.n + 1)]
for i in range(2, self.n+1):
self.fac[i] = (self.fac[i - 1] * i) % self.mod
self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod
def comb(self, n, m):
return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod
def iparse():
return list(map(int, input().split()))
if __name__ == "__main__":
n = int(input())
ml = 1
last = [0,0]
for i in range(n):
x = iparse()
# print(len(x))
l = (last[0] + x[0] - 1) // x[0]
r = (last[1] + x[1] - 1) // x[1]
m = max(l, r)
if m == 0:
m = 1
x[0] *= m
x[1] *= m
last = x
print(sum(last))
|
[
7,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
71,
2
],
[
56,
5
],
[
9,
8
],
[
74,
16
],
[
74,
25
],
[
68,
27
],
[
72,
33
],
[
66,
33
],
[
75,
34
],
[
57,
38
],
[
60,
38
],
[
63,
39
],
[
65,
41
],
[
69,
43
],
[
75,
44
],
[
59,
46
],
[
69,
48
],
[
63,
49
],
[
66,
53
],
[
72,
53
],
[
60,
54
],
[
57,
54
],
[
56,
57
],
[
59,
60
],
[
74,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
]
] | [
"T = 1\nA = 1\n\nfor n in range(int(input())):\n t,a = map(int,input().split())\n m = max(-(-T//t),-(-A//a))\n T = m*t\n A = m*a\n\nprint(T+A)",
"T = 1",
"T",
"1",
"A = 1",
"A",
"1",
"for n in range(int(input())):\n t,a = map(int,input().split())\n m = max(-(-T//t),-(-A//a))\n T = m*t\n A = m*a",
"n",
"range(int(input()))",
"range",
"int(input())",
"int",
"input()",
"input",
"t,a = map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"m = max(-(-T//t),-(-A//a))",
"m",
"max(-(-T//t),-(-A//a))",
"max",
"-(-T//t)",
"-T//t",
"-T",
"T",
"t",
"-(-A//a)",
"-A//a",
"-A",
"A",
"a",
"T = m*t",
"T",
"m*t",
"m",
"t",
"A = m*a",
"A",
"m*a",
"m",
"a",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"A = 1",
"1",
"A",
"A = m*a",
"m*a",
"A",
"a = map(int,input().split())",
"map(int,input().split())",
"a",
"T = m*t",
"m*t",
"T",
"m = max(-(-T//t),-(-A//a))",
"max(-(-T//t),-(-A//a))",
"m",
"T = 1",
"1",
"T",
"t,a = map(int,input().split())",
"map(int,input().split())",
"t"
] | T = 1
A = 1
for n in range(int(input())):
t,a = map(int,input().split())
m = max(-(-T//t),-(-A//a))
T = m*t
A = m*a
print(T+A)
|
[
7,
12,
13,
14,
2,
2,
2,
18,
13,
17,
18,
13,
17,
2,
18,
13,
17,
18,
13,
17,
17,
0,
18,
13,
17,
2,
18,
13,
17,
2,
2,
17,
18,
13,
17,
18,
13,
17,
0,
18,
13,
17,
2,
2,
18,
13,
17,
18,
13,
17,
18,
13,
17,
0,
18,
13,
17,
2,
18,
13,
17,
2,
2,
17,
18,
13,
17,
18,
13,
17,
0,
18,
13,
17,
2,
2,
18,
13,
17,
18,
13,
17,
18,
13,
17,
29,
13,
23,
13,
23,
13,
23,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
13,
4,
13,
13,
10,
13,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13
] | [
[
88,
8
],
[
90,
11
],
[
88,
15
],
[
90,
18
],
[
25,
22
],
[
92,
23
],
[
92,
27
],
[
92,
33
],
[
90,
36
],
[
42,
39
],
[
92,
40
],
[
92,
45
],
[
90,
48
],
[
90,
51
],
[
57,
54
],
[
92,
55
],
[
92,
59
],
[
92,
65
],
[
90,
68
],
[
74,
71
],
[
92,
72
],
[
92,
77
],
[
90,
80
],
[
90,
83
],
[
92,
86
],
[
88,
88
],
[
90,
90
],
[
92,
92
],
[
156,
94
],
[
102,
101
],
[
157,
104
],
[
150,
117
],
[
162,
120
],
[
151,
122
],
[
126,
125
],
[
157,
129
],
[
159,
132
],
[
154,
134
],
[
151,
136
],
[
125,
137
],
[
151,
139
],
[
125,
141
],
[
163,
143
],
[
160,
143
],
[
160,
148
],
[
163,
148
],
[
150,
151
],
[
156,
157
],
[
159,
160
],
[
162,
163
]
] | [
"def nextpt(ratio1, ratio2, pt):\n if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:\n pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]\n pt[1]=pt[0]*ratio2[1]//ratio2[0]\n else:\n pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]\n pt[0]=pt[1]*ratio2[0]//ratio2[1]\n return pt\n\nn=int(input())\nratios = [list(map(int,input().split())) for _ in range(n)]\n\npt=ratios[0]\nfor i in range(n-1):\n pt=nextpt(ratios[i], ratios[i+1], pt)\n\nprint(sum(pt))",
"def nextpt(ratio1, ratio2, pt):\n if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:\n pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]\n pt[1]=pt[0]*ratio2[1]//ratio2[0]\n else:\n pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]\n pt[0]=pt[1]*ratio2[0]//ratio2[1]\n return pt",
"nextpt",
"if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:\n pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]\n pt[1]=pt[0]*ratio2[1]//ratio2[0]\n else:\n pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]\n pt[0]=pt[1]*ratio2[0]//ratio2[1]\n ",
"ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0",
"ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]",
"ratio1[0]*ratio2[1]",
"ratio1[0]",
"ratio1",
"0",
"ratio2[1]",
"ratio2",
"1",
"ratio1[1]*ratio2[0]",
"ratio1[1]",
"ratio1",
"1",
"ratio2[0]",
"ratio2",
"0",
"0",
"pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]",
"pt[0]",
"pt",
"0",
"pt[0]+((-1)*pt[0])%ratio2[0]",
"pt[0]",
"pt",
"0",
"((-1)*pt[0])%ratio2[0]",
"(-1)*pt[0]",
"-1",
"pt[0]",
"pt",
"0",
"ratio2[0]",
"ratio2",
"0",
"pt[1]=pt[0]*ratio2[1]//ratio2[0]",
"pt[1]",
"pt",
"1",
"pt[0]*ratio2[1]//ratio2[0]",
"pt[0]*ratio2[1]",
"pt[0]",
"pt",
"0",
"ratio2[1]",
"ratio2",
"1",
"ratio2[0]",
"ratio2",
"0",
"pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]",
"pt[1]",
"pt",
"1",
"pt[1]+((-1)*pt[1])%ratio2[1]",
"pt[1]",
"pt",
"1",
"((-1)*pt[1])%ratio2[1]",
"(-1)*pt[1]",
"-1",
"pt[1]",
"pt",
"1",
"ratio2[1]",
"ratio2",
"1",
"pt[0]=pt[1]*ratio2[0]//ratio2[1]",
"pt[0]",
"pt",
"0",
"pt[1]*ratio2[0]//ratio2[1]",
"pt[1]*ratio2[0]",
"pt[1]",
"pt",
"1",
"ratio2[0]",
"ratio2",
"0",
"ratio2[1]",
"ratio2",
"1",
"return pt",
"pt",
"ratio1",
"ratio1",
"ratio2",
"ratio2",
"pt",
"pt",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int,input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ratios = [list(map(int,input().split())) for _ in range(n)]",
"ratios",
"[list(map(int,input().split())) for _ in range(n)]",
"pt=ratios[0]",
"pt",
"ratios[0]",
"ratios",
"0",
"for i in range(n-1):\n pt=nextpt(ratios[i], ratios[i+1], pt)",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"pt=nextpt(ratios[i], ratios[i+1], pt)",
"pt",
"nextpt(ratios[i], ratios[i+1], pt)",
"nextpt",
"ratios[i]",
"ratios",
"i",
"ratios[i+1]",
"ratios",
"i+1",
"i",
"1",
"pt",
"print(sum(pt))",
"print",
"sum(pt)",
"sum",
"pt",
"ratios = [list(map(int,input().split())) for _ in range(n)]",
"[list(map(int,input().split())) for _ in range(n)]",
"ratios",
"def nextpt(ratio1, ratio2, pt):\n if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:\n pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]\n pt[1]=pt[0]*ratio2[1]//ratio2[0]\n else:\n pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]\n pt[0]=pt[1]*ratio2[0]//ratio2[1]\n return pt",
"def nextpt(ratio1, ratio2, pt):\n if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:\n pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]\n pt[1]=pt[0]*ratio2[1]//ratio2[0]\n else:\n pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]\n pt[0]=pt[1]*ratio2[0]//ratio2[1]\n return pt",
"nextpt",
"n=int(input())",
"int(input())",
"n",
"pt=nextpt(ratios[i], ratios[i+1], pt)",
"nextpt(ratios[i], ratios[i+1], pt)",
"pt",
"pt=ratios[0]",
"ratios[0]",
"pt"
] | def nextpt(ratio1, ratio2, pt):
if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:
pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]
pt[1]=pt[0]*ratio2[1]//ratio2[0]
else:
pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]
pt[0]=pt[1]*ratio2[0]//ratio2[1]
return pt
n=int(input())
ratios = [list(map(int,input().split())) for _ in range(n)]
pt=ratios[0]
for i in range(n-1):
pt=nextpt(ratios[i], ratios[i+1], pt)
print(sum(pt)) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
12,
13,
0,
13,
2,
2,
2,
13,
17,
13,
17,
0,
13,
2,
2,
2,
13,
17,
13,
17,
0,
13,
4,
13,
13,
13,
29,
39,
2,
13,
13,
2,
13,
13,
23,
13,
23,
13,
23,
13,
23,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
13,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
107,
2
],
[
101,
8
],
[
14,
13
],
[
49,
17
],
[
45,
19
],
[
23,
22
],
[
51,
26
],
[
47,
28
],
[
32,
31
],
[
13,
34
],
[
22,
35
],
[
31,
39
],
[
45,
40
],
[
31,
42
],
[
47,
43
],
[
45,
45
],
[
47,
47
],
[
49,
49
],
[
51,
51
],
[
110,
53
],
[
110,
56
],
[
60,
59
],
[
108,
62
],
[
98,
64
],
[
98,
73
],
[
113,
75
],
[
93,
77
],
[
99,
78
],
[
90,
79
],
[
111,
80
],
[
114,
80
],
[
105,
81
],
[
96,
81
],
[
113,
82
],
[
114,
86
],
[
111,
86
],
[
96,
87
],
[
105,
87
],
[
98,
90
],
[
113,
96
],
[
98,
99
],
[
101,
102
],
[
110,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
]
] | [
"# https://atcoder.jp/contests/abc046/tasks/arc062_a\n# 条件を考えよう\n# iのときの割合の人数n[i],m[i]を考えると\n# n[i]=p*A[i], m[i]=p*B[i] かつ n[i]>=n[i-1], m[i]>=m[i-1] を満たす最小のn[i], m[i]\n# このような条件を満たすpを探すのは容易だ\n# n[i-1]//A[i] がn[i]をギリギリ超えないpなのだから、ギリギリ超えるpはn[i-1]//A[i] + 1 (ぴったり割り切れるときは注意)\n# nについてもmについてもギリギリ越したいのだから大きい方を採用する。(小さい方では片方が超えなくなる)\n\n\nN = int(input())\nans = 1\n\n\ndef ret_nm(t, a, n, m):\n times_t = (n - 1) // t + 1\n times_a = (m - 1) // a + 1\n times = max(times_t, times_a)\n return times * t, times * a\n\n\nn = m = 1\nfor _ in range(N):\n t, a = map(int, input().split())\n n, m = ret_nm(t, a, n, m)\n\n\nprint(n + m)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"ans = 1",
"ans",
"1",
"def ret_nm(t, a, n, m):\n times_t = (n - 1) // t + 1\n times_a = (m - 1) // a + 1\n times = max(times_t, times_a)\n return times * t, times * a",
"ret_nm",
"times_t = (n - 1) // t + 1",
"times_t",
"(n - 1) // t + 1",
"(n - 1) // t",
"n - 1",
"n",
"1",
"t",
"1",
"times_a = (m - 1) // a + 1",
"times_a",
"(m - 1) // a + 1",
"(m - 1) // a",
"m - 1",
"m",
"1",
"a",
"1",
"times = max(times_t, times_a)",
"times",
"max(times_t, times_a)",
"max",
"times_t",
"times_a",
"return times * t, times * a",
"return times * t, times * a",
"times * t",
"times",
"t",
"times * a",
"times",
"a",
"t",
"t",
"a",
"a",
"n",
"n",
"m",
"m",
"n = m = 1",
"n",
"1",
"= m = 1",
"m",
"1",
"for _ in range(N):\n t, a = map(int, input().split())\n n, m = ret_nm(t, a, n, m)",
"_",
"range(N)",
"range",
"N",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"n, m = ret_nm(t, a, n, m)",
"n",
"ret_nm(t, a, n, m)",
"ret_nm",
"t",
"a",
"n",
"m",
"m",
"print(n + m)",
"print",
"n + m",
"n",
"m",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"def ret_nm(t, a, n, m):\n times_t = (n - 1) // t + 1\n times_a = (m - 1) // a + 1\n times = max(times_t, times_a)\n return times * t, times * a",
"def ret_nm(t, a, n, m):\n times_t = (n - 1) // t + 1\n times_a = (m - 1) // a + 1\n times = max(times_t, times_a)\n return times * t, times * a",
"ret_nm",
"m = ret_nm(t, a, n, m)",
"ret_nm(t, a, n, m)",
"m",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"ans = 1",
"1",
"ans",
"m = 1",
"1",
"m",
"N = int(input())",
"int(input())",
"N",
"n = m = 1",
"1",
"n",
"n, m = ret_nm(t, a, n, m)",
"ret_nm(t, a, n, m)",
"n"
] | # https://atcoder.jp/contests/abc046/tasks/arc062_a
# 条件を考えよう
# iのときの割合の人数n[i],m[i]を考えると
# n[i]=p*A[i], m[i]=p*B[i] かつ n[i]>=n[i-1], m[i]>=m[i-1] を満たす最小のn[i], m[i]
# このような条件を満たすpを探すのは容易だ
# n[i-1]//A[i] がn[i]をギリギリ超えないpなのだから、ギリギリ超えるpはn[i-1]//A[i] + 1 (ぴったり割り切れるときは注意)
# nについてもmについてもギリギリ越したいのだから大きい方を採用する。(小さい方では片方が超えなくなる)
N = int(input())
ans = 1
def ret_nm(t, a, n, m):
times_t = (n - 1) // t + 1
times_a = (m - 1) // a + 1
times = max(times_t, times_a)
return times * t, times * a
n = m = 1
for _ in range(N):
t, a = map(int, input().split())
n, m = ret_nm(t, a, n, m)
print(n + m)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
40,
4,
13,
2,
40,
13,
13,
2,
40,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
40,
13,
10,
17,
13,
10,
4,
13
] | [
[
59,
2
],
[
74,
8
],
[
65,
10
],
[
14,
13
],
[
60,
16
],
[
77,
18
],
[
77,
27
],
[
71,
29
],
[
75,
35
],
[
69,
35
],
[
78,
36
],
[
66,
39
],
[
57,
39
],
[
63,
40
],
[
68,
42
],
[
72,
44
],
[
78,
45
],
[
56,
46
],
[
72,
48
],
[
63,
49
],
[
69,
53
],
[
75,
53
],
[
57,
54
],
[
66,
54
],
[
56,
57
],
[
59,
60
],
[
77,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
]
] | [
"n = int(input())\na,b = 1,1\nfor _ in range(n):\n x,y = map(int,input().split())\n k = -min(-a//x,-b//y)\n a,b = k*x,k*y\nprint(a+b)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a,b = 1,1",
"a",
"1",
"b",
"1",
"for _ in range(n):\n x,y = map(int,input().split())\n k = -min(-a//x,-b//y)\n a,b = k*x,k*y",
"_",
"range(n)",
"range",
"n",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"k = -min(-a//x,-b//y)",
"k",
"-min(-a//x,-b//y)",
"min(-a//x,-b//y)",
"min",
"-a//x",
"-a",
"a",
"x",
"-b//y",
"-b",
"b",
"y",
"a,b = k*x,k*y",
"a",
"k*x",
"k",
"x",
"b",
"k*y",
"k",
"y",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"b = k*x,k*y",
"k*y",
"b",
"n = int(input())",
"int(input())",
"n",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"b = 1,1",
"1",
"b",
"a,b = k*x,k*y",
"k*x",
"a",
"k = -min(-a//x,-b//y)",
"-min(-a//x,-b//y)",
"k",
"a,b = 1,1",
"1",
"a",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x"
] | n = int(input())
a,b = 1,1
for _ in range(n):
x,y = map(int,input().split())
k = -min(-a//x,-b//y)
a,b = k*x,k*y
print(a+b) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
15,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
2,
13,
17,
13,
17,
0,
13,
2,
2,
2,
13,
17,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
93,
2
],
[
99,
8
],
[
99,
17
],
[
22,
21
],
[
94,
25
],
[
102,
28
],
[
102,
37
],
[
96,
39
],
[
100,
43
],
[
85,
43
],
[
82,
45
],
[
105,
48
],
[
91,
52
],
[
88,
52
],
[
103,
54
],
[
78,
57
],
[
97,
60
],
[
106,
61
],
[
84,
63
],
[
82,
65
],
[
79,
66
],
[
87,
68
],
[
103,
70
],
[
79,
71
],
[
85,
75
],
[
100,
75
],
[
88,
76
],
[
91,
76
],
[
78,
79
],
[
102,
82
],
[
84,
85
],
[
87,
88
],
[
99,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
]
] | [
"n=int(input())\nx,y=map(int,input().split())\n\nimport math\nfor i in range(n-1):\n t,a=map(int,input().split())\n tbai=(x-1)//t+1\n abai=(y-1)//a+1\n bai=max(tbai,abai)\n x=t*bai\n y=a*bai\n #print(x,y)\nprint(x+y)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"import math",
"math",
"for i in range(n-1):\n t,a=map(int,input().split())\n tbai=(x-1)//t+1\n abai=(y-1)//a+1\n bai=max(tbai,abai)\n x=t*bai\n y=a*bai\n #print(x,y)",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"t,a=map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"tbai=(x-1)//t+1",
"tbai",
"(x-1)//t+1",
"(x-1)//t",
"x-1",
"x",
"1",
"t",
"1",
"abai=(y-1)//a+1",
"abai",
"(y-1)//a+1",
"(y-1)//a",
"y-1",
"y",
"1",
"a",
"1",
"bai=max(tbai,abai)",
"bai",
"max(tbai,abai)",
"max",
"tbai",
"abai",
"x=t*bai",
"x",
"t*bai",
"t",
"bai",
"y=a*bai",
"y",
"a*bai",
"a",
"bai",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"bai=max(tbai,abai)",
"max(tbai,abai)",
"bai",
"t,a=map(int,input().split())",
"map(int,input().split())",
"t",
"x=t*bai",
"t*bai",
"x",
"y=a*bai",
"a*bai",
"y",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"n=int(input())",
"int(input())",
"n",
"tbai=(x-1)//t+1",
"(x-1)//t+1",
"tbai",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"a=map(int,input().split())",
"map(int,input().split())",
"a",
"abai=(y-1)//a+1",
"(y-1)//a+1",
"abai"
] | n=int(input())
x,y=map(int,input().split())
import math
for i in range(n-1):
t,a=map(int,input().split())
tbai=(x-1)//t+1
abai=(y-1)//a+1
bai=max(tbai,abai)
x=t*bai
y=a*bai
#print(x,y)
print(x+y) |
[
7,
15,
12,
13,
29,
4,
18,
4,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
13,
14,
2,
2,
13,
13,
17,
29,
2,
13,
13,
29,
2,
2,
13,
13,
17,
23,
13,
23,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
39,
4,
13,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13
] | [
[
99,
13
],
[
109,
17
],
[
37,
23
],
[
39,
24
],
[
37,
28
],
[
39,
29
],
[
37,
33
],
[
39,
34
],
[
37,
37
],
[
39,
39
],
[
96,
41
],
[
117,
43
],
[
47,
46
],
[
100,
49
],
[
105,
51
],
[
109,
58
],
[
105,
60
],
[
111,
62
],
[
103,
67
],
[
97,
68
],
[
94,
68
],
[
106,
69
],
[
103,
71
],
[
118,
72
],
[
115,
72
],
[
91,
73
],
[
93,
75
],
[
112,
77
],
[
106,
78
],
[
114,
80
],
[
112,
82
],
[
91,
83
],
[
94,
87
],
[
97,
87
],
[
115,
88
],
[
118,
88
],
[
105,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
105,
106
],
[
111,
112
],
[
114,
115
],
[
117,
118
]
] | [
"from sys import stdin\ndef input():\n return stdin.readline().strip()\n\nn = int(input())\n\ndef adjust(x, y):\n if x % y == 0:\n return x // y\n else:\n return x//y + 1\n\nta, ao = 1, 1\nfor _ in range(n):\n t, a = map(int, input().split())\n mul = max([adjust(ta, t), adjust(ao, a)])\n ta = mul * t\n ao = mul * a\n\nprint(ta + ao)",
"from sys import stdin",
"def input():\n return stdin.readline().strip()",
"input",
"return stdin.readline().strip()",
"stdin.readline().strip()",
"stdin.readline().strip",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
"strip",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"def adjust(x, y):\n if x % y == 0:\n return x // y\n else:\n return x//y + 1",
"adjust",
"if x % y == 0:\n return x // y\n else:\n return x//y + 1",
"x % y == 0",
"x % y",
"x",
"y",
"0",
"return x // y",
"x // y",
"x",
"y",
"return x//y + 1",
"x//y + 1",
"x//y",
"x",
"y",
"1",
"x",
"x",
"y",
"y",
"ta, ao = 1, 1",
"ta",
"1",
"ao",
"1",
"for _ in range(n):\n t, a = map(int, input().split())\n mul = max([adjust(ta, t), adjust(ao, a)])\n ta = mul * t\n ao = mul * a",
"_",
"range(n)",
"range",
"n",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"mul = max([adjust(ta, t), adjust(ao, a)])",
"mul",
"max([adjust(ta, t), adjust(ao, a)])",
"max",
"[adjust(ta, t), adjust(ao, a)]",
"adjust(ta, t)",
"adjust",
"ta",
"t",
"adjust(ao, a)",
"adjust",
"ao",
"a",
"ta = mul * t",
"ta",
"mul * t",
"mul",
"t",
"ao = mul * a",
"ao",
"mul * a",
"mul",
"a",
"print(ta + ao)",
"print",
"ta + ao",
"ta",
"ao",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"ta = mul * t",
"mul * t",
"ta",
"ta, ao = 1, 1",
"1",
"ta",
"n = int(input())",
"int(input())",
"n",
"def adjust(x, y):\n if x % y == 0:\n return x // y\n else:\n return x//y + 1",
"def adjust(x, y):\n if x % y == 0:\n return x // y\n else:\n return x//y + 1",
"adjust",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"def input():\n return stdin.readline().strip()",
"def input():\n return stdin.readline().strip()",
"input",
"mul = max([adjust(ta, t), adjust(ao, a)])",
"max([adjust(ta, t), adjust(ao, a)])",
"mul",
"ao = mul * a",
"mul * a",
"ao",
"ao = 1, 1",
"1",
"ao"
] | from sys import stdin
def input():
return stdin.readline().strip()
n = int(input())
def adjust(x, y):
if x % y == 0:
return x // y
else:
return x//y + 1
ta, ao = 1, 1
for _ in range(n):
t, a = map(int, input().split())
mul = max([adjust(ta, t), adjust(ao, a)])
ta = mul * t
ao = mul * a
print(ta + ao) |
[
7,
15,
13,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
7,
6
],
[
13,
12
],
[
13,
21
],
[
24,
23
],
[
6,
27
],
[
31,
30
],
[
31,
39
],
[
42,
41
],
[
12,
47
],
[
55,
47
],
[
30,
48
],
[
21,
52
],
[
60,
52
],
[
39,
53
],
[
56,
55
],
[
30,
57
],
[
41,
58
],
[
61,
60
],
[
39,
62
],
[
41,
63
],
[
55,
67
],
[
12,
67
],
[
60,
68
],
[
21,
68
],
[
77,
74
]
] | [
"#!/usr/bin/env python3\nimport math\n\ndef main():\n N = int(input())\n T, A = map(int, input().split())\n for _ in range(N-1):\n t, a = map(int, input().split())\n # 桁が大きいとfloatの誤差が生じて正しく判定できない\n # 負の数にして切り捨てにすればceilと同じ挙動になる\n x = max(-(-T//t), -(-A//a))\n T = t*x\n A = a*x\n print(T+A)\n\nif __name__ == \"__main__\":\n main()",
"import math",
"math",
"def main():\n N = int(input())\n T, A = map(int, input().split())\n for _ in range(N-1):\n t, a = map(int, input().split())\n # 桁が大きいとfloatの誤差が生じて正しく判定できない\n # 負の数にして切り捨てにすればceilと同じ挙動になる\n x = max(-(-T//t), -(-A//a))\n T = t*x\n A = a*x\n print(T+A)",
"main",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T, A = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"for _ in range(N-1):\n t, a = map(int, input().split())\n # 桁が大きいとfloatの誤差が生じて正しく判定できない\n # 負の数にして切り捨てにすればceilと同じ挙動になる\n x = max(-(-T//t), -(-A//a))\n T = t*x\n A = a*x\n ",
"_",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"x = max(-(-T//t), -(-A//a))",
"x",
"max(-(-T//t), -(-A//a))",
"max",
"-(-T//t)",
"-T//t",
"-T",
"T",
"t",
"-(-A//a)",
"-A//a",
"-A",
"A",
"a",
"T = t*x",
"T",
"t*x",
"t",
"x",
"A = a*x",
"A",
"a*x",
"a",
"x",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n N = int(input())\n T, A = map(int, input().split())\n for _ in range(N-1):\n t, a = map(int, input().split())\n # 桁が大きいとfloatの誤差が生じて正しく判定できない\n # 負の数にして切り捨てにすればceilと同じ挙動になる\n x = max(-(-T//t), -(-A//a))\n T = t*x\n A = a*x\n print(T+A)",
"def main():\n N = int(input())\n T, A = map(int, input().split())\n for _ in range(N-1):\n t, a = map(int, input().split())\n # 桁が大きいとfloatの誤差が生じて正しく判定できない\n # 負の数にして切り捨てにすればceilと同じ挙動になる\n x = max(-(-T//t), -(-A//a))\n T = t*x\n A = a*x\n print(T+A)",
"main"
] | #!/usr/bin/env python3
import math
def main():
N = int(input())
T, A = map(int, input().split())
for _ in range(N-1):
t, a = map(int, input().split())
# 桁が大きいとfloatの誤差が生じて正しく判定できない
# 負の数にして切り捨てにすればceilと同じ挙動になる
x = max(-(-T//t), -(-A//a))
T = t*x
A = a*x
print(T+A)
if __name__ == "__main__":
main()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
40,
4,
13,
2,
40,
13,
13,
2,
40,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
40,
13,
10,
2,
13
] | [
[
64,
2
],
[
76,
8
],
[
76,
17
],
[
20,
19
],
[
65,
23
],
[
79,
26
],
[
79,
35
],
[
82,
37
],
[
71,
43
],
[
68,
43
],
[
74,
44
],
[
77,
47
],
[
86,
47
],
[
80,
48
],
[
67,
50
],
[
83,
52
],
[
74,
53
],
[
85,
54
],
[
83,
56
],
[
80,
57
],
[
68,
61
],
[
71,
61
],
[
86,
62
],
[
77,
62
],
[
64,
65
],
[
67,
68
],
[
76,
71
],
[
79,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
]
] | [
"n=int(input())\nnt,na=map(int,input().split())\nfor i in range(n-1):\n t,a=map(int,input().split())\n x=-min((-nt)//t,(-na)//a)\n nt,na=x*t,x*a\nprint(nt+na)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"nt,na=map(int,input().split())",
"nt",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"na",
"for i in range(n-1):\n t,a=map(int,input().split())\n x=-min((-nt)//t,(-na)//a)\n nt,na=x*t,x*a",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"t,a=map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"x=-min((-nt)//t,(-na)//a)",
"x",
"-min((-nt)//t,(-na)//a)",
"min((-nt)//t,(-na)//a)",
"min",
"(-nt)//t",
"-nt",
"nt",
"t",
"(-na)//a",
"-na",
"na",
"a",
"nt,na=x*t,x*a",
"nt",
"x*t",
"x",
"t",
"na",
"x*a",
"x",
"a",
"print(nt+na)",
"print",
"nt+na",
"nt",
"na",
"n=int(input())",
"int(input())",
"n",
"nt,na=x*t,x*a",
"x*t",
"nt",
"nt,na=map(int,input().split())",
"map(int,input().split())",
"nt",
"t,a=map(int,input().split())",
"map(int,input().split())",
"t",
"na=map(int,input().split())",
"map(int,input().split())",
"na",
"a=map(int,input().split())",
"map(int,input().split())",
"a",
"x=-min((-nt)//t,(-na)//a)",
"-min((-nt)//t,(-na)//a)",
"x",
"na=x*t,x*a",
"x*a",
"na"
] | n=int(input())
nt,na=map(int,input().split())
for i in range(n-1):
t,a=map(int,input().split())
x=-min((-nt)//t,(-na)//a)
nt,na=x*t,x*a
print(nt+na) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
12,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
17,
2,
17,
2,
40,
13,
13,
2,
17,
2,
40,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
84,
2
],
[
78,
8
],
[
69,
19
],
[
79,
21
],
[
69,
22
],
[
25,
24
],
[
85,
28
],
[
87,
30
],
[
79,
32
],
[
87,
33
],
[
90,
35
],
[
70,
43
],
[
76,
43
],
[
88,
44
],
[
67,
49
],
[
82,
49
],
[
73,
50
],
[
75,
52
],
[
88,
54
],
[
91,
55
],
[
81,
56
],
[
73,
58
],
[
91,
59
],
[
76,
63
],
[
70,
63
],
[
82,
64
],
[
67,
64
],
[
69,
67
],
[
69,
70
],
[
87,
73
],
[
75,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
]
] | [
"n=int(input())\nf=lambda:map(int,input().split())\na,b=f()\nfor _ in range(1,n):\n c,d=f()\n t=max(1,0--a//c,0--b//d)\n a,b=c*t,d*t\nprint(a+b)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"f=lambda:map(int,input().split())",
"f",
"lambda:map(int,input().split())",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a,b=f()",
"a",
"f()",
"f",
"b",
"for _ in range(1,n):\n c,d=f()\n t=max(1,0--a//c,0--b//d)\n a,b=c*t,d*t",
"_",
"range(1,n)",
"range",
"1",
"n",
"c,d=f()",
"c",
"f()",
"f",
"d",
"t=max(1,0--a//c,0--b//d)",
"t",
"max(1,0--a//c,0--b//d)",
"max",
"1",
"0--a//c",
"0",
"-a//c",
"-a",
"a",
"c",
"0--b//d",
"0",
"-b//d",
"-b",
"b",
"d",
"a,b=c*t,d*t",
"a",
"c*t",
"c",
"t",
"b",
"d*t",
"d",
"t",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"b=f()",
"f()",
"b",
"a,b=f()",
"f()",
"a",
"d=f()",
"f()",
"d",
"a,b=c*t,d*t",
"c*t",
"a",
"f=lambda:map(int,input().split())",
"lambda:map(int,input().split())",
"f",
"b=c*t,d*t",
"d*t",
"b",
"n=int(input())",
"int(input())",
"n",
"c,d=f()",
"f()",
"c",
"t=max(1,0--a//c,0--b//d)",
"max(1,0--a//c,0--b//d)",
"t"
] | n=int(input())
f=lambda:map(int,input().split())
a,b=f()
for _ in range(1,n):
c,d=f()
t=max(1,0--a//c,0--b//d)
a,b=c*t,d*t
print(a+b) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
13,
0,
13,
4,
13,
2,
13,
13,
2,
13,
13,
14,
2,
40,
2,
13,
13,
13,
40,
2,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
17,
13,
0,
13,
2,
2,
13,
17,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13
] | [
[
89,
2
],
[
10,
9
],
[
90,
12
],
[
107,
25
],
[
113,
28
],
[
113,
31
],
[
101,
38
],
[
114,
42
],
[
99,
42
],
[
105,
42
],
[
111,
45
],
[
93,
45
],
[
96,
45
],
[
102,
51
],
[
114,
53
],
[
99,
53
],
[
105,
53
],
[
102,
56
],
[
111,
58
],
[
93,
58
],
[
96,
58
],
[
104,
60
],
[
102,
62
],
[
95,
65
],
[
102,
67
],
[
98,
70
],
[
102,
73
],
[
92,
77
],
[
102,
80
],
[
93,
86
],
[
96,
86
],
[
111,
86
],
[
99,
87
],
[
105,
87
],
[
114,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
113,
111
],
[
113,
114
]
] | [
"n = int(input())\nTA = [list(map(int, input().split())) for _ in range(n)]\n\nT = A = 1\nfor t, a in TA:\n r = max(A//a, T//t)\n if r*a >= A and r*t >= T:\n A = r*a; T = r*t\n else:\n A = (r+1)*a; T = (r+1)*t\n\nprint(T+A)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for _ in range(n)]",
"TA",
"[list(map(int, input().split())) for _ in range(n)]",
"T = A = 1",
"T",
"1",
"= A = 1",
"A",
"1",
"for t, a in TA:\n r = max(A//a, T//t)\n if r*a >= A and r*t >= T:\n A = r*a; T = r*t\n else:\n A = (r+1)*a; T = (r+1)*t",
"t",
"a",
"TA",
"r = max(A//a, T//t)",
"r",
"max(A//a, T//t)",
"max",
"A//a",
"A",
"a",
"T//t",
"T",
"t",
"if r*a >= A and r*t >= T:\n A = r*a; T = r*t\n else:\n A = (r+1)*a; T = (r+1)*t",
"r*a >= A and r*t >= T",
"r*a >= A",
"r*a",
"r",
"a",
"A",
"r*t >= T",
"r*t",
"r",
"t",
"T",
"A = r*a",
"A",
"r*a",
"r",
"a",
"T = r*t",
"T",
"r*t",
"r",
"t",
"A = (r+1)*a",
"A",
"(r+1)*a",
"r+1",
"r",
"1",
"a",
"T = (r+1)*t",
"T",
"(r+1)*t",
"r+1",
"r",
"1",
"t",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"n = int(input())",
"int(input())",
"n",
"T = (r+1)*t",
"(r+1)*t",
"T",
"T = r*t",
"r*t",
"T",
"A = (r+1)*a",
"(r+1)*a",
"A",
"r = max(A//a, T//t)",
"max(A//a, T//t)",
"r",
"A = r*a",
"r*a",
"A",
"TA = [list(map(int, input().split())) for _ in range(n)]",
"[list(map(int, input().split())) for _ in range(n)]",
"TA",
"T = A = 1",
"1",
"T",
"A = 1",
"1",
"A"
] | n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]
T = A = 1
for t, a in TA:
r = max(A//a, T//t)
if r*a >= A and r*t >= T:
A = r*a; T = r*t
else:
A = (r+1)*a; T = (r+1)*t
print(T+A) |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13
] | [
[
101,
4
],
[
12,
11
],
[
102,
14
],
[
95,
27
],
[
86,
30
],
[
83,
33
],
[
87,
42
],
[
108,
42
],
[
105,
42
],
[
84,
45
],
[
93,
45
],
[
90,
45
],
[
104,
48
],
[
89,
51
],
[
98,
54
],
[
87,
60
],
[
108,
60
],
[
105,
60
],
[
84,
65
],
[
93,
65
],
[
90,
65
],
[
107,
68
],
[
99,
70
],
[
92,
73
],
[
99,
75
],
[
108,
80
],
[
105,
80
],
[
87,
80
],
[
93,
81
],
[
90,
81
],
[
84,
81
],
[
83,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
]
] | [
"import math\nN = int(input())\nTA = [list(map(int, input().split())) for i in range(N)]\n\nx = 1\ny = 1\nfor t, a in TA:\n if x <= t and y <= a:\n x = t\n y = a\n else:\n v = max(-(-x//t), -(-y//a))\n x = v * t\n y = v * a\n\n\nprint(x+y)",
"import math",
"math",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for i in range(N)]",
"TA",
"[list(map(int, input().split())) for i in range(N)]",
"x = 1",
"x",
"1",
"y = 1",
"y",
"1",
"for t, a in TA:\n if x <= t and y <= a:\n x = t\n y = a\n else:\n v = max(-(-x//t), -(-y//a))\n x = v * t\n y = v * a",
"t",
"a",
"TA",
"if x <= t and y <= a:\n x = t\n y = a\n else:\n v = max(-(-x//t), -(-y//a))\n x = v * t\n y = v * a",
"x <= t and y <= a",
"x <= t",
"x",
"t",
"y <= a",
"y",
"a",
"x = t",
"x",
"t",
"y = a",
"y",
"a",
"v = max(-(-x//t), -(-y//a))",
"v",
"max(-(-x//t), -(-y//a))",
"max",
"-(-x//t)",
"-x//t",
"-x",
"x",
"t",
"-(-y//a)",
"-y//a",
"-y",
"y",
"a",
"x = v * t",
"x",
"v * t",
"v",
"t",
"y = v * a",
"y",
"v * a",
"v",
"a",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"y = 1",
"1",
"y",
"x = 1",
"1",
"x",
"y = a",
"a",
"y",
"y = v * a",
"v * a",
"y",
"TA = [list(map(int, input().split())) for i in range(N)]",
"[list(map(int, input().split())) for i in range(N)]",
"TA",
"v = max(-(-x//t), -(-y//a))",
"max(-(-x//t), -(-y//a))",
"v",
"N = int(input())",
"int(input())",
"N",
"x = t",
"t",
"x",
"x = v * t",
"v * t",
"x"
] | import math
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]
x = 1
y = 1
for t, a in TA:
if x <= t and y <= a:
x = t
y = a
else:
v = max(-(-x//t), -(-y//a))
x = v * t
y = v * a
print(x+y)
|
[
7,
15,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
13,
13,
18,
13,
13,
18,
13,
13,
0,
13,
2,
18,
13,
13,
13,
0,
13,
2,
18,
13,
13,
13,
4,
13,
2,
13,
13,
12,
13,
0,
13,
17,
0,
13,
2,
17,
17,
42,
2,
2,
13,
13,
17,
0,
13,
2,
2,
13,
13,
17,
14,
2,
2,
13,
2,
13,
13,
2,
13,
2,
13,
13,
0,
13,
13,
0,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
23,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
6,
5
],
[
12,
11
],
[
15,
14
],
[
18,
17
],
[
5,
20
],
[
23,
22
],
[
23,
31
],
[
11,
34
],
[
22,
36
],
[
14,
39
],
[
31,
41
],
[
44,
43
],
[
11,
45
],
[
49,
48
],
[
14,
50
],
[
54,
53
],
[
5,
57
],
[
60,
59
],
[
43,
62
],
[
71,
62
],
[
48,
63
],
[
78,
63
],
[
11,
65
],
[
53,
66
],
[
14,
68
],
[
53,
69
],
[
72,
71
],
[
11,
74
],
[
53,
75
],
[
59,
76
],
[
79,
78
],
[
14,
81
],
[
53,
82
],
[
59,
83
],
[
71,
87
],
[
43,
87
],
[
78,
88
],
[
48,
88
],
[
93,
92
],
[
96,
95
],
[
95,
102
],
[
128,
102
],
[
92,
103
],
[
125,
103
],
[
107,
106
],
[
95,
109
],
[
128,
109
],
[
92,
110
],
[
125,
110
],
[
133,
115
],
[
137,
117
],
[
106,
118
],
[
135,
120
],
[
139,
122
],
[
106,
123
],
[
126,
125
],
[
106,
126
],
[
129,
128
],
[
106,
129
],
[
128,
131
],
[
95,
131
],
[
133,
133
],
[
135,
135
],
[
137,
137
],
[
139,
139
],
[
148,
145
]
] | [
"from math import ceil\ndef solve():\n N = int(input())\n T = []\n A = []\n for _ in range(N):\n t, a = map(int,input().split())\n T.append(t)\n A.append(a)\n \n now_t = T[0]\n now_a = A[0]\n\n for i in range(1,N):\n mul = f(now_t,now_a,T[i],A[i])\n now_t = T[i] * mul\n now_a = A[i] * mul\n \n print(now_t + now_a)\n\ndef f(now_t, now_a, t, a):\n left = 0\n right = 10 ** 18\n while right - left > 1:\n mid = (right + left) // 2\n if now_t > t * mid or now_a > a * mid:\n left = mid\n else:\n right = mid\n \n return right\n\nif __name__ == '__main__':\n solve()",
"from math import ceil",
"def solve():\n N = int(input())\n T = []\n A = []\n for _ in range(N):\n t, a = map(int,input().split())\n T.append(t)\n A.append(a)\n \n now_t = T[0]\n now_a = A[0]\n\n for i in range(1,N):\n mul = f(now_t,now_a,T[i],A[i])\n now_t = T[i] * mul\n now_a = A[i] * mul\n \n print(now_t + now_a)",
"solve",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T = []",
"T",
"[]",
"A = []",
"A",
"[]",
"for _ in range(N):\n t, a = map(int,input().split())\n T.append(t)\n A.append(a)\n \n ",
"_",
"range(N)",
"range",
"N",
"t, a = map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"T.append(t)",
"T.append",
"T",
"append",
"t",
"A.append(a)",
"A.append",
"A",
"append",
"a",
"now_t = T[0]",
"now_t",
"T[0]",
"T",
"0",
"now_a = A[0]",
"now_a",
"A[0]",
"A",
"0",
"for i in range(1,N):\n mul = f(now_t,now_a,T[i],A[i])\n now_t = T[i] * mul\n now_a = A[i] * mul\n \n ",
"i",
"range(1,N)",
"range",
"1",
"N",
"mul = f(now_t,now_a,T[i],A[i])",
"mul",
"f(now_t,now_a,T[i],A[i])",
"f",
"now_t",
"now_a",
"T[i]",
"T",
"i",
"A[i]",
"A",
"i",
"now_t = T[i] * mul",
"now_t",
"T[i] * mul",
"T[i]",
"T",
"i",
"mul",
"now_a = A[i] * mul",
"now_a",
"A[i] * mul",
"A[i]",
"A",
"i",
"mul",
"print(now_t + now_a)",
"print",
"now_t + now_a",
"now_t",
"now_a",
"def f(now_t, now_a, t, a):\n left = 0\n right = 10 ** 18\n while right - left > 1:\n mid = (right + left) // 2\n if now_t > t * mid or now_a > a * mid:\n left = mid\n else:\n right = mid\n \n return right",
"f",
"left = 0",
"left",
"0",
"right = 10 ** 18",
"right",
"10 ** 18",
"10",
"18",
"while right - left > 1:\n mid = (right + left) // 2\n if now_t > t * mid or now_a > a * mid:\n left = mid\n else:\n right = mid\n \n ",
"right - left > 1",
"right - left",
"right",
"left",
"1",
"mid = (right + left) // 2",
"mid",
"(right + left) // 2",
"right + left",
"right",
"left",
"2",
"if now_t > t * mid or now_a > a * mid:\n left = mid\n else:\n right = mid\n \n ",
"now_t > t * mid or now_a > a * mid",
"now_t > t * mid",
"now_t",
"t * mid",
"t",
"mid",
"now_a > a * mid",
"now_a",
"a * mid",
"a",
"mid",
"left = mid",
"left",
"mid",
"right = mid",
"right",
"mid",
"return right",
"right",
"now_t",
"now_t",
"now_a",
"now_a",
"t",
"t",
"a",
"a",
"if __name__ == '__main__':\n solve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"solve()",
"solve",
"def solve():\n N = int(input())\n T = []\n A = []\n for _ in range(N):\n t, a = map(int,input().split())\n T.append(t)\n A.append(a)\n \n now_t = T[0]\n now_a = A[0]\n\n for i in range(1,N):\n mul = f(now_t,now_a,T[i],A[i])\n now_t = T[i] * mul\n now_a = A[i] * mul\n \n print(now_t + now_a)",
"def solve():\n N = int(input())\n T = []\n A = []\n for _ in range(N):\n t, a = map(int,input().split())\n T.append(t)\n A.append(a)\n \n now_t = T[0]\n now_a = A[0]\n\n for i in range(1,N):\n mul = f(now_t,now_a,T[i],A[i])\n now_t = T[i] * mul\n now_a = A[i] * mul\n \n print(now_t + now_a)",
"solve",
"def f(now_t, now_a, t, a):\n left = 0\n right = 10 ** 18\n while right - left > 1:\n mid = (right + left) // 2\n if now_t > t * mid or now_a > a * mid:\n left = mid\n else:\n right = mid\n \n return right",
"def f(now_t, now_a, t, a):\n left = 0\n right = 10 ** 18\n while right - left > 1:\n mid = (right + left) // 2\n if now_t > t * mid or now_a > a * mid:\n left = mid\n else:\n right = mid\n \n return right",
"f"
] | from math import ceil
def solve():
N = int(input())
T = []
A = []
for _ in range(N):
t, a = map(int,input().split())
T.append(t)
A.append(a)
now_t = T[0]
now_a = A[0]
for i in range(1,N):
mul = f(now_t,now_a,T[i],A[i])
now_t = T[i] * mul
now_a = A[i] * mul
print(now_t + now_a)
def f(now_t, now_a, t, a):
left = 0
right = 10 ** 18
while right - left > 1:
mid = (right + left) // 2
if now_t > t * mid or now_a > a * mid:
left = mid
else:
right = mid
return right
if __name__ == '__main__':
solve() |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
18,
13,
10,
13,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
103,
2
],
[
10,
9
],
[
104,
12
],
[
97,
25
],
[
88,
28
],
[
82,
31
],
[
35,
34
],
[
104,
37
],
[
94,
39
],
[
98,
42
],
[
34,
43
],
[
100,
46
],
[
98,
49
],
[
34,
50
],
[
106,
53
],
[
89,
59
],
[
92,
59
],
[
95,
60
],
[
83,
64
],
[
86,
64
],
[
101,
65
],
[
91,
67
],
[
107,
69
],
[
95,
70
],
[
85,
72
],
[
107,
74
],
[
101,
75
],
[
92,
79
],
[
89,
79
],
[
86,
80
],
[
83,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
]
] | [
"n = int(input())\nab = [list(map(int, input().split())) for _ in range(n)]\n\nx = 1\ny = 1\nfor i in range(n):\n a = ab[i][0]\n b = ab[i][1]\n\n m = max(-(-x // a), -(-y // b))\n x = m * a\n y = m * b\nprint(x + y)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ab = [list(map(int, input().split())) for _ in range(n)]",
"ab",
"[list(map(int, input().split())) for _ in range(n)]",
"x = 1",
"x",
"1",
"y = 1",
"y",
"1",
"for i in range(n):\n a = ab[i][0]\n b = ab[i][1]\n\n m = max(-(-x // a), -(-y // b))\n x = m * a\n y = m * b",
"i",
"range(n)",
"range",
"n",
"a = ab[i][0]",
"a",
"ab[i][0]",
"[i]",
"ab",
"i",
"0",
"b = ab[i][1]",
"b",
"ab[i][1]",
"[i]",
"ab",
"i",
"1",
"m = max(-(-x // a), -(-y // b))",
"m",
"max(-(-x // a), -(-y // b))",
"max",
"-(-x // a)",
"-x // a",
"-x",
"x",
"a",
"-(-y // b)",
"-y // b",
"-y",
"y",
"b",
"x = m * a",
"x",
"m * a",
"m",
"a",
"y = m * b",
"y",
"m * b",
"m",
"b",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"y = 1",
"1",
"y",
"y = m * b",
"m * b",
"y",
"x = 1",
"1",
"x",
"x = m * a",
"m * a",
"x",
"a = ab[i][0]",
"ab[i][0]",
"a",
"ab = [list(map(int, input().split())) for _ in range(n)]",
"[list(map(int, input().split())) for _ in range(n)]",
"ab",
"b = ab[i][1]",
"ab[i][1]",
"b",
"n = int(input())",
"int(input())",
"n",
"m = max(-(-x // a), -(-y // b))",
"max(-(-x // a), -(-y // b))",
"m"
] | n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
x = 1
y = 1
for i in range(n):
a = ab[i][0]
b = ab[i][1]
m = max(-(-x // a), -(-y // b))
x = m * a
y = m * b
print(x + y)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
17,
13,
17,
12,
13,
29,
2,
2,
13,
13,
2,
2,
13,
13,
17,
23,
13,
23,
13,
28,
13,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
12,
13,
10,
2,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] | [
[
95,
2
],
[
10,
9
],
[
96,
12
],
[
86,
16
],
[
83,
19
],
[
101,
21
],
[
36,
28
],
[
38,
29
],
[
36,
32
],
[
38,
33
],
[
36,
36
],
[
38,
38
],
[
89,
44
],
[
78,
46
],
[
84,
47
],
[
81,
47
],
[
92,
50
],
[
78,
52
],
[
102,
53
],
[
105,
53
],
[
98,
56
],
[
90,
59
],
[
93,
60
],
[
80,
62
],
[
99,
64
],
[
104,
67
],
[
99,
69
],
[
81,
74
],
[
84,
74
],
[
105,
75
],
[
102,
75
],
[
80,
81
],
[
83,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
]
] | [
"N = int(input())\n\nTA = [[int(_) for _ in input().split()] for _ in range(N)]\n\nx, y = 1, 1\n\n\ndef ceil(a, b):\n return a // b + (a % b > 0)\n\n\nfor t, a in TA:\n tv = ceil(x, t)\n av = ceil(y, a)\n n = max(tv, av)\n x = n * t\n y = n * a\nprint(x + y)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"[int(_) for _ in input().split()] for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"[int(_) for _ in input().split()]",
"TA = [[int(_) for _ in input().split()] for _ in range(N)]",
"TA",
"[[int(_) for _ in input().split()] for _ in range(N)]",
"x, y = 1, 1",
"x",
"1",
"y",
"1",
"def ceil(a, b):\n return a // b + (a % b > 0)",
"ceil",
"return a // b + (a % b > 0)",
"a // b + (a % b > 0)",
"a // b",
"a",
"b",
"a % b > 0",
"a % b",
"a",
"b",
"0",
"a",
"a",
"b",
"b",
"for t, a in TA:\n tv = ceil(x, t)\n av = ceil(y, a)\n n = max(tv, av)\n x = n * t\n y = n * a",
"t",
"a",
"TA",
"tv = ceil(x, t)",
"tv",
"ceil(x, t)",
"ceil",
"x",
"t",
"av = ceil(y, a)",
"av",
"ceil(y, a)",
"ceil",
"y",
"a",
"n = max(tv, av)",
"n",
"max(tv, av)",
"max",
"tv",
"av",
"x = n * t",
"x",
"n * t",
"n",
"t",
"y = n * a",
"y",
"n * a",
"n",
"a",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"def ceil(a, b):\n return a // b + (a % b > 0)",
"def ceil(a, b):\n return a // b + (a % b > 0)",
"ceil",
"x = n * t",
"n * t",
"x",
"x, y = 1, 1",
"1",
"x",
"TA = [[int(_) for _ in input().split()] for _ in range(N)]",
"[[int(_) for _ in input().split()] for _ in range(N)]",
"TA",
"tv = ceil(x, t)",
"ceil(x, t)",
"tv",
"av = ceil(y, a)",
"ceil(y, a)",
"av",
"N = int(input())",
"int(input())",
"N",
"n = max(tv, av)",
"max(tv, av)",
"n",
"y = 1, 1",
"1",
"y",
"y = n * a",
"n * a",
"y"
] | N = int(input())
TA = [[int(_) for _ in input().split()] for _ in range(N)]
x, y = 1, 1
def ceil(a, b):
return a // b + (a % b > 0)
for t, a in TA:
tv = ceil(x, t)
av = ceil(y, a)
n = max(tv, av)
x = n * t
y = n * a
print(x + y)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
0,
13,
39,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
14,
2,
2,
18,
13,
2,
13,
17,
18,
13,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
14,
40,
2,
18,
13,
2,
13,
17,
18,
13,
13,
17,
0,
13,
17,
0,
13,
2,
18,
13,
2,
13,
17,
18,
13,
13,
14,
40,
2,
18,
13,
2,
13,
17,
18,
13,
13,
17,
0,
13,
17,
0,
13,
4,
13,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
4,
13,
2,
18,
13,
17,
18,
13,
17,
10,
2,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13
] | [
[
177,
2
],
[
171,
8
],
[
171,
17
],
[
192,
19
],
[
165,
22
],
[
193,
26
],
[
172,
28
],
[
166,
31
],
[
163,
33
],
[
36,
35
],
[
178,
39
],
[
189,
41
],
[
189,
50
],
[
193,
53
],
[
175,
55
],
[
172,
55
],
[
166,
58
],
[
190,
60
],
[
163,
60
],
[
193,
65
],
[
35,
67
],
[
140,
69
],
[
193,
70
],
[
35,
71
],
[
166,
74
],
[
35,
76
],
[
145,
78
],
[
166,
79
],
[
35,
80
],
[
159,
82
],
[
193,
85
],
[
35,
87
],
[
140,
89
],
[
193,
90
],
[
35,
91
],
[
193,
96
],
[
35,
98
],
[
140,
100
],
[
193,
101
],
[
35,
102
],
[
168,
105
],
[
180,
108
],
[
166,
111
],
[
35,
113
],
[
145,
115
],
[
166,
116
],
[
35,
117
],
[
166,
122
],
[
35,
124
],
[
145,
126
],
[
166,
127
],
[
35,
128
],
[
183,
131
],
[
186,
134
],
[
169,
137
],
[
160,
137
],
[
184,
138
],
[
181,
138
],
[
143,
140
],
[
193,
141
],
[
35,
142
],
[
187,
143
],
[
148,
145
],
[
166,
146
],
[
35,
147
],
[
187,
148
],
[
193,
153
],
[
166,
156
],
[
159,
160
],
[
171,
163
],
[
165,
166
],
[
168,
169
],
[
171,
172
],
[
189,
175
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
186,
187
],
[
189,
190
],
[
192,
193
]
] | [
"n = int(input())\nt_i,a_i = map(int,input().split())\nt = []\na = []\nt.append(t_i)\na.append(a_i)\nfor i in range(1,n):\n t_i,a_i = map(int,input().split())\n t.append(t_i)\n a.append(a_i)\n if t[i-1]>t[i] or a[i-1]>a[i]:\n t_max = t[i-1]//t[i]\n if t[i-1]%t[i]!=0:\n t_max += 1\n a_max = a[i-1]//a[i]\n if a[i-1]%a[i]!=0:\n a_max += 1\n bai = max(t_max,a_max)\n t[i] *= bai\n a[i] *= bai\nprint(t[-1]+a[-1])",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"t_i,a_i = map(int,input().split())",
"t_i",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a_i",
"t = []",
"t",
"[]",
"a = []",
"a",
"[]",
"t.append(t_i)",
"t.append",
"t",
"append",
"t_i",
"a.append(a_i)",
"a.append",
"a",
"append",
"a_i",
"for i in range(1,n):\n t_i,a_i = map(int,input().split())\n t.append(t_i)\n a.append(a_i)\n if t[i-1]>t[i] or a[i-1]>a[i]:\n t_max = t[i-1]//t[i]\n if t[i-1]%t[i]!=0:\n t_max += 1\n a_max = a[i-1]//a[i]\n if a[i-1]%a[i]!=0:\n a_max += 1\n bai = max(t_max,a_max)\n t[i] *= bai\n a[i] *= bai",
"i",
"range(1,n)",
"range",
"1",
"n",
"t_i,a_i = map(int,input().split())",
"t_i",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a_i",
"t.append(t_i)",
"t.append",
"t",
"append",
"t_i",
"a.append(a_i)",
"a.append",
"a",
"append",
"a_i",
"if t[i-1]>t[i] or a[i-1]>a[i]:\n t_max = t[i-1]//t[i]\n if t[i-1]%t[i]!=0:\n t_max += 1\n a_max = a[i-1]//a[i]\n if a[i-1]%a[i]!=0:\n a_max += 1\n bai = max(t_max,a_max)\n t[i] *= bai\n a[i] *= bai",
"t[i-1]>t[i] or a[i-1]>a[i]",
"t[i-1]>t[i]",
"t[i-1]",
"t",
"i-1",
"i",
"1",
"t[i]",
"t",
"i",
"a[i-1]>a[i]",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i]",
"a",
"i",
"t_max = t[i-1]//t[i]",
"t_max",
"t[i-1]//t[i]",
"t[i-1]",
"t",
"i-1",
"i",
"1",
"t[i]",
"t",
"i",
"if t[i-1]%t[i]!=0:\n t_max += 1\n ",
"t[i-1]%t[i]!=0",
"t[i-1]%t[i]",
"t[i-1]",
"t",
"i-1",
"i",
"1",
"t[i]",
"t",
"i",
"0",
"t_max += 1",
"t_max",
"1",
"a_max = a[i-1]//a[i]",
"a_max",
"a[i-1]//a[i]",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i]",
"a",
"i",
"if a[i-1]%a[i]!=0:\n a_max += 1\n ",
"a[i-1]%a[i]!=0",
"a[i-1]%a[i]",
"a[i-1]",
"a",
"i-1",
"i",
"1",
"a[i]",
"a",
"i",
"0",
"a_max += 1",
"a_max",
"1",
"bai = max(t_max,a_max)",
"bai",
"max(t_max,a_max)",
"max",
"t_max",
"a_max",
"t[i] *= bai",
"t[i]",
"t",
"i",
"bai",
"a[i] *= bai",
"a[i]",
"a",
"i",
"bai",
"print(t[-1]+a[-1])",
"print",
"t[-1]+a[-1]",
"t[-1]",
"t",
"-1",
"a[-1]",
"a",
"-1",
"t_max = t[i-1]//t[i]",
"t[i-1]//t[i]",
"t_max",
"a_i = map(int,input().split())",
"map(int,input().split())",
"a_i",
"a = []",
"[]",
"a",
"t_max += 1",
"1",
"t_max",
"t_i,a_i = map(int,input().split())",
"map(int,input().split())",
"t_i",
"t_i,a_i = map(int,input().split())",
"map(int,input().split())",
"t_i",
"n = int(input())",
"int(input())",
"n",
"a_max = a[i-1]//a[i]",
"a[i-1]//a[i]",
"a_max",
"a_max += 1",
"1",
"a_max",
"bai = max(t_max,a_max)",
"max(t_max,a_max)",
"bai",
"a_i = map(int,input().split())",
"map(int,input().split())",
"a_i",
"t = []",
"[]",
"t"
] | n = int(input())
t_i,a_i = map(int,input().split())
t = []
a = []
t.append(t_i)
a.append(a_i)
for i in range(1,n):
t_i,a_i = map(int,input().split())
t.append(t_i)
a.append(a_i)
if t[i-1]>t[i] or a[i-1]>a[i]:
t_max = t[i-1]//t[i]
if t[i-1]%t[i]!=0:
t_max += 1
a_max = a[i-1]//a[i]
if a[i-1]%a[i]!=0:
a_max += 1
bai = max(t_max,a_max)
t[i] *= bai
a[i] *= bai
print(t[-1]+a[-1]) |
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
79,
4
],
[
12,
11
],
[
80,
14
],
[
73,
27
],
[
82,
30
],
[
67,
32
],
[
85,
39
],
[
68,
45
],
[
71,
45
],
[
83,
50
],
[
77,
50
],
[
76,
53
],
[
86,
56
],
[
70,
57
],
[
86,
60
],
[
77,
64
],
[
83,
64
],
[
71,
65
],
[
68,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
]
] | [
"import math\nn = int(input())\nta = [list(map(int, input().split())) for i in range(n)]\nT,A = 1,1\nfor t,a in ta:\n mul = max(-(-A//a), -(-T//t))\n T,A = t * mul,a * mul\nprint(T+A)",
"import math",
"math",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ta = [list(map(int, input().split())) for i in range(n)]",
"ta",
"[list(map(int, input().split())) for i in range(n)]",
"T,A = 1,1",
"T",
"1",
"A",
"1",
"for t,a in ta:\n mul = max(-(-A//a), -(-T//t))\n T,A = t * mul,a * mul",
"t",
"a",
"ta",
"mul = max(-(-A//a), -(-T//t))",
"mul",
"max(-(-A//a), -(-T//t))",
"max",
"-(-A//a)",
"-A//a",
"-A",
"A",
"a",
"-(-T//t)",
"-T//t",
"-T",
"T",
"t",
"T,A = t * mul,a * mul",
"T",
"t * mul",
"t",
"mul",
"A",
"a * mul",
"a",
"mul",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"A = 1,1",
"1",
"A",
"A = t * mul,a * mul",
"a * mul",
"A",
"ta = [list(map(int, input().split())) for i in range(n)]",
"[list(map(int, input().split())) for i in range(n)]",
"ta",
"T,A = t * mul,a * mul",
"t * mul",
"T",
"n = int(input())",
"int(input())",
"n",
"T,A = 1,1",
"1",
"T",
"mul = max(-(-A//a), -(-T//t))",
"max(-(-A//a), -(-T//t))",
"mul"
] | import math
n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]
T,A = 1,1
for t,a in ta:
mul = max(-(-A//a), -(-T//t))
T,A = t * mul,a * mul
print(T+A)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
17,
0,
13,
39,
13,
13,
0,
13,
4,
13,
40,
2,
40,
18,
13,
17,
13,
40,
2,
40,
18,
13,
17,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
39,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
39,
13,
10,
2,
13,
10,
39,
13,
10,
4,
13,
10,
39,
13
] | [
[
79,
2
],
[
88,
8
],
[
14,
13
],
[
80,
16
],
[
82,
18
],
[
82,
27
],
[
13,
30
],
[
94,
33
],
[
97,
38
],
[
89,
45
],
[
101,
45
],
[
95,
45
],
[
83,
47
],
[
89,
52
],
[
101,
52
],
[
95,
52
],
[
77,
54
],
[
85,
56
],
[
83,
58
],
[
98,
59
],
[
91,
61
],
[
77,
63
],
[
98,
64
],
[
100,
66
],
[
101,
74
],
[
95,
74
],
[
89,
74
],
[
82,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
]
] | [
"n = int(input())\n\nvotes = [0, 0]\n\nfor i in range(n):\n a, b = map(int, input().split())\n if i == 0:\n votes = [a, b]\n else:\n num = max(-(-votes[0]//a), -(-votes[1]//b))\n x = a * num\n y = b * num\n votes = [x, y]\nprint(sum(votes))",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"votes = [0, 0]",
"votes",
"[0, 0]",
"0",
"0",
"for i in range(n):\n a, b = map(int, input().split())\n if i == 0:\n votes = [a, b]\n else:\n num = max(-(-votes[0]//a), -(-votes[1]//b))\n x = a * num\n y = b * num\n votes = [x, y]",
"i",
"range(n)",
"range",
"n",
"a, b = map(int, input().split())",
"a",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"if i == 0:\n votes = [a, b]\n else:\n num = max(-(-votes[0]//a), -(-votes[1]//b))\n x = a * num\n y = b * num\n votes = [x, y]",
"i == 0",
"i",
"0",
"votes = [a, b]",
"votes",
"[a, b]",
"a",
"b",
"num = max(-(-votes[0]//a), -(-votes[1]//b))",
"num",
"max(-(-votes[0]//a), -(-votes[1]//b))",
"max",
"-(-votes[0]//a)",
"-votes[0]//a",
"-votes[0]",
"votes[0]",
"votes",
"0",
"a",
"-(-votes[1]//b)",
"-votes[1]//b",
"-votes[1]",
"votes[1]",
"votes",
"1",
"b",
"x = a * num",
"x",
"a * num",
"a",
"num",
"y = b * num",
"y",
"b * num",
"b",
"num",
"votes = [x, y]",
"votes",
"[x, y]",
"x",
"y",
"print(sum(votes))",
"print",
"sum(votes)",
"sum",
"votes",
"b = map(int, input().split())",
"map(int, input().split())",
"b",
"n = int(input())",
"int(input())",
"n",
"a, b = map(int, input().split())",
"map(int, input().split())",
"a",
"x = a * num",
"a * num",
"x",
"votes = [0, 0]",
"[0, 0]",
"votes",
"y = b * num",
"b * num",
"y",
"votes = [a, b]",
"[a, b]",
"votes",
"num = max(-(-votes[0]//a), -(-votes[1]//b))",
"max(-(-votes[0]//a), -(-votes[1]//b))",
"num",
"votes = [x, y]",
"[x, y]",
"votes"
] | n = int(input())
votes = [0, 0]
for i in range(n):
a, b = map(int, input().split())
if i == 0:
votes = [a, b]
else:
num = max(-(-votes[0]//a), -(-votes[1]//b))
x = a * num
y = b * num
votes = [x, y]
print(sum(votes))
|
[
7,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
29,
13,
23,
13,
12,
13,
29,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
29,
4,
18,
13,
13,
13,
13,
23,
13,
23,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
18,
13,
13,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
42,
2,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
13,
14,
40,
2,
13,
13,
4,
18,
13,
13,
13,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
42,
2,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
17,
14,
40,
2,
13,
13,
4,
18,
13,
13,
13,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
15,
15,
15,
15,
13,
15,
13,
15,
15,
13,
15,
13,
15,
13,
15,
15,
15,
15,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
17,
0,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
18,
13,
17,
13,
12,
13,
0,
13,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
4,
13,
13,
13,
29,
39,
2,
13,
13,
2,
13,
13,
23,
13,
23,
13,
23,
13,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
13,
13,
18,
13,
13,
13,
4,
13,
2,
13,
13,
10,
12,
13,
10,
4,
13,
10,
13,
13,
10,
12,
13,
10,
18,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
37,
36
],
[
48,
39
],
[
48,
48
],
[
71,
68
],
[
73,
69
],
[
71,
71
],
[
73,
73
],
[
79,
78
],
[
96,
81
],
[
92,
87
],
[
94,
88
],
[
92,
92
],
[
94,
94
],
[
96,
96
],
[
101,
100
],
[
100,
106
],
[
135,
107
],
[
110,
109
],
[
131,
114
],
[
133,
115
],
[
109,
119
],
[
100,
120
],
[
100,
123
],
[
109,
125
],
[
100,
129
],
[
131,
131
],
[
133,
133
],
[
135,
135
],
[
140,
139
],
[
139,
145
],
[
173,
146
],
[
149,
148
],
[
314,
150
],
[
169,
151
],
[
171,
152
],
[
148,
157
],
[
139,
158
],
[
139,
161
],
[
148,
163
],
[
139,
167
],
[
169,
169
],
[
171,
171
],
[
173,
173
],
[
325,
200
],
[
298,
208
],
[
341,
210
],
[
214,
213
],
[
299,
216
],
[
344,
219
],
[
301,
221
],
[
319,
224
],
[
302,
226
],
[
319,
228
],
[
233,
232
],
[
272,
233
],
[
233,
234
],
[
237,
236
],
[
268,
240
],
[
232,
241
],
[
232,
243
],
[
246,
245
],
[
270,
249
],
[
234,
250
],
[
234,
252
],
[
255,
254
],
[
236,
257
],
[
245,
258
],
[
232,
262
],
[
254,
263
],
[
234,
265
],
[
254,
266
],
[
268,
268
],
[
270,
270
],
[
272,
272
],
[
275,
274
],
[
299,
278
],
[
322,
280
],
[
317,
282
],
[
320,
283
],
[
323,
283
],
[
308,
284
],
[
311,
284
],
[
302,
286
],
[
274,
287
],
[
322,
288
],
[
323,
292
],
[
320,
292
],
[
311,
293
],
[
308,
293
],
[
298,
299
],
[
301,
302
],
[
319,
308
],
[
322,
311
],
[
319,
320
],
[
322,
323
],
[
325,
326
]
] | [
"def getN():\n return int(input())\ndef getNM():\n return map(int, input().split())\ndef getList():\n return list(map(int, input().split()))\ndef getArray(intn):\n return [int(input()) for i in range(intn)]\ndef input():\n return sys.stdin.readline().rstrip()\ndef rand_N(ran1, ran2):\n return random.randint(ran1, ran2)\ndef rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]\ndef rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)\n\ndef rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)\n\nfrom collections import defaultdict, deque, Counter\nfrom sys import exit\nfrom decimal import *\nimport heapq\nimport math\nfrom fractions import gcd\nimport random\nimport string\nimport copy\nfrom itertools import permutations\nfrom operator import mul\nfrom functools import reduce\nfrom bisect import bisect_left, bisect_right\n\nimport sys\nsys.setrecursionlimit(1000000000)\nmod = 10 ** 9 + 7\n\n\n#############\n# Main Code #\n#############\n\"\"\"\nN = rand_N(2, 6)\nquery = rand_query(2, 10, N)\nprint(query)\nans_taka, ans_aoki = query[0]\n\"\"\"\n\nN = getN()\nquery = [getList() for i in range(N)]\n# 一回目の選挙速報の結果を受けて\nans_taka, ans_aoki = query[0]\n\n# 現在の高橋くん、青木くんの票数、選挙速報の結果の比を基に\n# 次の高橋くん、青木くんの票数の最小値が出てくる\ndef vote(taka, aoki, ratio):\n ratio_taka, ratio_aoki = ratio\n taka_multi = (taka + ratio_taka - 1) // ratio_taka\n aoki_multi = (aoki + ratio_aoki - 1) // ratio_aoki\n multi = max(taka_multi, aoki_multi)\n\n return [ratio_taka * multi, ratio_aoki * multi]\n\n# 選挙速報2回目〜\nfor i in range(1, N):\n ans_taka, ans_aoki = vote(ans_taka, ans_aoki, query[i])\n # print(ans_taka, ans_aoki)\nprint(ans_taka + ans_aoki)",
"def getN():\n return int(input())",
"getN",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"def getNM():\n return map(int, input().split())",
"getNM",
"return map(int, input().split())",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def getList():\n return list(map(int, input().split()))",
"getList",
"return list(map(int, input().split()))",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"getArray",
"int(input()) for i in range(intn)",
"for i in range(intn)",
"i",
"range(intn)",
"range",
"intn",
"for i in range(intn)",
"int(input())",
"int",
"input()",
"input",
"return [int(input()) for i in range(intn)]",
"[int(input()) for i in range(intn)]",
"intn",
"intn",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"return sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"rand_N",
"return random.randint(ran1, ran2)",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"ran1",
"ran1",
"ran2",
"ran2",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"rand_List",
"random.randint(ran1, ran2) for i in range(rantime)",
"for i in range(rantime)",
"i",
"range(rantime)",
"range",
"rantime",
"for i in range(rantime)",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"return [random.randint(ran1, ran2) for i in range(rantime)]",
"[random.randint(ran1, ran2) for i in range(rantime)]",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"rand_ints_nodup",
"ns = []",
"ns",
"[]",
"while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n ",
"len(ns) < rantime",
"len(ns)",
"len",
"ns",
"rantime",
"n = random.randint(ran1, ran2)",
"n",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"if not n in ns:\n ns.append(n)\n ",
"not n in ns",
"n in ns",
"n",
"ns",
"ns.append(n)",
"ns.append",
"ns",
"append",
"n",
"return sorted(ns)",
"sorted(ns)",
"sorted",
"ns",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"rand_query",
"r_query = []",
"r_query",
"[]",
"while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n ",
"len(r_query) < rantime",
"len(r_query)",
"len",
"r_query",
"rantime",
"n_q = rand_ints_nodup(ran1, ran2, 2)",
"n_q",
"rand_ints_nodup(ran1, ran2, 2)",
"rand_ints_nodup",
"ran1",
"ran2",
"2",
"if not n_q in r_query:\n r_query.append(n_q)\n ",
"not n_q in r_query",
"n_q in r_query",
"n_q",
"r_query",
"r_query.append(n_q)",
"r_query.append",
"r_query",
"append",
"n_q",
"return sorted(r_query)",
"sorted(r_query)",
"sorted",
"r_query",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"from collections import defaultdict, deque, Counter",
"from sys import exit",
"from decimal import *",
"import heapq",
"heapq",
"import math",
"math",
"from fractions import gcd",
"import random",
"random",
"import string",
"string",
"import copy",
"copy",
"from itertools import permutations",
"from operator import mul",
"from functools import reduce",
"from bisect import bisect_left, bisect_right",
"import sys",
"sys",
"sys.setrecursionlimit(1000000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1000000000",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"\"\"\"\nN = rand_N(2, 6)\nquery = rand_query(2, 10, N)\nprint(query)\nans_taka, ans_aoki = query[0]\n\"\"\"",
"N = getN()",
"N",
"getN()",
"getN",
"getList() for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"getList()",
"getList",
"query = [getList() for i in range(N)]",
"query",
"[getList() for i in range(N)]",
"ans_taka, ans_aoki = query[0]",
"ans_taka",
"query[0]",
"query",
"0",
"ans_aoki",
"def vote(taka, aoki, ratio):\n ratio_taka, ratio_aoki = ratio\n taka_multi = (taka + ratio_taka - 1) // ratio_taka\n aoki_multi = (aoki + ratio_aoki - 1) // ratio_aoki\n multi = max(taka_multi, aoki_multi)\n\n return [ratio_taka * multi, ratio_aoki * multi]\n\n# 選挙速報2回目〜",
"vote",
"ratio_taka, ratio_aoki = ratio",
"ratio_taka",
"ratio",
"ratio_aoki",
"taka_multi = (taka + ratio_taka - 1) // ratio_taka",
"taka_multi",
"(taka + ratio_taka - 1) // ratio_taka",
"taka + ratio_taka - 1",
"taka + ratio_taka",
"taka",
"ratio_taka",
"1",
"ratio_taka",
"aoki_multi = (aoki + ratio_aoki - 1) // ratio_aoki",
"aoki_multi",
"(aoki + ratio_aoki - 1) // ratio_aoki",
"aoki + ratio_aoki - 1",
"aoki + ratio_aoki",
"aoki",
"ratio_aoki",
"1",
"ratio_aoki",
"multi = max(taka_multi, aoki_multi)",
"multi",
"max(taka_multi, aoki_multi)",
"max",
"taka_multi",
"aoki_multi",
"return [ratio_taka * multi, ratio_aoki * multi]",
"[ratio_taka * multi, ratio_aoki * multi]",
"ratio_taka * multi",
"ratio_taka",
"multi",
"ratio_aoki * multi",
"ratio_aoki",
"multi",
"taka",
"taka",
"aoki",
"aoki",
"ratio",
"ratio",
"for i in range(1, N):\n ans_taka, ans_aoki = vote(ans_taka, ans_aoki, query[i])\n # print(ans_taka, ans_aoki)",
"i",
"range(1, N)",
"range",
"1",
"N",
"ans_taka, ans_aoki = vote(ans_taka, ans_aoki, query[i])",
"ans_taka",
"vote(ans_taka, ans_aoki, query[i])",
"vote",
"ans_taka",
"ans_aoki",
"query[i]",
"query",
"i",
"ans_aoki",
"print(ans_taka + ans_aoki)",
"print",
"ans_taka + ans_aoki",
"ans_taka",
"ans_aoki",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"rand_List",
"N = getN()",
"getN()",
"N",
"query = [getList() for i in range(N)]",
"[getList() for i in range(N)]",
"query",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"getArray",
"ans_aoki = query[0]",
"query[0]",
"ans_aoki",
"ans_aoki = vote(ans_taka, ans_aoki, query[i])",
"vote(ans_taka, ans_aoki, query[i])",
"ans_aoki",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"rand_ints_nodup",
"def vote(taka, aoki, ratio):\n ratio_taka, ratio_aoki = ratio\n taka_multi = (taka + ratio_taka - 1) // ratio_taka\n aoki_multi = (aoki + ratio_aoki - 1) // ratio_aoki\n multi = max(taka_multi, aoki_multi)\n\n return [ratio_taka * multi, ratio_aoki * multi]\n\n# 選挙速報2回目〜",
"def vote(taka, aoki, ratio):\n ratio_taka, ratio_aoki = ratio\n taka_multi = (taka + ratio_taka - 1) // ratio_taka\n aoki_multi = (aoki + ratio_aoki - 1) // ratio_aoki\n multi = max(taka_multi, aoki_multi)\n\n return [ratio_taka * multi, ratio_aoki * multi]\n\n# 選挙速報2回目〜",
"vote",
"ans_taka, ans_aoki = query[0]",
"query[0]",
"ans_taka",
"ans_taka, ans_aoki = vote(ans_taka, ans_aoki, query[i])",
"vote(ans_taka, ans_aoki, query[i])",
"ans_taka",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"rand_N",
"def getNM():\n return map(int, input().split())",
"def getNM():\n return map(int, input().split())",
"getNM",
"def input():\n return sys.stdin.readline().rstrip()",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"rand_query",
"def getN():\n return int(input())",
"def getN():\n return int(input())",
"getN",
"def getList():\n return list(map(int, input().split()))",
"def getList():\n return list(map(int, input().split()))",
"getList"
] | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
"""
N = rand_N(2, 6)
query = rand_query(2, 10, N)
print(query)
ans_taka, ans_aoki = query[0]
"""
N = getN()
query = [getList() for i in range(N)]
# 一回目の選挙速報の結果を受けて
ans_taka, ans_aoki = query[0]
# 現在の高橋くん、青木くんの票数、選挙速報の結果の比を基に
# 次の高橋くん、青木くんの票数の最小値が出てくる
def vote(taka, aoki, ratio):
ratio_taka, ratio_aoki = ratio
taka_multi = (taka + ratio_taka - 1) // ratio_taka
aoki_multi = (aoki + ratio_aoki - 1) // ratio_aoki
multi = max(taka_multi, aoki_multi)
return [ratio_taka * multi, ratio_aoki * multi]
# 選挙速報2回目〜
for i in range(1, N):
ans_taka, ans_aoki = vote(ans_taka, ans_aoki, query[i])
# print(ans_taka, ans_aoki)
print(ans_taka + ans_aoki) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
14,
2,
40,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
40,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
0,
13,
2,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
14,
40,
2,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
17,
0,
13,
17,
0,
13,
2,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
14,
40,
2,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
17,
0,
13,
17,
0,
18,
18,
13,
13,
17,
4,
13,
13,
13,
0,
18,
18,
13,
13,
17,
4,
13,
13,
13,
4,
13,
4,
13,
18,
13,
17,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
17,
13,
10,
18,
13,
10,
2,
13,
10,
4,
13
] | [
[
180,
2
],
[
10,
9
],
[
181,
12
],
[
165,
25
],
[
174,
28
],
[
166,
30
],
[
34,
33
],
[
181,
37
],
[
166,
43
],
[
33,
45
],
[
166,
50
],
[
33,
51
],
[
166,
56
],
[
33,
58
],
[
166,
63
],
[
33,
64
],
[
177,
67
],
[
166,
71
],
[
33,
73
],
[
166,
78
],
[
33,
79
],
[
166,
86
],
[
33,
88
],
[
166,
93
],
[
33,
94
],
[
162,
98
],
[
168,
101
],
[
166,
105
],
[
33,
107
],
[
166,
112
],
[
33,
113
],
[
166,
120
],
[
33,
122
],
[
166,
127
],
[
33,
128
],
[
171,
132
],
[
140,
135
],
[
166,
137
],
[
33,
138
],
[
163,
142
],
[
178,
142
],
[
172,
143
],
[
169,
143
],
[
150,
145
],
[
166,
147
],
[
33,
148
],
[
163,
152
],
[
178,
152
],
[
172,
153
],
[
169,
153
],
[
166,
159
],
[
162,
163
],
[
165,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
],
[
177,
178
],
[
180,
181
]
] | [
"n=int(input())\nta=[list(map(int,input().split())) for _ in range(n)]\nans=ta[0]\nfor i in range(1,n):\n if (ta[i-1][0]<=ta[i][0]) and (ta[i-1][1]<=ta[i][1]):\n pass\n else:\n l=ta[i-1][0]//ta[i][0]\n if ta[i-1][0]%ta[i][0]!=0:\n l+=1\n r=ta[i-1][1]//ta[i][1]\n if ta[i-1][1]%ta[i][1]!=0:\n r+=1\n ta[i][0]*=max(l,r)\n ta[i][1]*=max(l,r)\nprint(sum(ta[-1]))",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int,input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ta=[list(map(int,input().split())) for _ in range(n)]",
"ta",
"[list(map(int,input().split())) for _ in range(n)]",
"ans=ta[0]",
"ans",
"ta[0]",
"ta",
"0",
"for i in range(1,n):\n if (ta[i-1][0]<=ta[i][0]) and (ta[i-1][1]<=ta[i][1]):\n pass\n else:\n l=ta[i-1][0]//ta[i][0]\n if ta[i-1][0]%ta[i][0]!=0:\n l+=1\n r=ta[i-1][1]//ta[i][1]\n if ta[i-1][1]%ta[i][1]!=0:\n r+=1\n ta[i][0]*=max(l,r)\n ta[i][1]*=max(l,r)",
"i",
"range(1,n)",
"range",
"1",
"n",
"if (ta[i-1][0]<=ta[i][0]) and (ta[i-1][1]<=ta[i][1]):\n pass\n else:\n l=ta[i-1][0]//ta[i][0]\n if ta[i-1][0]%ta[i][0]!=0:\n l+=1\n r=ta[i-1][1]//ta[i][1]\n if ta[i-1][1]%ta[i][1]!=0:\n r+=1\n ta[i][0]*=max(l,r)\n ta[i][1]*=max(l,r)",
"(ta[i-1][0]<=ta[i][0]) and (ta[i-1][1]<=ta[i][1])",
"ta[i-1][0]<=ta[i][0]",
"ta[i-1][0]",
"[i-1]",
"ta",
"i-1",
"i",
"1",
"0",
"ta[i][0]",
"[i]",
"ta",
"i",
"0",
"ta[i-1][1]<=ta[i][1]",
"ta[i-1][1]",
"[i-1]",
"ta",
"i-1",
"i",
"1",
"1",
"ta[i][1]",
"[i]",
"ta",
"i",
"1",
"l=ta[i-1][0]//ta[i][0]",
"l",
"ta[i-1][0]//ta[i][0]",
"ta[i-1][0]",
"[i-1]",
"ta",
"i-1",
"i",
"1",
"0",
"ta[i][0]",
"[i]",
"ta",
"i",
"0",
"if ta[i-1][0]%ta[i][0]!=0:\n l+=1\n ",
"ta[i-1][0]%ta[i][0]!=0",
"ta[i-1][0]%ta[i][0]",
"ta[i-1][0]",
"[i-1]",
"ta",
"i-1",
"i",
"1",
"0",
"ta[i][0]",
"[i]",
"ta",
"i",
"0",
"0",
"l+=1",
"l",
"1",
"r=ta[i-1][1]//ta[i][1]",
"r",
"ta[i-1][1]//ta[i][1]",
"ta[i-1][1]",
"[i-1]",
"ta",
"i-1",
"i",
"1",
"1",
"ta[i][1]",
"[i]",
"ta",
"i",
"1",
"if ta[i-1][1]%ta[i][1]!=0:\n r+=1\n ",
"ta[i-1][1]%ta[i][1]!=0",
"ta[i-1][1]%ta[i][1]",
"ta[i-1][1]",
"[i-1]",
"ta",
"i-1",
"i",
"1",
"1",
"ta[i][1]",
"[i]",
"ta",
"i",
"1",
"0",
"r+=1",
"r",
"1",
"ta[i][0]*=max(l,r)",
"ta[i][0]",
"[i]",
"ta",
"i",
"0",
"max(l,r)",
"max",
"l",
"r",
"ta[i][1]*=max(l,r)",
"ta[i][1]",
"[i]",
"ta",
"i",
"1",
"max(l,r)",
"max",
"l",
"r",
"print(sum(ta[-1]))",
"print",
"sum(ta[-1])",
"sum",
"ta[-1]",
"ta",
"-1",
"l+=1",
"1",
"l",
"ta=[list(map(int,input().split())) for _ in range(n)]",
"[list(map(int,input().split())) for _ in range(n)]",
"ta",
"r=ta[i-1][1]//ta[i][1]",
"ta[i-1][1]//ta[i][1]",
"r",
"r+=1",
"1",
"r",
"ans=ta[0]",
"ta[0]",
"ans",
"l=ta[i-1][0]//ta[i][0]",
"ta[i-1][0]//ta[i][0]",
"l",
"n=int(input())",
"int(input())",
"n"
] | n=int(input())
ta=[list(map(int,input().split())) for _ in range(n)]
ans=ta[0]
for i in range(1,n):
if (ta[i-1][0]<=ta[i][0]) and (ta[i-1][1]<=ta[i][1]):
pass
else:
l=ta[i-1][0]//ta[i][0]
if ta[i-1][0]%ta[i][0]!=0:
l+=1
r=ta[i-1][1]//ta[i][1]
if ta[i-1][1]%ta[i][1]!=0:
r+=1
ta[i][0]*=max(l,r)
ta[i][1]*=max(l,r)
print(sum(ta[-1])) |
[
7,
15,
13,
15,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
18,
13,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
2,
2,
13,
18,
13,
13,
40,
2,
13,
18,
13,
13,
17,
2,
2,
13,
18,
13,
13,
40,
2,
13,
18,
13,
13,
17,
0,
13,
2,
18,
13,
13,
13,
0,
13,
2,
18,
13,
13,
13,
4,
13,
2,
13,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13,
10,
12,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
12,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13
] | [
[
115,
20
],
[
151,
26
],
[
151,
29
],
[
130,
32
],
[
116,
36
],
[
124,
38
],
[
116,
42
],
[
45,
44
],
[
116,
47
],
[
52,
49
],
[
131,
50
],
[
44,
51
],
[
155,
53
],
[
52,
54
],
[
125,
55
],
[
44,
56
],
[
59,
58
],
[
116,
61
],
[
136,
63
],
[
119,
68
],
[
128,
68
],
[
49,
69
],
[
131,
70
],
[
58,
71
],
[
119,
74
],
[
128,
74
],
[
49,
75
],
[
131,
76
],
[
58,
77
],
[
152,
81
],
[
140,
81
],
[
54,
82
],
[
125,
83
],
[
58,
84
],
[
152,
87
],
[
140,
87
],
[
54,
88
],
[
125,
89
],
[
58,
90
],
[
127,
93
],
[
49,
95
],
[
131,
96
],
[
58,
97
],
[
137,
98
],
[
139,
100
],
[
54,
102
],
[
125,
103
],
[
58,
104
],
[
137,
105
],
[
128,
109
],
[
119,
109
],
[
140,
110
],
[
152,
110
],
[
115,
116
],
[
151,
119
],
[
124,
125
],
[
127,
128
],
[
130,
131
],
[
136,
137
],
[
139,
140
],
[
151,
152
]
] | [
"import numpy as np\nimport sys\ndef sinput(): return sys.stdin.readline()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(): return list(imap())\ndef farr(): return list(fmap())\ndef sarr(): return sinput().split()\n\nn = int(input())\ntv = av = 1\nt = [0]*n; a = [0]*n\nfor i in range(n):\n t[i], a[i] = imap()\nfor i in range(n):\n tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))\n tv = t[i]*tmp; av=a[i]*tmp\nprint(tv+av)",
"import numpy as np",
"numpy",
"import sys",
"sys",
"def sinput(): return sys.stdin.readline()",
"sinput",
"def iinput(): return int(sinput())",
"iinput",
"def imap(): return map(int, sinput().split())",
"imap",
"def fmap(): return map(float, sinput().split())",
"fmap",
"def iarr(): return list(imap())",
"iarr",
"def farr(): return list(fmap())",
"farr",
"def sarr(): return sinput().split()",
"sarr",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"tv = av = 1",
"tv",
"1",
"= av = 1",
"av",
"1",
"t = [0]*n",
"t",
"[0]*n",
"[0]",
"0",
"n",
"a = [0]*n",
"a",
"[0]*n",
"[0]",
"0",
"n",
"for i in range(n):\n t[i], a[i] = imap()",
"i",
"range(n)",
"range",
"n",
"t[i], a[i] = imap()",
"t[i]",
"t",
"i",
"imap()",
"imap",
"a[i]",
"a",
"i",
"for i in range(n):\n tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))\n tv = t[i]*tmp; av=a[i]*tmp",
"i",
"range(n)",
"range",
"n",
"tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))",
"tmp",
"max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))",
"max",
"tv//t[i]+(tv%t[i]!=0)",
"tv//t[i]",
"tv",
"t[i]",
"t",
"i",
"tv%t[i]!=0",
"tv%t[i]",
"tv",
"t[i]",
"t",
"i",
"0",
"av//a[i]+(av%a[i]!=0)",
"av//a[i]",
"av",
"a[i]",
"a",
"i",
"av%a[i]!=0",
"av%a[i]",
"av",
"a[i]",
"a",
"i",
"0",
"tv = t[i]*tmp",
"tv",
"t[i]*tmp",
"t[i]",
"t",
"i",
"tmp",
"av=a[i]*tmp",
"av",
"a[i]*tmp",
"a[i]",
"a",
"i",
"tmp",
"print(tv+av)",
"print",
"tv+av",
"tv",
"av",
"def iinput(): return int(sinput())",
"def iinput(): return int(sinput())",
"iinput",
"n = int(input())",
"int(input())",
"n",
"tv = av = 1",
"1",
"tv",
"def farr(): return list(fmap())",
"def farr(): return list(fmap())",
"farr",
"a = [0]*n",
"[0]*n",
"a",
"tv = t[i]*tmp",
"t[i]*tmp",
"tv",
"t = [0]*n",
"[0]*n",
"t",
"def iarr(): return list(imap())",
"def iarr(): return list(imap())",
"iarr",
"tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))",
"max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))",
"tmp",
"av=a[i]*tmp",
"a[i]*tmp",
"av",
"def fmap(): return map(float, sinput().split())",
"def fmap(): return map(float, sinput().split())",
"fmap",
"def sarr(): return sinput().split()",
"def sarr(): return sinput().split()",
"sarr",
"def sinput(): return sys.stdin.readline()",
"def sinput(): return sys.stdin.readline()",
"sinput",
"av = 1",
"1",
"av",
"def imap(): return map(int, sinput().split())",
"def imap(): return map(int, sinput().split())",
"imap"
] | import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
n = int(input())
tv = av = 1
t = [0]*n; a = [0]*n
for i in range(n):
t[i], a[i] = imap()
for i in range(n):
tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))
tv = t[i]*tmp; av=a[i]*tmp
print(tv+av) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
13,
17,
14,
2,
13,
13,
0,
13,
2,
13,
13,
14,
40,
2,
13,
13,
17,
0,
13,
17,
14,
2,
13,
13,
0,
13,
2,
13,
13,
14,
40,
2,
13,
13,
17,
0,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
96,
2
],
[
129,
8
],
[
99,
10
],
[
14,
13
],
[
97,
16
],
[
120,
18
],
[
120,
27
],
[
111,
29
],
[
93,
31
],
[
130,
35
],
[
124,
35
],
[
121,
36
],
[
105,
38
],
[
130,
40
],
[
124,
40
],
[
121,
41
],
[
130,
45
],
[
124,
45
],
[
121,
46
],
[
114,
49
],
[
100,
53
],
[
103,
53
],
[
109,
54
],
[
117,
56
],
[
100,
58
],
[
103,
58
],
[
109,
59
],
[
100,
63
],
[
103,
63
],
[
109,
64
],
[
90,
67
],
[
126,
70
],
[
115,
73
],
[
106,
73
],
[
112,
73
],
[
91,
74
],
[
118,
74
],
[
94,
74
],
[
123,
76
],
[
127,
78
],
[
121,
79
],
[
102,
80
],
[
127,
82
],
[
109,
83
],
[
124,
87
],
[
130,
87
],
[
103,
88
],
[
100,
88
],
[
90,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
],
[
120,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
]
] | [
"n = int(input())\nA, B = 0, 0\nfor i in range(n):\n x, y = map(int,input().split())\n dx, dy = 1, 1\n if A > x:\n dx = A // x\n if A % x != 0:\n dx += 1\n \n if B > y:\n dy = B // y\n if B % y != 0:\n dy += 1\n \n a = max(dx, dy)\n A, B = a * x, a * y\nprint(A + B)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"A, B = 0, 0",
"A",
"0",
"B",
"0",
"for i in range(n):\n x, y = map(int,input().split())\n dx, dy = 1, 1\n if A > x:\n dx = A // x\n if A % x != 0:\n dx += 1\n \n if B > y:\n dy = B // y\n if B % y != 0:\n dy += 1\n \n a = max(dx, dy)\n A, B = a * x, a * y",
"i",
"range(n)",
"range",
"n",
"x, y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"dx, dy = 1, 1",
"dx",
"1",
"dy",
"1",
"if A > x:\n dx = A // x\n if A % x != 0:\n dx += 1\n \n ",
"A > x",
"A",
"x",
"dx = A // x",
"dx",
"A // x",
"A",
"x",
"if A % x != 0:\n dx += 1\n \n ",
"A % x != 0",
"A % x",
"A",
"x",
"0",
"dx += 1",
"dx",
"1",
"if B > y:\n dy = B // y\n if B % y != 0:\n dy += 1\n \n ",
"B > y",
"B",
"y",
"dy = B // y",
"dy",
"B // y",
"B",
"y",
"if B % y != 0:\n dy += 1\n \n ",
"B % y != 0",
"B % y",
"B",
"y",
"0",
"dy += 1",
"dy",
"1",
"a = max(dx, dy)",
"a",
"max(dx, dy)",
"max",
"dx",
"dy",
"A, B = a * x, a * y",
"A",
"a * x",
"a",
"x",
"B",
"a * y",
"a",
"y",
"print(A + B)",
"print",
"A + B",
"A",
"B",
"dy += 1",
"1",
"dy",
"dy = 1, 1",
"1",
"dy",
"n = int(input())",
"int(input())",
"n",
"B = 0, 0",
"0",
"B",
"B = a * x, a * y",
"a * y",
"B",
"dx = A // x",
"A // x",
"dx",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"dx, dy = 1, 1",
"1",
"dx",
"dx += 1",
"1",
"dx",
"dy = B // y",
"B // y",
"dy",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x",
"A, B = a * x, a * y",
"a * x",
"A",
"a = max(dx, dy)",
"max(dx, dy)",
"a",
"A, B = 0, 0",
"0",
"A"
] | n = int(input())
A, B = 0, 0
for i in range(n):
x, y = map(int,input().split())
dx, dy = 1, 1
if A > x:
dx = A // x
if A % x != 0:
dx += 1
if B > y:
dy = B // y
if B % y != 0:
dy += 1
a = max(dx, dy)
A, B = a * x, a * y
print(A + B) |
[
7,
12,
13,
29,
2,
2,
2,
13,
17,
13,
17,
23,
13,
23,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
2,
13,
10,
12,
13,
10,
4,
13
] | [
[
12,
7
],
[
14,
9
],
[
12,
12
],
[
14,
14
],
[
99,
16
],
[
24,
23
],
[
100,
26
],
[
87,
39
],
[
84,
42
],
[
90,
44
],
[
78,
51
],
[
97,
55
],
[
85,
56
],
[
82,
56
],
[
97,
59
],
[
91,
60
],
[
94,
60
],
[
81,
63
],
[
79,
66
],
[
93,
68
],
[
79,
71
],
[
82,
75
],
[
85,
75
],
[
94,
76
],
[
91,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
],
[
99,
100
]
] | [
"# from math import ceil\ndef ceil(x,y):\n return (x-1)//y+1\nN = int(input())\nTA = [list(map(int, input().split())) for _ in range(N)]\nt, a = 1, 1\nfor T, A in TA:\n rate = max(ceil(t, T), ceil(a, A))\n t = T * rate\n a = A * rate\nprint(t + a) \n ",
"def ceil(x,y):\n return (x-1)//y+1",
"ceil",
"return (x-1)//y+1",
"(x-1)//y+1",
"(x-1)//y",
"x-1",
"x",
"1",
"y",
"1",
"x",
"x",
"y",
"y",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for _ in range(N)]",
"TA",
"[list(map(int, input().split())) for _ in range(N)]",
"t, a = 1, 1",
"t",
"1",
"a",
"1",
"for T, A in TA:\n rate = max(ceil(t, T), ceil(a, A))\n t = T * rate\n a = A * rate",
"T",
"A",
"TA",
"rate = max(ceil(t, T), ceil(a, A))",
"rate",
"max(ceil(t, T), ceil(a, A))",
"max",
"ceil(t, T)",
"ceil",
"t",
"T",
"ceil(a, A)",
"ceil",
"a",
"A",
"t = T * rate",
"t",
"T * rate",
"T",
"rate",
"a = A * rate",
"a",
"A * rate",
"A",
"rate",
"print(t + a)",
"print",
"t + a",
"t",
"a",
"rate = max(ceil(t, T), ceil(a, A))",
"max(ceil(t, T), ceil(a, A))",
"rate",
"t = T * rate",
"T * rate",
"t",
"t, a = 1, 1",
"1",
"t",
"TA = [list(map(int, input().split())) for _ in range(N)]",
"[list(map(int, input().split())) for _ in range(N)]",
"TA",
"a = 1, 1",
"1",
"a",
"a = A * rate",
"A * rate",
"a",
"def ceil(x,y):\n return (x-1)//y+1",
"def ceil(x,y):\n return (x-1)//y+1",
"ceil",
"N = int(input())",
"int(input())",
"N"
] | # from math import ceil
def ceil(x,y):
return (x-1)//y+1
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
t, a = 1, 1
for T, A in TA:
rate = max(ceil(t, T), ceil(a, A))
t = T * rate
a = A * rate
print(t + a)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
80,
2
],
[
65,
8
],
[
59,
11
],
[
15,
14
],
[
81,
17
],
[
77,
19
],
[
77,
28
],
[
62,
30
],
[
66,
36
],
[
69,
36
],
[
75,
37
],
[
60,
41
],
[
72,
41
],
[
78,
42
],
[
68,
44
],
[
75,
46
],
[
63,
47
],
[
71,
49
],
[
78,
51
],
[
63,
52
],
[
69,
56
],
[
66,
56
],
[
72,
57
],
[
60,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
77,
75
],
[
77,
78
],
[
80,
81
]
] | [
"#!/usr/bin/env python3\nn = int(input())\ncur_t = 1\ncur_a = 1\nfor i in range(n):\n t, a = map(int, input().split())\n times = max(-(-cur_t // t), -(-cur_a // a))\n cur_t = t * times\n cur_a = a * times\n # print(cur_t, cur_a)\nprint(cur_t + cur_a)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"cur_t = 1",
"cur_t",
"1",
"cur_a = 1",
"cur_a",
"1",
"for i in range(n):\n t, a = map(int, input().split())\n times = max(-(-cur_t // t), -(-cur_a // a))\n cur_t = t * times\n cur_a = a * times\n # print(cur_t, cur_a)",
"i",
"range(n)",
"range",
"n",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"times = max(-(-cur_t // t), -(-cur_a // a))",
"times",
"max(-(-cur_t // t), -(-cur_a // a))",
"max",
"-(-cur_t // t)",
"-cur_t // t",
"-cur_t",
"cur_t",
"t",
"-(-cur_a // a)",
"-cur_a // a",
"-cur_a",
"cur_a",
"a",
"cur_t = t * times",
"cur_t",
"t * times",
"t",
"times",
"cur_a = a * times",
"cur_a",
"a * times",
"a",
"times",
"print(cur_t + cur_a)",
"print",
"cur_t + cur_a",
"cur_t",
"cur_a",
"cur_a = 1",
"1",
"cur_a",
"times = max(-(-cur_t // t), -(-cur_a // a))",
"max(-(-cur_t // t), -(-cur_a // a))",
"times",
"cur_t = 1",
"1",
"cur_t",
"cur_t = t * times",
"t * times",
"cur_t",
"cur_a = a * times",
"a * times",
"cur_a",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"n = int(input())",
"int(input())",
"n"
] | #!/usr/bin/env python3
n = int(input())
cur_t = 1
cur_a = 1
for i in range(n):
t, a = map(int, input().split())
times = max(-(-cur_t // t), -(-cur_a // a))
cur_t = t * times
cur_a = a * times
# print(cur_t, cur_a)
print(cur_t + cur_a)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
13,
0,
13,
13,
9,
14,
40,
13,
2,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
40,
2,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
13,
13,
0,
13,
13,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
13,
13,
14,
40,
2,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
13,
13,
0,
13,
13,
0,
13,
2,
2,
13,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13
] | [
[
168,
2
],
[
171,
8
],
[
138,
11
],
[
15,
14
],
[
169,
17
],
[
174,
19
],
[
174,
28
],
[
172,
32
],
[
136,
32
],
[
178,
32
],
[
166,
32
],
[
154,
32
],
[
187,
32
],
[
139,
35
],
[
160,
35
],
[
181,
35
],
[
148,
35
],
[
157,
35
],
[
163,
35
],
[
186,
38
],
[
175,
39
],
[
162,
41
],
[
151,
42
],
[
163,
46
],
[
139,
46
],
[
160,
46
],
[
181,
46
],
[
148,
46
],
[
157,
46
],
[
187,
48
],
[
172,
48
],
[
136,
48
],
[
178,
48
],
[
166,
48
],
[
154,
48
],
[
151,
50
],
[
175,
51
],
[
141,
53
],
[
187,
55
],
[
172,
55
],
[
136,
55
],
[
178,
55
],
[
166,
55
],
[
154,
55
],
[
175,
56
],
[
142,
60
],
[
184,
60
],
[
145,
60
],
[
133,
60
],
[
144,
63
],
[
175,
65
],
[
142,
66
],
[
184,
66
],
[
145,
66
],
[
133,
66
],
[
153,
68
],
[
187,
70
],
[
172,
70
],
[
136,
70
],
[
178,
70
],
[
166,
70
],
[
154,
70
],
[
145,
71
],
[
142,
71
],
[
184,
71
],
[
133,
71
],
[
156,
73
],
[
151,
76
],
[
154,
77
],
[
187,
77
],
[
172,
77
],
[
136,
77
],
[
178,
77
],
[
166,
77
],
[
175,
78
],
[
165,
80
],
[
166,
81
],
[
187,
81
],
[
172,
81
],
[
136,
81
],
[
178,
81
],
[
154,
81
],
[
147,
83
],
[
151,
86
],
[
166,
87
],
[
187,
87
],
[
172,
87
],
[
136,
87
],
[
178,
87
],
[
154,
87
],
[
175,
88
],
[
132,
90
],
[
163,
92
],
[
139,
92
],
[
160,
92
],
[
181,
92
],
[
148,
92
],
[
157,
92
],
[
151,
93
],
[
133,
97
],
[
184,
97
],
[
145,
97
],
[
142,
97
],
[
183,
100
],
[
151,
102
],
[
133,
103
],
[
184,
103
],
[
145,
103
],
[
142,
103
],
[
180,
105
],
[
163,
107
],
[
139,
107
],
[
160,
107
],
[
181,
107
],
[
148,
107
],
[
157,
107
],
[
184,
108
],
[
133,
108
],
[
145,
108
],
[
142,
108
],
[
177,
110
],
[
175,
113
],
[
181,
114
],
[
163,
114
],
[
139,
114
],
[
160,
114
],
[
148,
114
],
[
157,
114
],
[
151,
115
],
[
159,
117
],
[
160,
118
],
[
163,
118
],
[
139,
118
],
[
181,
118
],
[
148,
118
],
[
157,
118
],
[
135,
120
],
[
160,
123
],
[
163,
123
],
[
139,
123
],
[
181,
123
],
[
148,
123
],
[
157,
123
],
[
175,
124
],
[
151,
125
],
[
160,
129
],
[
181,
129
],
[
148,
129
],
[
157,
129
],
[
163,
129
],
[
139,
129
],
[
136,
130
],
[
178,
130
],
[
166,
130
],
[
154,
130
],
[
187,
130
],
[
172,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
174,
151
],
[
153,
154
],
[
156,
157
],
[
160,
159
],
[
163,
159
],
[
139,
159
],
[
181,
159
],
[
148,
159
],
[
157,
159
],
[
159,
160
],
[
151,
162
],
[
162,
163
],
[
166,
165
],
[
187,
165
],
[
172,
165
],
[
136,
165
],
[
178,
165
],
[
154,
165
],
[
165,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
175,
186
],
[
186,
187
]
] | [
"n = int(input())\nnt =0\nna = 0\nfor _ in range(n):\n t,a = map(int,input().split())\n if nt==0 and na==0:\n nt =t\n na =a\n continue\n if na <= nt*(a/t):\n mod = nt%t\n if not mod==0:\n mod = t - mod\n nt = nt + mod\n na = a*nt//t\n else:\n nt = nt\n na = a*nt//t\n else:\n mod = na%a\n if not mod==0:\n mod = a - mod\n na = na + mod\n nt = t*na//a\n else:\n na = na\n nt = na*t//a \n \n\nprint(na+nt)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"nt =0",
"nt",
"0",
"na = 0",
"na",
"0",
"for _ in range(n):\n t,a = map(int,input().split())\n if nt==0 and na==0:\n nt =t\n na =a\n continue\n if na <= nt*(a/t):\n mod = nt%t\n if not mod==0:\n mod = t - mod\n nt = nt + mod\n na = a*nt//t\n else:\n nt = nt\n na = a*nt//t\n else:\n mod = na%a\n if not mod==0:\n mod = a - mod\n na = na + mod\n nt = t*na//a\n else:\n na = na\n nt = na*t//a \n ",
"_",
"range(n)",
"range",
"n",
"t,a = map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"if nt==0 and na==0:\n nt =t\n na =a\n continue\n ",
"nt==0 and na==0",
"nt==0",
"nt",
"0",
"na==0",
"na",
"0",
"nt =t",
"nt",
"t",
"na =a",
"na",
"a",
"continue",
"if na <= nt*(a/t):\n mod = nt%t\n if not mod==0:\n mod = t - mod\n nt = nt + mod\n na = a*nt//t\n else:\n nt = nt\n na = a*nt//t\n else:\n mod = na%a\n if not mod==0:\n mod = a - mod\n na = na + mod\n nt = t*na//a\n else:\n na = na\n nt = na*t//a \n ",
"na <= nt*(a/t)",
"na",
"nt*(a/t)",
"nt",
"a/t",
"a",
"t",
"mod = nt%t",
"mod",
"nt%t",
"nt",
"t",
"if not mod==0:\n mod = t - mod\n nt = nt + mod\n na = a*nt//t\n else:\n nt = nt\n na = a*nt//t\n ",
"not mod==0",
"mod==0",
"mod",
"0",
"mod = t - mod",
"mod",
"t - mod",
"t",
"mod",
"nt = nt + mod",
"nt",
"nt + mod",
"nt",
"mod",
"na = a*nt//t",
"na",
"a*nt//t",
"a*nt",
"a",
"nt",
"t",
"nt = nt",
"nt",
"nt",
"na = a*nt//t",
"na",
"a*nt//t",
"a*nt",
"a",
"nt",
"t",
"mod = na%a",
"mod",
"na%a",
"na",
"a",
"if not mod==0:\n mod = a - mod\n na = na + mod\n nt = t*na//a\n else:\n na = na\n nt = na*t//a \n ",
"not mod==0",
"mod==0",
"mod",
"0",
"mod = a - mod",
"mod",
"a - mod",
"a",
"mod",
"na = na + mod",
"na",
"na + mod",
"na",
"mod",
"nt = t*na//a",
"nt",
"t*na//a",
"t*na",
"t",
"na",
"a",
"na = na",
"na",
"na",
"nt = na*t//a",
"nt",
"na*t//a",
"na*t",
"na",
"t",
"a",
"print(na+nt)",
"print",
"na+nt",
"na",
"nt",
"mod = na%a",
"na%a",
"mod",
"nt = na*t//a",
"na*t//a",
"nt",
"na = 0",
"0",
"na",
"mod = nt%t",
"nt%t",
"mod",
"mod = t - mod",
"t - mod",
"mod",
"na = a*nt//t",
"a*nt//t",
"na",
"a = map(int,input().split())",
"map(int,input().split())",
"a",
"nt = nt + mod",
"nt + mod",
"nt",
"na = a*nt//t",
"a*nt//t",
"na",
"na = na",
"na",
"na",
"na =a",
"a",
"na",
"nt = nt",
"nt",
"nt",
"n = int(input())",
"int(input())",
"n",
"nt =0",
"0",
"nt",
"t,a = map(int,input().split())",
"map(int,input().split())",
"t",
"nt = t*na//a",
"t*na//a",
"nt",
"na = na + mod",
"na + mod",
"na",
"mod = a - mod",
"a - mod",
"mod",
"nt =t",
"t",
"nt"
] | n = int(input())
nt =0
na = 0
for _ in range(n):
t,a = map(int,input().split())
if nt==0 and na==0:
nt =t
na =a
continue
if na <= nt*(a/t):
mod = nt%t
if not mod==0:
mod = t - mod
nt = nt + mod
na = a*nt//t
else:
nt = nt
na = a*nt//t
else:
mod = na%a
if not mod==0:
mod = a - mod
na = na + mod
nt = t*na//a
else:
na = na
nt = na*t//a
print(na+nt) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
18,
13,
17,
28,
13,
13,
18,
13,
39,
17,
0,
13,
4,
13,
2,
18,
13,
17,
13,
2,
18,
13,
17,
13,
42,
2,
2,
18,
13,
17,
2,
13,
13,
2,
18,
13,
17,
2,
13,
13,
0,
13,
17,
0,
18,
13,
17,
2,
13,
13,
0,
18,
13,
17,
2,
13,
13,
4,
13,
2,
18,
13,
17,
18,
13,
17,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
12,
13
] | [
[
104,
4
],
[
14,
13
],
[
105,
17
],
[
21,
20
],
[
13,
23
],
[
28,
27
],
[
31,
30
],
[
27,
32
],
[
27,
38
],
[
43,
42
],
[
30,
47
],
[
30,
52
],
[
30,
59
],
[
42,
63
],
[
72,
63
],
[
30,
66
],
[
42,
70
],
[
72,
70
],
[
73,
72
],
[
78,
75
],
[
30,
76
],
[
72,
80
],
[
42,
80
],
[
85,
82
],
[
30,
83
],
[
72,
87
],
[
42,
87
],
[
30,
92
],
[
30,
95
],
[
108,
102
],
[
104,
105
]
] | [
"import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n N = int(input())\n TA = [[int(x) for x in input().split()] for _ in range(N)]\n\n now = TA[0]\n for t, a in TA[1:]:\n i = max(now[0] //t , now[1] // a)\n while now[0] > t * i or now[1] > a * i:\n i += 1\n now[0] = t * i\n now[1] = a * i\n\n print(now[0] + now[1])\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def main():\n N = int(input())\n TA = [[int(x) for x in input().split()] for _ in range(N)]\n\n now = TA[0]\n for t, a in TA[1:]:\n i = max(now[0] //t , now[1] // a)\n while now[0] > t * i or now[1] > a * i:\n i += 1\n now[0] = t * i\n now[1] = a * i\n\n print(now[0] + now[1])",
"main",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"[int(x) for x in input().split()] for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"[int(x) for x in input().split()]",
"TA = [[int(x) for x in input().split()] for _ in range(N)]",
"TA",
"[[int(x) for x in input().split()] for _ in range(N)]",
"now = TA[0]",
"now",
"TA[0]",
"TA",
"0",
"for t, a in TA[1:]:\n i = max(now[0] //t , now[1] // a)\n while now[0] > t * i or now[1] > a * i:\n i += 1\n now[0] = t * i\n now[1] = a * i\n\n ",
"t",
"a",
"TA[1:]",
"TA",
"1:",
"1",
"i = max(now[0] //t , now[1] // a)",
"i",
"max(now[0] //t , now[1] // a)",
"max",
"now[0] //t",
"now[0]",
"now",
"0",
"t",
"now[1] // a",
"now[1]",
"now",
"1",
"a",
"while now[0] > t * i or now[1] > a * i:\n i += 1\n ",
"now[0] > t * i or now[1] > a * i",
"now[0] > t * i",
"now[0]",
"now",
"0",
"t * i",
"t",
"i",
"now[1] > a * i",
"now[1]",
"now",
"1",
"a * i",
"a",
"i",
"i += 1",
"i",
"1",
"now[0] = t * i",
"now[0]",
"now",
"0",
"t * i",
"t",
"i",
"now[1] = a * i",
"now[1]",
"now",
"1",
"a * i",
"a",
"i",
"print(now[0] + now[1])",
"print",
"now[0] + now[1]",
"now[0]",
"now",
"0",
"now[1]",
"now",
"1",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def main():\n N = int(input())\n TA = [[int(x) for x in input().split()] for _ in range(N)]\n\n now = TA[0]\n for t, a in TA[1:]:\n i = max(now[0] //t , now[1] // a)\n while now[0] > t * i or now[1] > a * i:\n i += 1\n now[0] = t * i\n now[1] = a * i\n\n print(now[0] + now[1])",
"def main():\n N = int(input())\n TA = [[int(x) for x in input().split()] for _ in range(N)]\n\n now = TA[0]\n for t, a in TA[1:]:\n i = max(now[0] //t , now[1] // a)\n while now[0] > t * i or now[1] > a * i:\n i += 1\n now[0] = t * i\n now[1] = a * i\n\n print(now[0] + now[1])",
"main"
] | import sys
input = sys.stdin.readline
def main():
N = int(input())
TA = [[int(x) for x in input().split()] for _ in range(N)]
now = TA[0]
for t, a in TA[1:]:
i = max(now[0] //t , now[1] // a)
while now[0] > t * i or now[1] > a * i:
i += 1
now[0] = t * i
now[1] = a * i
print(now[0] + now[1])
if __name__ == '__main__':
main()
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
13,
28,
13,
4,
13,
17,
13,
0,
13,
18,
13,
13,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
13,
13,
0,
13,
4,
13,
2,
2,
13,
2,
13,
17,
13,
2,
2,
13,
2,
13,
17,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13
] | [
[
130,
11
],
[
133,
18
],
[
136,
23
],
[
33,
32
],
[
131,
36
],
[
40,
39
],
[
32,
42
],
[
131,
52
],
[
56,
55
],
[
59,
58
],
[
55,
60
],
[
59,
62
],
[
65,
64
],
[
32,
68
],
[
71,
70
],
[
55,
72
],
[
64,
73
],
[
71,
74
],
[
58,
78
],
[
107,
78
],
[
84,
78
],
[
70,
79
],
[
62,
81
],
[
111,
81
],
[
86,
81
],
[
74,
82
],
[
85,
84
],
[
70,
85
],
[
87,
86
],
[
74,
87
],
[
90,
89
],
[
58,
94
],
[
107,
94
],
[
84,
94
],
[
70,
96
],
[
70,
98
],
[
62,
101
],
[
111,
101
],
[
86,
101
],
[
74,
103
],
[
74,
105
],
[
108,
107
],
[
70,
109
],
[
89,
110
],
[
112,
111
],
[
74,
113
],
[
89,
114
],
[
107,
118
],
[
84,
118
],
[
58,
118
],
[
111,
119
],
[
86,
119
],
[
62,
119
],
[
128,
125
],
[
130,
131
],
[
133,
134
],
[
136,
137
]
] | [
"import sys\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n n = int(input())\n TA = [list(map(int, input().split())) for _ in range(n)]\n\n t_pev, a_prev = TA[0]\n for i in range(1, n):\n t_now, a_now = TA[i]\n if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n print(t_pev + a_prev)\n\n\nif __name__ == '__main__':\n resolve()",
"import sys",
"sys",
"sys.setrecursionlimit(10 ** 7)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 7",
"10",
"7",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"f_inf = float('inf')",
"f_inf",
"float('inf')",
"float",
"'inf'",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"def resolve():\n n = int(input())\n TA = [list(map(int, input().split())) for _ in range(n)]\n\n t_pev, a_prev = TA[0]\n for i in range(1, n):\n t_now, a_now = TA[i]\n if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n print(t_pev + a_prev)",
"resolve",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for _ in range(n)]",
"TA",
"[list(map(int, input().split())) for _ in range(n)]",
"t_pev, a_prev = TA[0]",
"t_pev",
"TA[0]",
"TA",
"0",
"a_prev",
"for i in range(1, n):\n t_now, a_now = TA[i]\n if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n ",
"i",
"range(1, n)",
"range",
"1",
"n",
"t_now, a_now = TA[i]",
"t_now",
"TA[i]",
"TA",
"i",
"a_now",
"if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n ",
"t_pev <= t_now and a_prev <= a_now",
"t_pev <= t_now",
"t_pev",
"t_now",
"a_prev <= a_now",
"a_prev",
"a_now",
"t_pev, a_prev = t_now, a_now",
"t_pev",
"t_now",
"a_prev",
"a_now",
"d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)",
"d",
"max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)",
"max",
"(t_pev + (t_now - 1)) // t_now",
"t_pev + (t_now - 1)",
"t_pev",
"t_now - 1",
"t_now",
"1",
"t_now",
"(a_prev + (a_now - 1)) // a_now",
"a_prev + (a_now - 1)",
"a_prev",
"a_now - 1",
"a_now",
"1",
"a_now",
"t_pev, a_prev = t_now * d, a_now * d",
"t_pev",
"t_now * d",
"t_now",
"d",
"a_prev",
"a_now * d",
"a_now",
"d",
"print(t_pev + a_prev)",
"print",
"t_pev + a_prev",
"t_pev",
"a_prev",
"if __name__ == '__main__':\n resolve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"resolve()",
"resolve",
"def resolve():\n n = int(input())\n TA = [list(map(int, input().split())) for _ in range(n)]\n\n t_pev, a_prev = TA[0]\n for i in range(1, n):\n t_now, a_now = TA[i]\n if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n print(t_pev + a_prev)",
"def resolve():\n n = int(input())\n TA = [list(map(int, input().split())) for _ in range(n)]\n\n t_pev, a_prev = TA[0]\n for i in range(1, n):\n t_now, a_now = TA[i]\n if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n print(t_pev + a_prev)",
"resolve",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"f_inf = float('inf')",
"float('inf')",
"f_inf",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod"
] | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]
t_pev, a_prev = TA[0]
for i in range(1, n):
t_now, a_now = TA[i]
if t_pev <= t_now and a_prev <= a_now:
t_pev, a_prev = t_now, a_now
else:
d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)
t_pev, a_prev = t_now * d, a_now * d
print(t_pev + a_prev)
if __name__ == '__main__':
resolve()
|
[
7,
0,
13,
4,
13,
4,
13,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
84,
2
],
[
93,
10
],
[
93,
19
],
[
22,
21
],
[
85,
25
],
[
99,
28
],
[
99,
37
],
[
96,
39
],
[
91,
49
],
[
79,
49
],
[
76,
50
],
[
94,
54
],
[
88,
54
],
[
100,
55
],
[
78,
57
],
[
97,
59
],
[
76,
60
],
[
87,
62
],
[
97,
64
],
[
100,
65
],
[
81,
67
],
[
79,
69
],
[
91,
69
],
[
88,
70
],
[
94,
70
],
[
82,
73
],
[
99,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
93,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
]
] | [
"N = int(input())\nimport math\nt, a = map(int,input().split())\nfor i in range(N-1):\n T, A = map(int,input().split())\n g = math.ceil(max(-(-t//T),-(-a//A)))\n t = g*T\n a = g*A\n \nans = t + a\nprint(ans)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"import math",
"math",
"t, a = map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"for i in range(N-1):\n T, A = map(int,input().split())\n g = math.ceil(max(-(-t//T),-(-a//A)))\n t = g*T\n a = g*A\n ",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"T, A = map(int,input().split())",
"T",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"g = math.ceil(max(-(-t//T),-(-a//A)))",
"g",
"math.ceil(max(-(-t//T),-(-a//A)))",
"math.ceil",
"math",
"ceil",
"max(-(-t//T),-(-a//A))",
"max",
"-(-t//T)",
"-t//T",
"-t",
"t",
"T",
"-(-a//A)",
"-a//A",
"-a",
"a",
"A",
"t = g*T",
"t",
"g*T",
"g",
"T",
"a = g*A",
"a",
"g*A",
"g",
"A",
"ans = t + a",
"ans",
"t + a",
"t",
"a",
"print(ans)",
"print",
"ans",
"T, A = map(int,input().split())",
"map(int,input().split())",
"T",
"t = g*T",
"g*T",
"t",
"ans = t + a",
"t + a",
"ans",
"N = int(input())",
"int(input())",
"N",
"a = g*A",
"g*A",
"a",
"t, a = map(int,input().split())",
"map(int,input().split())",
"t",
"a = map(int,input().split())",
"map(int,input().split())",
"a",
"g = math.ceil(max(-(-t//T),-(-a//A)))",
"math.ceil(max(-(-t//T),-(-a//A)))",
"g",
"A = map(int,input().split())",
"map(int,input().split())",
"A"
] | N = int(input())
import math
t, a = map(int,input().split())
for i in range(N-1):
T, A = map(int,input().split())
g = math.ceil(max(-(-t//T),-(-a//A)))
t = g*T
a = g*A
ans = t + a
print(ans) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
39,
4,
13,
12,
13,
12,
13,
12,
13,
23,
13,
12,
13,
23,
13,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
29,
2,
17,
2,
40,
13,
13,
23,
13,
23,
13,
0,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
4,
13,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
17,
10,
2,
13,
10,
2,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
13,
13,
10,
18,
13,
10,
18,
13,
10,
12,
13,
10,
17,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
168,
4
],
[
34,
33
],
[
169,
41
],
[
47,
46
],
[
184,
53
],
[
61,
61
],
[
65,
65
],
[
207,
67
],
[
159,
72
],
[
88,
85
],
[
90,
86
],
[
88,
88
],
[
90,
90
],
[
201,
92
],
[
214,
94
],
[
98,
97
],
[
202,
100
],
[
184,
103
],
[
174,
105
],
[
198,
108
],
[
186,
110
],
[
114,
113
],
[
202,
116
],
[
177,
118
],
[
175,
121
],
[
113,
122
],
[
180,
125
],
[
175,
128
],
[
113,
129
],
[
204,
132
],
[
172,
136
],
[
199,
137
],
[
190,
137
],
[
178,
138
],
[
172,
140
],
[
187,
141
],
[
163,
141
],
[
181,
142
],
[
189,
144
],
[
178,
146
],
[
205,
147
],
[
162,
148
],
[
181,
150
],
[
205,
151
],
[
190,
155
],
[
199,
155
],
[
163,
156
],
[
187,
156
],
[
159,
160
],
[
162,
163
],
[
168,
169
],
[
174,
175
],
[
177,
178
],
[
180,
181
],
[
186,
187
],
[
189,
190
],
[
198,
199
],
[
201,
202
],
[
204,
205
],
[
207,
208
]
] | [
"# coding: utf-8\n# hello worldと表示する\nimport sys\n#import numpy\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor,pi,factorial\nfrom operator import itemgetter\nfrom copy import deepcopy\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\ndef ceil(x,y):\n return (-1)*((-x)//y)\n \nn=I()\npairs=[LI() for i in range(n)]\nx,y=1,1\nfor i in range(n):\n a=pairs[i][0]\n b=pairs[i][1]\n k=max(ceil(x,a),ceil(y,b))\n x,y=a*k,b*k\nprint(x+y)\n\n\n\n\n\n'''def pair_revise(x,y,a,b):\n global p\n global q\n i=max(ceil(x/a),ceil(y/b))\n p,q=a*i,b*i\n return p,q\nu,v=1,1\nfor i in range(n):\n u,v=pair_revise(u,v,pairs[i][0],pairs[i][1])\n print(u,v)\nprint(u+v)'''\n\n \n \n \n\n\n",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"sys.setrecursionlimit(10**7)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**7",
"10",
"7",
"from collections import Counter, deque",
"from collections import defaultdict",
"from itertools import combinations, permutations, accumulate, groupby, product",
"from bisect import bisect_left,bisect_right",
"from heapq import heapify, heappop, heappush",
"from math import floor,pi,factorial",
"from operator import itemgetter",
"from copy import deepcopy",
"def I(): return int(input())",
"I",
"def MI(): return map(int, input().split())",
"MI",
"def LI(): return list(map(int, input().split()))",
"LI",
"int(input()) for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"int(input())",
"int",
"input()",
"input",
"def LI2(): return [int(input()) for i in range(n)]",
"LI2",
"[LI()]for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"[LI()]",
"LI()",
"LI",
"def MXI(): return [[LI()]for i in range(n)]",
"MXI",
"def SI(): return input().rstrip()",
"SI",
"def printns(x): print('\\n'.join(x))",
"printns",
"x",
"x",
"def printni(x): print('\\n'.join(list(map(str,x))))",
"printni",
"x",
"x",
"inf = 10**17",
"inf",
"10**17",
"10",
"17",
"mod = 10**9 + 7",
"mod",
"10**9 + 7",
"10**9",
"10",
"9",
"7",
"def ceil(x,y):\n return (-1)*((-x)//y)\n ",
"ceil",
"return (-1)*((-x)//y)",
"(-1)*((-x)//y)",
"-1",
"(-x)//y",
"-x",
"x",
"y",
"x",
"x",
"y",
"y",
"n=I()",
"n",
"I()",
"I",
"LI() for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"LI()",
"LI",
"pairs=[LI() for i in range(n)]",
"pairs",
"[LI() for i in range(n)]",
"x,y=1,1",
"x",
"1",
"y",
"1",
"for i in range(n):\n a=pairs[i][0]\n b=pairs[i][1]\n k=max(ceil(x,a),ceil(y,b))\n x,y=a*k,b*k",
"i",
"range(n)",
"range",
"n",
"a=pairs[i][0]",
"a",
"pairs[i][0]",
"[i]",
"pairs",
"i",
"0",
"b=pairs[i][1]",
"b",
"pairs[i][1]",
"[i]",
"pairs",
"i",
"1",
"k=max(ceil(x,a),ceil(y,b))",
"k",
"max(ceil(x,a),ceil(y,b))",
"max",
"ceil(x,a)",
"ceil",
"x",
"a",
"ceil(y,b)",
"ceil",
"y",
"b",
"x,y=a*k,b*k",
"x",
"a*k",
"a",
"k",
"y",
"b*k",
"b",
"k",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"'''def pair_revise(x,y,a,b):\n global p\n global q\n i=max(ceil(x/a),ceil(y/b))\n p,q=a*i,b*i\n return p,q\nu,v=1,1\nfor i in range(n):\n u,v=pair_revise(u,v,pairs[i][0],pairs[i][1])\n print(u,v)\nprint(u+v)'''",
"mod = 10**9 + 7",
"10**9 + 7",
"mod",
"y=a*k,b*k",
"b*k",
"y",
"def printns(x): print('\\n'.join(x))",
"def printns(x): print('\\n'.join(x))",
"printns",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def ceil(x,y):\n return (-1)*((-x)//y)\n ",
"def ceil(x,y):\n return (-1)*((-x)//y)\n ",
"ceil",
"pairs=[LI() for i in range(n)]",
"[LI() for i in range(n)]",
"pairs",
"a=pairs[i][0]",
"pairs[i][0]",
"a",
"b=pairs[i][1]",
"pairs[i][1]",
"b",
"def LI(): return list(map(int, input().split()))",
"def LI(): return list(map(int, input().split()))",
"LI",
"y=1,1",
"1",
"y",
"x,y=a*k,b*k",
"a*k",
"x",
"def LI2(): return [int(input()) for i in range(n)]",
"def LI2(): return [int(input()) for i in range(n)]",
"LI2",
"def MXI(): return [[LI()]for i in range(n)]",
"def MXI(): return [[LI()]for i in range(n)]",
"MXI",
"x,y=1,1",
"1",
"x",
"n=I()",
"I()",
"n",
"k=max(ceil(x,a),ceil(y,b))",
"max(ceil(x,a),ceil(y,b))",
"k",
"inf = 10**17",
"10**17",
"inf",
"def printni(x): print('\\n'.join(list(map(str,x))))",
"def printni(x): print('\\n'.join(list(map(str,x))))",
"printni",
"def I(): return int(input())",
"def I(): return int(input())",
"I",
"def SI(): return input().rstrip()",
"def SI(): return input().rstrip()",
"SI",
"def MI(): return map(int, input().split())",
"def MI(): return map(int, input().split())",
"MI"
] | # coding: utf-8
# hello worldと表示する
import sys
#import numpy
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor,pi,factorial
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
def ceil(x,y):
return (-1)*((-x)//y)
n=I()
pairs=[LI() for i in range(n)]
x,y=1,1
for i in range(n):
a=pairs[i][0]
b=pairs[i][1]
k=max(ceil(x,a),ceil(y,b))
x,y=a*k,b*k
print(x+y)
'''def pair_revise(x,y,a,b):
global p
global q
i=max(ceil(x/a),ceil(y/b))
p,q=a*i,b*i
return p,q
u,v=1,1
for i in range(n):
u,v=pair_revise(u,v,pairs[i][0],pairs[i][1])
print(u,v)
print(u+v)'''
|
[
7,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
14,
40,
13,
29,
4,
13,
4,
13,
29,
4,
13,
23,
13,
17,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
12,
13,
10,
2,
13,
10,
2,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13
] | [
[
26,
16
],
[
27,
26
],
[
102,
42
],
[
124,
44
],
[
105,
46
],
[
120,
48
],
[
52,
51
],
[
103,
54
],
[
99,
56
],
[
109,
58
],
[
99,
59
],
[
96,
61
],
[
106,
67
],
[
112,
67
],
[
94,
68
],
[
94,
70
],
[
121,
74
],
[
115,
74
],
[
100,
75
],
[
100,
77
],
[
111,
79
],
[
97,
81
],
[
94,
82
],
[
114,
83
],
[
97,
85
],
[
100,
86
],
[
112,
90
],
[
106,
90
],
[
115,
91
],
[
121,
91
],
[
99,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
],
[
111,
112
],
[
114,
115
],
[
120,
121
]
] | [
"def cin():\n\treturn map(int,input().split())\n\ndef cino(test=False):\n if not test:\n return int(input())\n else:\n return input()\ndef cina():\n return list(map(int,input().split()))\n\na = cino()\nx,y = 1,1\nfor _ in range(a):\n p,q = cin()\n k = max((x+p-1)//p,(y+q-1)//q)\n x,y = k*p,k*q\nprint(x+y)\n ",
"def cin():\n\treturn map(int,input().split())",
"cin",
"return map(int,input().split())",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def cino(test=False):\n if not test:\n return int(input())\n else:\n return input()",
"cino",
"if not test:\n return int(input())\n else:\n return input()",
"not test",
"test",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"return input()",
"input()",
"input",
"test=False",
"test",
"False",
"def cina():\n return list(map(int,input().split()))",
"cina",
"return list(map(int,input().split()))",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a = cino()",
"a",
"cino()",
"cino",
"x,y = 1,1",
"x",
"1",
"y",
"1",
"for _ in range(a):\n p,q = cin()\n k = max((x+p-1)//p,(y+q-1)//q)\n x,y = k*p,k*q",
"_",
"range(a)",
"range",
"a",
"p,q = cin()",
"p",
"cin()",
"cin",
"q",
"k = max((x+p-1)//p,(y+q-1)//q)",
"k",
"max((x+p-1)//p,(y+q-1)//q)",
"max",
"(x+p-1)//p",
"x+p-1",
"x+p",
"x",
"p",
"1",
"p",
"(y+q-1)//q",
"y+q-1",
"y+q",
"y",
"q",
"1",
"q",
"x,y = k*p,k*q",
"x",
"k*p",
"k",
"p",
"y",
"k*q",
"k",
"q",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"p,q = cin()",
"cin()",
"p",
"k = max((x+p-1)//p,(y+q-1)//q)",
"max((x+p-1)//p,(y+q-1)//q)",
"k",
"q = cin()",
"cin()",
"q",
"a = cino()",
"cino()",
"a",
"x,y = 1,1",
"1",
"x",
"def cin():\n\treturn map(int,input().split())",
"def cin():\n\treturn map(int,input().split())",
"cin",
"x,y = k*p,k*q",
"k*p",
"x",
"y = k*p,k*q",
"k*q",
"y",
"def cina():\n return list(map(int,input().split()))",
"def cina():\n return list(map(int,input().split()))",
"cina",
"y = 1,1",
"1",
"y",
"def cino(test=False):\n if not test:\n return int(input())\n else:\n return input()",
"def cino(test=False):\n if not test:\n return int(input())\n else:\n return input()",
"cino"
] | def cin():
return map(int,input().split())
def cino(test=False):
if not test:
return int(input())
else:
return input()
def cina():
return list(map(int,input().split()))
a = cino()
x,y = 1,1
for _ in range(a):
p,q = cin()
k = max((x+p-1)//p,(y+q-1)//q)
x,y = k*p,k*q
print(x+y)
|
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
0,
13,
40,
2,
40,
18,
13,
17,
18,
18,
13,
13,
17,
0,
13,
40,
2,
40,
18,
13,
17,
18,
18,
13,
13,
17,
41,
28,
13,
18,
13,
13,
4,
2,
4,
13,
13,
13,
13,
0,
13,
13,
4,
13,
4,
13,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
18,
13,
10,
40,
13,
10,
40,
13
] | [
[
94,
4
],
[
12,
11
],
[
95,
14
],
[
88,
27
],
[
97,
30
],
[
89,
32
],
[
36,
35
],
[
95,
39
],
[
100,
41
],
[
98,
46
],
[
92,
46
],
[
89,
50
],
[
35,
51
],
[
103,
54
],
[
98,
59
],
[
92,
59
],
[
89,
63
],
[
35,
64
],
[
69,
68
],
[
89,
70
],
[
35,
71
],
[
101,
76
],
[
104,
77
],
[
68,
78
],
[
91,
80
],
[
92,
86
],
[
98,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
]
] | [
"import math\n\nn = int(input())\nl = [list(map(int, input().split())) for _ in range(n)]\n\nx = l[0]\nfor i in range(1,n):\n #y = math.ceil(x[0] / l[i][0]) # 'ceil'では 'WA'.\n #z = math.ceil(x[1] / l[i][1]) # 'ceil'では、商が桁の大きなfloatの場合、高次桁で結果に狂いが生じる.\n y = -(-x[0] // l[i][0])\n z = -(-x[1] // l[i][1])\n x = [max(y, z) * j for j in l[i]]\n\nprint(sum(x))",
"import math",
"math",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l = [list(map(int, input().split())) for _ in range(n)]",
"l",
"[list(map(int, input().split())) for _ in range(n)]",
"x = l[0]",
"x",
"l[0]",
"l",
"0",
"for i in range(1,n):\n #y = math.ceil(x[0] / l[i][0]) # 'ceil'では 'WA'.\n #z = math.ceil(x[1] / l[i][1]) # 'ceil'では、商が桁の大きなfloatの場合、高次桁で結果に狂いが生じる.\n y = -(-x[0] // l[i][0])\n z = -(-x[1] // l[i][1])\n x = [max(y, z) * j for j in l[i]]",
"i",
"range(1,n)",
"range",
"1",
"n",
"y = -(-x[0] // l[i][0])",
"y",
"-(-x[0] // l[i][0])",
"-x[0] // l[i][0]",
"-x[0]",
"x[0]",
"x",
"0",
"l[i][0]",
"[i]",
"l",
"i",
"0",
"z = -(-x[1] // l[i][1])",
"z",
"-(-x[1] // l[i][1])",
"-x[1] // l[i][1]",
"-x[1]",
"x[1]",
"x",
"1",
"l[i][1]",
"[i]",
"l",
"i",
"1",
"max(y, z) * j for j in l[i]",
"for j in l[i]",
"j",
"l[i]",
"l",
"i",
"for j in l[i]",
"max(y, z) * j",
"max(y, z)",
"max",
"y",
"z",
"j",
"x = [max(y, z) * j for j in l[i]]",
"x",
"[max(y, z) * j for j in l[i]]",
"print(sum(x))",
"print",
"sum(x)",
"sum",
"x",
"l = [list(map(int, input().split())) for _ in range(n)]",
"[list(map(int, input().split())) for _ in range(n)]",
"l",
"x = [max(y, z) * j for j in l[i]]",
"[max(y, z) * j for j in l[i]]",
"x",
"n = int(input())",
"int(input())",
"n",
"x = l[0]",
"l[0]",
"x",
"y = -(-x[0] // l[i][0])",
"-(-x[0] // l[i][0])",
"y",
"z = -(-x[1] // l[i][1])",
"-(-x[1] // l[i][1])",
"z"
] | import math
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
x = l[0]
for i in range(1,n):
#y = math.ceil(x[0] / l[i][0]) # 'ceil'では 'WA'.
#z = math.ceil(x[1] / l[i][1]) # 'ceil'では、商が桁の大きなfloatの場合、高次桁で結果に狂いが生じる.
y = -(-x[0] // l[i][0])
z = -(-x[1] // l[i][1])
x = [max(y, z) * j for j in l[i]]
print(sum(x))
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
40,
13,
18,
13,
17,
40,
13,
18,
13,
17,
0,
13,
39,
13,
13,
0,
13,
4,
13,
2,
2,
2,
18,
13,
17,
17,
13,
17,
2,
2,
2,
18,
13,
17,
17,
13,
17,
0,
13,
39,
2,
13,
13,
2,
13,
13,
4,
13,
4,
13,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13
] | [
[
94,
2
],
[
97,
8
],
[
14,
13
],
[
95,
16
],
[
100,
18
],
[
100,
27
],
[
101,
31
],
[
98,
33
],
[
83,
33
],
[
92,
33
],
[
89,
36
],
[
95,
36
],
[
98,
38
],
[
83,
38
],
[
92,
38
],
[
91,
41
],
[
85,
46
],
[
98,
53
],
[
83,
53
],
[
92,
53
],
[
101,
56
],
[
98,
62
],
[
83,
62
],
[
92,
62
],
[
89,
65
],
[
95,
65
],
[
82,
68
],
[
101,
71
],
[
86,
72
],
[
89,
74
],
[
95,
74
],
[
86,
75
],
[
83,
80
],
[
92,
80
],
[
98,
80
],
[
82,
83
],
[
85,
86
],
[
100,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
]
] | [
"t = int(input())\npar = [0, 0]\nfor i in range(t):\n\tp, t = map(int, input().split())\n\tif p >= par[0] and t >= par[1]:\n\t\tpar = [p, t]\n\telse:\n\t\tn = max((par[0]-1)//p + 1, (par[1]-1)//t +1)\n\t\tpar = [p*n, t*n]\nprint(sum(par))",
"t = int(input())",
"t",
"int(input())",
"int",
"input()",
"input",
"par = [0, 0]",
"par",
"[0, 0]",
"0",
"0",
"for i in range(t):\n\tp, t = map(int, input().split())\n\tif p >= par[0] and t >= par[1]:\n\t\tpar = [p, t]\n\telse:\n\t\tn = max((par[0]-1)//p + 1, (par[1]-1)//t +1)\n\t\tpar = [p*n, t*n]",
"i",
"range(t)",
"range",
"t",
"p, t = map(int, input().split())",
"p",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"if p >= par[0] and t >= par[1]:\n\t\tpar = [p, t]\n\telse:\n\t\tn = max((par[0]-1)//p + 1, (par[1]-1)//t +1)\n\t\tpar = [p*n, t*n]",
"p >= par[0] and t >= par[1]",
"p >= par[0]",
"p",
"par[0]",
"par",
"0",
"t >= par[1]",
"t",
"par[1]",
"par",
"1",
"par = [p, t]",
"par",
"[p, t]",
"p",
"t",
"n = max((par[0]-1)//p + 1, (par[1]-1)//t +1)",
"n",
"max((par[0]-1)//p + 1, (par[1]-1)//t +1)",
"max",
"(par[0]-1)//p + 1",
"(par[0]-1)//p",
"par[0]-1",
"par[0]",
"par",
"0",
"1",
"p",
"1",
"(par[1]-1)//t +1",
"(par[1]-1)//t",
"par[1]-1",
"par[1]",
"par",
"1",
"1",
"t",
"1",
"par = [p*n, t*n]",
"par",
"[p*n, t*n]",
"p*n",
"p",
"n",
"t*n",
"t",
"n",
"print(sum(par))",
"print",
"sum(par)",
"sum",
"par",
"par = [p*n, t*n]",
"[p*n, t*n]",
"par",
"n = max((par[0]-1)//p + 1, (par[1]-1)//t +1)",
"max((par[0]-1)//p + 1, (par[1]-1)//t +1)",
"n",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"par = [p, t]",
"[p, t]",
"par",
"t = int(input())",
"int(input())",
"t",
"par = [0, 0]",
"[0, 0]",
"par",
"p, t = map(int, input().split())",
"map(int, input().split())",
"p"
] | t = int(input())
par = [0, 0]
for i in range(t):
p, t = map(int, input().split())
if p >= par[0] and t >= par[1]:
par = [p, t]
else:
n = max((par[0]-1)//p + 1, (par[1]-1)//t +1)
par = [p*n, t*n]
print(sum(par))
|
[
7,
15,
13,
15,
15,
13,
12,
13,
4,
13,
8,
2,
13,
17,
17,
17,
29,
23,
13,
12,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
13,
14,
2,
13,
17,
0,
13,
13,
13,
13,
9,
0,
13,
4,
13,
2,
13,
13,
2,
13,
13,
0,
13,
2,
13,
17,
28,
13,
4,
13,
13,
2,
13,
17,
14,
2,
40,
2,
13,
13,
13,
40,
2,
13,
13,
13,
0,
13,
13,
3,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
29,
14,
40,
17,
4,
13,
4,
13,
4,
18,
13,
13,
10,
12,
13,
10,
12,
13
] | [
[
18,
12
],
[
18,
18
],
[
23,
22
],
[
30,
29
],
[
22,
33
],
[
36,
35
],
[
29,
38
],
[
41,
40
],
[
22,
49
],
[
41,
52
],
[
35,
55
],
[
59,
58
],
[
40,
59
],
[
61,
60
],
[
52,
61
],
[
65,
64
],
[
58,
68
],
[
103,
68
],
[
40,
69
],
[
60,
71
],
[
107,
71
],
[
52,
72
],
[
75,
74
],
[
64,
76
],
[
80,
79
],
[
64,
82
],
[
64,
84
],
[
40,
90
],
[
79,
91
],
[
58,
92
],
[
103,
92
],
[
52,
95
],
[
79,
96
],
[
60,
97
],
[
107,
97
],
[
100,
99
],
[
79,
100
],
[
104,
103
],
[
40,
105
],
[
108,
107
],
[
52,
109
],
[
103,
114
],
[
58,
114
],
[
107,
115
],
[
60,
115
],
[
133,
123
]
] | [
"### ----------------\n### ここから\n### ----------------\n\nimport sys\nfrom io import StringIO\nimport unittest\n\ndef yn(b):\n print(\"Yes\" if b==1 else \"No\")\n return\n\ndef resolve():\n readline=sys.stdin.readline\n\n #a,b,c=map(int, readline().rstrip().split())\n #arr=list(map(int, readline().rstrip().split()))\n n=int(readline())\n for i in range(n):\n x,y=map(int, readline().rstrip().split())\n if i==0:\n a,b=x,y\n continue\n start=max(a//x,b//y)\n zz=start-1\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n a,b=x*z,y*z\n print(a+b)\n #ss=readline().rstrip()\n #yn(1)\n\n return\n\nif 'doTest' not in globals():\n resolve()\n sys.exit()\n\n### ----------------\n### ここまで \n### ----------------",
"import sys",
"sys",
"from io import StringIO",
"import unittest",
"unittest",
"def yn(b):\n print(\"Yes\" if b==1 else \"No\")\n return",
"yn",
"print(\"Yes\" if b==1 else \"No\")",
"print",
"\"Yes\" if b==1 else \"No\"",
"b==1",
"b",
"1",
"\"Yes\"",
"\"No\"",
"return",
"b",
"b",
"def resolve():\n readline=sys.stdin.readline\n\n #a,b,c=map(int, readline().rstrip().split())\n #arr=list(map(int, readline().rstrip().split()))\n n=int(readline())\n for i in range(n):\n x,y=map(int, readline().rstrip().split())\n if i==0:\n a,b=x,y\n continue\n start=max(a//x,b//y)\n zz=start-1\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n a,b=x*z,y*z\n print(a+b)\n #ss=readline().rstrip()\n #yn(1)\n\n return",
"resolve",
"readline=sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"n=int(readline())",
"n",
"int(readline())",
"int",
"readline()",
"readline",
"for i in range(n):\n x,y=map(int, readline().rstrip().split())\n if i==0:\n a,b=x,y\n continue\n start=max(a//x,b//y)\n zz=start-1\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n a,b=x*z,y*z\n ",
"i",
"range(n)",
"range",
"n",
"x,y=map(int, readline().rstrip().split())",
"x",
"map(int, readline().rstrip().split())",
"map",
"int",
"readline().rstrip().split()",
"().rstrip().split",
"().rstrip()",
"().rstrip",
"()",
"readline",
"rstrip",
"split",
"y",
"if i==0:\n a,b=x,y\n continue\n ",
"i==0",
"i",
"0",
"a,b=x,y",
"a",
"x",
"b",
"y",
"continue",
"start=max(a//x,b//y)",
"start",
"max(a//x,b//y)",
"max",
"a//x",
"a",
"x",
"b//y",
"b",
"y",
"zz=start-1",
"zz",
"start-1",
"start",
"1",
"for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n ",
"z",
"range(start,start+1000)",
"range",
"start",
"start+1000",
"start",
"1000",
"if x*z>=a and y*z>=b:\n zz=z\n break\n ",
"x*z>=a and y*z>=b",
"x*z>=a",
"x*z",
"x",
"z",
"a",
"y*z>=b",
"y*z",
"y",
"z",
"b",
"zz=z",
"zz",
"z",
"break",
"a,b=x*z,y*z",
"a",
"x*z",
"x",
"z",
"b",
"y*z",
"y",
"z",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"return",
"if 'doTest' not in globals():\n resolve()\n sys.exit()\n\n### ----------------\n### ここまで \n### ----------------",
"'doTest' not in globals()",
"'doTest'",
"globals()",
"globals",
"resolve()",
"resolve",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"def yn(b):\n print(\"Yes\" if b==1 else \"No\")\n return",
"def yn(b):\n print(\"Yes\" if b==1 else \"No\")\n return",
"yn",
"def resolve():\n readline=sys.stdin.readline\n\n #a,b,c=map(int, readline().rstrip().split())\n #arr=list(map(int, readline().rstrip().split()))\n n=int(readline())\n for i in range(n):\n x,y=map(int, readline().rstrip().split())\n if i==0:\n a,b=x,y\n continue\n start=max(a//x,b//y)\n zz=start-1\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n a,b=x*z,y*z\n print(a+b)\n #ss=readline().rstrip()\n #yn(1)\n\n return",
"def resolve():\n readline=sys.stdin.readline\n\n #a,b,c=map(int, readline().rstrip().split())\n #arr=list(map(int, readline().rstrip().split()))\n n=int(readline())\n for i in range(n):\n x,y=map(int, readline().rstrip().split())\n if i==0:\n a,b=x,y\n continue\n start=max(a//x,b//y)\n zz=start-1\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n a,b=x*z,y*z\n print(a+b)\n #ss=readline().rstrip()\n #yn(1)\n\n return",
"resolve"
] | ### ----------------
### ここから
### ----------------
import sys
from io import StringIO
import unittest
def yn(b):
print("Yes" if b==1 else "No")
return
def resolve():
readline=sys.stdin.readline
#a,b,c=map(int, readline().rstrip().split())
#arr=list(map(int, readline().rstrip().split()))
n=int(readline())
for i in range(n):
x,y=map(int, readline().rstrip().split())
if i==0:
a,b=x,y
continue
start=max(a//x,b//y)
zz=start-1
for z in range(start,start+1000):
if x*z>=a and y*z>=b:
zz=z
break
a,b=x*z,y*z
print(a+b)
#ss=readline().rstrip()
#yn(1)
return
if 'doTest' not in globals():
resolve()
sys.exit()
### ----------------
### ここまで
### ----------------
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
76,
2
],
[
64,
8
],
[
73,
11
],
[
15,
14
],
[
77,
17
],
[
61,
19
],
[
61,
28
],
[
70,
30
],
[
74,
36
],
[
68,
36
],
[
59,
37
],
[
65,
41
],
[
80,
41
],
[
62,
42
],
[
79,
44
],
[
62,
46
],
[
71,
47
],
[
67,
48
],
[
59,
50
],
[
71,
51
],
[
80,
55
],
[
65,
55
],
[
68,
56
],
[
74,
56
],
[
61,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
]
] | [
"N = int(input())\n\ntak = 1\naok = 1\n\nfor _ in range(N):\n t, a = map(int, input().split())\n d = max(-(-aok // a), -(-tak // t))\n tak, aok = t * d, a * d\n\nprint(tak + aok)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"tak = 1",
"tak",
"1",
"aok = 1",
"aok",
"1",
"for _ in range(N):\n t, a = map(int, input().split())\n d = max(-(-aok // a), -(-tak // t))\n tak, aok = t * d, a * d",
"_",
"range(N)",
"range",
"N",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"d = max(-(-aok // a), -(-tak // t))",
"d",
"max(-(-aok // a), -(-tak // t))",
"max",
"-(-aok // a)",
"-aok // a",
"-aok",
"aok",
"a",
"-(-tak // t)",
"-tak // t",
"-tak",
"tak",
"t",
"tak, aok = t * d, a * d",
"tak",
"t * d",
"t",
"d",
"aok",
"a * d",
"a",
"d",
"print(tak + aok)",
"print",
"tak + aok",
"tak",
"aok",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"tak = 1",
"1",
"tak",
"aok = t * d, a * d",
"a * d",
"aok",
"d = max(-(-aok // a), -(-tak // t))",
"max(-(-aok // a), -(-tak // t))",
"d",
"aok = 1",
"1",
"aok",
"N = int(input())",
"int(input())",
"N",
"tak, aok = t * d, a * d",
"t * d",
"tak"
] | N = int(input())
tak = 1
aok = 1
for _ in range(N):
t, a = map(int, input().split())
d = max(-(-aok // a), -(-tak // t))
tak, aok = t * d, a * d
print(tak + aok) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
39,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
18,
13,
17,
13,
28,
13,
4,
13,
17,
13,
0,
13,
18,
13,
13,
13,
14,
2,
2,
13,
13,
2,
13,
13,
0,
13,
4,
13,
2,
2,
13,
13,
40,
2,
13,
13,
17,
2,
2,
13,
13,
40,
2,
13,
13,
17,
0,
13,
2,
13,
13,
13,
2,
13,
13,
0,
13,
13,
13,
13,
4,
13,
2,
13,
13,
10,
13,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
18,
13,
10,
39,
13
] | [
[
127,
4
],
[
118,
11
],
[
128,
15
],
[
142,
17
],
[
21,
20
],
[
119,
23
],
[
27,
26
],
[
128,
30
],
[
26,
35
],
[
143,
38
],
[
139,
42
],
[
143,
44
],
[
139,
46
],
[
49,
48
],
[
119,
52
],
[
121,
54
],
[
143,
56
],
[
48,
57
],
[
121,
58
],
[
122,
62
],
[
140,
63
],
[
134,
63
],
[
137,
63
],
[
116,
65
],
[
113,
66
],
[
110,
66
],
[
131,
66
],
[
124,
68
],
[
140,
73
],
[
134,
73
],
[
137,
73
],
[
122,
74
],
[
140,
77
],
[
134,
77
],
[
137,
77
],
[
122,
78
],
[
113,
82
],
[
110,
82
],
[
131,
82
],
[
116,
83
],
[
113,
86
],
[
110,
86
],
[
131,
86
],
[
116,
87
],
[
136,
90
],
[
122,
92
],
[
125,
93
],
[
130,
94
],
[
116,
96
],
[
125,
97
],
[
133,
99
],
[
122,
100
],
[
109,
101
],
[
116,
102
],
[
134,
106
],
[
137,
106
],
[
140,
106
],
[
110,
107
],
[
131,
107
],
[
113,
107
],
[
116,
109
],
[
109,
110
],
[
139,
113
],
[
121,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
],
[
130,
131
],
[
122,
133
],
[
133,
134
],
[
136,
137
],
[
139,
140
],
[
142,
143
]
] | [
"import sys\ninput = sys.stdin.readline\n\nN = int(input())\nTA = []\n\nfor _ in range(N):\n TA.append([int(x) for x in input().split()])\n\nx, y = TA[0]\n\nfor i in range(1, N):\n X, Y = TA[i]\n if X < x or Y < y:\n mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))\n x, y = X * mul, Y * mul\n else:\n x, y = X, Y\n # print(x, y)\n\nprint(x + y)\n\n",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"TA = []",
"TA",
"[]",
"for _ in range(N):\n TA.append([int(x) for x in input().split()])",
"_",
"range(N)",
"range",
"N",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"TA.append([int(x) for x in input().split()])",
"TA.append",
"TA",
"append",
"[int(x) for x in input().split()]",
"x, y = TA[0]",
"x",
"TA[0]",
"TA",
"0",
"y",
"for i in range(1, N):\n X, Y = TA[i]\n if X < x or Y < y:\n mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))\n x, y = X * mul, Y * mul\n else:\n x, y = X, Y\n # print(x, y)",
"i",
"range(1, N)",
"range",
"1",
"N",
"X, Y = TA[i]",
"X",
"TA[i]",
"TA",
"i",
"Y",
"if X < x or Y < y:\n mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))\n x, y = X * mul, Y * mul\n else:\n x, y = X, Y\n # print(x, y)",
"X < x or Y < y",
"X < x",
"X",
"x",
"Y < y",
"Y",
"y",
"mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))",
"mul",
"max(x // X + (x % X != 0), y // Y + (y % Y != 0))",
"max",
"x // X + (x % X != 0)",
"x // X",
"x",
"X",
"x % X != 0",
"x % X",
"x",
"X",
"0",
"y // Y + (y % Y != 0)",
"y // Y",
"y",
"Y",
"y % Y != 0",
"y % Y",
"y",
"Y",
"0",
"x, y = X * mul, Y * mul",
"x",
"X * mul",
"X",
"mul",
"y",
"Y * mul",
"Y",
"mul",
"x, y = X, Y",
"x",
"X",
"y",
"Y",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"y = X, Y",
"Y",
"y",
"y = TA[0]",
"TA[0]",
"y",
"Y = TA[i]",
"TA[i]",
"Y",
"N = int(input())",
"int(input())",
"N",
"X, Y = TA[i]",
"TA[i]",
"X",
"mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))",
"max(x // X + (x % X != 0), y // Y + (y % Y != 0))",
"mul",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"y = X * mul, Y * mul",
"Y * mul",
"y",
"x, y = X, Y",
"X",
"x",
"x, y = X * mul, Y * mul",
"X * mul",
"x",
"x, y = TA[0]",
"TA[0]",
"x",
"TA = []",
"[]",
"TA"
] | import sys
input = sys.stdin.readline
N = int(input())
TA = []
for _ in range(N):
TA.append([int(x) for x in input().split()])
x, y = TA[0]
for i in range(1, N):
X, Y = TA[i]
if X < x or Y < y:
mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))
x, y = X * mul, Y * mul
else:
x, y = X, Y
# print(x, y)
print(x + y)
|
[
7,
15,
13,
13,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
15,
0,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
18,
18,
13,
17,
17,
0,
13,
18,
18,
13,
17,
17,
28,
13,
13,
18,
13,
39,
17,
0,
13,
4,
13,
40,
2,
40,
13,
13,
40,
2,
40,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
13,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13,
10,
18,
13,
10,
4,
13
] | [
[
24,
23
],
[
149,
29
],
[
33,
33
],
[
160,
42
],
[
145,
47
],
[
130,
55
],
[
125,
57
],
[
61,
60
],
[
131,
63
],
[
155,
66
],
[
121,
68
],
[
157,
71
],
[
122,
74
],
[
136,
78
],
[
122,
81
],
[
122,
88
],
[
133,
92
],
[
158,
98
],
[
152,
98
],
[
137,
103
],
[
140,
103
],
[
151,
106
],
[
134,
109
],
[
139,
111
],
[
134,
114
],
[
152,
118
],
[
158,
118
],
[
140,
119
],
[
137,
119
],
[
121,
122
],
[
130,
131
],
[
133,
134
],
[
136,
137
],
[
139,
140
],
[
145,
146
],
[
151,
152
],
[
157,
158
],
[
160,
161
]
] | [
"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nN = INT()\nTA = [LIST() for _ in range(N)]\n\nT = TA[0][0]\nA = TA[0][1]\n\nfor t, a in TA[1:]:\n\tp = max(-(-T//t), -(-A//a))\n\tT = t*p\n\tA = a*p\n\t\nprint(T+A)\n",
"import sys, re",
"sys",
"re",
"from collections import deque, defaultdict, Counter",
"from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd",
"from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby",
"from operator import itemgetter, mul",
"from copy import deepcopy",
"from string import ascii_lowercase, ascii_uppercase, digits",
"from bisect import bisect, bisect_left, insort, insort_left",
"from heapq import heappush, heappop",
"from functools import reduce",
"def input(): return sys.stdin.readline().strip()",
"input",
"def INT(): return int(input())",
"INT",
"def MAP(): return map(int, input().split())",
"MAP",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"MAP() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"MAP()",
"MAP",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"n",
"n",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"from decimal import *",
"N = INT()",
"N",
"INT()",
"INT",
"LIST() for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"LIST()",
"LIST",
"TA = [LIST() for _ in range(N)]",
"TA",
"[LIST() for _ in range(N)]",
"T = TA[0][0]",
"T",
"TA[0][0]",
"[0]",
"TA",
"0",
"0",
"A = TA[0][1]",
"A",
"TA[0][1]",
"[0]",
"TA",
"0",
"1",
"for t, a in TA[1:]:\n\tp = max(-(-T//t), -(-A//a))\n\tT = t*p\n\tA = a*p\n\t",
"t",
"a",
"TA[1:]",
"TA",
"1:",
"1",
"p = max(-(-T//t), -(-A//a))",
"p",
"max(-(-T//t), -(-A//a))",
"max",
"-(-T//t)",
"-T//t",
"-T",
"T",
"t",
"-(-A//a)",
"-A//a",
"-A",
"A",
"a",
"T = t*p",
"T",
"t*p",
"t",
"p",
"A = a*p",
"A",
"a*p",
"a",
"p",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"TA = [LIST() for _ in range(N)]",
"[LIST() for _ in range(N)]",
"TA",
"def INT(): return int(input())",
"def INT(): return int(input())",
"INT",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"N = INT()",
"INT()",
"N",
"p = max(-(-T//t), -(-A//a))",
"max(-(-T//t), -(-A//a))",
"p",
"A = TA[0][1]",
"TA[0][1]",
"A",
"A = a*p",
"a*p",
"A",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"def MAP(): return map(int, input().split())",
"def MAP(): return map(int, input().split())",
"MAP",
"T = t*p",
"t*p",
"T",
"def LIST(): return list(map(int, input().split()))",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"T = TA[0][0]",
"TA[0][0]",
"T",
"INF = float('inf')",
"float('inf')",
"INF"
] | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
N = INT()
TA = [LIST() for _ in range(N)]
T = TA[0][0]
A = TA[0][1]
for t, a in TA[1:]:
p = max(-(-T//t), -(-A//a))
T = t*p
A = a*p
print(T+A)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
2,
2,
17,
17,
17,
42,
2,
2,
13,
13,
17,
0,
13,
2,
2,
13,
13,
17,
14,
2,
40,
2,
13,
13,
13,
40,
2,
13,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
92,
2
],
[
95,
8
],
[
89,
10
],
[
14,
13
],
[
93,
16
],
[
119,
18
],
[
119,
29
],
[
98,
31
],
[
86,
34
],
[
87,
43
],
[
111,
43
],
[
99,
44
],
[
102,
44
],
[
107,
47
],
[
99,
50
],
[
102,
50
],
[
87,
51
],
[
111,
51
],
[
120,
57
],
[
108,
58
],
[
96,
59
],
[
105,
59
],
[
117,
62
],
[
108,
63
],
[
90,
64
],
[
114,
64
],
[
110,
66
],
[
108,
67
],
[
101,
69
],
[
108,
70
],
[
104,
72
],
[
120,
74
],
[
111,
75
],
[
87,
75
],
[
113,
76
],
[
117,
78
],
[
111,
79
],
[
87,
79
],
[
105,
83
],
[
96,
83
],
[
114,
84
],
[
90,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
108,
101
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
108,
110
],
[
110,
111
],
[
113,
114
],
[
119,
117
],
[
119,
120
]
] | [
"n = int(input())\npt, pa = 0, 0\nfor _ in range(n):\n t, a = tuple(map(int, input().split()))\n l = 0\n r = 10**18+1\n while (r-l) > 1:\n mid = (l+r)//2\n if (t*mid >= pt and a*mid >= pa):\n r = mid\n else:\n l = mid\n pt, pa = t*r, a*r\n\nprint(pt+pa)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"pt, pa = 0, 0",
"pt",
"0",
"pa",
"0",
"for _ in range(n):\n t, a = tuple(map(int, input().split()))\n l = 0\n r = 10**18+1\n while (r-l) > 1:\n mid = (l+r)//2\n if (t*mid >= pt and a*mid >= pa):\n r = mid\n else:\n l = mid\n pt, pa = t*r, a*r",
"_",
"range(n)",
"range",
"n",
"t, a = tuple(map(int, input().split()))",
"t",
"tuple(map(int, input().split()))",
"tuple",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"l = 0",
"l",
"0",
"r = 10**18+1",
"r",
"10**18+1",
"10**18",
"10",
"18",
"1",
"while (r-l) > 1:\n mid = (l+r)//2\n if (t*mid >= pt and a*mid >= pa):\n r = mid\n else:\n l = mid\n ",
"(r-l) > 1",
"r-l",
"r",
"l",
"1",
"mid = (l+r)//2",
"mid",
"(l+r)//2",
"l+r",
"l",
"r",
"2",
"if (t*mid >= pt and a*mid >= pa):\n r = mid\n else:\n l = mid\n ",
"t*mid >= pt and a*mid >= pa",
"t*mid >= pt",
"t*mid",
"t",
"mid",
"pt",
"a*mid >= pa",
"a*mid",
"a",
"mid",
"pa",
"r = mid",
"r",
"mid",
"l = mid",
"l",
"mid",
"pt, pa = t*r, a*r",
"pt",
"t*r",
"t",
"r",
"pa",
"a*r",
"a",
"r",
"print(pt+pa)",
"print",
"pt+pa",
"pt",
"pa",
"r = 10**18+1",
"10**18+1",
"r",
"pa = 0, 0",
"0",
"pa",
"n = int(input())",
"int(input())",
"n",
"pt, pa = 0, 0",
"0",
"pt",
"l = 0",
"0",
"l",
"l = mid",
"mid",
"l",
"pt, pa = t*r, a*r",
"t*r",
"pt",
"mid = (l+r)//2",
"(l+r)//2",
"mid",
"r = mid",
"mid",
"r",
"pa = t*r, a*r",
"a*r",
"pa",
"a = tuple(map(int, input().split()))",
"tuple(map(int, input().split()))",
"a",
"t, a = tuple(map(int, input().split()))",
"tuple(map(int, input().split()))",
"t"
] | n = int(input())
pt, pa = 0, 0
for _ in range(n):
t, a = tuple(map(int, input().split()))
l = 0
r = 10**18+1
while (r-l) > 1:
mid = (l+r)//2
if (t*mid >= pt and a*mid >= pa):
r = mid
else:
l = mid
pt, pa = t*r, a*r
print(pt+pa)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
4,
13,
2,
2,
13,
17,
13,
2,
2,
13,
17,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] | [
[
91,
2
],
[
82,
8
],
[
82,
17
],
[
73,
19
],
[
80,
21
],
[
83,
22
],
[
25,
24
],
[
92,
28
],
[
97,
31
],
[
97,
40
],
[
88,
42
],
[
80,
48
],
[
95,
48
],
[
98,
50
],
[
83,
53
],
[
77,
53
],
[
86,
55
],
[
94,
58
],
[
89,
60
],
[
98,
61
],
[
76,
63
],
[
89,
65
],
[
86,
66
],
[
95,
70
],
[
80,
70
],
[
77,
71
],
[
83,
71
],
[
73,
74
],
[
76,
77
],
[
82,
80
],
[
82,
83
],
[
97,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
]
] | [
"n=int(input())\nx,y=map(int,input().split())\nz=x+y\nfor i in range(n-1):\n a,b=map(int,input().split())\n k=max((x-1)//a,(y-1)//b)+1\n x=k*a\n y=k*b\nprint(x+y)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"z=x+y",
"z",
"x+y",
"x",
"y",
"for i in range(n-1):\n a,b=map(int,input().split())\n k=max((x-1)//a,(y-1)//b)+1\n x=k*a\n y=k*b",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"a,b=map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"k=max((x-1)//a,(y-1)//b)+1",
"k",
"max((x-1)//a,(y-1)//b)+1",
"max((x-1)//a,(y-1)//b)",
"max",
"(x-1)//a",
"x-1",
"x",
"1",
"a",
"(y-1)//b",
"y-1",
"y",
"1",
"b",
"1",
"x=k*a",
"x",
"k*a",
"k",
"a",
"y=k*b",
"y",
"k*b",
"k",
"b",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"z=x+y",
"x+y",
"z",
"y=k*b",
"k*b",
"y",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"b=map(int,input().split())",
"map(int,input().split())",
"b",
"k=max((x-1)//a,(y-1)//b)+1",
"max((x-1)//a,(y-1)//b)+1",
"k",
"n=int(input())",
"int(input())",
"n",
"x=k*a",
"k*a",
"x",
"a,b=map(int,input().split())",
"map(int,input().split())",
"a"
] | n=int(input())
x,y=map(int,input().split())
z=x+y
for i in range(n-1):
a,b=map(int,input().split())
k=max((x-1)//a,(y-1)//b)+1
x=k*a
y=k*b
print(x+y) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
13,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
0,
13,
13,
14,
2,
2,
13,
13,
2,
13,
13,
0,
13,
2,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
4,
13,
2,
2,
2,
13,
13,
17,
13,
2,
2,
2,
13,
13,
17,
13,
14,
2,
13,
13,
0,
13,
2,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
2,
2,
2,
13,
13,
17,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13
] | [
[
158,
2
],
[
10,
9
],
[
159,
12
],
[
179,
25
],
[
170,
28
],
[
176,
30
],
[
171,
40
],
[
165,
40
],
[
162,
40
],
[
183,
40
],
[
186,
40
],
[
177,
43
],
[
156,
43
],
[
168,
43
],
[
153,
43
],
[
174,
43
],
[
185,
45
],
[
173,
48
],
[
171,
54
],
[
165,
54
],
[
162,
54
],
[
183,
54
],
[
186,
54
],
[
177,
57
],
[
156,
57
],
[
168,
57
],
[
153,
57
],
[
174,
57
],
[
182,
59
],
[
171,
67
],
[
165,
67
],
[
162,
67
],
[
183,
67
],
[
186,
67
],
[
177,
74
],
[
156,
74
],
[
168,
74
],
[
153,
74
],
[
174,
74
],
[
152,
79
],
[
183,
87
],
[
171,
87
],
[
165,
87
],
[
162,
87
],
[
186,
87
],
[
177,
94
],
[
156,
94
],
[
168,
94
],
[
153,
94
],
[
174,
94
],
[
171,
101
],
[
165,
101
],
[
162,
101
],
[
183,
101
],
[
186,
101
],
[
161,
103
],
[
171,
109
],
[
165,
109
],
[
162,
109
],
[
183,
109
],
[
186,
109
],
[
167,
114
],
[
162,
120
],
[
171,
120
],
[
165,
120
],
[
183,
120
],
[
186,
120
],
[
164,
125
],
[
177,
131
],
[
156,
131
],
[
168,
131
],
[
153,
131
],
[
174,
131
],
[
155,
136
],
[
177,
142
],
[
156,
142
],
[
168,
142
],
[
153,
142
],
[
174,
142
],
[
165,
149
],
[
162,
149
],
[
183,
149
],
[
186,
149
],
[
171,
149
],
[
156,
150
],
[
168,
150
],
[
153,
150
],
[
174,
150
],
[
177,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
],
[
161,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
],
[
182,
183
],
[
185,
186
]
] | [
"n = int(input())\nquery = [tuple(map(int, input().split())) for _ in range(n)]\n\nx, y = 1, 1\nfor t, a in query:\n if t >= x and a >= y:\n x = t\n y = a\n else:\n if t < x and a < y:\n x = t * max((x + t - 1) // t, (y + a - 1) // a)\n y = a * max((x + t - 1) // t, (y + a - 1) // a)\n elif t < x:\n x = t * ((x + t - 1) // t)\n y = a * ((x + t - 1) // t)\n else:\n x = t * ((y + a - 1) // a)\n y = a * ((y + a - 1) // a)\nprint(x + y)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"tuple(map(int, input().split())) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"tuple(map(int, input().split()))",
"tuple",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"query = [tuple(map(int, input().split())) for _ in range(n)]",
"query",
"[tuple(map(int, input().split())) for _ in range(n)]",
"x, y = 1, 1",
"x",
"1",
"y",
"1",
"for t, a in query:\n if t >= x and a >= y:\n x = t\n y = a\n else:\n if t < x and a < y:\n x = t * max((x + t - 1) // t, (y + a - 1) // a)\n y = a * max((x + t - 1) // t, (y + a - 1) // a)\n elif t < x:\n x = t * ((x + t - 1) // t)\n y = a * ((x + t - 1) // t)\n else:\n x = t * ((y + a - 1) // a)\n y = a * ((y + a - 1) // a)",
"t",
"a",
"query",
"if t >= x and a >= y:\n x = t\n y = a\n else:\n if t < x and a < y:\n x = t * max((x + t - 1) // t, (y + a - 1) // a)\n y = a * max((x + t - 1) // t, (y + a - 1) // a)\n elif t < x:\n x = t * ((x + t - 1) // t)\n y = a * ((x + t - 1) // t)\n else:\n x = t * ((y + a - 1) // a)\n y = a * ((y + a - 1) // a)",
"t >= x and a >= y",
"t >= x",
"t",
"x",
"a >= y",
"a",
"y",
"x = t",
"x",
"t",
"y = a",
"y",
"a",
"if t < x and a < y:\n x = t * max((x + t - 1) // t, (y + a - 1) // a)\n y = a * max((x + t - 1) // t, (y + a - 1) // a)\n elif t < x:\n x = t * ((x + t - 1) // t)\n y = a * ((x + t - 1) // t)\n else:\n x = t * ((y + a - 1) // a)\n y = a * ((y + a - 1) // a)",
"t < x and a < y",
"t < x",
"t",
"x",
"a < y",
"a",
"y",
"x = t * max((x + t - 1) // t, (y + a - 1) // a)",
"x",
"t * max((x + t - 1) // t, (y + a - 1) // a)",
"t",
"max((x + t - 1) // t, (y + a - 1) // a)",
"max",
"(x + t - 1) // t",
"x + t - 1",
"x + t",
"x",
"t",
"1",
"t",
"(y + a - 1) // a",
"y + a - 1",
"y + a",
"y",
"a",
"1",
"a",
"y = a * max((x + t - 1) // t, (y + a - 1) // a)",
"y",
"a * max((x + t - 1) // t, (y + a - 1) // a)",
"a",
"max((x + t - 1) // t, (y + a - 1) // a)",
"max",
"(x + t - 1) // t",
"x + t - 1",
"x + t",
"x",
"t",
"1",
"t",
"(y + a - 1) // a",
"y + a - 1",
"y + a",
"y",
"a",
"1",
"a",
"elif t < x:\n x = t * ((x + t - 1) // t)\n y = a * ((x + t - 1) // t)\n ",
"t < x",
"t",
"x",
"x = t * ((x + t - 1) // t)",
"x",
"t * ((x + t - 1) // t)",
"t",
"(x + t - 1) // t",
"x + t - 1",
"x + t",
"x",
"t",
"1",
"t",
"y = a * ((x + t - 1) // t)",
"y",
"a * ((x + t - 1) // t)",
"a",
"(x + t - 1) // t",
"x + t - 1",
"x + t",
"x",
"t",
"1",
"t",
"x = t * ((y + a - 1) // a)",
"x",
"t * ((y + a - 1) // a)",
"t",
"(y + a - 1) // a",
"y + a - 1",
"y + a",
"y",
"a",
"1",
"a",
"y = a * ((y + a - 1) // a)",
"y",
"a * ((y + a - 1) // a)",
"a",
"(y + a - 1) // a",
"y + a - 1",
"y + a",
"y",
"a",
"1",
"a",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"y = a * max((x + t - 1) // t, (y + a - 1) // a)",
"a * max((x + t - 1) // t, (y + a - 1) // a)",
"y",
"y = a * ((y + a - 1) // a)",
"a * ((y + a - 1) // a)",
"y",
"n = int(input())",
"int(input())",
"n",
"x = t * ((x + t - 1) // t)",
"t * ((x + t - 1) // t)",
"x",
"x = t * ((y + a - 1) // a)",
"t * ((y + a - 1) // a)",
"x",
"y = a * ((x + t - 1) // t)",
"a * ((x + t - 1) // t)",
"y",
"x, y = 1, 1",
"1",
"x",
"y = a",
"a",
"y",
"y = 1, 1",
"1",
"y",
"query = [tuple(map(int, input().split())) for _ in range(n)]",
"[tuple(map(int, input().split())) for _ in range(n)]",
"query",
"x = t * max((x + t - 1) // t, (y + a - 1) // a)",
"t * max((x + t - 1) // t, (y + a - 1) // a)",
"x",
"x = t",
"t",
"x"
] | n = int(input())
query = [tuple(map(int, input().split())) for _ in range(n)]
x, y = 1, 1
for t, a in query:
if t >= x and a >= y:
x = t
y = a
else:
if t < x and a < y:
x = t * max((x + t - 1) // t, (y + a - 1) // a)
y = a * max((x + t - 1) // t, (y + a - 1) // a)
elif t < x:
x = t * ((x + t - 1) // t)
y = a * ((x + t - 1) // t)
else:
x = t * ((y + a - 1) // a)
y = a * ((y + a - 1) // a)
print(x + y) |
[
7,
15,
15,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
13,
18,
13,
13,
0,
13,
40,
2,
40,
13,
13,
13,
40,
2,
40,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
18,
13,
10,
40,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
18,
13,
10,
40,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
124,
4
],
[
94,
10
],
[
125,
14
],
[
112,
16
],
[
125,
20
],
[
23,
22
],
[
125,
25
],
[
30,
27
],
[
95,
28
],
[
22,
29
],
[
30,
38
],
[
113,
39
],
[
22,
40
],
[
127,
42
],
[
103,
44
],
[
48,
47
],
[
125,
50
],
[
97,
52
],
[
27,
53
],
[
95,
54
],
[
47,
55
],
[
115,
56
],
[
38,
57
],
[
113,
58
],
[
47,
59
],
[
100,
61
],
[
128,
65
],
[
110,
65
],
[
98,
66
],
[
118,
67
],
[
104,
71
],
[
122,
71
],
[
116,
72
],
[
106,
74
],
[
101,
77
],
[
119,
78
],
[
109,
80
],
[
107,
82
],
[
98,
83
],
[
121,
84
],
[
107,
86
],
[
116,
87
],
[
110,
91
],
[
128,
91
],
[
122,
92
],
[
104,
92
],
[
94,
95
],
[
27,
97
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
38,
115
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"from math import gcd\nfrom math import ceil\nn = int(input())\nT = [0] * n\nA = [0] * n\nfor i in range(n):\n T[i], A[i] = map(int, input().split())\n\nt, a = 1, 1\nfor i in range(n):\n t_rate, a_rate = T[i], A[i]\n #print(t_rate, a_rate)\n t_mul, a_mul = -(-t // t_rate), -(-a // a_rate)\n #print(t_mul, a_mul)\n mul_num = max(t_mul, a_mul)\n t, a = mul_num * t_rate, mul_num * a_rate\n\nprint(t + a)",
"from math import gcd",
"from math import ceil",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"T = [0] * n",
"T",
"[0] * n",
"[0]",
"0",
"n",
"A = [0] * n",
"A",
"[0] * n",
"[0]",
"0",
"n",
"for i in range(n):\n T[i], A[i] = map(int, input().split())",
"i",
"range(n)",
"range",
"n",
"T[i], A[i] = map(int, input().split())",
"T[i]",
"T",
"i",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A[i]",
"A",
"i",
"t, a = 1, 1",
"t",
"1",
"a",
"1",
"for i in range(n):\n t_rate, a_rate = T[i], A[i]\n #print(t_rate, a_rate)\n t_mul, a_mul = -(-t // t_rate), -(-a // a_rate)\n #print(t_mul, a_mul)\n mul_num = max(t_mul, a_mul)\n t, a = mul_num * t_rate, mul_num * a_rate",
"i",
"range(n)",
"range",
"n",
"t_rate, a_rate = T[i], A[i]",
"t_rate",
"T[i]",
"T",
"i",
"a_rate",
"A[i]",
"A",
"i",
"t_mul, a_mul = -(-t // t_rate), -(-a // a_rate)",
"t_mul",
"-(-t // t_rate)",
"-t // t_rate",
"-t",
"t",
"t_rate",
"a_mul",
"-(-a // a_rate)",
"-a // a_rate",
"-a",
"a",
"a_rate",
"mul_num = max(t_mul, a_mul)",
"mul_num",
"max(t_mul, a_mul)",
"max",
"t_mul",
"a_mul",
"t, a = mul_num * t_rate, mul_num * a_rate",
"t",
"mul_num * t_rate",
"mul_num",
"t_rate",
"a",
"mul_num * a_rate",
"mul_num",
"a_rate",
"print(t + a)",
"print",
"t + a",
"t",
"a",
"T = [0] * n",
"[0] * n",
"T",
"t_rate, a_rate = T[i], A[i]",
"T[i]",
"t_rate",
"t_mul, a_mul = -(-t // t_rate), -(-a // a_rate)",
"-(-t // t_rate)",
"t_mul",
"a = 1, 1",
"1",
"a",
"mul_num = max(t_mul, a_mul)",
"max(t_mul, a_mul)",
"mul_num",
"t, a = mul_num * t_rate, mul_num * a_rate",
"mul_num * t_rate",
"t",
"A = [0] * n",
"[0] * n",
"A",
"a_rate = T[i], A[i]",
"A[i]",
"a_rate",
"a_mul = -(-t // t_rate), -(-a // a_rate)",
"-(-a // a_rate)",
"a_mul",
"a = mul_num * t_rate, mul_num * a_rate",
"mul_num * a_rate",
"a",
"n = int(input())",
"int(input())",
"n",
"t, a = 1, 1",
"1",
"t"
] | from math import gcd
from math import ceil
n = int(input())
T = [0] * n
A = [0] * n
for i in range(n):
T[i], A[i] = map(int, input().split())
t, a = 1, 1
for i in range(n):
t_rate, a_rate = T[i], A[i]
#print(t_rate, a_rate)
t_mul, a_mul = -(-t // t_rate), -(-a // a_rate)
#print(t_mul, a_mul)
mul_num = max(t_mul, a_mul)
t, a = mul_num * t_rate, mul_num * a_rate
print(t + a) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
0,
13,
13,
9,
0,
13,
17,
0,
13,
17,
14,
40,
2,
13,
13,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
2,
13,
13,
14,
2,
2,
13,
13,
17,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13
] | [
[
119,
2
],
[
158,
8
],
[
158,
17
],
[
20,
19
],
[
120,
23
],
[
143,
25
],
[
143,
34
],
[
129,
38
],
[
159,
39
],
[
156,
39
],
[
126,
39
],
[
144,
41
],
[
138,
42
],
[
123,
42
],
[
150,
42
],
[
125,
44
],
[
129,
45
],
[
149,
47
],
[
144,
48
],
[
152,
51
],
[
131,
54
],
[
126,
59
],
[
159,
59
],
[
156,
59
],
[
129,
60
],
[
113,
63
],
[
126,
66
],
[
159,
66
],
[
156,
66
],
[
129,
67
],
[
146,
70
],
[
126,
72
],
[
159,
72
],
[
156,
72
],
[
129,
73
],
[
150,
77
],
[
138,
77
],
[
123,
77
],
[
144,
78
],
[
140,
81
],
[
150,
83
],
[
138,
83
],
[
123,
83
],
[
144,
84
],
[
116,
86
],
[
150,
89
],
[
138,
89
],
[
123,
89
],
[
144,
90
],
[
134,
93
],
[
147,
96
],
[
114,
96
],
[
153,
96
],
[
117,
97
],
[
141,
97
],
[
132,
97
],
[
155,
99
],
[
129,
101
],
[
135,
102
],
[
122,
103
],
[
144,
105
],
[
135,
106
],
[
156,
110
],
[
126,
110
],
[
159,
110
],
[
123,
111
],
[
150,
111
],
[
138,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
129,
125
],
[
125,
126
],
[
143,
129
],
[
131,
132
],
[
134,
135
],
[
158,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
144,
149
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
]
] | [
"n=int(input())\na,b=map(int,input().split())\nfor i in range(1,n):\n x,y=map(int,input().split()) \n if x>=a and y>=b:\n a=x \n b=y \n continue \n mul1=-1 \n mul2=-1 \n if a%x!=0: \n mul1=a//x +1 \n else:\n mul1=a//x \n if b%y==0:\n mul2=b//y \n else: \n mul2=b//y+1 \n m=max(mul1,mul2) \n # print(m,x,y)\n a,b=x*m,y*m \n # print(a,b,'gd')\nprint(a+b)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a,b=map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"for i in range(1,n):\n x,y=map(int,input().split()) \n if x>=a and y>=b:\n a=x \n b=y \n continue \n mul1=-1 \n mul2=-1 \n if a%x!=0: \n mul1=a//x +1 \n else:\n mul1=a//x \n if b%y==0:\n mul2=b//y \n else: \n mul2=b//y+1 \n m=max(mul1,mul2) \n # print(m,x,y)\n a,b=x*m,y*m \n # print(a,b,'gd')",
"i",
"range(1,n)",
"range",
"1",
"n",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if x>=a and y>=b:\n a=x \n b=y \n continue \n ",
"x>=a and y>=b",
"x>=a",
"x",
"a",
"y>=b",
"y",
"b",
"a=x",
"a",
"x",
"b=y",
"b",
"y",
"continue",
"mul1=-1",
"mul1",
"-1",
"mul2=-1",
"mul2",
"-1",
"if a%x!=0: \n mul1=a//x +1 \n else:\n mul1=a//x \n ",
"a%x!=0",
"a%x",
"a",
"x",
"0",
"mul1=a//x +1",
"mul1",
"a//x +1",
"a//x",
"a",
"x",
"1",
"mul1=a//x",
"mul1",
"a//x",
"a",
"x",
"if b%y==0:\n mul2=b//y \n else: \n mul2=b//y+1 \n ",
"b%y==0",
"b%y",
"b",
"y",
"0",
"mul2=b//y",
"mul2",
"b//y",
"b",
"y",
"mul2=b//y+1",
"mul2",
"b//y+1",
"b//y",
"b",
"y",
"1",
"m=max(mul1,mul2)",
"m",
"max(mul1,mul2)",
"max",
"mul1",
"mul2",
"a,b=x*m,y*m",
"a",
"x*m",
"x",
"m",
"b",
"y*m",
"y",
"m",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"mul1=a//x +1",
"a//x +1",
"mul1",
"mul2=b//y+1",
"b//y+1",
"mul2",
"n=int(input())",
"int(input())",
"n",
"b=x*m,y*m",
"y*m",
"b",
"a=x",
"x",
"a",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"mul2=-1",
"-1",
"mul2",
"m=max(mul1,mul2)",
"max(mul1,mul2)",
"m",
"b=map(int,input().split())",
"map(int,input().split())",
"b",
"mul2=b//y",
"b//y",
"mul2",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"mul1=a//x",
"a//x",
"mul1",
"b=y",
"y",
"b",
"mul1=-1",
"-1",
"mul1",
"a,b=x*m,y*m",
"x*m",
"a",
"a,b=map(int,input().split())",
"map(int,input().split())",
"a"
] | n=int(input())
a,b=map(int,input().split())
for i in range(1,n):
x,y=map(int,input().split())
if x>=a and y>=b:
a=x
b=y
continue
mul1=-1
mul2=-1
if a%x!=0:
mul1=a//x +1
else:
mul1=a//x
if b%y==0:
mul2=b//y
else:
mul2=b//y+1
m=max(mul1,mul2)
# print(m,x,y)
a,b=x*m,y*m
# print(a,b,'gd')
print(a+b) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
17,
13,
14,
2,
2,
13,
13,
17,
0,
18,
13,
17,
13,
0,
18,
13,
17,
2,
2,
2,
13,
13,
17,
13,
0,
18,
13,
17,
2,
2,
18,
13,
17,
13,
13,
14,
2,
18,
13,
17,
13,
0,
18,
13,
17,
2,
2,
17,
17,
17,
14,
2,
2,
13,
13,
17,
0,
18,
13,
17,
13,
0,
18,
13,
17,
2,
2,
2,
13,
13,
17,
13,
0,
18,
13,
17,
2,
2,
18,
13,
17,
13,
13,
14,
2,
18,
13,
17,
13,
0,
18,
13,
17,
2,
2,
17,
17,
17,
14,
40,
2,
18,
13,
17,
18,
13,
17,
2,
18,
13,
17,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
4,
13,
2,
13,
13,
10,
39,
13,
10,
18,
13,
10,
39,
13,
10,
17,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
17,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
196,
2
],
[
190,
8
],
[
202,
11
],
[
15,
14
],
[
197,
17
],
[
181,
19
],
[
187,
24
],
[
211,
29
],
[
211,
42
],
[
191,
46
],
[
206,
46
],
[
194,
46
],
[
209,
47
],
[
53,
50
],
[
182,
51
],
[
191,
53
],
[
206,
53
],
[
194,
53
],
[
58,
55
],
[
182,
56
],
[
191,
61
],
[
206,
61
],
[
194,
61
],
[
209,
62
],
[
209,
64
],
[
69,
66
],
[
188,
67
],
[
182,
72
],
[
209,
74
],
[
212,
75
],
[
188,
79
],
[
203,
81
],
[
185,
81
],
[
200,
81
],
[
86,
83
],
[
188,
84
],
[
203,
94
],
[
185,
94
],
[
200,
94
],
[
212,
95
],
[
101,
98
],
[
188,
99
],
[
203,
101
],
[
185,
101
],
[
200,
101
],
[
106,
103
],
[
188,
104
],
[
203,
109
],
[
185,
109
],
[
200,
109
],
[
212,
110
],
[
212,
112
],
[
117,
114
],
[
182,
115
],
[
188,
120
],
[
212,
122
],
[
209,
123
],
[
182,
127
],
[
191,
129
],
[
206,
129
],
[
194,
129
],
[
134,
131
],
[
182,
132
],
[
182,
143
],
[
188,
146
],
[
182,
150
],
[
188,
153
],
[
193,
156
],
[
182,
158
],
[
199,
161
],
[
188,
163
],
[
205,
166
],
[
182,
168
],
[
184,
171
],
[
188,
173
],
[
185,
178
],
[
200,
178
],
[
203,
178
],
[
206,
179
],
[
194,
179
],
[
191,
179
],
[
181,
182
],
[
184,
185
],
[
187,
188
],
[
190,
191
],
[
193,
194
],
[
196,
197
],
[
199,
200
],
[
202,
203
],
[
205,
206
],
[
211,
209
],
[
211,
212
]
] | [
"N = int(input())\nT = 1\nA = 1\nfor i in range(N):\n Tk = [0,0]\n Ak = [0,0]\n Tn,An = map(int,input().rstrip().split(\" \"))\n if T % Tn == 0:\n Tk[0] = T\n else:\n Tk[0] = (T // Tn + 1) * Tn\n Ak[0] = (Tk[0] // Tn) * An\n if Ak[0] < A:\n Ak[0] = 10 ** 18 + 1\n\n if A % An == 0:\n Ak[1] = A\n else:\n Ak[1] = (A // An + 1) * An\n Tk[1] = (Ak[1] // An) * Tn\n if Tk[1] < T:\n Tk[1] = 10 ** 18 + 1\n \n if Tk[0] + Ak[0] <= Tk[1] + Ak[1]:\n T = Tk[0]\n A = Ak[0]\n else:\n T = Tk[1]\n A = Ak[1]\nprint(A + T)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T = 1",
"T",
"1",
"A = 1",
"A",
"1",
"for i in range(N):\n Tk = [0,0]\n Ak = [0,0]\n Tn,An = map(int,input().rstrip().split(\" \"))\n if T % Tn == 0:\n Tk[0] = T\n else:\n Tk[0] = (T // Tn + 1) * Tn\n Ak[0] = (Tk[0] // Tn) * An\n if Ak[0] < A:\n Ak[0] = 10 ** 18 + 1\n\n if A % An == 0:\n Ak[1] = A\n else:\n Ak[1] = (A // An + 1) * An\n Tk[1] = (Ak[1] // An) * Tn\n if Tk[1] < T:\n Tk[1] = 10 ** 18 + 1\n \n if Tk[0] + Ak[0] <= Tk[1] + Ak[1]:\n T = Tk[0]\n A = Ak[0]\n else:\n T = Tk[1]\n A = Ak[1]",
"i",
"range(N)",
"range",
"N",
"Tk = [0,0]",
"Tk",
"[0,0]",
"0",
"0",
"Ak = [0,0]",
"Ak",
"[0,0]",
"0",
"0",
"Tn,An = map(int,input().rstrip().split(\" \"))",
"Tn",
"map(int,input().rstrip().split(\" \"))",
"map",
"int",
"input().rstrip().split(\" \")",
"().rstrip().split",
"().rstrip()",
"().rstrip",
"()",
"input",
"rstrip",
"split",
"\" \"",
"An",
"if T % Tn == 0:\n Tk[0] = T\n else:\n Tk[0] = (T // Tn + 1) * Tn\n ",
"T % Tn == 0",
"T % Tn",
"T",
"Tn",
"0",
"Tk[0] = T",
"Tk[0]",
"Tk",
"0",
"T",
"Tk[0] = (T // Tn + 1) * Tn",
"Tk[0]",
"Tk",
"0",
"(T // Tn + 1) * Tn",
"T // Tn + 1",
"T // Tn",
"T",
"Tn",
"1",
"Tn",
"Ak[0] = (Tk[0] // Tn) * An",
"Ak[0]",
"Ak",
"0",
"(Tk[0] // Tn) * An",
"Tk[0] // Tn",
"Tk[0]",
"Tk",
"0",
"Tn",
"An",
"if Ak[0] < A:\n Ak[0] = 10 ** 18 + 1\n\n ",
"Ak[0] < A",
"Ak[0]",
"Ak",
"0",
"A",
"Ak[0] = 10 ** 18 + 1",
"Ak[0]",
"Ak",
"0",
"10 ** 18 + 1",
"10 ** 18",
"10",
"18",
"1",
"if A % An == 0:\n Ak[1] = A\n else:\n Ak[1] = (A // An + 1) * An\n ",
"A % An == 0",
"A % An",
"A",
"An",
"0",
"Ak[1] = A",
"Ak[1]",
"Ak",
"1",
"A",
"Ak[1] = (A // An + 1) * An",
"Ak[1]",
"Ak",
"1",
"(A // An + 1) * An",
"A // An + 1",
"A // An",
"A",
"An",
"1",
"An",
"Tk[1] = (Ak[1] // An) * Tn",
"Tk[1]",
"Tk",
"1",
"(Ak[1] // An) * Tn",
"Ak[1] // An",
"Ak[1]",
"Ak",
"1",
"An",
"Tn",
"if Tk[1] < T:\n Tk[1] = 10 ** 18 + 1\n \n ",
"Tk[1] < T",
"Tk[1]",
"Tk",
"1",
"T",
"Tk[1] = 10 ** 18 + 1",
"Tk[1]",
"Tk",
"1",
"10 ** 18 + 1",
"10 ** 18",
"10",
"18",
"1",
"if Tk[0] + Ak[0] <= Tk[1] + Ak[1]:\n T = Tk[0]\n A = Ak[0]\n else:\n T = Tk[1]\n A = Ak[1]",
"Tk[0] + Ak[0] <= Tk[1] + Ak[1]",
"Tk[0] + Ak[0]",
"Tk[0]",
"Tk",
"0",
"Ak[0]",
"Ak",
"0",
"Tk[1] + Ak[1]",
"Tk[1]",
"Tk",
"1",
"Ak[1]",
"Ak",
"1",
"T = Tk[0]",
"T",
"Tk[0]",
"Tk",
"0",
"A = Ak[0]",
"A",
"Ak[0]",
"Ak",
"0",
"T = Tk[1]",
"T",
"Tk[1]",
"Tk",
"1",
"A = Ak[1]",
"A",
"Ak[1]",
"Ak",
"1",
"print(A + T)",
"print",
"A + T",
"A",
"T",
"Tk = [0,0]",
"[0,0]",
"Tk",
"A = Ak[1]",
"Ak[1]",
"A",
"Ak = [0,0]",
"[0,0]",
"Ak",
"T = 1",
"1",
"T",
"T = Tk[0]",
"Tk[0]",
"T",
"N = int(input())",
"int(input())",
"N",
"A = Ak[0]",
"Ak[0]",
"A",
"A = 1",
"1",
"A",
"T = Tk[1]",
"Tk[1]",
"T",
"Tn,An = map(int,input().rstrip().split(\" \"))",
"map(int,input().rstrip().split(\" \"))",
"Tn",
"An = map(int,input().rstrip().split(\" \"))",
"map(int,input().rstrip().split(\" \"))",
"An"
] | N = int(input())
T = 1
A = 1
for i in range(N):
Tk = [0,0]
Ak = [0,0]
Tn,An = map(int,input().rstrip().split(" "))
if T % Tn == 0:
Tk[0] = T
else:
Tk[0] = (T // Tn + 1) * Tn
Ak[0] = (Tk[0] // Tn) * An
if Ak[0] < A:
Ak[0] = 10 ** 18 + 1
if A % An == 0:
Ak[1] = A
else:
Ak[1] = (A // An + 1) * An
Tk[1] = (Ak[1] // An) * Tn
if Tk[1] < T:
Tk[1] = 10 ** 18 + 1
if Tk[0] + Ak[0] <= Tk[1] + Ak[1]:
T = Tk[0]
A = Ak[0]
else:
T = Tk[1]
A = Ak[1]
print(A + T) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
13,
17,
28,
13,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
13,
0,
13,
13,
9,
14,
2,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
13,
0,
13,
13,
14,
2,
13,
13,
0,
13,
4,
13,
2,
2,
13,
13,
13,
2,
2,
13,
13,
13,
42,
2,
2,
13,
13,
2,
2,
13,
2,
13,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
13,
2,
13,
13,
0,
13,
4,
13,
2,
2,
13,
13,
13,
2,
2,
13,
13,
13,
42,
2,
2,
13,
13,
2,
2,
13,
2,
13,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13
] | [
[
185,
2
],
[
10,
9
],
[
186,
12
],
[
197,
25
],
[
179,
28
],
[
176,
30
],
[
180,
39
],
[
165,
39
],
[
156,
39
],
[
162,
39
],
[
192,
39
],
[
177,
42
],
[
189,
42
],
[
159,
42
],
[
183,
42
],
[
195,
42
],
[
191,
45
],
[
194,
48
],
[
167,
56
],
[
192,
59
],
[
180,
59
],
[
165,
59
],
[
156,
59
],
[
162,
59
],
[
195,
60
],
[
177,
60
],
[
189,
60
],
[
159,
60
],
[
183,
60
],
[
161,
62
],
[
168,
63
],
[
182,
65
],
[
168,
66
],
[
203,
72
],
[
192,
77
],
[
180,
77
],
[
165,
77
],
[
156,
77
],
[
162,
77
],
[
195,
82
],
[
177,
82
],
[
189,
82
],
[
159,
82
],
[
183,
82
],
[
204,
88
],
[
201,
88
],
[
174,
88
],
[
171,
88
],
[
192,
89
],
[
180,
89
],
[
165,
89
],
[
156,
89
],
[
162,
89
],
[
204,
94
],
[
201,
94
],
[
174,
94
],
[
171,
94
],
[
195,
96
],
[
177,
96
],
[
189,
96
],
[
159,
96
],
[
183,
96
],
[
200,
98
],
[
155,
101
],
[
201,
102
],
[
204,
102
],
[
174,
102
],
[
171,
102
],
[
158,
104
],
[
156,
108
],
[
162,
108
],
[
192,
108
],
[
180,
108
],
[
165,
108
],
[
170,
111
],
[
195,
116
],
[
177,
116
],
[
189,
116
],
[
159,
116
],
[
183,
116
],
[
192,
121
],
[
180,
121
],
[
165,
121
],
[
156,
121
],
[
162,
121
],
[
171,
127
],
[
174,
127
],
[
201,
127
],
[
204,
127
],
[
195,
128
],
[
177,
128
],
[
189,
128
],
[
159,
128
],
[
183,
128
],
[
171,
133
],
[
174,
133
],
[
201,
133
],
[
204,
133
],
[
192,
135
],
[
180,
135
],
[
165,
135
],
[
156,
135
],
[
162,
135
],
[
173,
137
],
[
188,
140
],
[
174,
141
],
[
201,
141
],
[
204,
141
],
[
171,
141
],
[
164,
143
],
[
189,
147
],
[
159,
147
],
[
183,
147
],
[
195,
147
],
[
177,
147
],
[
189,
152
],
[
159,
152
],
[
183,
152
],
[
195,
152
],
[
177,
152
],
[
165,
153
],
[
156,
153
],
[
162,
153
],
[
192,
153
],
[
180,
153
],
[
201,
155
],
[
204,
155
],
[
174,
155
],
[
171,
155
],
[
155,
156
],
[
158,
159
],
[
168,
161
],
[
161,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
],
[
168,
182
],
[
182,
183
],
[
185,
186
],
[
174,
188
],
[
201,
188
],
[
204,
188
],
[
171,
188
],
[
188,
189
],
[
191,
192
],
[
194,
195
],
[
197,
198
],
[
200,
201
],
[
203,
204
]
] | [
"N = int(input())\nTA = [list(map(int, input().split())) for _ in range(N)]\n\nT, A = 0, 0\nfor t, a in TA:\n if T == 0 and A == 0:\n T = t\n A = a\n continue\n if t == a:\n M = max(T, A)\n T = M\n A = M\n elif t < a:\n n = max((T // t) * t, (A // a) * t)\n while n < T or a * (n // t) < A:\n n += t\n T = n\n A = a * (T // t)\n else:\n n = max((A // a) * a, (T // t) * a)\n while n < A or t * (n // a) < T:\n n += a\n A = n\n T = t * (A // a)\nprint(A + T)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int, input().split())) for _ in range(N)]",
"TA",
"[list(map(int, input().split())) for _ in range(N)]",
"T, A = 0, 0",
"T",
"0",
"A",
"0",
"for t, a in TA:\n if T == 0 and A == 0:\n T = t\n A = a\n continue\n if t == a:\n M = max(T, A)\n T = M\n A = M\n elif t < a:\n n = max((T // t) * t, (A // a) * t)\n while n < T or a * (n // t) < A:\n n += t\n T = n\n A = a * (T // t)\n else:\n n = max((A // a) * a, (T // t) * a)\n while n < A or t * (n // a) < T:\n n += a\n A = n\n T = t * (A // a)",
"t",
"a",
"TA",
"if T == 0 and A == 0:\n T = t\n A = a\n continue\n ",
"T == 0 and A == 0",
"T == 0",
"T",
"0",
"A == 0",
"A",
"0",
"T = t",
"T",
"t",
"A = a",
"A",
"a",
"continue",
"if t == a:\n M = max(T, A)\n T = M\n A = M\n elif t < a:\n n = max((T // t) * t, (A // a) * t)\n while n < T or a * (n // t) < A:\n n += t\n T = n\n A = a * (T // t)\n else:\n n = max((A // a) * a, (T // t) * a)\n while n < A or t * (n // a) < T:\n n += a\n A = n\n T = t * (A // a)",
"t == a",
"t",
"a",
"M = max(T, A)",
"M",
"max(T, A)",
"max",
"T",
"A",
"T = M",
"T",
"M",
"A = M",
"A",
"M",
"elif t < a:\n n = max((T // t) * t, (A // a) * t)\n while n < T or a * (n // t) < A:\n n += t\n T = n\n A = a * (T // t)\n ",
"t < a",
"t",
"a",
"n = max((T // t) * t, (A // a) * t)",
"n",
"max((T // t) * t, (A // a) * t)",
"max",
"(T // t) * t",
"T // t",
"T",
"t",
"t",
"(A // a) * t",
"A // a",
"A",
"a",
"t",
"while n < T or a * (n // t) < A:\n n += t\n ",
"n < T or a * (n // t) < A",
"n < T",
"n",
"T",
"a * (n // t) < A",
"a * (n // t)",
"a",
"n // t",
"n",
"t",
"A",
"n += t",
"n",
"t",
"T = n",
"T",
"n",
"A = a * (T // t)",
"A",
"a * (T // t)",
"a",
"T // t",
"T",
"t",
"n = max((A // a) * a, (T // t) * a)",
"n",
"max((A // a) * a, (T // t) * a)",
"max",
"(A // a) * a",
"A // a",
"A",
"a",
"a",
"(T // t) * a",
"T // t",
"T",
"t",
"a",
"while n < A or t * (n // a) < T:\n n += a\n ",
"n < A or t * (n // a) < T",
"n < A",
"n",
"A",
"t * (n // a) < T",
"t * (n // a)",
"t",
"n // a",
"n",
"a",
"T",
"n += a",
"n",
"a",
"A = n",
"A",
"n",
"T = t * (A // a)",
"T",
"t * (A // a)",
"t",
"A // a",
"A",
"a",
"print(A + T)",
"print",
"A + T",
"A",
"T",
"T = n",
"n",
"T",
"A = a * (T // t)",
"a * (T // t)",
"A",
"T = M",
"M",
"T",
"T = t * (A // a)",
"t * (A // a)",
"T",
"M = max(T, A)",
"max(T, A)",
"M",
"n = max((A // a) * a, (T // t) * a)",
"max((A // a) * a, (T // t) * a)",
"n",
"n += a",
"a",
"n",
"A = 0, 0",
"0",
"A",
"T, A = 0, 0",
"0",
"T",
"A = M",
"M",
"A",
"N = int(input())",
"int(input())",
"N",
"A = n",
"n",
"A",
"T = t",
"t",
"T",
"A = a",
"a",
"A",
"TA = [list(map(int, input().split())) for _ in range(N)]",
"[list(map(int, input().split())) for _ in range(N)]",
"TA",
"n += t",
"t",
"n",
"n = max((T // t) * t, (A // a) * t)",
"max((T // t) * t, (A // a) * t)",
"n"
] | N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
T, A = 0, 0
for t, a in TA:
if T == 0 and A == 0:
T = t
A = a
continue
if t == a:
M = max(T, A)
T = M
A = M
elif t < a:
n = max((T // t) * t, (A // a) * t)
while n < T or a * (n // t) < A:
n += t
T = n
A = a * (T // t)
else:
n = max((A // a) * a, (T // t) * a)
while n < A or t * (n // a) < T:
n += a
A = n
T = t * (A // a)
print(A + T) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
4,
13,
39,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] | [
[
72,
2
],
[
93,
8
],
[
75,
10
],
[
14,
13
],
[
73,
16
],
[
90,
18
],
[
90,
27
],
[
69,
29
],
[
94,
33
],
[
85,
33
],
[
79,
34
],
[
79,
36
],
[
87,
38
],
[
76,
42
],
[
97,
42
],
[
91,
43
],
[
91,
45
],
[
81,
47
],
[
84,
54
],
[
79,
56
],
[
82,
57
],
[
96,
59
],
[
91,
61
],
[
82,
62
],
[
85,
66
],
[
94,
66
],
[
97,
67
],
[
76,
67
],
[
69,
70
],
[
72,
73
],
[
75,
76
],
[
90,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
],
[
96,
97
]
] | [
"N = int(input())\nT, A = 1, 1\nfor i in range(N):\n t, a = map(int, input().split())\n # それぞれ一番近い倍数をもとめる\n tt = (T + t - 1) // t\n at = (A + a - 1) // a\n # 大きい方で掛ける\n mt = max([tt, at])\n T = t * mt\n A = a * mt\nprint(T + A)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"T, A = 1, 1",
"T",
"1",
"A",
"1",
"for i in range(N):\n t, a = map(int, input().split())\n # それぞれ一番近い倍数をもとめる\n tt = (T + t - 1) // t\n at = (A + a - 1) // a\n # 大きい方で掛ける\n mt = max([tt, at])\n T = t * mt\n A = a * mt",
"i",
"range(N)",
"range",
"N",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"tt = (T + t - 1) // t",
"tt",
"(T + t - 1) // t",
"T + t - 1",
"T + t",
"T",
"t",
"1",
"t",
"at = (A + a - 1) // a",
"at",
"(A + a - 1) // a",
"A + a - 1",
"A + a",
"A",
"a",
"1",
"a",
"mt = max([tt, at])",
"mt",
"max([tt, at])",
"max",
"[tt, at]",
"tt",
"at",
"T = t * mt",
"T",
"t * mt",
"t",
"mt",
"A = a * mt",
"A",
"a * mt",
"a",
"mt",
"print(T + A)",
"print",
"T + A",
"T",
"A",
"tt = (T + t - 1) // t",
"(T + t - 1) // t",
"tt",
"N = int(input())",
"int(input())",
"N",
"A = 1, 1",
"1",
"A",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"mt = max([tt, at])",
"max([tt, at])",
"mt",
"T = t * mt",
"t * mt",
"T",
"at = (A + a - 1) // a",
"(A + a - 1) // a",
"at",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"T, A = 1, 1",
"1",
"T",
"A = a * mt",
"a * mt",
"A"
] | N = int(input())
T, A = 1, 1
for i in range(N):
t, a = map(int, input().split())
# それぞれ一番近い倍数をもとめる
tt = (T + t - 1) // t
at = (A + a - 1) // a
# 大きい方で掛ける
mt = max([tt, at])
T = t * mt
A = a * mt
print(T + A)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
40,
13,
18,
18,
13,
13,
17,
40,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
13,
40,
2,
13,
40,
18,
18,
13,
13,
17,
0,
13,
40,
2,
13,
40,
18,
18,
13,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
18,
18,
13,
13,
17,
0,
13,
2,
13,
18,
18,
13,
13,
17,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
40,
13,
10,
2,
13,
10,
2,
13,
10,
40,
13,
10,
17,
13,
10,
17,
13,
10,
18,
13,
10,
18,
13,
10,
13,
13
] | [
[
120,
2
],
[
10,
9
],
[
121,
12
],
[
150,
25
],
[
141,
28
],
[
138,
31
],
[
35,
34
],
[
121,
37
],
[
142,
41
],
[
130,
41
],
[
145,
41
],
[
151,
44
],
[
34,
45
],
[
139,
48
],
[
133,
48
],
[
148,
48
],
[
151,
51
],
[
34,
52
],
[
144,
55
],
[
151,
58
],
[
34,
59
],
[
147,
62
],
[
151,
65
],
[
34,
66
],
[
135,
69
],
[
142,
72
],
[
130,
72
],
[
145,
72
],
[
151,
76
],
[
34,
77
],
[
126,
80
],
[
139,
83
],
[
133,
83
],
[
148,
83
],
[
151,
87
],
[
34,
88
],
[
123,
91
],
[
136,
94
],
[
127,
95
],
[
129,
97
],
[
124,
99
],
[
151,
102
],
[
34,
103
],
[
132,
106
],
[
124,
108
],
[
151,
111
],
[
34,
112
],
[
130,
117
],
[
145,
117
],
[
142,
117
],
[
133,
118
],
[
148,
118
],
[
139,
118
],
[
120,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
]
] | [
"n = int(input())\na = [list(map(int, input().split())) for i in range(n)]\nx=0\ny=0\nfor i in range(n):\n if x<=a[i][0] and y<=a[i][1]:\n x=a[i][0]\n y=a[i][1]\n else:\n v=-(x//-a[i][0])\n w=-(y//-a[i][1])\n u=max(v,w)\n x=u*a[i][0]\n y=u*a[i][1]\n\nprint(x+y)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int, input().split())) for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a = [list(map(int, input().split())) for i in range(n)]",
"a",
"[list(map(int, input().split())) for i in range(n)]",
"x=0",
"x",
"0",
"y=0",
"y",
"0",
"for i in range(n):\n if x<=a[i][0] and y<=a[i][1]:\n x=a[i][0]\n y=a[i][1]\n else:\n v=-(x//-a[i][0])\n w=-(y//-a[i][1])\n u=max(v,w)\n x=u*a[i][0]\n y=u*a[i][1]",
"i",
"range(n)",
"range",
"n",
"if x<=a[i][0] and y<=a[i][1]:\n x=a[i][0]\n y=a[i][1]\n else:\n v=-(x//-a[i][0])\n w=-(y//-a[i][1])\n u=max(v,w)\n x=u*a[i][0]\n y=u*a[i][1]",
"x<=a[i][0] and y<=a[i][1]",
"x<=a[i][0]",
"x",
"a[i][0]",
"[i]",
"a",
"i",
"0",
"y<=a[i][1]",
"y",
"a[i][1]",
"[i]",
"a",
"i",
"1",
"x=a[i][0]",
"x",
"a[i][0]",
"[i]",
"a",
"i",
"0",
"y=a[i][1]",
"y",
"a[i][1]",
"[i]",
"a",
"i",
"1",
"v=-(x//-a[i][0])",
"v",
"-(x//-a[i][0])",
"x//-a[i][0]",
"x",
"-a[i][0]",
"a[i][0]",
"[i]",
"a",
"i",
"0",
"w=-(y//-a[i][1])",
"w",
"-(y//-a[i][1])",
"y//-a[i][1]",
"y",
"-a[i][1]",
"a[i][1]",
"[i]",
"a",
"i",
"1",
"u=max(v,w)",
"u",
"max(v,w)",
"max",
"v",
"w",
"x=u*a[i][0]",
"x",
"u*a[i][0]",
"u",
"a[i][0]",
"[i]",
"a",
"i",
"0",
"y=u*a[i][1]",
"y",
"u*a[i][1]",
"u",
"a[i][1]",
"[i]",
"a",
"i",
"1",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"n = int(input())",
"int(input())",
"n",
"u=max(v,w)",
"max(v,w)",
"u",
"w=-(y//-a[i][1])",
"-(y//-a[i][1])",
"w",
"x=u*a[i][0]",
"u*a[i][0]",
"x",
"y=u*a[i][1]",
"u*a[i][1]",
"y",
"v=-(x//-a[i][0])",
"-(x//-a[i][0])",
"v",
"y=0",
"0",
"y",
"x=0",
"0",
"x",
"x=a[i][0]",
"a[i][0]",
"x",
"y=a[i][1]",
"a[i][1]",
"y",
"a = [list(map(int, input().split())) for i in range(n)]",
"[list(map(int, input().split())) for i in range(n)]",
"a"
] | n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x=0
y=0
for i in range(n):
if x<=a[i][0] and y<=a[i][1]:
x=a[i][0]
y=a[i][1]
else:
v=-(x//-a[i][0])
w=-(y//-a[i][1])
u=max(v,w)
x=u*a[i][0]
y=u*a[i][1]
print(x+y) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13
] | [
[
101,
2
],
[
122,
8
],
[
122,
18
],
[
21,
20
],
[
102,
24
],
[
104,
27
],
[
104,
37
],
[
105,
41
],
[
93,
42
],
[
126,
42
],
[
120,
42
],
[
96,
44
],
[
123,
45
],
[
99,
45
],
[
108,
45
],
[
119,
47
],
[
105,
48
],
[
107,
50
],
[
96,
51
],
[
116,
53
],
[
93,
57
],
[
126,
57
],
[
120,
57
],
[
105,
58
],
[
105,
60
],
[
113,
62
],
[
123,
66
],
[
99,
66
],
[
108,
66
],
[
96,
67
],
[
96,
69
],
[
110,
71
],
[
117,
74
],
[
114,
75
],
[
125,
77
],
[
111,
79
],
[
105,
80
],
[
98,
82
],
[
111,
84
],
[
96,
85
],
[
126,
89
],
[
120,
89
],
[
93,
89
],
[
99,
90
],
[
108,
90
],
[
123,
90
],
[
122,
93
],
[
104,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
96,
107
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
105,
119
],
[
119,
120
],
[
122,
123
],
[
125,
126
]
] | [
"N = int(input())\nt, a = map(int, input().split(' '))\n\nfor _ in range(N - 1):\n nt, na = map(int, input().split(' '))\n if nt >= t and na >= a:\n t = nt\n a = na\n else:\n tr = (t + nt - 1) // nt\n ar = (a + na - 1) // na\n r = max(tr, ar)\n t = r * nt\n a = r * na\n\nprint(t + a)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"t, a = map(int, input().split(' '))",
"t",
"map(int, input().split(' '))",
"map",
"int",
"input().split(' ')",
"().split",
"()",
"input",
"split",
"' '",
"a",
"for _ in range(N - 1):\n nt, na = map(int, input().split(' '))\n if nt >= t and na >= a:\n t = nt\n a = na\n else:\n tr = (t + nt - 1) // nt\n ar = (a + na - 1) // na\n r = max(tr, ar)\n t = r * nt\n a = r * na",
"_",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"nt, na = map(int, input().split(' '))",
"nt",
"map(int, input().split(' '))",
"map",
"int",
"input().split(' ')",
"().split",
"()",
"input",
"split",
"' '",
"na",
"if nt >= t and na >= a:\n t = nt\n a = na\n else:\n tr = (t + nt - 1) // nt\n ar = (a + na - 1) // na\n r = max(tr, ar)\n t = r * nt\n a = r * na",
"nt >= t and na >= a",
"nt >= t",
"nt",
"t",
"na >= a",
"na",
"a",
"t = nt",
"t",
"nt",
"a = na",
"a",
"na",
"tr = (t + nt - 1) // nt",
"tr",
"(t + nt - 1) // nt",
"t + nt - 1",
"t + nt",
"t",
"nt",
"1",
"nt",
"ar = (a + na - 1) // na",
"ar",
"(a + na - 1) // na",
"a + na - 1",
"a + na",
"a",
"na",
"1",
"na",
"r = max(tr, ar)",
"r",
"max(tr, ar)",
"max",
"tr",
"ar",
"t = r * nt",
"t",
"r * nt",
"r",
"nt",
"a = r * na",
"a",
"r * na",
"r",
"na",
"print(t + a)",
"print",
"t + a",
"t",
"a",
"t, a = map(int, input().split(' '))",
"map(int, input().split(' '))",
"t",
"na = map(int, input().split(' '))",
"map(int, input().split(' '))",
"na",
"a = r * na",
"r * na",
"a",
"N = int(input())",
"int(input())",
"N",
"nt, na = map(int, input().split(' '))",
"map(int, input().split(' '))",
"nt",
"a = na",
"na",
"a",
"r = max(tr, ar)",
"max(tr, ar)",
"r",
"ar = (a + na - 1) // na",
"(a + na - 1) // na",
"ar",
"tr = (t + nt - 1) // nt",
"(t + nt - 1) // nt",
"tr",
"t = nt",
"nt",
"t",
"a = map(int, input().split(' '))",
"map(int, input().split(' '))",
"a",
"t = r * nt",
"r * nt",
"t"
] | N = int(input())
t, a = map(int, input().split(' '))
for _ in range(N - 1):
nt, na = map(int, input().split(' '))
if nt >= t and na >= a:
t = nt
a = na
else:
tr = (t + nt - 1) // nt
ar = (a + na - 1) // na
r = max(tr, ar)
t = r * nt
a = r * na
print(t + a)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
18,
18,
13,
17,
17,
0,
13,
18,
18,
13,
17,
17,
28,
13,
13,
0,
13,
4,
13,
2,
2,
13,
18,
13,
17,
2,
2,
13,
18,
13,
17,
17,
2,
2,
13,
18,
13,
17,
2,
2,
13,
18,
13,
17,
17,
0,
13,
2,
18,
13,
17,
13,
0,
13,
2,
18,
13,
17,
13,
4,
13,
2,
13,
13,
10,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13
] | [
[
103,
2
],
[
10,
9
],
[
104,
12
],
[
94,
25
],
[
109,
28
],
[
95,
31
],
[
106,
35
],
[
95,
38
],
[
43,
42
],
[
95,
42
],
[
112,
45
],
[
110,
50
],
[
98,
50
],
[
42,
52
],
[
110,
56
],
[
98,
56
],
[
42,
58
],
[
107,
63
],
[
101,
63
],
[
42,
65
],
[
107,
69
],
[
101,
69
],
[
42,
71
],
[
97,
75
],
[
42,
78
],
[
113,
80
],
[
100,
82
],
[
42,
85
],
[
113,
87
],
[
98,
91
],
[
110,
91
],
[
101,
92
],
[
107,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
]
] | [
"n = int(input())\n\ntlist = [list(map(int,input().split())) for i in range(n)]\n\na = tlist[0][0]\nb = tlist[0][1]\n\nfor t in tlist:\n multi = max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))\n # print('multi', multi)\n # print('a b', a, b)\n a = t[0]*multi\n b = t[1]*multi\n\nprint(a + b)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"list(map(int,input().split())) for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"tlist = [list(map(int,input().split())) for i in range(n)]",
"tlist",
"[list(map(int,input().split())) for i in range(n)]",
"a = tlist[0][0]",
"a",
"tlist[0][0]",
"[0]",
"tlist",
"0",
"0",
"b = tlist[0][1]",
"b",
"tlist[0][1]",
"[0]",
"tlist",
"0",
"1",
"for t in tlist:\n multi = max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))\n # print('multi', multi)\n # print('a b', a, b)\n a = t[0]*multi\n b = t[1]*multi",
"t",
"tlist",
"multi = max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))",
"multi",
"max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))",
"max",
"(a//t[0]) + (a%t[0] > 0)",
"a//t[0]",
"a",
"t[0]",
"t",
"0",
"a%t[0] > 0",
"a%t[0]",
"a",
"t[0]",
"t",
"0",
"0",
"(b//t[1]) + (b%t[1] > 0)",
"b//t[1]",
"b",
"t[1]",
"t",
"1",
"b%t[1] > 0",
"b%t[1]",
"b",
"t[1]",
"t",
"1",
"0",
"a = t[0]*multi",
"a",
"t[0]*multi",
"t[0]",
"t",
"0",
"multi",
"b = t[1]*multi",
"b",
"t[1]*multi",
"t[1]",
"t",
"1",
"multi",
"print(a + b)",
"print",
"a + b",
"a",
"b",
"tlist = [list(map(int,input().split())) for i in range(n)]",
"[list(map(int,input().split())) for i in range(n)]",
"tlist",
"a = t[0]*multi",
"t[0]*multi",
"a",
"b = t[1]*multi",
"t[1]*multi",
"b",
"n = int(input())",
"int(input())",
"n",
"b = tlist[0][1]",
"tlist[0][1]",
"b",
"a = tlist[0][0]",
"tlist[0][0]",
"a",
"multi = max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))",
"max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))",
"multi"
] | n = int(input())
tlist = [list(map(int,input().split())) for i in range(n)]
a = tlist[0][0]
b = tlist[0][1]
for t in tlist:
multi = max((a//t[0]) + (a%t[0] > 0), (b//t[1]) + (b%t[1] > 0))
# print('multi', multi)
# print('a b', a, b)
a = t[0]*multi
b = t[1]*multi
print(a + b)
|
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
40,
2,
40,
13,
18,
18,
13,
13,
17,
40,
2,
40,
13,
18,
18,
13,
13,
17,
0,
13,
2,
18,
18,
13,
13,
17,
13,
0,
13,
2,
18,
18,
13,
13,
17,
13,
4,
13,
2,
13,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13
] | [
[
99,
2
],
[
10,
9
],
[
100,
12
],
[
84,
25
],
[
93,
28
],
[
87,
31
],
[
35,
34
],
[
100,
37
],
[
90,
39
],
[
94,
45
],
[
97,
45
],
[
85,
48
],
[
34,
49
],
[
88,
54
],
[
103,
54
],
[
85,
57
],
[
34,
58
],
[
96,
61
],
[
85,
65
],
[
34,
66
],
[
91,
68
],
[
102,
70
],
[
85,
74
],
[
34,
75
],
[
91,
77
],
[
97,
81
],
[
94,
81
],
[
103,
82
],
[
88,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
]
] | [
"N = int(input())\nTA = [list(map(int,input().split())) for _ in range(N)]\nt = 1\na = 1\nfor i in range(N):\n x = max(-(-t // TA[i][0]),-(-a // TA[i][1]))\n t = TA[i][0] * x\n a = TA[i][1] * x\nprint(t + a)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"list(map(int,input().split())) for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"TA = [list(map(int,input().split())) for _ in range(N)]",
"TA",
"[list(map(int,input().split())) for _ in range(N)]",
"t = 1",
"t",
"1",
"a = 1",
"a",
"1",
"for i in range(N):\n x = max(-(-t // TA[i][0]),-(-a // TA[i][1]))\n t = TA[i][0] * x\n a = TA[i][1] * x",
"i",
"range(N)",
"range",
"N",
"x = max(-(-t // TA[i][0]),-(-a // TA[i][1]))",
"x",
"max(-(-t // TA[i][0]),-(-a // TA[i][1]))",
"max",
"-(-t // TA[i][0])",
"-t // TA[i][0]",
"-t",
"t",
"TA[i][0]",
"[i]",
"TA",
"i",
"0",
"-(-a // TA[i][1])",
"-a // TA[i][1]",
"-a",
"a",
"TA[i][1]",
"[i]",
"TA",
"i",
"1",
"t = TA[i][0] * x",
"t",
"TA[i][0] * x",
"TA[i][0]",
"[i]",
"TA",
"i",
"0",
"x",
"a = TA[i][1] * x",
"a",
"TA[i][1] * x",
"TA[i][1]",
"[i]",
"TA",
"i",
"1",
"x",
"print(t + a)",
"print",
"t + a",
"t",
"a",
"TA = [list(map(int,input().split())) for _ in range(N)]",
"[list(map(int,input().split())) for _ in range(N)]",
"TA",
"a = 1",
"1",
"a",
"x = max(-(-t // TA[i][0]),-(-a // TA[i][1]))",
"max(-(-t // TA[i][0]),-(-a // TA[i][1]))",
"x",
"t = 1",
"1",
"t",
"t = TA[i][0] * x",
"TA[i][0] * x",
"t",
"N = int(input())",
"int(input())",
"N",
"a = TA[i][1] * x",
"TA[i][1] * x",
"a"
] | N = int(input())
TA = [list(map(int,input().split())) for _ in range(N)]
t = 1
a = 1
for i in range(N):
x = max(-(-t // TA[i][0]),-(-a // TA[i][1]))
t = TA[i][0] * x
a = TA[i][1] * x
print(t + a) |
[
7,
0,
13,
17,
14,
2,
13,
17,
0,
13,
4,
13,
4,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
14,
2,
13,
17,
0,
13,
17,
0,
13,
39,
17,
17,
17,
17,
17,
0,
13,
39,
17,
17,
17,
17,
17,
0,
13,
17,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
2,
13,
18,
13,
2,
13,
17,
2,
13,
18,
13,
2,
13,
17,
0,
13,
4,
13,
2,
2,
2,
13,
13,
18,
13,
2,
13,
17,
17,
17,
0,
13,
2,
13,
18,
13,
2,
13,
17,
0,
13,
2,
13,
18,
13,
2,
13,
17,
0,
13,
4,
13,
2,
2,
2,
13,
13,
18,
13,
2,
13,
17,
17,
17,
0,
13,
2,
13,
18,
13,
2,
13,
17,
0,
13,
2,
13,
18,
13,
2,
13,
17,
4,
13,
2,
13,
13,
10,
2,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
39,
13,
10,
17,
13,
10,
39,
13
] | [
[
218,
2
],
[
219,
6
],
[
191,
9
],
[
221,
15
],
[
192,
19
],
[
185,
21
],
[
192,
25
],
[
28,
27
],
[
192,
30
],
[
35,
32
],
[
222,
33
],
[
27,
34
],
[
35,
43
],
[
186,
44
],
[
27,
45
],
[
219,
48
],
[
203,
51
],
[
230,
54
],
[
224,
62
],
[
227,
70
],
[
188,
73
],
[
231,
75
],
[
222,
75
],
[
212,
78
],
[
225,
80
],
[
186,
80
],
[
197,
83
],
[
87,
86
],
[
204,
90
],
[
192,
90
],
[
189,
95
],
[
183,
95
],
[
195,
95
],
[
231,
97
],
[
222,
97
],
[
86,
99
],
[
213,
102
],
[
216,
102
],
[
207,
102
],
[
225,
104
],
[
186,
104
],
[
86,
106
],
[
200,
109
],
[
189,
115
],
[
183,
115
],
[
195,
115
],
[
198,
116
],
[
231,
118
],
[
222,
118
],
[
86,
120
],
[
194,
125
],
[
201,
127
],
[
210,
127
],
[
231,
129
],
[
222,
129
],
[
86,
131
],
[
206,
134
],
[
201,
136
],
[
210,
136
],
[
225,
138
],
[
186,
138
],
[
86,
140
],
[
209,
143
],
[
213,
149
],
[
216,
149
],
[
207,
149
],
[
198,
150
],
[
225,
152
],
[
186,
152
],
[
86,
154
],
[
182,
159
],
[
210,
161
],
[
201,
161
],
[
231,
163
],
[
222,
163
],
[
86,
165
],
[
215,
168
],
[
210,
170
],
[
201,
170
],
[
225,
172
],
[
186,
172
],
[
86,
174
],
[
216,
179
],
[
207,
179
],
[
213,
179
],
[
183,
180
],
[
195,
180
],
[
189,
180
],
[
182,
183
],
[
185,
186
],
[
188,
189
],
[
191,
192
],
[
194,
195
],
[
197,
198
],
[
200,
201
],
[
203,
204
],
[
206,
207
],
[
209,
210
],
[
212,
213
],
[
215,
216
],
[
218,
219
],
[
221,
222
],
[
224,
225
],
[
227,
228
],
[
230,
231
]
] | [
"icase=0\nif icase==0:\n n=int(input())\n t=[0]*n\n a=[0]*n\n\n for i in range(n):\n t[i],a[i]=map(int,input().split())\nelif icase==1:\n n=5\n t=[3,48,31,231,3]\n a=[10,17,199,23,2]\n ans=6930\n\nti=t[0]\nai=a[0]\ndt=1\nfor i in range(n-1):\n if ti/t[i+1]>ai/a[i+1]:\n ii=max((ti-dt)//t[i+1]+1,1)\n ti=ii*t[i+1]\n ai=ii*a[i+1]\n else:\n ii=max((ai-dt)//a[i+1]+1,1)\n ti=ii*t[i+1]\n ai=ii*a[i+1]\n\nprint(ai+ti)\n ",
"icase=0",
"icase",
"0",
"if icase==0:\n n=int(input())\n t=[0]*n\n a=[0]*n\n\n for i in range(n):\n t[i],a[i]=map(int,input().split())\nelif icase==1:\n n=5\n t=[3,48,31,231,3]\n a=[10,17,199,23,2]\n ans=6930",
"icase==0",
"icase",
"0",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"t=[0]*n",
"t",
"[0]*n",
"[0]",
"0",
"n",
"a=[0]*n",
"a",
"[0]*n",
"[0]",
"0",
"n",
"for i in range(n):\n t[i],a[i]=map(int,input().split())",
"i",
"range(n)",
"range",
"n",
"t[i],a[i]=map(int,input().split())",
"t[i]",
"t",
"i",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a[i]",
"a",
"i",
"elif icase==1:\n n=5\n t=[3,48,31,231,3]\n a=[10,17,199,23,2]\n ans=6930",
"icase==1",
"icase",
"1",
"n=5",
"n",
"5",
"t=[3,48,31,231,3]",
"t",
"[3,48,31,231,3]",
"3",
"48",
"31",
"231",
"3",
"a=[10,17,199,23,2]",
"a",
"[10,17,199,23,2]",
"10",
"17",
"199",
"23",
"2",
"ans=6930",
"ans",
"6930",
"ti=t[0]",
"ti",
"t[0]",
"t",
"0",
"ai=a[0]",
"ai",
"a[0]",
"a",
"0",
"dt=1",
"dt",
"1",
"for i in range(n-1):\n if ti/t[i+1]>ai/a[i+1]:\n ii=max((ti-dt)//t[i+1]+1,1)\n ti=ii*t[i+1]\n ai=ii*a[i+1]\n else:\n ii=max((ai-dt)//a[i+1]+1,1)\n ti=ii*t[i+1]\n ai=ii*a[i+1]",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if ti/t[i+1]>ai/a[i+1]:\n ii=max((ti-dt)//t[i+1]+1,1)\n ti=ii*t[i+1]\n ai=ii*a[i+1]\n else:\n ii=max((ai-dt)//a[i+1]+1,1)\n ti=ii*t[i+1]\n ai=ii*a[i+1]",
"ti/t[i+1]>ai/a[i+1]",
"ti/t[i+1]",
"ti",
"t[i+1]",
"t",
"i+1",
"i",
"1",
"ai/a[i+1]",
"ai",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"ii=max((ti-dt)//t[i+1]+1,1)",
"ii",
"max((ti-dt)//t[i+1]+1,1)",
"max",
"(ti-dt)//t[i+1]+1",
"(ti-dt)//t[i+1]",
"ti-dt",
"ti",
"dt",
"t[i+1]",
"t",
"i+1",
"i",
"1",
"1",
"1",
"ti=ii*t[i+1]",
"ti",
"ii*t[i+1]",
"ii",
"t[i+1]",
"t",
"i+1",
"i",
"1",
"ai=ii*a[i+1]",
"ai",
"ii*a[i+1]",
"ii",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"ii=max((ai-dt)//a[i+1]+1,1)",
"ii",
"max((ai-dt)//a[i+1]+1,1)",
"max",
"(ai-dt)//a[i+1]+1",
"(ai-dt)//a[i+1]",
"ai-dt",
"ai",
"dt",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"1",
"1",
"ti=ii*t[i+1]",
"ti",
"ii*t[i+1]",
"ii",
"t[i+1]",
"t",
"i+1",
"i",
"1",
"ai=ii*a[i+1]",
"ai",
"ii*a[i+1]",
"ii",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"print(ai+ti)",
"print",
"ai+ti",
"ai",
"ti",
"ti=ii*t[i+1]",
"ii*t[i+1]",
"ti",
"a=[0]*n",
"[0]*n",
"a",
"ti=t[0]",
"t[0]",
"ti",
"n=int(input())",
"int(input())",
"n",
"ti=ii*t[i+1]",
"ii*t[i+1]",
"ti",
"dt=1",
"1",
"dt",
"ii=max((ti-dt)//t[i+1]+1,1)",
"max((ti-dt)//t[i+1]+1,1)",
"ii",
"n=5",
"5",
"n",
"ai=ii*a[i+1]",
"ii*a[i+1]",
"ai",
"ii=max((ai-dt)//a[i+1]+1,1)",
"max((ai-dt)//a[i+1]+1,1)",
"ii",
"ai=a[0]",
"a[0]",
"ai",
"ai=ii*a[i+1]",
"ii*a[i+1]",
"ai",
"icase=0",
"0",
"icase",
"t=[0]*n",
"[0]*n",
"t",
"a=[10,17,199,23,2]",
"[10,17,199,23,2]",
"a",
"ans=6930",
"6930",
"ans",
"t=[3,48,31,231,3]",
"[3,48,31,231,3]",
"t"
] | icase=0
if icase==0:
n=int(input())
t=[0]*n
a=[0]*n
for i in range(n):
t[i],a[i]=map(int,input().split())
elif icase==1:
n=5
t=[3,48,31,231,3]
a=[10,17,199,23,2]
ans=6930
ti=t[0]
ai=a[0]
dt=1
for i in range(n-1):
if ti/t[i+1]>ai/a[i+1]:
ii=max((ti-dt)//t[i+1]+1,1)
ti=ii*t[i+1]
ai=ii*a[i+1]
else:
ii=max((ai-dt)//a[i+1]+1,1)
ti=ii*t[i+1]
ai=ii*a[i+1]
print(ai+ti)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
40,
2,
40,
13,
13,
13,
40,
2,
40,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
40,
13,
10,
17,
13,
10,
17,
13,
10,
40,
13,
10,
4,
13,
10,
4,
13
] | [
[
62,
2
],
[
77,
8
],
[
80,
10
],
[
14,
13
],
[
63,
16
],
[
89,
18
],
[
89,
27
],
[
83,
29
],
[
78,
33
],
[
72,
33
],
[
87,
34
],
[
74,
35
],
[
81,
39
],
[
66,
39
],
[
90,
40
],
[
68,
42
],
[
84,
45
],
[
75,
46
],
[
71,
48
],
[
87,
50
],
[
69,
51
],
[
65,
52
],
[
90,
54
],
[
69,
55
],
[
72,
59
],
[
78,
59
],
[
66,
60
],
[
81,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
89,
87
],
[
89,
90
]
] | [
"n = int(input())\nnt, na = 1, 1\nfor _ in range(n):\n t, a = map(int, input().split())\n x, y = -(-nt//t), -(-na//a)\n m = max(x, y)\n nt, na = t*m, a*m\nprint(nt+na)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"nt, na = 1, 1",
"nt",
"1",
"na",
"1",
"for _ in range(n):\n t, a = map(int, input().split())\n x, y = -(-nt//t), -(-na//a)\n m = max(x, y)\n nt, na = t*m, a*m",
"_",
"range(n)",
"range",
"n",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"x, y = -(-nt//t), -(-na//a)",
"x",
"-(-nt//t)",
"-nt//t",
"-nt",
"nt",
"t",
"y",
"-(-na//a)",
"-na//a",
"-na",
"na",
"a",
"m = max(x, y)",
"m",
"max(x, y)",
"max",
"x",
"y",
"nt, na = t*m, a*m",
"nt",
"t*m",
"t",
"m",
"na",
"a*m",
"a",
"m",
"print(nt+na)",
"print",
"nt+na",
"nt",
"na",
"n = int(input())",
"int(input())",
"n",
"na = t*m, a*m",
"a*m",
"na",
"m = max(x, y)",
"max(x, y)",
"m",
"nt, na = t*m, a*m",
"t*m",
"nt",
"y = -(-nt//t), -(-na//a)",
"-(-na//a)",
"y",
"nt, na = 1, 1",
"1",
"nt",
"na = 1, 1",
"1",
"na",
"x, y = -(-nt//t), -(-na//a)",
"-(-nt//t)",
"x",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"a = map(int, input().split())",
"map(int, input().split())",
"a"
] | n = int(input())
nt, na = 1, 1
for _ in range(n):
t, a = map(int, input().split())
x, y = -(-nt//t), -(-na//a)
m = max(x, y)
nt, na = t*m, a*m
print(nt+na)
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
15,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
39,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
17,
18,
18,
13,
13,
17,
17,
2,
2,
2,
13,
17,
18,
18,
13,
13,
17,
17,
0,
13,
2,
18,
18,
13,
13,
17,
13,
0,
13,
2,
18,
18,
13,
13,
17,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
39,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
99,
2
],
[
108,
8
],
[
14,
13
],
[
100,
16
],
[
117,
18
],
[
117,
27
],
[
109,
30
],
[
96,
36
],
[
114,
39
],
[
43,
42
],
[
100,
45
],
[
120,
47
],
[
97,
53
],
[
103,
53
],
[
109,
57
],
[
42,
58
],
[
115,
64
],
[
112,
64
],
[
109,
68
],
[
42,
69
],
[
102,
73
],
[
109,
77
],
[
42,
78
],
[
121,
80
],
[
111,
82
],
[
109,
86
],
[
42,
87
],
[
121,
89
],
[
103,
93
],
[
97,
93
],
[
112,
94
],
[
115,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
117,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
]
] | [
"n=int(input())\nlists=[]\nimport math\nfor i in range(n):\n a,t=map(int,input().split())\n lists.append([a,t])\nx=1\ny=1\nfor i in range(n):\n j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)\n x=lists[i][0]*j\n y=lists[i][1]*j\nprint(x+y)",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"lists=[]",
"lists",
"[]",
"import math",
"math",
"for i in range(n):\n a,t=map(int,input().split())\n lists.append([a,t])",
"i",
"range(n)",
"range",
"n",
"a,t=map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"lists.append([a,t])",
"lists.append",
"lists",
"append",
"[a,t]",
"a",
"t",
"x=1",
"x",
"1",
"y=1",
"y",
"1",
"for i in range(n):\n j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)\n x=lists[i][0]*j\n y=lists[i][1]*j",
"i",
"range(n)",
"range",
"n",
"j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)",
"j",
"max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)",
"max",
"(x-1)//lists[i][0]+1",
"(x-1)//lists[i][0]",
"x-1",
"x",
"1",
"lists[i][0]",
"[i]",
"lists",
"i",
"0",
"1",
"(y-1)//lists[i][1]+1",
"(y-1)//lists[i][1]",
"y-1",
"y",
"1",
"lists[i][1]",
"[i]",
"lists",
"i",
"1",
"1",
"x=lists[i][0]*j",
"x",
"lists[i][0]*j",
"lists[i][0]",
"[i]",
"lists",
"i",
"0",
"j",
"y=lists[i][1]*j",
"y",
"lists[i][1]*j",
"lists[i][1]",
"[i]",
"lists",
"i",
"1",
"j",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"x=1",
"1",
"x",
"n=int(input())",
"int(input())",
"n",
"x=lists[i][0]*j",
"lists[i][0]*j",
"x",
"t=map(int,input().split())",
"map(int,input().split())",
"t",
"lists=[]",
"[]",
"lists",
"y=lists[i][1]*j",
"lists[i][1]*j",
"y",
"y=1",
"1",
"y",
"a,t=map(int,input().split())",
"map(int,input().split())",
"a",
"j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)",
"max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)",
"j"
] | n=int(input())
lists=[]
import math
for i in range(n):
a,t=map(int,input().split())
lists.append([a,t])
x=1
y=1
for i in range(n):
j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)
x=lists[i][0]*j
y=lists[i][1]*j
print(x+y) |
[
7,
12,
13,
14,
40,
2,
13,
13,
17,
29,
2,
13,
2,
13,
2,
13,
13,
29,
13,
23,
13,
23,
13,
0,
13,
39,
0,
13,
4,
13,
4,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
39,
13,
13,
0,
13,
18,
18,
13,
17,
17,
0,
13,
18,
18,
13,
17,
17,
28,
13,
4,
13,
17,
13,
14,
2,
40,
13,
18,
18,
13,
13,
17,
40,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
14,
2,
2,
13,
18,
18,
13,
13,
17,
40,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
13,
18,
18,
13,
13,
17,
0,
13,
2,
2,
13,
18,
18,
13,
13,
17,
18,
18,
13,
13,
17,
14,
2,
40,
13,
18,
18,
13,
13,
17,
2,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
13,
18,
18,
13,
13,
17,
0,
13,
2,
2,
13,
18,
18,
13,
13,
17,
18,
18,
13,
13,
17,
0,
13,
4,
13,
13,
18,
18,
13,
13,
17,
0,
13,
4,
13,
13,
18,
18,
13,
13,
17,
14,
2,
13,
2,
2,
13,
18,
18,
13,
13,
17,
18,
18,
13,
13,
17,
0,
13,
2,
2,
13,
18,
18,
13,
13,
17,
18,
18,
13,
13,
17,
0,
13,
2,
2,
13,
18,
18,
13,
13,
17,
18,
18,
13,
13,
17,
4,
13,
2,
13,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
39,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
2,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
20,
6
],
[
22,
7
],
[
20,
11
],
[
22,
13
],
[
20,
15
],
[
22,
16
],
[
20,
18
],
[
20,
20
],
[
22,
22
],
[
274,
24
],
[
289,
27
],
[
34,
33
],
[
290,
36
],
[
304,
38
],
[
304,
47
],
[
275,
50
],
[
262,
56
],
[
275,
59
],
[
268,
63
],
[
275,
66
],
[
71,
70
],
[
290,
74
],
[
263,
78
],
[
260,
78
],
[
299,
78
],
[
272,
78
],
[
302,
78
],
[
308,
78
],
[
275,
81
],
[
70,
82
],
[
269,
85
],
[
281,
85
],
[
266,
85
],
[
296,
85
],
[
293,
85
],
[
287,
85
],
[
275,
88
],
[
70,
89
],
[
301,
92
],
[
275,
95
],
[
70,
96
],
[
292,
99
],
[
275,
102
],
[
70,
103
],
[
263,
108
],
[
260,
108
],
[
299,
108
],
[
272,
108
],
[
302,
108
],
[
308,
108
],
[
275,
111
],
[
70,
112
],
[
269,
115
],
[
281,
115
],
[
266,
115
],
[
296,
115
],
[
293,
115
],
[
287,
115
],
[
275,
118
],
[
70,
119
],
[
271,
122
],
[
278,
124
],
[
263,
125
],
[
260,
125
],
[
299,
125
],
[
272,
125
],
[
302,
125
],
[
308,
125
],
[
275,
128
],
[
70,
129
],
[
295,
132
],
[
272,
135
],
[
263,
135
],
[
260,
135
],
[
299,
135
],
[
302,
135
],
[
308,
135
],
[
275,
138
],
[
70,
139
],
[
275,
143
],
[
70,
144
],
[
263,
149
],
[
260,
149
],
[
299,
149
],
[
272,
149
],
[
302,
149
],
[
308,
149
],
[
275,
152
],
[
70,
153
],
[
269,
156
],
[
281,
156
],
[
266,
156
],
[
296,
156
],
[
293,
156
],
[
287,
156
],
[
275,
159
],
[
70,
160
],
[
265,
163
],
[
278,
165
],
[
269,
166
],
[
281,
166
],
[
266,
166
],
[
296,
166
],
[
293,
166
],
[
287,
166
],
[
275,
169
],
[
70,
170
],
[
298,
173
],
[
266,
176
],
[
269,
176
],
[
281,
176
],
[
296,
176
],
[
293,
176
],
[
287,
176
],
[
275,
179
],
[
70,
180
],
[
275,
184
],
[
70,
185
],
[
307,
188
],
[
278,
190
],
[
263,
191
],
[
260,
191
],
[
299,
191
],
[
272,
191
],
[
302,
191
],
[
308,
191
],
[
275,
194
],
[
70,
195
],
[
286,
198
],
[
278,
200
],
[
269,
201
],
[
281,
201
],
[
266,
201
],
[
296,
201
],
[
293,
201
],
[
287,
201
],
[
275,
204
],
[
70,
205
],
[
308,
209
],
[
263,
209
],
[
260,
209
],
[
299,
209
],
[
272,
209
],
[
302,
209
],
[
287,
212
],
[
269,
212
],
[
281,
212
],
[
266,
212
],
[
296,
212
],
[
293,
212
],
[
275,
215
],
[
70,
216
],
[
275,
220
],
[
70,
221
],
[
280,
224
],
[
308,
227
],
[
263,
227
],
[
260,
227
],
[
299,
227
],
[
272,
227
],
[
302,
227
],
[
275,
230
],
[
70,
231
],
[
275,
235
],
[
70,
236
],
[
259,
239
],
[
287,
242
],
[
269,
242
],
[
281,
242
],
[
266,
242
],
[
296,
242
],
[
293,
242
],
[
275,
245
],
[
70,
246
],
[
275,
250
],
[
70,
251
],
[
260,
256
],
[
299,
256
],
[
272,
256
],
[
302,
256
],
[
308,
256
],
[
263,
256
],
[
281,
257
],
[
266,
257
],
[
296,
257
],
[
293,
257
],
[
287,
257
],
[
269,
257
],
[
259,
260
],
[
262,
263
],
[
265,
266
],
[
268,
269
],
[
271,
272
],
[
274,
275
],
[
280,
281
],
[
304,
284
],
[
286,
287
],
[
289,
290
],
[
292,
293
],
[
295,
296
],
[
298,
299
],
[
301,
302
],
[
304,
305
],
[
307,
308
]
] | [
"\ndef func(n,x):\n if n%x!=0:\n return n+(x-n%x)\n else:\n return n\nX=[]\nn=int(input())\nfor i in range(n):\n t,a=map(int,input().split())\n X.append([t,a])\n\nT=X[0][0]\nA=X[0][1]\n\nfor i in range(1,n):\n if T<=X[i][0] and A<=X[i][1]:\n T=X[i][0]\n A=X[i][1]\n elif T>X[i][0] and A<=X[i][1]:\n T=func(T,X[i][0])\n A=T*X[i][1]//X[i][0]\n elif T<=X[i][0] and A>X[i][0]:\n A=func(A,X[i][1])\n T=A*X[i][0]//X[i][1]\n else:\n T=func(T,X[i][0])\n A=func(A,X[i][1])\n if T>A*X[i][0]//X[i][1]:\n A=T*X[i][1]//X[i][0]\n else:\n T=A*X[i][0]//X[i][1]\nprint(T+A)",
"def func(n,x):\n if n%x!=0:\n return n+(x-n%x)\n else:\n return n",
"func",
"if n%x!=0:\n return n+(x-n%x)\n else:\n return n",
"n%x!=0",
"n%x",
"n",
"x",
"0",
"return n+(x-n%x)",
"n+(x-n%x)",
"n",
"x-n%x",
"x",
"n%x",
"n",
"x",
"return n",
"n",
"n",
"n",
"x",
"x",
"X=[]",
"X",
"[]",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"for i in range(n):\n t,a=map(int,input().split())\n X.append([t,a])",
"i",
"range(n)",
"range",
"n",
"t,a=map(int,input().split())",
"t",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"X.append([t,a])",
"X.append",
"X",
"append",
"[t,a]",
"t",
"a",
"T=X[0][0]",
"T",
"X[0][0]",
"[0]",
"X",
"0",
"0",
"A=X[0][1]",
"A",
"X[0][1]",
"[0]",
"X",
"0",
"1",
"for i in range(1,n):\n if T<=X[i][0] and A<=X[i][1]:\n T=X[i][0]\n A=X[i][1]\n elif T>X[i][0] and A<=X[i][1]:\n T=func(T,X[i][0])\n A=T*X[i][1]//X[i][0]\n elif T<=X[i][0] and A>X[i][0]:\n A=func(A,X[i][1])\n T=A*X[i][0]//X[i][1]\n else:\n T=func(T,X[i][0])\n A=func(A,X[i][1])\n if T>A*X[i][0]//X[i][1]:\n A=T*X[i][1]//X[i][0]\n else:\n T=A*X[i][0]//X[i][1]",
"i",
"range(1,n)",
"range",
"1",
"n",
"if T<=X[i][0] and A<=X[i][1]:\n T=X[i][0]\n A=X[i][1]\n elif T>X[i][0] and A<=X[i][1]:\n T=func(T,X[i][0])\n A=T*X[i][1]//X[i][0]\n elif T<=X[i][0] and A>X[i][0]:\n A=func(A,X[i][1])\n T=A*X[i][0]//X[i][1]\n else:\n T=func(T,X[i][0])\n A=func(A,X[i][1])\n if T>A*X[i][0]//X[i][1]:\n A=T*X[i][1]//X[i][0]\n else:\n T=A*X[i][0]//X[i][1]",
"T<=X[i][0] and A<=X[i][1]",
"T<=X[i][0]",
"T",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A<=X[i][1]",
"A",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"T=X[i][0]",
"T",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A=X[i][1]",
"A",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"elif T>X[i][0] and A<=X[i][1]:\n T=func(T,X[i][0])\n A=T*X[i][1]//X[i][0]\n ",
"T>X[i][0] and A<=X[i][1]",
"T>X[i][0]",
"T",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A<=X[i][1]",
"A",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"T=func(T,X[i][0])",
"T",
"func(T,X[i][0])",
"func",
"T",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A=T*X[i][1]//X[i][0]",
"A",
"T*X[i][1]//X[i][0]",
"T*X[i][1]",
"T",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"elif T<=X[i][0] and A>X[i][0]:\n A=func(A,X[i][1])\n T=A*X[i][0]//X[i][1]\n ",
"T<=X[i][0] and A>X[i][0]",
"T<=X[i][0]",
"T",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A>X[i][0]",
"A",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A=func(A,X[i][1])",
"A",
"func(A,X[i][1])",
"func",
"A",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"T=A*X[i][0]//X[i][1]",
"T",
"A*X[i][0]//X[i][1]",
"A*X[i][0]",
"A",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"T=func(T,X[i][0])",
"T",
"func(T,X[i][0])",
"func",
"T",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"A=func(A,X[i][1])",
"A",
"func(A,X[i][1])",
"func",
"A",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"if T>A*X[i][0]//X[i][1]:\n A=T*X[i][1]//X[i][0]\n else:\n T=A*X[i][0]//X[i][1]",
"T>A*X[i][0]//X[i][1]",
"T",
"A*X[i][0]//X[i][1]",
"A*X[i][0]",
"A",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"A=T*X[i][1]//X[i][0]",
"A",
"T*X[i][1]//X[i][0]",
"T*X[i][1]",
"T",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"T=A*X[i][0]//X[i][1]",
"T",
"A*X[i][0]//X[i][1]",
"A*X[i][0]",
"A",
"X[i][0]",
"[i]",
"X",
"i",
"0",
"X[i][1]",
"[i]",
"X",
"i",
"1",
"print(T+A)",
"print",
"T+A",
"T",
"A",
"T=A*X[i][0]//X[i][1]",
"A*X[i][0]//X[i][1]",
"T",
"T=X[0][0]",
"X[0][0]",
"T",
"A=func(A,X[i][1])",
"func(A,X[i][1])",
"A",
"A=X[0][1]",
"X[0][1]",
"A",
"T=func(T,X[i][0])",
"func(T,X[i][0])",
"T",
"X=[]",
"[]",
"X",
"def func(n,x):\n if n%x!=0:\n return n+(x-n%x)\n else:\n return n",
"def func(n,x):\n if n%x!=0:\n return n+(x-n%x)\n else:\n return n",
"func",
"A=T*X[i][1]//X[i][0]",
"T*X[i][1]//X[i][0]",
"A",
"a=map(int,input().split())",
"map(int,input().split())",
"a",
"A=func(A,X[i][1])",
"func(A,X[i][1])",
"A",
"n=int(input())",
"int(input())",
"n",
"A=X[i][1]",
"X[i][1]",
"A",
"A=T*X[i][1]//X[i][0]",
"T*X[i][1]//X[i][0]",
"A",
"T=A*X[i][0]//X[i][1]",
"A*X[i][0]//X[i][1]",
"T",
"T=X[i][0]",
"X[i][0]",
"T",
"t,a=map(int,input().split())",
"map(int,input().split())",
"t",
"T=func(T,X[i][0])",
"func(T,X[i][0])",
"T"
] |
def func(n,x):
if n%x!=0:
return n+(x-n%x)
else:
return n
X=[]
n=int(input())
for i in range(n):
t,a=map(int,input().split())
X.append([t,a])
T=X[0][0]
A=X[0][1]
for i in range(1,n):
if T<=X[i][0] and A<=X[i][1]:
T=X[i][0]
A=X[i][1]
elif T>X[i][0] and A<=X[i][1]:
T=func(T,X[i][0])
A=T*X[i][1]//X[i][0]
elif T<=X[i][0] and A>X[i][0]:
A=func(A,X[i][1])
T=A*X[i][0]//X[i][1]
else:
T=func(T,X[i][0])
A=func(A,X[i][1])
if T>A*X[i][0]//X[i][1]:
A=T*X[i][1]//X[i][0]
else:
T=A*X[i][0]//X[i][1]
print(T+A) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
40,
13,
18,
13,
17,
40,
13,
18,
13,
17,
0,
13,
39,
13,
13,
0,
13,
4,
13,
2,
2,
2,
18,
13,
17,
17,
13,
17,
2,
2,
2,
18,
13,
17,
17,
13,
17,
0,
13,
39,
2,
13,
13,
2,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
39,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13
] | [
[
85,
2
],
[
97,
8
],
[
14,
13
],
[
86,
16
],
[
100,
18
],
[
100,
27
],
[
95,
31
],
[
98,
33
],
[
89,
33
],
[
92,
33
],
[
101,
36
],
[
98,
38
],
[
89,
38
],
[
92,
38
],
[
91,
41
],
[
82,
46
],
[
98,
53
],
[
89,
53
],
[
92,
53
],
[
95,
56
],
[
98,
62
],
[
89,
62
],
[
92,
62
],
[
101,
65
],
[
88,
68
],
[
95,
71
],
[
83,
72
],
[
101,
74
],
[
83,
75
],
[
89,
80
],
[
92,
80
],
[
98,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
],
[
100,
95
],
[
97,
98
],
[
100,
101
]
] | [
"n = int(input())\nbefore = [0, 0]\nfor i in range(n):\n t, a = map(int, input().split())\n if t >= before[0] and a >= before[1]:\n before = [t, a]\n else:\n mul = max((before[0]-1)//t+1, (before[1]-1)//a+1)\n before = [t*mul, a*mul]\n\nprint(sum(before))",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"before = [0, 0]",
"before",
"[0, 0]",
"0",
"0",
"for i in range(n):\n t, a = map(int, input().split())\n if t >= before[0] and a >= before[1]:\n before = [t, a]\n else:\n mul = max((before[0]-1)//t+1, (before[1]-1)//a+1)\n before = [t*mul, a*mul]",
"i",
"range(n)",
"range",
"n",
"t, a = map(int, input().split())",
"t",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a",
"if t >= before[0] and a >= before[1]:\n before = [t, a]\n else:\n mul = max((before[0]-1)//t+1, (before[1]-1)//a+1)\n before = [t*mul, a*mul]",
"t >= before[0] and a >= before[1]",
"t >= before[0]",
"t",
"before[0]",
"before",
"0",
"a >= before[1]",
"a",
"before[1]",
"before",
"1",
"before = [t, a]",
"before",
"[t, a]",
"t",
"a",
"mul = max((before[0]-1)//t+1, (before[1]-1)//a+1)",
"mul",
"max((before[0]-1)//t+1, (before[1]-1)//a+1)",
"max",
"(before[0]-1)//t+1",
"(before[0]-1)//t",
"before[0]-1",
"before[0]",
"before",
"0",
"1",
"t",
"1",
"(before[1]-1)//a+1",
"(before[1]-1)//a",
"before[1]-1",
"before[1]",
"before",
"1",
"1",
"a",
"1",
"before = [t*mul, a*mul]",
"before",
"[t*mul, a*mul]",
"t*mul",
"t",
"mul",
"a*mul",
"a",
"mul",
"print(sum(before))",
"print",
"sum(before)",
"sum",
"before",
"mul = max((before[0]-1)//t+1, (before[1]-1)//a+1)",
"max((before[0]-1)//t+1, (before[1]-1)//a+1)",
"mul",
"n = int(input())",
"int(input())",
"n",
"before = [t*mul, a*mul]",
"[t*mul, a*mul]",
"before",
"before = [t, a]",
"[t, a]",
"before",
"t, a = map(int, input().split())",
"map(int, input().split())",
"t",
"before = [0, 0]",
"[0, 0]",
"before",
"a = map(int, input().split())",
"map(int, input().split())",
"a"
] | n = int(input())
before = [0, 0]
for i in range(n):
t, a = map(int, input().split())
if t >= before[0] and a >= before[1]:
before = [t, a]
else:
mul = max((before[0]-1)//t+1, (before[1]-1)//a+1)
before = [t*mul, a*mul]
print(sum(before)) |
[
7,
0,
13,
4,
13,
4,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
0,
13,
4,
18,
13,
13,
17,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
28,
13,
13,
0,
13,
4,
13,
2,
13,
18,
13,
17,
2,
13,
18,
13,
17,
42,
17,
0,
13,
2,
18,
13,
17,
13,
0,
13,
2,
18,
13,
17,
13,
14,
2,
40,
13,
13,
40,
13,
13,
0,
13,
13,
0,
13,
13,
3,
0,
13,
17,
4,
13,
2,
13,
13,
10,
18,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
18,
13
] | [
[
125,
2
],
[
10,
9
],
[
126,
12
],
[
128,
16
],
[
107,
19
],
[
119,
22
],
[
113,
25
],
[
129,
28
],
[
134,
32
],
[
114,
34
],
[
98,
37
],
[
114,
39
],
[
43,
42
],
[
129,
42
],
[
101,
45
],
[
135,
49
],
[
108,
49
],
[
123,
49
],
[
42,
51
],
[
99,
54
],
[
120,
54
],
[
105,
54
],
[
42,
56
],
[
110,
61
],
[
42,
64
],
[
102,
66
],
[
132,
66
],
[
116,
68
],
[
42,
71
],
[
102,
73
],
[
132,
73
],
[
111,
77
],
[
135,
78
],
[
108,
78
],
[
123,
78
],
[
117,
80
],
[
99,
81
],
[
120,
81
],
[
105,
81
],
[
122,
83
],
[
111,
84
],
[
104,
86
],
[
117,
87
],
[
131,
90
],
[
123,
95
],
[
135,
95
],
[
108,
95
],
[
105,
96
],
[
99,
96
],
[
120,
96
],
[
98,
99
],
[
101,
102
],
[
117,
104
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
111,
122
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
]
] | [
"N = int(input())\nratios = [[i for i in map(int,input().split())] for j in range(N)]\n\nans_a = 0\nans_t = 0\nratio = ratios.pop(0)\nans_a = ratio[0]\nans_t = ratio[1]\n\nfor ratio in ratios:\n i = max(ans_a // ratio[0], ans_t // ratio[1])\n while True:\n temp_a = ratio[0]*i\n temp_t = ratio[1]*i\n if temp_a >= ans_a and temp_t >= ans_t:\n ans_a = temp_a\n ans_t = temp_t\n break\n i += 1\n \nprint(ans_a + ans_t)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"[i for i in map(int,input().split())] for j in range(N)",
"for j in range(N)",
"j",
"range(N)",
"range",
"N",
"for j in range(N)",
"[i for i in map(int,input().split())]",
"ratios = [[i for i in map(int,input().split())] for j in range(N)]",
"ratios",
"[[i for i in map(int,input().split())] for j in range(N)]",
"ans_a = 0",
"ans_a",
"0",
"ans_t = 0",
"ans_t",
"0",
"ratio = ratios.pop(0)",
"ratio",
"ratios.pop(0)",
"ratios.pop",
"ratios",
"pop",
"0",
"ans_a = ratio[0]",
"ans_a",
"ratio[0]",
"ratio",
"0",
"ans_t = ratio[1]",
"ans_t",
"ratio[1]",
"ratio",
"1",
"for ratio in ratios:\n i = max(ans_a // ratio[0], ans_t // ratio[1])\n while True:\n temp_a = ratio[0]*i\n temp_t = ratio[1]*i\n if temp_a >= ans_a and temp_t >= ans_t:\n ans_a = temp_a\n ans_t = temp_t\n break\n i += 1\n ",
"ratio",
"ratios",
"i = max(ans_a // ratio[0], ans_t // ratio[1])",
"i",
"max(ans_a // ratio[0], ans_t // ratio[1])",
"max",
"ans_a // ratio[0]",
"ans_a",
"ratio[0]",
"ratio",
"0",
"ans_t // ratio[1]",
"ans_t",
"ratio[1]",
"ratio",
"1",
"while True:\n temp_a = ratio[0]*i\n temp_t = ratio[1]*i\n if temp_a >= ans_a and temp_t >= ans_t:\n ans_a = temp_a\n ans_t = temp_t\n break\n i += 1\n ",
"True",
"temp_a = ratio[0]*i",
"temp_a",
"ratio[0]*i",
"ratio[0]",
"ratio",
"0",
"i",
"temp_t = ratio[1]*i",
"temp_t",
"ratio[1]*i",
"ratio[1]",
"ratio",
"1",
"i",
"if temp_a >= ans_a and temp_t >= ans_t:\n ans_a = temp_a\n ans_t = temp_t\n break\n ",
"temp_a >= ans_a and temp_t >= ans_t",
"temp_a >= ans_a",
"temp_a",
"ans_a",
"temp_t >= ans_t",
"temp_t",
"ans_t",
"ans_a = temp_a",
"ans_a",
"temp_a",
"ans_t = temp_t",
"ans_t",
"temp_t",
"break",
"i += 1",
"i",
"1",
"print(ans_a + ans_t)",
"print",
"ans_a + ans_t",
"ans_a",
"ans_t",
"ans_t = ratio[1]",
"ratio[1]",
"ans_t",
"i = max(ans_a // ratio[0], ans_t // ratio[1])",
"max(ans_a // ratio[0], ans_t // ratio[1])",
"i",
"ans_t = temp_t",
"temp_t",
"ans_t",
"ans_a = 0",
"0",
"ans_a",
"temp_a = ratio[0]*i",
"ratio[0]*i",
"temp_a",
"ratio = ratios.pop(0)",
"ratios.pop(0)",
"ratio",
"temp_t = ratio[1]*i",
"ratio[1]*i",
"temp_t",
"ans_t = 0",
"0",
"ans_t",
"ans_a = temp_a",
"temp_a",
"ans_a",
"N = int(input())",
"int(input())",
"N",
"ratios = [[i for i in map(int,input().split())] for j in range(N)]",
"[[i for i in map(int,input().split())] for j in range(N)]",
"ratios",
"i += 1",
"1",
"i",
"ans_a = ratio[0]",
"ratio[0]",
"ans_a"
] | N = int(input())
ratios = [[i for i in map(int,input().split())] for j in range(N)]
ans_a = 0
ans_t = 0
ratio = ratios.pop(0)
ans_a = ratio[0]
ans_t = ratio[1]
for ratio in ratios:
i = max(ans_a // ratio[0], ans_t // ratio[1])
while True:
temp_a = ratio[0]*i
temp_t = ratio[1]*i
if temp_a >= ans_a and temp_t >= ans_t:
ans_a = temp_a
ans_t = temp_t
break
i += 1
print(ans_a + ans_t) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
13,
14,
40,
2,
13,
13,
17,
0,
13,
2,
13,
13,
14,
40,
2,
13,
13,
17,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] | [
[
98,
2
],
[
71,
8
],
[
80,
10
],
[
14,
13
],
[
99,
16
],
[
92,
18
],
[
92,
27
],
[
95,
29
],
[
72,
31
],
[
75,
31
],
[
90,
32
],
[
72,
36
],
[
75,
36
],
[
90,
37
],
[
77,
40
],
[
81,
42
],
[
87,
42
],
[
93,
43
],
[
81,
47
],
[
87,
47
],
[
93,
48
],
[
83,
51
],
[
96,
54
],
[
78,
55
],
[
74,
57
],
[
90,
59
],
[
84,
60
],
[
86,
61
],
[
93,
63
],
[
84,
64
],
[
75,
68
],
[
72,
68
],
[
87,
69
],
[
81,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
],
[
92,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
]
] | [
"n = int(input())\n\nt0, a0 = 1, 1\n\nfor i in range(n):\n t1, a1 = map(int, input().split())\n f0 = t0 // t1\n if t0 % t1 != 0:f0 += 1\n f1 = a0 // a1\n if a0 % a1 != 0:f1 += 1\n f = max(f0, f1)\n t0, a0 = t1*f, a1*f\n\nprint(t0 + a0)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"t0, a0 = 1, 1",
"t0",
"1",
"a0",
"1",
"for i in range(n):\n t1, a1 = map(int, input().split())\n f0 = t0 // t1\n if t0 % t1 != 0:f0 += 1\n f1 = a0 // a1\n if a0 % a1 != 0:f1 += 1\n f = max(f0, f1)\n t0, a0 = t1*f, a1*f",
"i",
"range(n)",
"range",
"n",
"t1, a1 = map(int, input().split())",
"t1",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a1",
"f0 = t0 // t1",
"f0",
"t0 // t1",
"t0",
"t1",
"if t0 % t1 != 0:f0 += 1\n ",
"t0 % t1 != 0",
"t0 % t1",
"t0",
"t1",
"0",
"f1 = a0 // a1",
"f1",
"a0 // a1",
"a0",
"a1",
"if a0 % a1 != 0:f1 += 1\n ",
"a0 % a1 != 0",
"a0 % a1",
"a0",
"a1",
"0",
"f = max(f0, f1)",
"f",
"max(f0, f1)",
"max",
"f0",
"f1",
"t0, a0 = t1*f, a1*f",
"t0",
"t1*f",
"t1",
"f",
"a0",
"a1*f",
"a1",
"f",
"print(t0 + a0)",
"print",
"t0 + a0",
"t0",
"a0",
"t0, a0 = 1, 1",
"1",
"t0",
"t0, a0 = t1*f, a1*f",
"t1*f",
"t0",
"f1 = a0 // a1",
"a0 // a1",
"f1",
"a0 = 1, 1",
"1",
"a0",
"f = max(f0, f1)",
"max(f0, f1)",
"f",
"a0 = t1*f, a1*f",
"a1*f",
"a0",
"t1, a1 = map(int, input().split())",
"map(int, input().split())",
"t1",
"a1 = map(int, input().split())",
"map(int, input().split())",
"a1",
"f0 = t0 // t1",
"t0 // t1",
"f0",
"n = int(input())",
"int(input())",
"n"
] | n = int(input())
t0, a0 = 1, 1
for i in range(n):
t1, a1 = map(int, input().split())
f0 = t0 // t1
if t0 % t1 != 0:f0 += 1
f1 = a0 // a1
if a0 % a1 != 0:f1 += 1
f = max(f0, f1)
t0, a0 = t1*f, a1*f
print(t0 + a0) |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
13,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
82,
2
],
[
94,
8
],
[
94,
17
],
[
20,
19
],
[
83,
23
],
[
97,
26
],
[
97,
35
],
[
85,
37
],
[
95,
41
],
[
92,
41
],
[
80,
42
],
[
80,
44
],
[
100,
46
],
[
77,
50
],
[
104,
50
],
[
98,
51
],
[
98,
53
],
[
88,
55
],
[
86,
58
],
[
101,
59
],
[
91,
61
],
[
80,
63
],
[
89,
64
],
[
103,
66
],
[
98,
68
],
[
89,
69
],
[
92,
73
],
[
95,
73
],
[
104,
74
],
[
77,
74
],
[
94,
77
],
[
97,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
]
] | [
"n = int(input())\n\na,b = map(int, input().split())\n\nfor _ in range(n-1):\n c,d = map(int, input().split())\n i = (a+c-1)//c\n j = (b+d-1)//d\n k = max(i,j)\n a = c*k\n b = d*k\nprint(a+b)",
"n = int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"a,b = map(int, input().split())",
"a",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"for _ in range(n-1):\n c,d = map(int, input().split())\n i = (a+c-1)//c\n j = (b+d-1)//d\n k = max(i,j)\n a = c*k\n b = d*k",
"_",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"c,d = map(int, input().split())",
"c",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"d",
"i = (a+c-1)//c",
"i",
"(a+c-1)//c",
"a+c-1",
"a+c",
"a",
"c",
"1",
"c",
"j = (b+d-1)//d",
"j",
"(b+d-1)//d",
"b+d-1",
"b+d",
"b",
"d",
"1",
"d",
"k = max(i,j)",
"k",
"max(i,j)",
"max",
"i",
"j",
"a = c*k",
"a",
"c*k",
"c",
"k",
"b = d*k",
"b",
"d*k",
"d",
"k",
"print(a+b)",
"print",
"a+b",
"a",
"b",
"b = map(int, input().split())",
"map(int, input().split())",
"b",
"c,d = map(int, input().split())",
"map(int, input().split())",
"c",
"n = int(input())",
"int(input())",
"n",
"i = (a+c-1)//c",
"(a+c-1)//c",
"i",
"k = max(i,j)",
"max(i,j)",
"k",
"a = c*k",
"c*k",
"a",
"a,b = map(int, input().split())",
"map(int, input().split())",
"a",
"d = map(int, input().split())",
"map(int, input().split())",
"d",
"j = (b+d-1)//d",
"(b+d-1)//d",
"j",
"b = d*k",
"d*k",
"b"
] | n = int(input())
a,b = map(int, input().split())
for _ in range(n-1):
c,d = map(int, input().split())
i = (a+c-1)//c
j = (b+d-1)//d
k = max(i,j)
a = c*k
b = d*k
print(a+b)
|
[
7,
15,
13,
4,
18,
13,
13,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
2,
2,
2,
13,
17,
13,
17,
2,
2,
2,
13,
17,
13,
17,
0,
13,
2,
13,
13,
13,
2,
13,
13,
4,
13,
2,
13,
13,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13
] | [
[
105,
9
],
[
96,
14
],
[
102,
21
],
[
36,
35
],
[
103,
39
],
[
42,
41
],
[
44,
43
],
[
47,
46
],
[
35,
49
],
[
52,
51
],
[
103,
58
],
[
52,
60
],
[
63,
62
],
[
41,
68
],
[
80,
68
],
[
51,
70
],
[
43,
75
],
[
84,
75
],
[
60,
77
],
[
81,
80
],
[
62,
82
],
[
51,
83
],
[
85,
84
],
[
62,
86
],
[
60,
87
],
[
80,
91
],
[
41,
91
],
[
84,
92
],
[
43,
92
],
[
100,
94
],
[
96,
97
],
[
102,
103
],
[
105,
106
]
] | [
"import sys\nsys.setrecursionlimit(2147483647)\nINF=float(\"inf\")\nMOD=10**9+7\ninput=lambda :sys.stdin.readline().rstrip()\ndef resolve():\n n=int(input())\n x,y=1,1\n for _ in range(n):\n a,b=map(int,input().split())\n k=max((x-1)//a+1,(y-1)//b+1)\n x,y=k*a,k*b\n print(x+y)\nresolve()",
"import sys",
"sys",
"sys.setrecursionlimit(2147483647)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"2147483647",
"INF=float(\"inf\")",
"INF",
"float(\"inf\")",
"float",
"\"inf\"",
"MOD=10**9+7",
"MOD",
"10**9+7",
"10**9",
"10",
"9",
"7",
"input=lambda :sys.stdin.readline().rstrip()",
"input",
"lambda :sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"def resolve():\n n=int(input())\n x,y=1,1\n for _ in range(n):\n a,b=map(int,input().split())\n k=max((x-1)//a+1,(y-1)//b+1)\n x,y=k*a,k*b\n print(x+y)",
"resolve",
"n=int(input())",
"n",
"int(input())",
"int",
"input()",
"input",
"x,y=1,1",
"x",
"1",
"y",
"1",
"for _ in range(n):\n a,b=map(int,input().split())\n k=max((x-1)//a+1,(y-1)//b+1)\n x,y=k*a,k*b\n ",
"_",
"range(n)",
"range",
"n",
"a,b=map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"k=max((x-1)//a+1,(y-1)//b+1)",
"k",
"max((x-1)//a+1,(y-1)//b+1)",
"max",
"(x-1)//a+1",
"(x-1)//a",
"x-1",
"x",
"1",
"a",
"1",
"(y-1)//b+1",
"(y-1)//b",
"y-1",
"y",
"1",
"b",
"1",
"x,y=k*a,k*b",
"x",
"k*a",
"k",
"a",
"y",
"k*b",
"k",
"b",
"print(x+y)",
"print",
"x+y",
"x",
"y",
"resolve()",
"resolve",
"MOD=10**9+7",
"10**9+7",
"MOD",
"def resolve():\n n=int(input())\n x,y=1,1\n for _ in range(n):\n a,b=map(int,input().split())\n k=max((x-1)//a+1,(y-1)//b+1)\n x,y=k*a,k*b\n print(x+y)",
"def resolve():\n n=int(input())\n x,y=1,1\n for _ in range(n):\n a,b=map(int,input().split())\n k=max((x-1)//a+1,(y-1)//b+1)\n x,y=k*a,k*b\n print(x+y)",
"resolve",
"input=lambda :sys.stdin.readline().rstrip()",
"lambda :sys.stdin.readline().rstrip()",
"input",
"INF=float(\"inf\")",
"float(\"inf\")",
"INF"
] | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
n=int(input())
x,y=1,1
for _ in range(n):
a,b=map(int,input().split())
k=max((x-1)//a+1,(y-1)//b+1)
x,y=k*a,k*b
print(x+y)
resolve() |
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
2,
2,
13,
13,
17,
13,
0,
13,
2,
13,
4,
13,
13,
13,
0,
13,
2,
13,
4,
13,
13,
13,
4,
13,
2,
13,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
81,
2
],
[
75,
8
],
[
69,
11
],
[
15,
14
],
[
82,
17
],
[
87,
19
],
[
87,
28
],
[
93,
30
],
[
88,
34
],
[
76,
35
],
[
73,
35
],
[
88,
37
],
[
84,
39
],
[
79,
43
],
[
70,
44
],
[
91,
44
],
[
79,
46
],
[
72,
48
],
[
88,
50
],
[
94,
53
],
[
85,
54
],
[
90,
56
],
[
79,
58
],
[
94,
61
],
[
85,
62
],
[
73,
66
],
[
76,
66
],
[
91,
67
],
[
70,
67
],
[
69,
70
],
[
72,
73
],
[
75,
76
],
[
87,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
]
] | [
"N = int(input())\nx = 1\ny = 1\nfor i in range(N):\n T, A = map(int, input().split())\n p = (T + x - 1) // T\n q = (A + y - 1) // A\n x = T * max(p, q)\n y = A * max(p, q)\n #print(f\"[{x} {y}]\")\nprint(x + y)",
"N = int(input())",
"N",
"int(input())",
"int",
"input()",
"input",
"x = 1",
"x",
"1",
"y = 1",
"y",
"1",
"for i in range(N):\n T, A = map(int, input().split())\n p = (T + x - 1) // T\n q = (A + y - 1) // A\n x = T * max(p, q)\n y = A * max(p, q)\n #print(f\"[{x} {y}]\")",
"i",
"range(N)",
"range",
"N",
"T, A = map(int, input().split())",
"T",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A",
"p = (T + x - 1) // T",
"p",
"(T + x - 1) // T",
"T + x - 1",
"T + x",
"T",
"x",
"1",
"T",
"q = (A + y - 1) // A",
"q",
"(A + y - 1) // A",
"A + y - 1",
"A + y",
"A",
"y",
"1",
"A",
"x = T * max(p, q)",
"x",
"T * max(p, q)",
"T",
"max(p, q)",
"max",
"p",
"q",
"y = A * max(p, q)",
"y",
"A * max(p, q)",
"A",
"max(p, q)",
"max",
"p",
"q",
"print(x + y)",
"print",
"x + y",
"x",
"y",
"y = 1",
"1",
"y",
"x = T * max(p, q)",
"T * max(p, q)",
"x",
"x = 1",
"1",
"x",
"A = map(int, input().split())",
"map(int, input().split())",
"A",
"N = int(input())",
"int(input())",
"N",
"q = (A + y - 1) // A",
"(A + y - 1) // A",
"q",
"T, A = map(int, input().split())",
"map(int, input().split())",
"T",
"y = A * max(p, q)",
"A * max(p, q)",
"y",
"p = (T + x - 1) // T",
"(T + x - 1) // T",
"p"
] | N = int(input())
x = 1
y = 1
for i in range(N):
T, A = map(int, input().split())
p = (T + x - 1) // T
q = (A + y - 1) // A
x = T * max(p, q)
y = A * max(p, q)
#print(f"[{x} {y}]")
print(x + y)
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
4,
13,
4,
13,
39,
17,
0,
13,
17,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
13,
13,
0,
13,
17,
0,
13,
2,
18,
13,
13,
17,
0,
13,
17,
0,
13,
2,
18,
13,
13,
17,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
18,
13,
10,
17,
13,
10,
17,
13,
10,
18,
13,
10,
17,
13,
10,
17,
13
] | [
[
72,
4
],
[
81,
11
],
[
73,
16
],
[
75,
20
],
[
69,
23
],
[
78,
26
],
[
30,
29
],
[
82,
34
],
[
76,
37
],
[
85,
37
],
[
70,
38
],
[
88,
38
],
[
87,
40
],
[
63,
43
],
[
82,
46
],
[
29,
47
],
[
84,
50
],
[
66,
53
],
[
82,
56
],
[
29,
57
],
[
67,
61
],
[
64,
61
],
[
79,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
],
[
72,
73
],
[
75,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
]
] | [
"import sys\ninput = sys.stdin.readline\nS = list(input())[: -1]\ng = 0\np = 0\nres = 0\nfor i in range(len(S)):\n if g > p:\n p += 1\n res += S[i] == \"g\"\n else:\n g += 1\n res -= S[i] == \"p\"\nprint(res)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"S = list(input())[: -1]",
"S",
"list(input())[: -1]",
"(input())",
"list",
"input()",
"input",
": -1",
"-1",
"g = 0",
"g",
"0",
"p = 0",
"p",
"0",
"res = 0",
"res",
"0",
"for i in range(len(S)):\n if g > p:\n p += 1\n res += S[i] == \"g\"\n else:\n g += 1\n res -= S[i] == \"p\"",
"i",
"range(len(S))",
"range",
"len(S)",
"len",
"S",
"if g > p:\n p += 1\n res += S[i] == \"g\"\n else:\n g += 1\n res -= S[i] == \"p\"",
"g > p",
"g",
"p",
"p += 1",
"p",
"1",
"res += S[i] == \"g\"",
"res",
"S[i] == \"g\"",
"S[i]",
"S",
"i",
"\"g\"",
"g += 1",
"g",
"1",
"res -= S[i] == \"p\"",
"res",
"S[i] == \"p\"",
"S[i]",
"S",
"i",
"\"p\"",
"print(res)",
"print",
"res",
"res += S[i] == \"g\"",
"S[i] == \"g\"",
"res",
"res -= S[i] == \"p\"",
"S[i] == \"p\"",
"res",
"p = 0",
"0",
"p",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"g = 0",
"0",
"g",
"res = 0",
"0",
"res",
"S = list(input())[: -1]",
"list(input())[: -1]",
"S",
"g += 1",
"1",
"g",
"p += 1",
"1",
"p"
] | import sys
input = sys.stdin.readline
S = list(input())[: -1]
g = 0
p = 0
res = 0
for i in range(len(S)):
if g > p:
p += 1
res += S[i] == "g"
else:
g += 1
res -= S[i] == "p"
print(res) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.