node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
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,
2,
39,
17,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
13,
4,
18,
13,
13,
18,
13,
13,
0,
18,
13,
2,
18,
13,
13,
17,
17,
0,
18,
13,
2,
18,
13,
13,
17,
17,
14,
2,
18,
13,
2,
18,
13,
13,
17,
17,
4,
18,
13,
13,
18,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] | [
[
141,
3
],
[
141,
12
],
[
132,
14
],
[
135,
16
],
[
20,
19
],
[
130,
22
],
[
138,
24
],
[
138,
33
],
[
133,
36
],
[
124,
38
],
[
136,
41
],
[
139,
43
],
[
147,
45
],
[
142,
49
],
[
126,
51
],
[
127,
56
],
[
144,
60
],
[
64,
63
],
[
133,
68
],
[
133,
72
],
[
63,
73
],
[
127,
74
],
[
127,
77
],
[
136,
80
],
[
63,
81
],
[
90,
83
],
[
148,
84
],
[
133,
87
],
[
63,
88
],
[
99,
92
],
[
148,
93
],
[
136,
96
],
[
63,
97
],
[
148,
103
],
[
133,
106
],
[
63,
107
],
[
127,
112
],
[
133,
115
],
[
63,
116
],
[
127,
121
],
[
138,
124
],
[
126,
127
],
[
141,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
]
] | [
"# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 7 14:28:00 2020\n\n@author: NEC-PCuser\n\"\"\"\n\nN, M = map(int, input().split())\nx, y = [], []\n\nfor i in range(M):\n x_tmp, y_tmp = map(int, input().split())\n x.append(x_tmp)\n y.append(y_tmp)\n\nbox = [1] * N \nball_set = set()\nball_set.add(1)\nstart_flg = True\nfor i in range(len(x)):\n if x[i] in ball_set:\n ball_set.add(y[i])\n box[x[i] - 1] -= 1\n box[y[i] - 1] += 1\n if box[x[i] - 1] == 0:\n ball_set.discard(x[i])\n\nprint(len(ball_set))\n",
"\"\"\"\nCreated on Sun Jun 7 14:28:00 2020\n\n@author: NEC-PCuser\n\"\"\"",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"x, y = [], []",
"x",
"[]",
"y",
"[]",
"for i in range(M):\n x_tmp, y_tmp = map(int, input().split())\n x.append(x_tmp)\n y.append(y_tmp)",
"i",
"range(M)",
"range",
"M",
"x_tmp, y_tmp = map(int, input().split())",
"x_tmp",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y_tmp",
"x.append(x_tmp)",
"x.append",
"x",
"append",
"x_tmp",
"y.append(y_tmp)",
"y.append",
"y",
"append",
"y_tmp",
"box = [1] * N",
"box",
"[1] * N",
"[1]",
"1",
"N",
"ball_set = set()",
"ball_set",
"set()",
"set",
"ball_set.add(1)",
"ball_set.add",
"ball_set",
"add",
"1",
"start_flg = True",
"start_flg",
"True",
"for i in range(len(x)):\n if x[i] in ball_set:\n ball_set.add(y[i])\n box[x[i] - 1] -= 1\n box[y[i] - 1] += 1\n if box[x[i] - 1] == 0:\n ball_set.discard(x[i])",
"i",
"range(len(x))",
"range",
"len(x)",
"len",
"x",
"if x[i] in ball_set:\n ball_set.add(y[i])\n ",
"x[i] in ball_set",
"x[i]",
"x",
"i",
"ball_set",
"ball_set.add(y[i])",
"ball_set.add",
"ball_set",
"add",
"y[i]",
"y",
"i",
"box[x[i] - 1] -= 1",
"box[x[i] - 1]",
"box",
"x[i] - 1",
"x[i]",
"x",
"i",
"1",
"1",
"box[y[i] - 1] += 1",
"box[y[i] - 1]",
"box",
"y[i] - 1",
"y[i]",
"y",
"i",
"1",
"1",
"if box[x[i] - 1] == 0:\n ball_set.discard(x[i])",
"box[x[i] - 1] == 0",
"box[x[i] - 1]",
"box",
"x[i] - 1",
"x[i]",
"x",
"i",
"1",
"0",
"ball_set.discard(x[i])",
"ball_set.discard",
"ball_set",
"discard",
"x[i]",
"x",
"i",
"print(len(ball_set))",
"print",
"len(ball_set)",
"len",
"ball_set",
"x_tmp, y_tmp = map(int, input().split())",
"map(int, input().split())",
"x_tmp",
"ball_set = set()",
"set()",
"ball_set",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"x, y = [], []",
"[]",
"x",
"y = [], []",
"[]",
"y",
"y_tmp = map(int, input().split())",
"map(int, input().split())",
"y_tmp",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"start_flg = True",
"True",
"start_flg",
"box = [1] * N",
"[1] * N",
"box"
] | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 7 14:28:00 2020
@author: NEC-PCuser
"""
N, M = map(int, input().split())
x, y = [], []
for i in range(M):
x_tmp, y_tmp = map(int, input().split())
x.append(x_tmp)
y.append(y_tmp)
box = [1] * N
ball_set = set()
ball_set.add(1)
start_flg = True
for i in range(len(x)):
if x[i] in ball_set:
ball_set.add(y[i])
box[x[i] - 1] -= 1
box[y[i] - 1] += 1
if box[x[i] - 1] == 0:
ball_set.discard(x[i])
print(len(ball_set))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
13,
17,
39,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
18,
18,
13,
13,
17,
17,
40,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
13,
17,
28,
13,
13,
14,
2,
18,
13,
17,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] | [
[
148,
2
],
[
148,
12
],
[
16,
15
],
[
149,
18
],
[
133,
24
],
[
30,
27
],
[
134,
28
],
[
139,
34
],
[
38,
37
],
[
131,
40
],
[
142,
42
],
[
142,
52
],
[
145,
54
],
[
151,
57
],
[
134,
64
],
[
146,
65
],
[
143,
65
],
[
134,
71
],
[
146,
72
],
[
143,
72
],
[
81,
76
],
[
134,
78
],
[
152,
79
],
[
137,
79
],
[
88,
83
],
[
134,
85
],
[
152,
86
],
[
137,
86
],
[
95,
90
],
[
134,
92
],
[
146,
93
],
[
143,
93
],
[
134,
100
],
[
146,
101
],
[
143,
101
],
[
110,
105
],
[
134,
107
],
[
146,
108
],
[
143,
108
],
[
154,
112
],
[
116,
115
],
[
134,
115
],
[
115,
120
],
[
157,
124
],
[
158,
128
],
[
155,
128
],
[
148,
131
],
[
133,
134
],
[
142,
137
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
148,
149
],
[
151,
152
],
[
154,
155
],
[
157,
158
]
] | [
"n,m = map(int,input().split(\" \"))\nar = [[0,1] for i in range(n)]\nar[0] = [1,1]\nr = 0\nfor i in range(m):\n a,b = map(int,input().split(\" \"))\n a -= 1\n b -= 1\n if ar[a][0] == 1 and ar[a][1] >= 1:\n ar[b][0] = 1\n ar[b][1] += 1\n ar[a][1] -= 1\n if ar[a][1] == 0:\n ar[a][0] = 0\ncount = 0\nfor r in ar:\n if r[0] == 1:\n count += 1\nprint(count)",
"n,m = map(int,input().split(\" \"))",
"n",
"map(int,input().split(\" \"))",
"map",
"int",
"input().split(\" \")",
"().split",
"()",
"input",
"split",
"\" \"",
"m",
"[0,1] for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"[0,1]",
"0",
"1",
"ar = [[0,1] for i in range(n)]",
"ar",
"[[0,1] for i in range(n)]",
"ar[0] = [1,1]",
"ar[0]",
"ar",
"0",
"[1,1]",
"1",
"1",
"r = 0",
"r",
"0",
"for i in range(m):\n a,b = map(int,input().split(\" \"))\n a -= 1\n b -= 1\n if ar[a][0] == 1 and ar[a][1] >= 1:\n ar[b][0] = 1\n ar[b][1] += 1\n ar[a][1] -= 1\n if ar[a][1] == 0:\n ar[a][0] = 0",
"i",
"range(m)",
"range",
"m",
"a,b = map(int,input().split(\" \"))",
"a",
"map(int,input().split(\" \"))",
"map",
"int",
"input().split(\" \")",
"().split",
"()",
"input",
"split",
"\" \"",
"b",
"a -= 1",
"a",
"1",
"b -= 1",
"b",
"1",
"if ar[a][0] == 1 and ar[a][1] >= 1:\n ar[b][0] = 1\n ",
"ar[a][0] == 1 and ar[a][1] >= 1",
"ar[a][0] == 1",
"ar[a][0]",
"[a]",
"ar",
"a",
"0",
"1",
"ar[a][1] >= 1",
"ar[a][1]",
"[a]",
"ar",
"a",
"1",
"1",
"ar[b][0] = 1",
"ar[b][0]",
"[b]",
"ar",
"b",
"0",
"1",
"ar[b][1] += 1",
"ar[b][1]",
"[b]",
"ar",
"b",
"1",
"1",
"ar[a][1] -= 1",
"ar[a][1]",
"[a]",
"ar",
"a",
"1",
"1",
"if ar[a][1] == 0:\n ar[a][0] = 0",
"ar[a][1] == 0",
"ar[a][1]",
"[a]",
"ar",
"a",
"1",
"0",
"ar[a][0] = 0",
"ar[a][0]",
"[a]",
"ar",
"a",
"0",
"0",
"count = 0",
"count",
"0",
"for r in ar:\n if r[0] == 1:\n count += 1",
"r",
"ar",
"if r[0] == 1:\n count += 1",
"r[0] == 1",
"r[0]",
"r",
"0",
"1",
"count += 1",
"count",
"1",
"print(count)",
"print",
"count",
"m = map(int,input().split(\" \"))",
"map(int,input().split(\" \"))",
"m",
"ar = [[0,1] for i in range(n)]",
"[[0,1] for i in range(n)]",
"ar",
"b = map(int,input().split(\" \"))",
"map(int,input().split(\" \"))",
"b",
"r = 0",
"0",
"r",
"a,b = map(int,input().split(\" \"))",
"map(int,input().split(\" \"))",
"a",
"a -= 1",
"1",
"a",
"n,m = map(int,input().split(\" \"))",
"map(int,input().split(\" \"))",
"n",
"b -= 1",
"1",
"b",
"count = 0",
"0",
"count",
"count += 1",
"1",
"count"
] | n,m = map(int,input().split(" "))
ar = [[0,1] for i in range(n)]
ar[0] = [1,1]
r = 0
for i in range(m):
a,b = map(int,input().split(" "))
a -= 1
b -= 1
if ar[a][0] == 1 and ar[a][1] >= 1:
ar[b][0] = 1
ar[b][1] += 1
ar[a][1] -= 1
if ar[a][1] == 0:
ar[a][0] = 0
count = 0
for r in ar:
if r[0] == 1:
count += 1
print(count) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
17,
0,
13,
4,
13,
39,
17,
13,
13,
28,
13,
13,
13,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13
] | [
[
98,
2
],
[
98,
11
],
[
15,
14
],
[
99,
17
],
[
92,
30
],
[
35,
34
],
[
96,
39
],
[
34,
42
],
[
104,
45
],
[
101,
50
],
[
105,
59
],
[
105,
62
],
[
77,
67
],
[
102,
68
],
[
105,
73
],
[
80,
77
],
[
102,
78
],
[
85,
82
],
[
102,
83
],
[
105,
90
],
[
92,
93
],
[
98,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
]
] | [
"n, m = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(m)]\n\nred, cnt = set([1]), {i: 1 for i in range(1, n + 1)}\nfor xi, yi in xy:\n if xi in red:\n red.add(yi)\n if cnt[xi] == 1:\n red.remove(xi)\n cnt[xi] -= 1\n cnt[yi] += 1\nprint(len(red))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"list(map(int, input().split())) for _ in range(m)",
"for _ in range(m)",
"_",
"range(m)",
"range",
"m",
"for _ in range(m)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xy = [list(map(int, input().split())) for _ in range(m)]",
"xy",
"[list(map(int, input().split())) for _ in range(m)]",
"i: 1 for i in range(1, n + 1)",
"for i in range(1, n + 1)",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"for i in range(1, n + 1)",
"i",
"1",
"red, cnt = set([1]), {i: 1 for i in range(1, n + 1)}",
"red",
"set([1])",
"set",
"[1]",
"1",
"cnt",
"{i: 1 for i in range(1, n + 1)}",
"for xi, yi in xy:\n if xi in red:\n red.add(yi)\n if cnt[xi] == 1:\n red.remove(xi)\n cnt[xi] -= 1\n cnt[yi] += 1",
"xi",
"yi",
"xy",
"if xi in red:\n red.add(yi)\n if cnt[xi] == 1:\n red.remove(xi)\n ",
"xi in red",
"xi",
"red",
"red.add(yi)",
"red.add",
"red",
"add",
"yi",
"if cnt[xi] == 1:\n red.remove(xi)\n ",
"cnt[xi] == 1",
"cnt[xi]",
"cnt",
"xi",
"1",
"red.remove(xi)",
"red.remove",
"red",
"remove",
"xi",
"cnt[xi] -= 1",
"cnt[xi]",
"cnt",
"xi",
"1",
"cnt[yi] += 1",
"cnt[yi]",
"cnt",
"yi",
"1",
"print(len(red))",
"print",
"len(red)",
"len",
"red",
"xy = [list(map(int, input().split())) for _ in range(m)]",
"[list(map(int, input().split())) for _ in range(m)]",
"xy",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"cnt = set([1]), {i: 1 for i in range(1, n + 1)}",
"{i: 1 for i in range(1, n + 1)}",
"cnt",
"red, cnt = set([1]), {i: 1 for i in range(1, n + 1)}",
"set([1])",
"red"
] | n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
red, cnt = set([1]), {i: 1 for i in range(1, n + 1)}
for xi, yi in xy:
if xi in red:
red.add(yi)
if cnt[xi] == 1:
red.remove(xi)
cnt[xi] -= 1
cnt[yi] += 1
print(len(red))
|
[
7,
0,
13,
12,
2,
4,
13,
13,
17,
23,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
106,
2
],
[
115,
11
],
[
115,
20
],
[
112,
22
],
[
116,
30
],
[
109,
33
],
[
116,
37
],
[
40,
39
],
[
101,
42
],
[
118,
44
],
[
107,
47
],
[
118,
53
],
[
113,
56
],
[
119,
57
],
[
62,
59
],
[
113,
60
],
[
104,
61
],
[
67,
64
],
[
110,
65
],
[
119,
66
],
[
72,
69
],
[
110,
70
],
[
104,
71
],
[
64,
75
],
[
85,
75
],
[
110,
76
],
[
119,
77
],
[
83,
80
],
[
113,
81
],
[
119,
82
],
[
88,
85
],
[
110,
86
],
[
119,
87
],
[
93,
90
],
[
110,
91
],
[
104,
92
],
[
113,
98
],
[
115,
101
],
[
118,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
]
] | [
"int1 = lambda x: int(x) - 1\n\nN, M = map(int, input().split())\n\nred = [True] + [False] * (N-1)\nn_ball = [1] * N\n\nfor _ in range(M):\n x,y = map(int1, input().split())\n if red[x]:\n red[y] = True\n n_ball[x] -= 1\n n_ball[y] += 1\n if n_ball[x] == 0:\n red[x] = False\n else:\n n_ball[x] -= 1\n n_ball[y] += 1\n\nprint(sum(red))",
"int1 = lambda x: int(x) - 1",
"int1",
"lambda x: int(x) - 1",
"int(x) - 1",
"int(x)",
"int",
"x",
"1",
"x",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"red = [True] + [False] * (N-1)",
"red",
"[True] + [False] * (N-1)",
"[True]",
"True",
"[False] * (N-1)",
"[False]",
"False",
"N-1",
"N",
"1",
"n_ball = [1] * N",
"n_ball",
"[1] * N",
"[1]",
"1",
"N",
"for _ in range(M):\n x,y = map(int1, input().split())\n if red[x]:\n red[y] = True\n n_ball[x] -= 1\n n_ball[y] += 1\n if n_ball[x] == 0:\n red[x] = False\n else:\n n_ball[x] -= 1\n n_ball[y] += 1",
"_",
"range(M)",
"range",
"M",
"x,y = map(int1, input().split())",
"x",
"map(int1, input().split())",
"map",
"int1",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if red[x]:\n red[y] = True\n n_ball[x] -= 1\n n_ball[y] += 1\n if n_ball[x] == 0:\n red[x] = False\n else:\n n_ball[x] -= 1\n n_ball[y] += 1",
"red[x]",
"red",
"x",
"red[y] = True",
"red[y]",
"red",
"y",
"True",
"n_ball[x] -= 1",
"n_ball[x]",
"n_ball",
"x",
"1",
"n_ball[y] += 1",
"n_ball[y]",
"n_ball",
"y",
"1",
"if n_ball[x] == 0:\n red[x] = False\n ",
"n_ball[x] == 0",
"n_ball[x]",
"n_ball",
"x",
"0",
"red[x] = False",
"red[x]",
"red",
"x",
"False",
"n_ball[x] -= 1",
"n_ball[x]",
"n_ball",
"x",
"1",
"n_ball[y] += 1",
"n_ball[y]",
"n_ball",
"y",
"1",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"y = map(int1, input().split())",
"map(int1, input().split())",
"y",
"int1 = lambda x: int(x) - 1",
"lambda x: int(x) - 1",
"int1",
"n_ball = [1] * N",
"[1] * N",
"n_ball",
"red = [True] + [False] * (N-1)",
"[True] + [False] * (N-1)",
"red",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"x,y = map(int1, input().split())",
"map(int1, input().split())",
"x"
] | int1 = lambda x: int(x) - 1
N, M = map(int, input().split())
red = [True] + [False] * (N-1)
n_ball = [1] * N
for _ in range(M):
x,y = map(int1, input().split())
if red[x]:
red[y] = True
n_ball[x] -= 1
n_ball[y] += 1
if n_ball[x] == 0:
red[x] = False
else:
n_ball[x] -= 1
n_ball[y] += 1
print(sum(red)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
2,
39,
17,
39,
17,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
39,
17,
13,
28,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
2,
2,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13
] | [
[
107,
2
],
[
107,
11
],
[
15,
14
],
[
102,
17
],
[
110,
30
],
[
113,
33
],
[
108,
44
],
[
104,
47
],
[
108,
54
],
[
63,
60
],
[
105,
61
],
[
68,
65
],
[
105,
66
],
[
87,
71
],
[
114,
72
],
[
79,
76
],
[
114,
77
],
[
60,
82
],
[
105,
83
],
[
90,
87
],
[
114,
88
],
[
107,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
]
] | [
"N,M=map(int,input().split())\nxy=[list(map(int,input().split()))for _ in range(M)]\n\ncountR=[0]+[1]+[0]*(N-1)\ncountBall=[0]+[1]*N\n\nfor x,y in xy:\n countBall[x]-=1\n countBall[y]+=1\n if countR[x]>0:\n countR[y]+=1\n if countBall[x]<1:\n countR[x]=0\n\nprint(sum(r*b>0 for r,b in zip(countR,countBall)))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"list(map(int,input().split()))for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xy=[list(map(int,input().split()))for _ in range(M)]",
"xy",
"[list(map(int,input().split()))for _ in range(M)]",
"countR=[0]+[1]+[0]*(N-1)",
"countR",
"[0]+[1]+[0]*(N-1)",
"[0]+[1]",
"[0]",
"0",
"[1]",
"1",
"[0]*(N-1)",
"[0]",
"0",
"N-1",
"N",
"1",
"countBall=[0]+[1]*N",
"countBall",
"[0]+[1]*N",
"[0]",
"0",
"[1]*N",
"[1]",
"1",
"N",
"for x,y in xy:\n countBall[x]-=1\n countBall[y]+=1\n if countR[x]>0:\n countR[y]+=1\n if countBall[x]<1:\n countR[x]=0",
"x",
"y",
"xy",
"countBall[x]-=1",
"countBall[x]",
"countBall",
"x",
"1",
"countBall[y]+=1",
"countBall[y]",
"countBall",
"y",
"1",
"if countR[x]>0:\n countR[y]+=1\n ",
"countR[x]>0",
"countR[x]",
"countR",
"x",
"0",
"countR[y]+=1",
"countR[y]",
"countR",
"y",
"1",
"if countBall[x]<1:\n countR[x]=0",
"countBall[x]<1",
"countBall[x]",
"countBall",
"x",
"1",
"countR[x]=0",
"countR[x]",
"countR",
"x",
"0",
"print(sum(r*b>0 for r,b in zip(countR,countBall)))",
"print",
"sum(r*b>0 for r,b in zip(countR,countBall))",
"sum",
"r*b>0",
"r*b",
"r",
"b",
"0",
"M=map(int,input().split())",
"map(int,input().split())",
"M",
"countBall=[0]+[1]*N",
"[0]+[1]*N",
"countBall",
"N,M=map(int,input().split())",
"map(int,input().split())",
"N",
"xy=[list(map(int,input().split()))for _ in range(M)]",
"[list(map(int,input().split()))for _ in range(M)]",
"xy",
"countR=[0]+[1]+[0]*(N-1)",
"[0]+[1]+[0]*(N-1)",
"countR"
] | N,M=map(int,input().split())
xy=[list(map(int,input().split()))for _ in range(M)]
countR=[0]+[1]+[0]*(N-1)
countBall=[0]+[1]*N
for x,y in xy:
countBall[x]-=1
countBall[y]+=1
if countR[x]>0:
countR[y]+=1
if countBall[x]<1:
countR[x]=0
print(sum(r*b>0 for r,b in zip(countR,countBall))) |
[
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,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
13,
13,
10,
18,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13
] | [
[
148,
4
],
[
145,
13
],
[
142,
22
],
[
157,
38
],
[
146,
45
],
[
157,
47
],
[
51,
50
],
[
158,
53
],
[
146,
63
],
[
139,
66
],
[
154,
69
],
[
152,
73
],
[
78,
75
],
[
155,
76
],
[
160,
80
],
[
152,
84
],
[
155,
91
],
[
101,
96
],
[
155,
97
],
[
108,
103
],
[
161,
104
],
[
115,
110
],
[
161,
111
],
[
161,
119
],
[
130,
125
],
[
155,
126
],
[
155,
135
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
148,
149
],
[
157,
152
],
[
154,
155
],
[
157,
158
],
[
160,
161
]
] | [
"import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn, m = map(int, readline().split())\nxy = [list(map(int, readline().split())) for _ in range(m)]\nflag = [False] * n\nflag[0] = True\ncnt = [1] * n\nfor x, y in xy:\n if flag[x - 1]:\n flag[y - 1] = True\n cnt[x - 1] -= 1\n cnt[y - 1] += 1\n if cnt[x - 1] == 0:\n flag[x - 1] = False\nprint(flag.count(True))",
"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",
"sys.setrecursionlimit(10 ** 7)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 7",
"10",
"7",
"n, m = map(int, readline().split())",
"n",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"m",
"list(map(int, readline().split())) for _ in range(m)",
"for _ in range(m)",
"_",
"range(m)",
"range",
"m",
"for _ in range(m)",
"list(map(int, readline().split()))",
"list",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"xy = [list(map(int, readline().split())) for _ in range(m)]",
"xy",
"[list(map(int, readline().split())) for _ in range(m)]",
"flag = [False] * n",
"flag",
"[False] * n",
"[False]",
"False",
"n",
"flag[0] = True",
"flag[0]",
"flag",
"0",
"True",
"cnt = [1] * n",
"cnt",
"[1] * n",
"[1]",
"1",
"n",
"for x, y in xy:\n if flag[x - 1]:\n flag[y - 1] = True\n cnt[x - 1] -= 1\n cnt[y - 1] += 1\n if cnt[x - 1] == 0:\n flag[x - 1] = False",
"x",
"y",
"xy",
"if flag[x - 1]:\n flag[y - 1] = True\n ",
"flag[x - 1]",
"flag",
"x - 1",
"x",
"1",
"flag[y - 1] = True",
"flag[y - 1]",
"flag",
"y - 1",
"y",
"1",
"True",
"cnt[x - 1] -= 1",
"cnt[x - 1]",
"cnt",
"x - 1",
"x",
"1",
"1",
"cnt[y - 1] += 1",
"cnt[y - 1]",
"cnt",
"y - 1",
"y",
"1",
"1",
"if cnt[x - 1] == 0:\n flag[x - 1] = False",
"cnt[x - 1] == 0",
"cnt[x - 1]",
"cnt",
"x - 1",
"x",
"1",
"0",
"flag[x - 1] = False",
"flag[x - 1]",
"flag",
"x - 1",
"x",
"1",
"False",
"print(flag.count(True))",
"print",
"flag.count(True)",
"flag.count",
"flag",
"count",
"True",
"xy = [list(map(int, readline().split())) for _ in range(m)]",
"[list(map(int, readline().split())) for _ in range(m)]",
"xy",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"n, m = map(int, readline().split())",
"map(int, readline().split())",
"n",
"flag = [False] * n",
"[False] * n",
"flag",
"m = map(int, readline().split())",
"map(int, readline().split())",
"m",
"cnt = [1] * n",
"[1] * n",
"cnt"
] | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, m = map(int, readline().split())
xy = [list(map(int, readline().split())) for _ in range(m)]
flag = [False] * n
flag[0] = True
cnt = [1] * n
for x, y in xy:
if flag[x - 1]:
flag[y - 1] = True
cnt[x - 1] -= 1
cnt[y - 1] += 1
if cnt[x - 1] == 0:
flag[x - 1] = False
print(flag.count(True))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
102,
2
],
[
102,
11
],
[
99,
13
],
[
103,
17
],
[
22,
19
],
[
100,
20
],
[
93,
24
],
[
103,
28
],
[
31,
30
],
[
97,
33
],
[
90,
35
],
[
90,
44
],
[
108,
46
],
[
105,
49
],
[
55,
52
],
[
94,
53
],
[
109,
54
],
[
88,
54
],
[
60,
57
],
[
94,
58
],
[
106,
59
],
[
91,
59
],
[
100,
63
],
[
109,
64
],
[
88,
64
],
[
69,
66
],
[
100,
67
],
[
106,
68
],
[
91,
68
],
[
52,
72
],
[
94,
73
],
[
109,
74
],
[
88,
74
],
[
80,
77
],
[
100,
78
],
[
109,
79
],
[
88,
79
],
[
100,
85
],
[
90,
88
],
[
90,
91
],
[
93,
94
],
[
102,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
],
[
108,
109
]
] | [
"N, M = map(int, input().split())\n\nRed = [0]*N\nRed[0] = 1\nNum = [1]*N\n\nfor i in range(M):\n In, Out = map(int, input().split())\n In -= 1\n Out -= 1\n Num[In] -= 1\n Num[Out] += 1\n if Red[In]:\n Red[Out] = 1\n if Num[In] == 0:\n Red[In] = 0\n\nprint(sum(Red))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"Red = [0]*N",
"Red",
"[0]*N",
"[0]",
"0",
"N",
"Red[0] = 1",
"Red[0]",
"Red",
"0",
"1",
"Num = [1]*N",
"Num",
"[1]*N",
"[1]",
"1",
"N",
"for i in range(M):\n In, Out = map(int, input().split())\n In -= 1\n Out -= 1\n Num[In] -= 1\n Num[Out] += 1\n if Red[In]:\n Red[Out] = 1\n if Num[In] == 0:\n Red[In] = 0",
"i",
"range(M)",
"range",
"M",
"In, Out = map(int, input().split())",
"In",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"Out",
"In -= 1",
"In",
"1",
"Out -= 1",
"Out",
"1",
"Num[In] -= 1",
"Num[In]",
"Num",
"In",
"1",
"Num[Out] += 1",
"Num[Out]",
"Num",
"Out",
"1",
"if Red[In]:\n Red[Out] = 1\n ",
"Red[In]",
"Red",
"In",
"Red[Out] = 1",
"Red[Out]",
"Red",
"Out",
"1",
"if Num[In] == 0:\n Red[In] = 0",
"Num[In] == 0",
"Num[In]",
"Num",
"In",
"0",
"Red[In] = 0",
"Red[In]",
"Red",
"In",
"0",
"print(sum(Red))",
"print",
"sum(Red)",
"sum",
"Red",
"In, Out = map(int, input().split())",
"map(int, input().split())",
"In",
"Out = map(int, input().split())",
"map(int, input().split())",
"Out",
"Num = [1]*N",
"[1]*N",
"Num",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"Red = [0]*N",
"[0]*N",
"Red",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"Out -= 1",
"1",
"Out",
"In -= 1",
"1",
"In"
] | N, M = map(int, input().split())
Red = [0]*N
Red[0] = 1
Num = [1]*N
for i in range(M):
In, Out = map(int, input().split())
In -= 1
Out -= 1
Num[In] -= 1
Num[Out] += 1
if Red[In]:
Red[Out] = 1
if Num[In] == 0:
Red[In] = 0
print(sum(Red)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13
] | [
[
114,
2
],
[
114,
11
],
[
15,
14
],
[
115,
17
],
[
108,
30
],
[
111,
33
],
[
106,
38
],
[
44,
41
],
[
112,
42
],
[
49,
46
],
[
112,
47
],
[
102,
51
],
[
106,
56
],
[
62,
59
],
[
103,
60
],
[
71,
68
],
[
103,
69
],
[
76,
73
],
[
103,
74
],
[
112,
80
],
[
87,
84
],
[
112,
85
],
[
73,
90
],
[
103,
91
],
[
112,
98
],
[
102,
103
],
[
114,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
]
] | [
"N, M = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(M)]\nred = [0] * (N+1) #赤になりうる場所を1とする\nred[1] = 1\nred[0] = \"\"\nball = [1] * (N+1) #個数\nball[0] = \"\"\nfor x, y in xy:\n ball[y] += 1\n ball[x] -= 1\n if red[x] == 1:\n red[y] = 1\n if ball[x] == 0: red[x] = 0\nprint(red.count(1))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"list(map(int, input().split())) for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xy = [list(map(int, input().split())) for _ in range(M)]",
"xy",
"[list(map(int, input().split())) for _ in range(M)]",
"red = [0] * (N+1)",
"red",
"[0] * (N+1)",
"[0]",
"0",
"N+1",
"N",
"1",
"red[1] = 1",
"red[1]",
"red",
"1",
"1",
"red[0] = \"\"",
"red[0]",
"red",
"0",
"\"\"",
"ball = [1] * (N+1)",
"ball",
"[1] * (N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"ball[0] = \"\"",
"ball[0]",
"ball",
"0",
"\"\"",
"for x, y in xy:\n ball[y] += 1\n ball[x] -= 1\n if red[x] == 1:\n red[y] = 1\n if ball[x] == 0: red[x] = 0",
"x",
"y",
"xy",
"ball[y] += 1",
"ball[y]",
"ball",
"y",
"1",
"ball[x] -= 1",
"ball[x]",
"ball",
"x",
"1",
"if red[x] == 1:\n red[y] = 1\n if ball[x] == 0: red[x] = 0",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"if ball[x] == 0: red[x]",
"ball[x] == 0",
"ball[x]",
"ball",
"x",
"0",
"print(red.count(1))",
"print",
"red.count(1)",
"red.count",
"red",
"count",
"1",
"ball = [1] * (N+1)",
"[1] * (N+1)",
"ball",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"xy = [list(map(int, input().split())) for _ in range(M)]",
"[list(map(int, input().split())) for _ in range(M)]",
"xy",
"red = [0] * (N+1)",
"[0] * (N+1)",
"red",
"M = map(int, input().split())",
"map(int, input().split())",
"M"
] | N, M = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(M)]
red = [0] * (N+1) #赤になりうる場所を1とする
red[1] = 1
red[0] = ""
ball = [1] * (N+1) #個数
ball[0] = ""
for x, y in xy:
ball[y] += 1
ball[x] -= 1
if red[x] == 1:
red[y] = 1
if ball[x] == 0: red[x] = 0
print(red.count(1)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
40,
18,
13,
2,
13,
17,
17,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
2,
18,
13,
2,
13,
17,
17,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13
] | [
[
143,
2
],
[
143,
11
],
[
15,
14
],
[
144,
17
],
[
140,
21
],
[
26,
25
],
[
144,
28
],
[
137,
32
],
[
38,
35
],
[
138,
36
],
[
41,
40
],
[
132,
43
],
[
134,
45
],
[
134,
54
],
[
61,
56
],
[
141,
57
],
[
135,
59
],
[
68,
63
],
[
141,
64
],
[
129,
66
],
[
141,
73
],
[
135,
75
],
[
138,
80
],
[
135,
82
],
[
91,
86
],
[
138,
87
],
[
129,
89
],
[
141,
96
],
[
135,
98
],
[
138,
103
],
[
135,
105
],
[
114,
109
],
[
138,
110
],
[
135,
112
],
[
121,
116
],
[
138,
117
],
[
129,
119
],
[
138,
126
],
[
134,
129
],
[
143,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
]
] | [
"N,M=map(int,input().split())\nballs=[1 for _ in range(N)]\nanswers=[0 for _ in range(N)]\nanswers[0]=1\nfor _ in range(M):\n x,y=map(int,input().split())\n balls[x-1]-=1\n balls[y-1]+=1\n if balls[x-1]>=1 and answers[x-1]==1:\n answers[y-1]=1\n elif balls[x-1]==0 and answers[x-1]==1:\n answers[x-1]=0\n answers[y-1]=1\nprint(sum(answers))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"1 for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"1",
"balls=[1 for _ in range(N)]",
"balls",
"[1 for _ in range(N)]",
"0 for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"0",
"answers=[0 for _ in range(N)]",
"answers",
"[0 for _ in range(N)]",
"answers[0]=1",
"answers[0]",
"answers",
"0",
"1",
"for _ in range(M):\n x,y=map(int,input().split())\n balls[x-1]-=1\n balls[y-1]+=1\n if balls[x-1]>=1 and answers[x-1]==1:\n answers[y-1]=1\n elif balls[x-1]==0 and answers[x-1]==1:\n answers[x-1]=0\n answers[y-1]=1",
"_",
"range(M)",
"range",
"M",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"balls[x-1]-=1",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"1",
"balls[y-1]+=1",
"balls[y-1]",
"balls",
"y-1",
"y",
"1",
"1",
"if balls[x-1]>=1 and answers[x-1]==1:\n answers[y-1]=1\n elif balls[x-1]==0 and answers[x-1]==1:\n answers[x-1]=0\n answers[y-1]=1",
"balls[x-1]>=1 and answers[x-1]==1",
"balls[x-1]>=1",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"1",
"answers[x-1]==1",
"answers[x-1]",
"answers",
"x-1",
"x",
"1",
"1",
"answers[y-1]=1",
"answers[y-1]",
"answers",
"y-1",
"y",
"1",
"1",
"elif balls[x-1]==0 and answers[x-1]==1:\n answers[x-1]=0\n answers[y-1]=1",
"balls[x-1]==0 and answers[x-1]==1",
"balls[x-1]==0",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"0",
"answers[x-1]==1",
"answers[x-1]",
"answers",
"x-1",
"x",
"1",
"1",
"answers[x-1]=0",
"answers[x-1]",
"answers",
"x-1",
"x",
"1",
"0",
"answers[y-1]=1",
"answers[y-1]",
"answers",
"y-1",
"y",
"1",
"1",
"print(sum(answers))",
"print",
"sum(answers)",
"sum",
"answers",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"M=map(int,input().split())",
"map(int,input().split())",
"M",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"answers=[0 for _ in range(N)]",
"[0 for _ in range(N)]",
"answers",
"balls=[1 for _ in range(N)]",
"[1 for _ in range(N)]",
"balls",
"N,M=map(int,input().split())",
"map(int,input().split())",
"N"
] | N,M=map(int,input().split())
balls=[1 for _ in range(N)]
answers=[0 for _ in range(N)]
answers[0]=1
for _ in range(M):
x,y=map(int,input().split())
balls[x-1]-=1
balls[y-1]+=1
if balls[x-1]>=1 and answers[x-1]==1:
answers[y-1]=1
elif balls[x-1]==0 and answers[x-1]==1:
answers[x-1]=0
answers[y-1]=1
print(sum(answers))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
40,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
135,
2
],
[
135,
11
],
[
138,
13
],
[
133,
17
],
[
123,
19
],
[
133,
23
],
[
28,
25
],
[
124,
26
],
[
31,
30
],
[
136,
33
],
[
129,
35
],
[
129,
44
],
[
120,
46
],
[
130,
48
],
[
121,
48
],
[
117,
50
],
[
127,
52
],
[
118,
52
],
[
67,
56
],
[
124,
57
],
[
121,
58
],
[
130,
58
],
[
102,
62
],
[
87,
62
],
[
72,
62
],
[
139,
63
],
[
121,
64
],
[
130,
64
],
[
70,
67
],
[
124,
68
],
[
121,
69
],
[
130,
69
],
[
75,
72
],
[
139,
73
],
[
121,
74
],
[
130,
74
],
[
80,
77
],
[
124,
78
],
[
118,
79
],
[
127,
79
],
[
85,
82
],
[
139,
83
],
[
118,
84
],
[
127,
84
],
[
90,
87
],
[
139,
88
],
[
121,
89
],
[
130,
89
],
[
95,
92
],
[
124,
93
],
[
118,
94
],
[
127,
94
],
[
100,
97
],
[
139,
98
],
[
118,
99
],
[
127,
99
],
[
105,
102
],
[
139,
103
],
[
121,
104
],
[
130,
104
],
[
110,
107
],
[
139,
108
],
[
118,
109
],
[
127,
109
],
[
124,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
129,
127
],
[
129,
130
],
[
135,
133
],
[
135,
136
],
[
138,
139
]
] | [
"n, m = map(int, input().split())\nC = [1]*n\nP = [0]*n\nP[0] = 1\n\nfor i in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n if P[x] != 0:\n if C[x] == 1:\n P[x] = 0\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += 1\n #print(i)\n #print(P)\n #print(C)\nprint(sum(P))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"C = [1]*n",
"C",
"[1]*n",
"[1]",
"1",
"n",
"P = [0]*n",
"P",
"[0]*n",
"[0]",
"0",
"n",
"P[0] = 1",
"P[0]",
"P",
"0",
"1",
"for i in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n if P[x] != 0:\n if C[x] == 1:\n P[x] = 0\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += 1\n #print(i)\n #print(P)\n #print(C)",
"i",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x, y = x-1, y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"if P[x] != 0:\n if C[x] == 1:\n P[x] = 0\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += 1\n #print(i)\n #print(P)\n #print(C)",
"P[x] != 0",
"P[x]",
"P",
"x",
"0",
"if C[x] == 1:\n P[x] = 0\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n ",
"C[x] == 1",
"C[x]",
"C",
"x",
"1",
"P[x] = 0",
"P[x]",
"P",
"x",
"0",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"P[y] = 1",
"P[y]",
"P",
"y",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"P[y] = 1",
"P[y]",
"P",
"y",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"print(sum(P))",
"print",
"sum(P)",
"sum",
"P",
"y = x-1, y-1",
"y-1",
"y",
"x, y = x-1, y-1",
"x-1",
"x",
"P = [0]*n",
"[0]*n",
"P",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"C = [1]*n",
"[1]*n",
"C"
] | n, m = map(int, input().split())
C = [1]*n
P = [0]*n
P[0] = 1
for i in range(m):
x, y = map(int, input().split())
x, y = x-1, y-1
if P[x] != 0:
if C[x] == 1:
P[x] = 0
C[x] -= 1
P[y] = 1
C[y] += 1
else:
C[x] -= 1
P[y] = 1
C[y] += 1
else:
C[x] -= 1
C[y] += 1
#print(i)
#print(P)
#print(C)
print(sum(P))
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
17,
0,
13,
4,
18,
13,
13,
39,
13,
17,
0,
18,
13,
39,
17,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
18,
13,
39,
0,
13,
4,
18,
13,
13,
40,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
131,
4
],
[
131,
13
],
[
137,
16
],
[
28,
25
],
[
138,
26
],
[
33,
30
],
[
138,
31
],
[
122,
35
],
[
39,
38
],
[
117,
41
],
[
125,
43
],
[
125,
52
],
[
138,
57
],
[
120,
59
],
[
68,
63
],
[
138,
64
],
[
126,
66
],
[
75,
70
],
[
138,
71
],
[
120,
73
],
[
138,
79
],
[
120,
81
],
[
90,
85
],
[
138,
86
],
[
120,
88
],
[
97,
92
],
[
138,
93
],
[
126,
95
],
[
128,
99
],
[
138,
101
],
[
134,
104
],
[
129,
110
],
[
135,
114
],
[
131,
117
],
[
125,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
]
] | [
"import numpy as np\nn, m = map(int, input().split())\n'''\nxx = []\nyy = []\n'''\nbox = np.zeros((n, 2))\nbox[:, 0] = 1\nbox[0, 1] = 1\n\n\ncount = 0\nfor _ in range(m):\n x, y = map(int, input().split())\n '''\n xx.append(x)\n yy.append(y)\n '''\n if (box[x - 1, 1] == 1):\n box[y - 1, 1] = 1\n\n box[x - 1, 0] -= 1\n\n if (box[x - 1, 0] == 0):\n box[x - 1, 1] = 0\n\n box[y - 1, 0] += 1\n\n # 赤玉が一度でもある場合\ntar = box[:, 1]\nans = np.sum(tar != 0)\nprint(ans)\n\n#xy = [list(map(int, input().split())) for _ in range(m)]",
"import numpy as np",
"numpy",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"'''\nxx = []\nyy = []\n'''",
"box = np.zeros((n, 2))",
"box",
"np.zeros((n, 2))",
"np.zeros",
"np",
"zeros",
"(n, 2)",
"n",
"2",
"box[:, 0] = 1",
"box[:, 0]",
"box",
":",
"1",
"box[0, 1] = 1",
"box[0, 1]",
"box",
"0",
"1",
"count = 0",
"count",
"0",
"for _ in range(m):\n x, y = map(int, input().split())\n '''\n xx.append(x)\n yy.append(y)\n '''\n if (box[x - 1, 1] == 1):\n box[y - 1, 1] = 1\n\n box[x - 1, 0] -= 1\n\n if (box[x - 1, 0] == 0):\n box[x - 1, 1] = 0\n\n box[y - 1, 0] += 1\n\n # 赤玉が一度でもある場合",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"'''\n xx.append(x)\n yy.append(y)\n '''",
"if (box[x - 1, 1] == 1):\n box[y - 1, 1] = 1\n\n ",
"box[x - 1, 1] == 1",
"box[x - 1, 1]",
"box",
"x - 1",
"x",
"1",
"1",
"box[y - 1, 1] = 1",
"box[y - 1, 1]",
"box",
"y - 1",
"y",
"1",
"1",
"box[x - 1, 0] -= 1",
"box[x - 1, 0]",
"box",
"x - 1",
"x",
"1",
"1",
"if (box[x - 1, 0] == 0):\n box[x - 1, 1] = 0\n\n ",
"box[x - 1, 0] == 0",
"box[x - 1, 0]",
"box",
"x - 1",
"x",
"1",
"0",
"box[x - 1, 1] = 0",
"box[x - 1, 1]",
"box",
"x - 1",
"x",
"1",
"0",
"box[y - 1, 0] += 1",
"box[y - 1, 0]",
"box",
"y - 1",
"y",
"1",
"1",
"tar = box[:, 1]",
"tar",
"box[:, 1]",
"box",
":",
"ans = np.sum(tar != 0)",
"ans",
"np.sum(tar != 0)",
"np.sum",
"np",
"sum",
"tar != 0",
"tar",
"0",
"print(ans)",
"print",
"ans",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"count = 0",
"0",
"count",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"tar = box[:, 1]",
"box[:, 1]",
"tar",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"ans = np.sum(tar != 0)",
"np.sum(tar != 0)",
"ans",
"box = np.zeros((n, 2))",
"np.zeros((n, 2))",
"box"
] | import numpy as np
n, m = map(int, input().split())
'''
xx = []
yy = []
'''
box = np.zeros((n, 2))
box[:, 0] = 1
box[0, 1] = 1
count = 0
for _ in range(m):
x, y = map(int, input().split())
'''
xx.append(x)
yy.append(y)
'''
if (box[x - 1, 1] == 1):
box[y - 1, 1] = 1
box[x - 1, 0] -= 1
if (box[x - 1, 0] == 0):
box[x - 1, 1] = 0
box[y - 1, 0] += 1
# 赤玉が一度でもある場合
tar = box[:, 1]
ans = np.sum(tar != 0)
print(ans)
#xy = [list(map(int, input().split())) for _ in range(m)]
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
102,
2
],
[
102,
11
],
[
96,
13
],
[
103,
17
],
[
87,
19
],
[
103,
23
],
[
28,
25
],
[
88,
26
],
[
31,
30
],
[
91,
33
],
[
99,
35
],
[
99,
50
],
[
55,
52
],
[
97,
53
],
[
100,
54
],
[
60,
57
],
[
97,
58
],
[
94,
59
],
[
88,
63
],
[
100,
64
],
[
69,
66
],
[
88,
67
],
[
94,
68
],
[
52,
72
],
[
97,
73
],
[
100,
74
],
[
80,
77
],
[
88,
78
],
[
100,
79
],
[
88,
85
],
[
87,
88
],
[
102,
91
],
[
99,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
]
] | [
"n, m = map(int, input().split())\ncounts = [1] * n\ncands = [False] * n\ncands[0] = True\nfor _ in range(m):\n x, y = map(lambda t: int(t) - 1, input().split())\n counts[x] -= 1\n counts[y] += 1\n if cands[x]:\n cands[y] = True\n if counts[x] == 0:\n cands[x] = False\nprint(sum(cands))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"counts = [1] * n",
"counts",
"[1] * n",
"[1]",
"1",
"n",
"cands = [False] * n",
"cands",
"[False] * n",
"[False]",
"False",
"n",
"cands[0] = True",
"cands[0]",
"cands",
"0",
"True",
"for _ in range(m):\n x, y = map(lambda t: int(t) - 1, input().split())\n counts[x] -= 1\n counts[y] += 1\n if cands[x]:\n cands[y] = True\n if counts[x] == 0:\n cands[x] = False",
"_",
"range(m)",
"range",
"m",
"x, y = map(lambda t: int(t) - 1, input().split())",
"x",
"map(lambda t: int(t) - 1, input().split())",
"map",
"lambda t: int(t) - 1",
"int(t) - 1",
"int(t)",
"int",
"t",
"1",
"t",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"counts[x] -= 1",
"counts[x]",
"counts",
"x",
"1",
"counts[y] += 1",
"counts[y]",
"counts",
"y",
"1",
"if cands[x]:\n cands[y] = True\n if counts[x] == 0:\n cands[x] = False",
"cands[x]",
"cands",
"x",
"cands[y] = True",
"cands[y]",
"cands",
"y",
"True",
"if counts[x] == 0:\n cands[x] = False",
"counts[x] == 0",
"counts[x]",
"counts",
"x",
"0",
"cands[x] = False",
"cands[x]",
"cands",
"x",
"False",
"print(sum(cands))",
"print",
"sum(cands)",
"sum",
"cands",
"cands = [False] * n",
"[False] * n",
"cands",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"y = map(lambda t: int(t) - 1, input().split())",
"map(lambda t: int(t) - 1, input().split())",
"y",
"counts = [1] * n",
"[1] * n",
"counts",
"x, y = map(lambda t: int(t) - 1, input().split())",
"map(lambda t: int(t) - 1, input().split())",
"x",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n"
] | n, m = map(int, input().split())
counts = [1] * n
cands = [False] * n
cands[0] = True
for _ in range(m):
x, y = map(lambda t: int(t) - 1, input().split())
counts[x] -= 1
counts[y] += 1
if cands[x]:
cands[y] = True
if counts[x] == 0:
cands[x] = False
print(sum(cands)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
109,
2
],
[
109,
11
],
[
106,
13
],
[
110,
17
],
[
97,
19
],
[
110,
23
],
[
28,
25
],
[
98,
26
],
[
31,
30
],
[
101,
33
],
[
112,
35
],
[
112,
44
],
[
98,
48
],
[
104,
50
],
[
59,
54
],
[
98,
55
],
[
113,
57
],
[
66,
61
],
[
107,
62
],
[
104,
64
],
[
73,
68
],
[
107,
69
],
[
113,
71
],
[
107,
77
],
[
104,
79
],
[
88,
83
],
[
98,
84
],
[
104,
86
],
[
98,
93
],
[
97,
98
],
[
109,
101
],
[
112,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
]
] | [
"N,M=map(int,input().split())\nL=[1]*N\nS=[-1]*N\nS[0]=1\nfor i in range(M):\n\tx,y=map(int,input().split())\n\tif S[x-1]==1:\n\t\tS[y-1]=1\n\tL[x-1]-=1\n\tL[y-1]+=1\n\tif L[x-1]==0:\n\t\tS[x-1]=-1\nprint(S.count(1))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"L=[1]*N",
"L",
"[1]*N",
"[1]",
"1",
"N",
"S=[-1]*N",
"S",
"[-1]*N",
"[-1]",
"-1",
"N",
"S[0]=1",
"S[0]",
"S",
"0",
"1",
"for i in range(M):\n\tx,y=map(int,input().split())\n\tif S[x-1]==1:\n\t\tS[y-1]=1\n\tL[x-1]-=1\n\tL[y-1]+=1\n\tif L[x-1]==0:\n\t\tS[x-1]=-1",
"i",
"range(M)",
"range",
"M",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if S[x-1]==1:\n\t\tS[y-1]=1\n\t",
"S[x-1]==1",
"S[x-1]",
"S",
"x-1",
"x",
"1",
"1",
"S[y-1]=1",
"S[y-1]",
"S",
"y-1",
"y",
"1",
"1",
"L[x-1]-=1",
"L[x-1]",
"L",
"x-1",
"x",
"1",
"1",
"L[y-1]+=1",
"L[y-1]",
"L",
"y-1",
"y",
"1",
"1",
"if L[x-1]==0:\n\t\tS[x-1]=-1",
"L[x-1]==0",
"L[x-1]",
"L",
"x-1",
"x",
"1",
"0",
"S[x-1]=-1",
"S[x-1]",
"S",
"x-1",
"x",
"1",
"-1",
"print(S.count(1))",
"print",
"S.count(1)",
"S.count",
"S",
"count",
"1",
"S=[-1]*N",
"[-1]*N",
"S",
"M=map(int,input().split())",
"map(int,input().split())",
"M",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"L=[1]*N",
"[1]*N",
"L",
"N,M=map(int,input().split())",
"map(int,input().split())",
"N",
"y=map(int,input().split())",
"map(int,input().split())",
"y"
] | N,M=map(int,input().split())
L=[1]*N
S=[-1]*N
S[0]=1
for i in range(M):
x,y=map(int,input().split())
if S[x-1]==1:
S[y-1]=1
L[x-1]-=1
L[y-1]+=1
if L[x-1]==0:
S[x-1]=-1
print(S.count(1)) |
[
7,
15,
13,
12,
13,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
23,
13,
23,
13,
23,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
13,
4,
13,
13,
13,
13,
4,
13,
18,
4,
18,
13,
13,
13,
0,
13,
17,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] | [
[
11,
6
],
[
65,
8
],
[
67,
9
],
[
18,
13
],
[
65,
15
],
[
69,
16
],
[
65,
23
],
[
67,
24
],
[
65,
31
],
[
67,
32
],
[
41,
36
],
[
65,
38
],
[
67,
39
],
[
48,
43
],
[
65,
45
],
[
69,
46
],
[
65,
53
],
[
67,
54
],
[
63,
58
],
[
65,
60
],
[
69,
61
],
[
65,
65
],
[
67,
67
],
[
69,
69
],
[
147,
71
],
[
147,
80
],
[
84,
83
],
[
145,
86
],
[
141,
92
],
[
100,
95
],
[
142,
97
],
[
103,
102
],
[
148,
105
],
[
156,
107
],
[
156,
122
],
[
151,
124
],
[
142,
125
],
[
154,
126
],
[
157,
127
],
[
142,
135
],
[
138,
137
],
[
141,
142
],
[
147,
145
],
[
147,
148
],
[
156,
154
],
[
156,
157
]
] | [
"import numpy as np\n\ndef transfer(state, x, y):\n state[x][0] -= 1\n state[y][0] += 1\n if state[x][0] == 0:\n if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n else:\n if state[x][1] == 1:\n state[y][1] = 1\n \nn, m = map(int, input().split())\n\nstate = [[1, 0] for _ in range(n)]\nstate[0][1] = 1\nfor i in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n transfer(state, x, y)\n\nprint(np.sum(state, axis=0)[1])",
"import numpy as np",
"numpy",
"def transfer(state, x, y):\n state[x][0] -= 1\n state[y][0] += 1\n if state[x][0] == 0:\n if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n else:\n if state[x][1] == 1:\n state[y][1] = 1\n ",
"transfer",
"state[x][0] -= 1",
"state[x][0]",
"[x]",
"state",
"x",
"0",
"1",
"state[y][0] += 1",
"state[y][0]",
"[y]",
"state",
"y",
"0",
"1",
"if state[x][0] == 0:\n if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n else:\n if state[x][1] == 1:\n state[y][1] = 1\n ",
"state[x][0] == 0",
"state[x][0]",
"[x]",
"state",
"x",
"0",
"0",
"if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n ",
"state[x][1] == 1",
"state[x][1]",
"[x]",
"state",
"x",
"1",
"1",
"state[x][1] = 0",
"state[x][1]",
"[x]",
"state",
"x",
"1",
"0",
"state[y][1] = 1",
"state[y][1]",
"[y]",
"state",
"y",
"1",
"1",
"if state[x][1] == 1:\n state[y][1] = 1\n ",
"state[x][1] == 1",
"state[x][1]",
"[x]",
"state",
"x",
"1",
"1",
"state[y][1] = 1",
"state[y][1]",
"[y]",
"state",
"y",
"1",
"1",
"state",
"state",
"x",
"x",
"y",
"y",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"[1, 0] for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"[1, 0]",
"1",
"0",
"state = [[1, 0] for _ in range(n)]",
"state",
"[[1, 0] for _ in range(n)]",
"state[0][1] = 1",
"state[0][1]",
"[0]",
"state",
"0",
"1",
"1",
"for i in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n transfer(state, x, y)",
"i",
"range(m)",
"range",
"m",
"x, y = map(lambda x: int(x) - 1, input().split())",
"x",
"map(lambda x: int(x) - 1, input().split())",
"map",
"lambda x: int(x) - 1",
"int(x) - 1",
"int(x)",
"int",
"x",
"1",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"transfer(state, x, y)",
"transfer",
"state",
"x",
"y",
"print(np.sum(state, axis=0)[1])",
"print",
"np.sum(state, axis=0)[1]",
"np.sum(state, axis=0)",
"np.sum",
"np",
"sum",
"state",
"axis=0",
"axis",
"0",
"1",
"state = [[1, 0] for _ in range(n)]",
"[[1, 0] for _ in range(n)]",
"state",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"def transfer(state, x, y):\n state[x][0] -= 1\n state[y][0] += 1\n if state[x][0] == 0:\n if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n else:\n if state[x][1] == 1:\n state[y][1] = 1\n ",
"def transfer(state, x, y):\n state[x][0] -= 1\n state[y][0] += 1\n if state[x][0] == 0:\n if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n else:\n if state[x][1] == 1:\n state[y][1] = 1\n ",
"transfer",
"x, y = map(lambda x: int(x) - 1, input().split())",
"map(lambda x: int(x) - 1, input().split())",
"x",
"y = map(lambda x: int(x) - 1, input().split())",
"map(lambda x: int(x) - 1, input().split())",
"y"
] | import numpy as np
def transfer(state, x, y):
state[x][0] -= 1
state[y][0] += 1
if state[x][0] == 0:
if state[x][1] == 1:
state[x][1] = 0
state[y][1] = 1
else:
if state[x][1] == 1:
state[y][1] = 1
n, m = map(int, input().split())
state = [[1, 0] for _ in range(n)]
state[0][1] = 1
for i in range(m):
x, y = map(lambda x: int(x) - 1, input().split())
transfer(state, x, y)
print(np.sum(state, axis=0)[1]) |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
17,
15,
13,
4,
18,
13,
13,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
13,
2,
2,
13,
17,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
12,
13,
10,
2,
13
] | [
[
121,
2
],
[
127,
9
],
[
24,
23
],
[
24,
32
],
[
35,
34
],
[
23,
38
],
[
43,
40
],
[
34,
41
],
[
46,
45
],
[
23,
49
],
[
52,
51
],
[
32,
54
],
[
57,
56
],
[
57,
65
],
[
68,
67
],
[
71,
70
],
[
34,
74
],
[
67,
75
],
[
56,
75
],
[
80,
77
],
[
34,
78
],
[
70,
79
],
[
65,
79
],
[
93,
83
],
[
45,
84
],
[
67,
85
],
[
56,
85
],
[
91,
88
],
[
34,
89
],
[
67,
90
],
[
56,
90
],
[
96,
93
],
[
45,
94
],
[
67,
95
],
[
56,
95
],
[
101,
98
],
[
45,
99
],
[
70,
100
],
[
65,
100
],
[
104,
103
],
[
103,
113
],
[
125,
119
],
[
121,
122
],
[
127,
128
]
] | [
"MOD = 10 ** 9 + 7\nINF = 10 ** 11\nimport sys\nsys.setrecursionlimit(100000000)\n\ndef main():\n N,M = map(int,input().split())\n possible = [0] * N\n possible[0] = 1\n ball_cnt = [1] * N\n for _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if possible[x]:\n possible[y] = 1\n if ball_cnt[x] == 1:\n possible[x] = 0\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n ans = sum((b > 0)*p for b,p in zip(ball_cnt,possible))\n print(ans)\nif __name__ == '__main__':\n main()",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"INF = 10 ** 11",
"INF",
"10 ** 11",
"10",
"11",
"import sys",
"sys",
"sys.setrecursionlimit(100000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"100000000",
"def main():\n N,M = map(int,input().split())\n possible = [0] * N\n possible[0] = 1\n ball_cnt = [1] * N\n for _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if possible[x]:\n possible[y] = 1\n if ball_cnt[x] == 1:\n possible[x] = 0\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n ans = sum((b > 0)*p for b,p in zip(ball_cnt,possible))\n print(ans)",
"main",
"N,M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"possible = [0] * N",
"possible",
"[0] * N",
"[0]",
"0",
"N",
"possible[0] = 1",
"possible[0]",
"possible",
"0",
"1",
"ball_cnt = [1] * N",
"ball_cnt",
"[1] * N",
"[1]",
"1",
"N",
"for _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if possible[x]:\n possible[y] = 1\n if ball_cnt[x] == 1:\n possible[x] = 0\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n ",
"_",
"range(M)",
"range",
"M",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if possible[x]:\n possible[y] = 1\n if ball_cnt[x] == 1:\n possible[x] = 0\n ",
"possible[x]",
"possible",
"x",
"possible[y] = 1",
"possible[y]",
"possible",
"y",
"1",
"if ball_cnt[x] == 1:\n possible[x] = 0\n ",
"ball_cnt[x] == 1",
"ball_cnt[x]",
"ball_cnt",
"x",
"1",
"possible[x] = 0",
"possible[x]",
"possible",
"x",
"0",
"ball_cnt[x] -= 1",
"ball_cnt[x]",
"ball_cnt",
"x",
"1",
"ball_cnt[y] += 1",
"ball_cnt[y]",
"ball_cnt",
"y",
"1",
"ans = sum((b > 0)*p for b,p in zip(ball_cnt,possible))",
"ans",
"sum((b > 0)*p for b,p in zip(ball_cnt,possible))",
"sum",
"(b > 0)*p",
"b > 0",
"b",
"0",
"p",
"print(ans)",
"print",
"ans",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"def main():\n N,M = map(int,input().split())\n possible = [0] * N\n possible[0] = 1\n ball_cnt = [1] * N\n for _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if possible[x]:\n possible[y] = 1\n if ball_cnt[x] == 1:\n possible[x] = 0\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n ans = sum((b > 0)*p for b,p in zip(ball_cnt,possible))\n print(ans)",
"def main():\n N,M = map(int,input().split())\n possible = [0] * N\n possible[0] = 1\n ball_cnt = [1] * N\n for _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if possible[x]:\n possible[y] = 1\n if ball_cnt[x] == 1:\n possible[x] = 0\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n ans = sum((b > 0)*p for b,p in zip(ball_cnt,possible))\n print(ans)",
"main",
"INF = 10 ** 11",
"10 ** 11",
"INF"
] | MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)
def main():
N,M = map(int,input().split())
possible = [0] * N
possible[0] = 1
ball_cnt = [1] * N
for _ in range(M):
x,y = map(int,input().split())
x -= 1
y -= 1
if possible[x]:
possible[y] = 1
if ball_cnt[x] == 1:
possible[x] = 0
ball_cnt[x] -= 1
ball_cnt[y] += 1
ans = sum((b > 0)*p for b,p in zip(ball_cnt,possible))
print(ans)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
40,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
109,
2
],
[
109,
11
],
[
15,
14
],
[
110,
17
],
[
97,
30
],
[
103,
33
],
[
107,
38
],
[
100,
41
],
[
107,
46
],
[
52,
49
],
[
104,
50
],
[
61,
58
],
[
104,
59
],
[
85,
62
],
[
104,
63
],
[
58,
65
],
[
104,
66
],
[
72,
69
],
[
101,
70
],
[
77,
74
],
[
101,
75
],
[
69,
80
],
[
101,
81
],
[
88,
85
],
[
104,
86
],
[
104,
93
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
109,
107
],
[
109,
110
]
] | [
"#!/usr/bin/env python3\n\n#import\n#import math\n#import numpy as np\nN, M = map(int, input().split())\nQ = [list(map(int, input().split())) for _ in range(M)]\n\nR = [False] * (N + 1)\nnum = [1] * (N + 1)\n\nR[1] = True\n\nfor x, y in Q:\n R[y] = R[x] or R[y]\n num[x] -= 1\n num[y] += 1\n\n if num[x] <= 0:\n R[x] = False\n\nprint(R.count(True))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"list(map(int, input().split())) for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"Q = [list(map(int, input().split())) for _ in range(M)]",
"Q",
"[list(map(int, input().split())) for _ in range(M)]",
"R = [False] * (N + 1)",
"R",
"[False] * (N + 1)",
"[False]",
"False",
"N + 1",
"N",
"1",
"num = [1] * (N + 1)",
"num",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"R[1] = True",
"R[1]",
"R",
"1",
"True",
"for x, y in Q:\n R[y] = R[x] or R[y]\n num[x] -= 1\n num[y] += 1\n\n if num[x] <= 0:\n R[x] = False",
"x",
"y",
"Q",
"R[y] = R[x] or R[y]",
"R[y]",
"R",
"y",
"R[x] or R[y]",
"R[x]",
"R",
"x",
"R[y]",
"R",
"y",
"num[x] -= 1",
"num[x]",
"num",
"x",
"1",
"num[y] += 1",
"num[y]",
"num",
"y",
"1",
"if num[x] <= 0:\n R[x] = False",
"num[x] <= 0",
"num[x]",
"num",
"x",
"0",
"R[x] = False",
"R[x]",
"R",
"x",
"False",
"print(R.count(True))",
"print",
"R.count(True)",
"R.count",
"R",
"count",
"True",
"Q = [list(map(int, input().split())) for _ in range(M)]",
"[list(map(int, input().split())) for _ in range(M)]",
"Q",
"num = [1] * (N + 1)",
"[1] * (N + 1)",
"num",
"R = [False] * (N + 1)",
"[False] * (N + 1)",
"R",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"M = map(int, input().split())",
"map(int, input().split())",
"M"
] | #!/usr/bin/env python3
#import
#import math
#import numpy as np
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(M)]
R = [False] * (N + 1)
num = [1] * (N + 1)
R[1] = True
for x, y in Q:
R[y] = R[x] or R[y]
num[x] -= 1
num[y] += 1
if num[x] <= 0:
R[x] = False
print(R.count(True)) |
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
12,
13,
29,
18,
4,
18,
18,
13,
13,
13,
39,
17,
12,
13,
29,
2,
39,
17,
4,
13,
4,
13,
13,
23,
13,
4,
18,
13,
13,
17,
0,
13,
2,
4,
13,
17,
17,
17,
41,
28,
13,
4,
13,
17,
4,
4,
13,
2,
4,
13,
17,
13,
0,
13,
13,
0,
13,
39,
39,
17,
17,
39,
17,
17,
39,
17,
17,
39,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
13,
13,
10,
2,
13,
10,
12,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
12,
13,
10,
39,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
38,
36
],
[
38,
38
],
[
195,
45
],
[
55,
54
],
[
54,
65
],
[
183,
67
],
[
207,
70
],
[
210,
85
],
[
190,
92
],
[
210,
94
],
[
98,
97
],
[
211,
100
],
[
190,
110
],
[
198,
113
],
[
213,
116
],
[
193,
120
],
[
201,
122
],
[
193,
126
],
[
131,
128
],
[
202,
129
],
[
186,
137
],
[
187,
139
],
[
216,
141
],
[
217,
143
],
[
173,
147
],
[
202,
148
],
[
187,
149
],
[
155,
152
],
[
202,
153
],
[
217,
154
],
[
160,
157
],
[
214,
158
],
[
187,
159
],
[
165,
162
],
[
214,
163
],
[
217,
164
],
[
157,
168
],
[
214,
169
],
[
187,
170
],
[
176,
173
],
[
202,
174
],
[
187,
175
],
[
202,
181
],
[
183,
184
],
[
186,
187
],
[
210,
193
],
[
195,
196
],
[
198,
199
],
[
201,
202
],
[
207,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
]
] | [
"import bisect\nimport copy\nimport heapq\nimport math\nimport sys\nfrom collections import *\nfrom functools import lru_cache\nfrom itertools import accumulate, combinations, permutations, product\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\nsys.setrecursionlimit(500000)\nmod=pow(10,9)+7\nal=[chr(ord('a') + i) for i in range(26)]\ndirection=[[1,0],[0,1],[-1,0],[0,-1]]\n\nn,m=map(int,input().split())\nxy=[list(map(int,input().split())) for i in range(m)]\n\nlst=[1]*n\nanslst=[0]*n\nanslst[0]=1\n\nfor x,y in xy:\n x,y=x-1,y-1\n if anslst[x]==1:\n anslst[y]=1\n lst[x]-=1\n lst[y]+=1\n if lst[x]==0:\n anslst[x]=0\n\nprint(sum(anslst))",
"import bisect",
"bisect",
"import copy",
"copy",
"import heapq",
"heapq",
"import math",
"math",
"import sys",
"sys",
"from collections import *",
"from functools import lru_cache",
"from itertools import accumulate, combinations, permutations, product",
"def input():\n return sys.stdin.readline()[:-1]",
"input",
"return sys.stdin.readline()[:-1]",
"sys.stdin.readline()[:-1]",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
":-1",
"-1",
"def ruiseki(lst):\n return [0]+list(accumulate(lst))",
"ruiseki",
"return [0]+list(accumulate(lst))",
"[0]+list(accumulate(lst))",
"[0]",
"0",
"list(accumulate(lst))",
"list",
"accumulate(lst)",
"accumulate",
"lst",
"lst",
"lst",
"sys.setrecursionlimit(500000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"500000",
"mod=pow(10,9)+7",
"mod",
"pow(10,9)+7",
"pow(10,9)",
"pow",
"10",
"9",
"7",
"chr(ord('a') + i) for i in range(26)",
"for i in range(26)",
"i",
"range(26)",
"range",
"26",
"for i in range(26)",
"chr(ord('a') + i)",
"chr",
"ord('a') + i",
"ord('a')",
"ord",
"'a'",
"i",
"al=[chr(ord('a') + i) for i in range(26)]",
"al",
"[chr(ord('a') + i) for i in range(26)]",
"direction=[[1,0],[0,1],[-1,0],[0,-1]]",
"direction",
"[[1,0],[0,1],[-1,0],[0,-1]]",
"[1,0]",
"1",
"0",
"[0,1]",
"0",
"1",
"[-1,0]",
"-1",
"0",
"[0,-1]",
"0",
"-1",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"list(map(int,input().split())) for i in range(m)",
"for i in range(m)",
"i",
"range(m)",
"range",
"m",
"for i in range(m)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xy=[list(map(int,input().split())) for i in range(m)]",
"xy",
"[list(map(int,input().split())) for i in range(m)]",
"lst=[1]*n",
"lst",
"[1]*n",
"[1]",
"1",
"n",
"anslst=[0]*n",
"anslst",
"[0]*n",
"[0]",
"0",
"n",
"anslst[0]=1",
"anslst[0]",
"anslst",
"0",
"1",
"for x,y in xy:\n x,y=x-1,y-1\n if anslst[x]==1:\n anslst[y]=1\n lst[x]-=1\n lst[y]+=1\n if lst[x]==0:\n anslst[x]=0",
"x",
"y",
"xy",
"x,y=x-1,y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"if anslst[x]==1:\n anslst[y]=1\n ",
"anslst[x]==1",
"anslst[x]",
"anslst",
"x",
"1",
"anslst[y]=1",
"anslst[y]",
"anslst",
"y",
"1",
"lst[x]-=1",
"lst[x]",
"lst",
"x",
"1",
"lst[y]+=1",
"lst[y]",
"lst",
"y",
"1",
"if lst[x]==0:\n anslst[x]=0",
"lst[x]==0",
"lst[x]",
"lst",
"x",
"0",
"anslst[x]=0",
"anslst[x]",
"anslst",
"x",
"0",
"print(sum(anslst))",
"print",
"sum(anslst)",
"sum",
"anslst",
"al=[chr(ord('a') + i) for i in range(26)]",
"[chr(ord('a') + i) for i in range(26)]",
"al",
"x,y=x-1,y-1",
"x-1",
"x",
"def input():\n return sys.stdin.readline()[:-1]",
"def input():\n return sys.stdin.readline()[:-1]",
"input",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"mod=pow(10,9)+7",
"pow(10,9)+7",
"mod",
"xy=[list(map(int,input().split())) for i in range(m)]",
"[list(map(int,input().split())) for i in range(m)]",
"xy",
"anslst=[0]*n",
"[0]*n",
"anslst",
"def ruiseki(lst):\n return [0]+list(accumulate(lst))",
"def ruiseki(lst):\n return [0]+list(accumulate(lst))",
"ruiseki",
"direction=[[1,0],[0,1],[-1,0],[0,-1]]",
"[[1,0],[0,1],[-1,0],[0,-1]]",
"direction",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"lst=[1]*n",
"[1]*n",
"lst",
"y=x-1,y-1",
"y-1",
"y"
] | import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]
n,m=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(m)]
lst=[1]*n
anslst=[0]*n
anslst[0]=1
for x,y in xy:
x,y=x-1,y-1
if anslst[x]==1:
anslst[y]=1
lst[x]-=1
lst[y]+=1
if lst[x]==0:
anslst[x]=0
print(sum(anslst)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
113,
2
],
[
113,
11
],
[
92,
13
],
[
114,
17
],
[
104,
19
],
[
114,
27
],
[
31,
30
],
[
99,
33
],
[
110,
35
],
[
110,
44
],
[
101,
46
],
[
111,
48
],
[
102,
48
],
[
107,
50
],
[
96,
52
],
[
108,
52
],
[
58,
55
],
[
93,
56
],
[
102,
57
],
[
111,
57
],
[
63,
60
],
[
93,
61
],
[
108,
62
],
[
96,
62
],
[
82,
66
],
[
105,
67
],
[
102,
68
],
[
111,
68
],
[
74,
71
],
[
105,
72
],
[
108,
73
],
[
96,
73
],
[
55,
77
],
[
93,
78
],
[
102,
79
],
[
111,
79
],
[
85,
82
],
[
105,
83
],
[
102,
84
],
[
111,
84
],
[
105,
90
],
[
92,
93
],
[
110,
96
],
[
113,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
]
] | [
"n, m = map(int, input().split())\n\nball = [1] * n\nflag = [1] + [0] * (n-1)\n\nfor _ in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n\n ball[x] -= 1\n ball[y] += 1\n\n if flag[x] == 1:\n flag[y] = 1\n\n if ball[x] == 0:\n flag[x] = 0\n\nprint(sum(flag))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ball = [1] * n",
"ball",
"[1] * n",
"[1]",
"1",
"n",
"flag = [1] + [0] * (n-1)",
"flag",
"[1] + [0] * (n-1)",
"[1]",
"1",
"[0] * (n-1)",
"[0]",
"0",
"n-1",
"n",
"1",
"for _ in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n\n ball[x] -= 1\n ball[y] += 1\n\n if flag[x] == 1:\n flag[y] = 1\n\n if ball[x] == 0:\n flag[x] = 0",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x, y = x-1, y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"ball[x] -= 1",
"ball[x]",
"ball",
"x",
"1",
"ball[y] += 1",
"ball[y]",
"ball",
"y",
"1",
"if flag[x] == 1:\n flag[y] = 1\n\n ",
"flag[x] == 1",
"flag[x]",
"flag",
"x",
"1",
"flag[y] = 1",
"flag[y]",
"flag",
"y",
"1",
"if ball[x] == 0:\n flag[x] = 0",
"ball[x] == 0",
"ball[x]",
"ball",
"x",
"0",
"flag[x] = 0",
"flag[x]",
"flag",
"x",
"0",
"print(sum(flag))",
"print",
"sum(flag)",
"sum",
"flag",
"ball = [1] * n",
"[1] * n",
"ball",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"x, y = x-1, y-1",
"x-1",
"x",
"flag = [1] + [0] * (n-1)",
"[1] + [0] * (n-1)",
"flag",
"y = x-1, y-1",
"y-1",
"y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n"
] | n, m = map(int, input().split())
ball = [1] * n
flag = [1] + [0] * (n-1)
for _ in range(m):
x, y = map(int, input().split())
x, y = x-1, y-1
ball[x] -= 1
ball[y] += 1
if flag[x] == 1:
flag[y] = 1
if ball[x] == 0:
flag[x] = 0
print(sum(flag)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
13,
17,
18,
13,
13,
0,
13,
17,
4,
13,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
158,
2
],
[
158,
11
],
[
15,
14
],
[
159,
17
],
[
149,
21
],
[
137,
24
],
[
144,
28
],
[
131,
30
],
[
144,
34
],
[
39,
36
],
[
132,
37
],
[
134,
41
],
[
45,
44
],
[
159,
47
],
[
146,
49
],
[
150,
52
],
[
44,
53
],
[
140,
56
],
[
150,
59
],
[
44,
60
],
[
68,
63
],
[
138,
64
],
[
147,
66
],
[
75,
70
],
[
138,
71
],
[
141,
73
],
[
132,
79
],
[
147,
81
],
[
90,
85
],
[
132,
86
],
[
141,
88
],
[
138,
94
],
[
147,
96
],
[
105,
100
],
[
132,
101
],
[
147,
103
],
[
152,
107
],
[
111,
110
],
[
144,
113
],
[
138,
118
],
[
110,
119
],
[
132,
122
],
[
110,
123
],
[
155,
125
],
[
156,
129
],
[
153,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
158,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
]
] | [
"n,m = map(int,input().split())\nxy = [[int(i) for i in input().split()] for _ in range(m)]\nnum = [1]*n\nred = [False]*n\nred[0] = True\nflag = True\nfor i in range(m):\n p = xy[i][0]\n q = xy[i][1]\n num[p-1] -= 1\n num[q-1] += 1\n if red[p-1]==True:\n red[q-1] = True\n \n if num[p-1]==0:\n red[p-1] = False\n \n\ncount = 0\nfor i in range(n):\n if num[i]>0 and red[i]:\n count += 1\nprint(count)",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"[int(i) for i in input().split()] for _ in range(m)",
"for _ in range(m)",
"_",
"range(m)",
"range",
"m",
"for _ in range(m)",
"[int(i) for i in input().split()]",
"xy = [[int(i) for i in input().split()] for _ in range(m)]",
"xy",
"[[int(i) for i in input().split()] for _ in range(m)]",
"num = [1]*n",
"num",
"[1]*n",
"[1]",
"1",
"n",
"red = [False]*n",
"red",
"[False]*n",
"[False]",
"False",
"n",
"red[0] = True",
"red[0]",
"red",
"0",
"True",
"flag = True",
"flag",
"True",
"for i in range(m):\n p = xy[i][0]\n q = xy[i][1]\n num[p-1] -= 1\n num[q-1] += 1\n if red[p-1]==True:\n red[q-1] = True\n \n if num[p-1]==0:\n red[p-1] = False\n ",
"i",
"range(m)",
"range",
"m",
"p = xy[i][0]",
"p",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"q = xy[i][1]",
"q",
"xy[i][1]",
"[i]",
"xy",
"i",
"1",
"num[p-1] -= 1",
"num[p-1]",
"num",
"p-1",
"p",
"1",
"1",
"num[q-1] += 1",
"num[q-1]",
"num",
"q-1",
"q",
"1",
"1",
"if red[p-1]==True:\n red[q-1] = True\n \n ",
"red[p-1]==True",
"red[p-1]",
"red",
"p-1",
"p",
"1",
"True",
"red[q-1] = True",
"red[q-1]",
"red",
"q-1",
"q",
"1",
"True",
"if num[p-1]==0:\n red[p-1] = False\n ",
"num[p-1]==0",
"num[p-1]",
"num",
"p-1",
"p",
"1",
"0",
"red[p-1] = False",
"red[p-1]",
"red",
"p-1",
"p",
"1",
"False",
"count = 0",
"count",
"0",
"for i in range(n):\n if num[i]>0 and red[i]:\n count += 1",
"i",
"range(n)",
"range",
"n",
"if num[i]>0 and red[i]:\n count += 1",
"num[i]>0 and red[i]",
"num[i]>0",
"num[i]",
"num",
"i",
"0",
"red[i]",
"red",
"i",
"count += 1",
"count",
"1",
"print(count)",
"print",
"count",
"red = [False]*n",
"[False]*n",
"red",
"flag = True",
"True",
"flag",
"num = [1]*n",
"[1]*n",
"num",
"q = xy[i][1]",
"xy[i][1]",
"q",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"p = xy[i][0]",
"xy[i][0]",
"p",
"xy = [[int(i) for i in input().split()] for _ in range(m)]",
"[[int(i) for i in input().split()] for _ in range(m)]",
"xy",
"count = 0",
"0",
"count",
"count += 1",
"1",
"count",
"m = map(int,input().split())",
"map(int,input().split())",
"m"
] | n,m = map(int,input().split())
xy = [[int(i) for i in input().split()] for _ in range(m)]
num = [1]*n
red = [False]*n
red[0] = True
flag = True
for i in range(m):
p = xy[i][0]
q = xy[i][1]
num[p-1] -= 1
num[q-1] += 1
if red[p-1]==True:
red[q-1] = True
if num[p-1]==0:
red[p-1] = False
count = 0
for i in range(n):
if num[i]>0 and red[i]:
count += 1
print(count) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
18,
13,
13,
14,
40,
18,
13,
13,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] | [
[
124,
2
],
[
124,
11
],
[
109,
13
],
[
125,
17
],
[
22,
19
],
[
110,
20
],
[
118,
24
],
[
125,
28
],
[
31,
30
],
[
116,
33
],
[
127,
35
],
[
127,
44
],
[
121,
46
],
[
136,
49
],
[
55,
52
],
[
119,
53
],
[
122,
54
],
[
128,
54
],
[
60,
57
],
[
119,
58
],
[
137,
59
],
[
113,
59
],
[
65,
62
],
[
110,
63
],
[
137,
64
],
[
113,
64
],
[
78,
66
],
[
110,
67
],
[
122,
68
],
[
128,
68
],
[
62,
69
],
[
110,
70
],
[
137,
71
],
[
113,
71
],
[
52,
74
],
[
119,
75
],
[
122,
76
],
[
128,
76
],
[
81,
78
],
[
110,
79
],
[
122,
80
],
[
128,
80
],
[
130,
83
],
[
87,
86
],
[
125,
89
],
[
110,
94
],
[
86,
95
],
[
119,
99
],
[
86,
100
],
[
133,
103
],
[
134,
107
],
[
131,
107
],
[
109,
110
],
[
127,
113
],
[
124,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
],
[
130,
131
],
[
133,
134
],
[
136,
137
]
] | [
"n, m = map(int, input().split())\n\nr = [False] * n\nr[0] = True\nl = [1] * n\n\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n l[x] -= 1\n l[y] += 1\n r[y] = r[x] | r[y]\n if not l[x]:\n r[x] = False\n\nc = 0\nfor i in range(n):\n if r[i] == True and l[i] > 0:\n c += 1\n\nprint(c)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"r = [False] * n",
"r",
"[False] * n",
"[False]",
"False",
"n",
"r[0] = True",
"r[0]",
"r",
"0",
"True",
"l = [1] * n",
"l",
"[1] * n",
"[1]",
"1",
"n",
"for _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n l[x] -= 1\n l[y] += 1\n r[y] = r[x] | r[y]\n if not l[x]:\n r[x] = False",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"l[x] -= 1",
"l[x]",
"l",
"x",
"1",
"l[y] += 1",
"l[y]",
"l",
"y",
"1",
"r[y] = r[x] | r[y]",
"r[y]",
"r",
"y",
"r[x] | r[y]",
"r[x]",
"r",
"x",
"r[y]",
"r",
"y",
"if not l[x]:\n r[x] = False",
"not l[x]",
"l[x]",
"l",
"x",
"r[x] = False",
"r[x]",
"r",
"x",
"False",
"c = 0",
"c",
"0",
"for i in range(n):\n if r[i] == True and l[i] > 0:\n c += 1",
"i",
"range(n)",
"range",
"n",
"if r[i] == True and l[i] > 0:\n c += 1",
"r[i] == True and l[i] > 0",
"r[i] == True",
"r[i]",
"r",
"i",
"True",
"l[i] > 0",
"l[i]",
"l",
"i",
"0",
"c += 1",
"c",
"1",
"print(c)",
"print",
"c",
"r = [False] * n",
"[False] * n",
"r",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"l = [1] * n",
"[1] * n",
"l",
"x -= 1",
"1",
"x",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"c = 0",
"0",
"c",
"c += 1",
"1",
"c",
"y -= 1",
"1",
"y"
] | n, m = map(int, input().split())
r = [False] * n
r[0] = True
l = [1] * n
for _ in range(m):
x, y = map(int, input().split())
x -= 1
y -= 1
l[x] -= 1
l[y] += 1
r[y] = r[x] | r[y]
if not l[x]:
r[x] = False
c = 0
for i in range(n):
if r[i] == True and l[i] > 0:
c += 1
print(c)
|
[
7,
15,
13,
15,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
2,
18,
13,
2,
13,
17,
17,
40,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
2,
18,
13,
2,
13,
17,
17,
40,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
40,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
4,
13,
10,
18,
13,
10,
12,
13
] | [
[
205,
5
],
[
202,
21
],
[
199,
26
],
[
36,
35
],
[
206,
42
],
[
36,
44
],
[
47,
46
],
[
35,
50
],
[
53,
52
],
[
35,
56
],
[
61,
58
],
[
46,
59
],
[
66,
63
],
[
52,
64
],
[
69,
68
],
[
44,
71
],
[
74,
73
],
[
206,
80
],
[
74,
82
],
[
46,
87
],
[
73,
89
],
[
52,
94
],
[
73,
96
],
[
105,
100
],
[
52,
101
],
[
73,
103
],
[
46,
109
],
[
82,
111
],
[
120,
115
],
[
46,
116
],
[
82,
118
],
[
127,
122
],
[
52,
123
],
[
82,
125
],
[
46,
132
],
[
73,
134
],
[
52,
139
],
[
73,
141
],
[
150,
145
],
[
52,
146
],
[
73,
148
],
[
157,
152
],
[
52,
153
],
[
82,
155
],
[
164,
159
],
[
46,
160
],
[
73,
162
],
[
171,
166
],
[
46,
167
],
[
82,
169
],
[
174,
173
],
[
177,
176
],
[
35,
179
],
[
46,
183
],
[
176,
184
],
[
188,
187
],
[
187,
191
],
[
173,
191
],
[
209,
197
],
[
199,
200
],
[
202,
203
],
[
205,
206
]
] | [
"import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, M = map(int, readline().split())\n R = [0]*(N)\n W = [1]*(N)\n R[0] = 1\n W[0] = 0\n for _ in range(M):\n x, y = map(int, readline().split())\n if R[x-1]==1 and W[x-1]>=1:\n W[x-1] -= 1\n if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n else:\n R[x-1] -= 1\n R[y-1] += 1\n ans = 0\n for i in range(N):\n if R[i]>=1:\n ans += 1\n print(ans)\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"from collections import Counter",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"sys.setrecursionlimit(10 ** 8)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 8",
"10",
"8",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"def main():\n N, M = map(int, readline().split())\n R = [0]*(N)\n W = [1]*(N)\n R[0] = 1\n W[0] = 0\n for _ in range(M):\n x, y = map(int, readline().split())\n if R[x-1]==1 and W[x-1]>=1:\n W[x-1] -= 1\n if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n else:\n R[x-1] -= 1\n R[y-1] += 1\n ans = 0\n for i in range(N):\n if R[i]>=1:\n ans += 1\n print(ans)",
"main",
"N, M = map(int, readline().split())",
"N",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"M",
"R = [0]*(N)",
"R",
"[0]*(N)",
"[0]",
"0",
"N",
"W = [1]*(N)",
"W",
"[1]*(N)",
"[1]",
"1",
"N",
"R[0] = 1",
"R[0]",
"R",
"0",
"1",
"W[0] = 0",
"W[0]",
"W",
"0",
"0",
"for _ in range(M):\n x, y = map(int, readline().split())\n if R[x-1]==1 and W[x-1]>=1:\n W[x-1] -= 1\n if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n else:\n R[x-1] -= 1\n R[y-1] += 1\n ",
"_",
"range(M)",
"range",
"M",
"x, y = map(int, readline().split())",
"x",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"y",
"if R[x-1]==1 and W[x-1]>=1:\n W[x-1] -= 1\n if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n else:\n R[x-1] -= 1\n R[y-1] += 1\n ",
"R[x-1]==1 and W[x-1]>=1",
"R[x-1]==1",
"R[x-1]",
"R",
"x-1",
"x",
"1",
"1",
"W[x-1]>=1",
"W[x-1]",
"W",
"x-1",
"x",
"1",
"1",
"W[x-1] -= 1",
"W[x-1]",
"W",
"x-1",
"x",
"1",
"1",
"if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n ",
"R[y-1]==0",
"R[y-1]",
"R",
"y-1",
"y",
"1",
"0",
"R[y-1]+=1",
"R[y-1]",
"R",
"y-1",
"y",
"1",
"1",
"W[y-1]+=1",
"W[y-1]",
"W",
"y-1",
"y",
"1",
"1",
"elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n ",
"R[x-1]==0 and W[x-1]>=1",
"R[x-1]==0",
"R[x-1]",
"R",
"x-1",
"x",
"1",
"0",
"W[x-1]>=1",
"W[x-1]",
"W",
"x-1",
"x",
"1",
"1",
"W[x-1] -= 1",
"W[x-1]",
"W",
"x-1",
"x",
"1",
"1",
"W[y-1] += 1",
"W[y-1]",
"W",
"y-1",
"y",
"1",
"1",
"R[x-1] -= 1",
"R[x-1]",
"R",
"x-1",
"x",
"1",
"1",
"R[y-1] += 1",
"R[y-1]",
"R",
"y-1",
"y",
"1",
"1",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if R[i]>=1:\n ans += 1\n ",
"i",
"range(N)",
"range",
"N",
"if R[i]>=1:\n ans += 1\n ",
"R[i]>=1",
"R[i]",
"R",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"INF = float('inf')",
"float('inf')",
"INF",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"def main():\n N, M = map(int, readline().split())\n R = [0]*(N)\n W = [1]*(N)\n R[0] = 1\n W[0] = 0\n for _ in range(M):\n x, y = map(int, readline().split())\n if R[x-1]==1 and W[x-1]>=1:\n W[x-1] -= 1\n if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n else:\n R[x-1] -= 1\n R[y-1] += 1\n ans = 0\n for i in range(N):\n if R[i]>=1:\n ans += 1\n print(ans)",
"def main():\n N, M = map(int, readline().split())\n R = [0]*(N)\n W = [1]*(N)\n R[0] = 1\n W[0] = 0\n for _ in range(M):\n x, y = map(int, readline().split())\n if R[x-1]==1 and W[x-1]>=1:\n W[x-1] -= 1\n if R[y-1]==0:\n R[y-1]+=1\n else:\n W[y-1]+=1\n elif R[x-1]==0 and W[x-1]>=1:\n W[x-1] -= 1\n W[y-1] += 1\n else:\n R[x-1] -= 1\n R[y-1] += 1\n ans = 0\n for i in range(N):\n if R[i]>=1:\n ans += 1\n print(ans)",
"main"
] | import sys
from collections import Counter
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
N, M = map(int, readline().split())
R = [0]*(N)
W = [1]*(N)
R[0] = 1
W[0] = 0
for _ in range(M):
x, y = map(int, readline().split())
if R[x-1]==1 and W[x-1]>=1:
W[x-1] -= 1
if R[y-1]==0:
R[y-1]+=1
else:
W[y-1]+=1
elif R[x-1]==0 and W[x-1]>=1:
W[x-1] -= 1
W[y-1] += 1
else:
R[x-1] -= 1
R[y-1] += 1
ans = 0
for i in range(N):
if R[i]>=1:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
18,
13,
2,
13,
17,
17,
17,
9,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
14,
2,
18,
18,
13,
2,
13,
17,
17,
17,
14,
2,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
153,
2
],
[
153,
11
],
[
15,
14
],
[
154,
17
],
[
150,
23
],
[
31,
26
],
[
151,
28
],
[
156,
33
],
[
37,
36
],
[
139,
39
],
[
147,
41
],
[
147,
50
],
[
151,
55
],
[
145,
57
],
[
70,
63
],
[
151,
65
],
[
145,
67
],
[
79,
72
],
[
151,
74
],
[
148,
76
],
[
151,
84
],
[
145,
86
],
[
151,
94
],
[
148,
96
],
[
108,
101
],
[
151,
103
],
[
148,
105
],
[
159,
110
],
[
151,
116
],
[
145,
118
],
[
130,
123
],
[
151,
125
],
[
145,
127
],
[
141,
132
],
[
142,
136
],
[
160,
136
],
[
157,
136
],
[
153,
139
],
[
141,
142
],
[
147,
145
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
],
[
159,
160
]
] | [
"n, m = map(int,input().split())\nbox = [[1,0] for i in range(n)]#個数、赤の可能性\nbox[0][1] = 1\nans = 1\n\nfor i in range(m):\n x, y = map(int,input().split())\n if box[x-1][0] == 0:\n continue\n box[x-1][0] -= 1\n box[y-1][0] += 1\n if box[x-1][1] == 1:\n if box[y-1][1] == 0:\n box[y-1][1] = 1\n ans += 1\n if box[x-1][0] == 0:\n box[x-1][1] = 0\n ans -= 1\n\n\nprint(ans)\n\n",
"n, m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"[1,0] for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"[1,0]",
"1",
"0",
"box = [[1,0] for i in range(n)]",
"box",
"[[1,0] for i in range(n)]",
"box[0][1] = 1",
"box[0][1]",
"[0]",
"box",
"0",
"1",
"1",
"ans = 1",
"ans",
"1",
"for i in range(m):\n x, y = map(int,input().split())\n if box[x-1][0] == 0:\n continue\n box[x-1][0] -= 1\n box[y-1][0] += 1\n if box[x-1][1] == 1:\n if box[y-1][1] == 0:\n box[y-1][1] = 1\n ans += 1\n if box[x-1][0] == 0:\n box[x-1][1] = 0\n ans -= 1",
"i",
"range(m)",
"range",
"m",
"x, y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if box[x-1][0] == 0:\n continue\n ",
"box[x-1][0] == 0",
"box[x-1][0]",
"[x-1]",
"box",
"x-1",
"x",
"1",
"0",
"0",
"continue",
"box[x-1][0] -= 1",
"box[x-1][0]",
"[x-1]",
"box",
"x-1",
"x",
"1",
"0",
"1",
"box[y-1][0] += 1",
"box[y-1][0]",
"[y-1]",
"box",
"y-1",
"y",
"1",
"0",
"1",
"if box[x-1][1] == 1:\n if box[y-1][1] == 0:\n box[y-1][1] = 1\n ans += 1\n if box[x-1][0] == 0:\n box[x-1][1] = 0\n ans -= 1",
"box[x-1][1] == 1",
"box[x-1][1]",
"[x-1]",
"box",
"x-1",
"x",
"1",
"1",
"1",
"if box[y-1][1] == 0:\n box[y-1][1] = 1\n ans += 1\n ",
"box[y-1][1] == 0",
"box[y-1][1]",
"[y-1]",
"box",
"y-1",
"y",
"1",
"1",
"0",
"box[y-1][1] = 1",
"box[y-1][1]",
"[y-1]",
"box",
"y-1",
"y",
"1",
"1",
"1",
"ans += 1",
"ans",
"1",
"if box[x-1][0] == 0:\n box[x-1][1] = 0\n ans -= 1",
"box[x-1][0] == 0",
"box[x-1][0]",
"[x-1]",
"box",
"x-1",
"x",
"1",
"0",
"0",
"box[x-1][1] = 0",
"box[x-1][1]",
"[x-1]",
"box",
"x-1",
"x",
"1",
"1",
"0",
"ans -= 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"ans -= 1",
"1",
"ans",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"box = [[1,0] for i in range(n)]",
"[[1,0] for i in range(n)]",
"box",
"n, m = map(int,input().split())",
"map(int,input().split())",
"n",
"ans = 1",
"1",
"ans",
"ans += 1",
"1",
"ans"
] | n, m = map(int,input().split())
box = [[1,0] for i in range(n)]#個数、赤の可能性
box[0][1] = 1
ans = 1
for i in range(m):
x, y = map(int,input().split())
if box[x-1][0] == 0:
continue
box[x-1][0] -= 1
box[y-1][0] += 1
if box[x-1][1] == 1:
if box[y-1][1] == 0:
box[y-1][1] = 1
ans += 1
if box[x-1][0] == 0:
box[x-1][1] = 0
ans -= 1
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
13,
14,
13,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
117,
2
],
[
117,
11
],
[
123,
13
],
[
97,
17
],
[
99,
19
],
[
97,
23
],
[
28,
25
],
[
124,
26
],
[
31,
30
],
[
118,
33
],
[
120,
35
],
[
120,
44
],
[
111,
46
],
[
114,
49
],
[
55,
52
],
[
100,
53
],
[
115,
54
],
[
109,
54
],
[
124,
58
],
[
112,
59
],
[
121,
59
],
[
64,
61
],
[
124,
62
],
[
115,
63
],
[
109,
63
],
[
69,
66
],
[
100,
67
],
[
112,
68
],
[
121,
68
],
[
66,
72
],
[
100,
73
],
[
112,
74
],
[
121,
74
],
[
80,
77
],
[
124,
78
],
[
112,
79
],
[
121,
79
],
[
102,
82
],
[
86,
85
],
[
124,
85
],
[
105,
90
],
[
106,
94
],
[
103,
94
],
[
117,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
],
[
120,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
]
] | [
"n,m = map(int,input().split())\nans = [False]*n\ncnt = [1]*n\nans[0] = True\nfor i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n cnt[y] += 1\n if ans[x]:\n ans[y] = True\n cnt[x] -= 1\n if cnt[x]==0:\n ans[x] = False\nc = 0\nfor i in ans:\n if i:\n c += 1\n\nprint(c)\n ",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ans = [False]*n",
"ans",
"[False]*n",
"[False]",
"False",
"n",
"cnt = [1]*n",
"cnt",
"[1]*n",
"[1]",
"1",
"n",
"ans[0] = True",
"ans[0]",
"ans",
"0",
"True",
"for i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n cnt[y] += 1\n if ans[x]:\n ans[y] = True\n cnt[x] -= 1\n if cnt[x]==0:\n ans[x] = False",
"i",
"range(m)",
"range",
"m",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"if ans[x]:\n ans[y] = True\n ",
"ans[x]",
"ans",
"x",
"ans[y] = True",
"ans[y]",
"ans",
"y",
"True",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"if cnt[x]==0:\n ans[x] = False",
"cnt[x]==0",
"cnt[x]",
"cnt",
"x",
"0",
"ans[x] = False",
"ans[x]",
"ans",
"x",
"False",
"c = 0",
"c",
"0",
"for i in ans:\n if i:\n c += 1",
"i",
"ans",
"if i:\n c += 1",
"i",
"c += 1",
"c",
"1",
"print(c)",
"print",
"c",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"cnt = [1]*n",
"[1]*n",
"cnt",
"c = 0",
"0",
"c",
"c += 1",
"1",
"c",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"x -= 1",
"1",
"x",
"y -= 1",
"1",
"y",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x",
"ans = [False]*n",
"[False]*n",
"ans"
] | n,m = map(int,input().split())
ans = [False]*n
cnt = [1]*n
ans[0] = True
for i in range(m):
x,y = map(int,input().split())
x -= 1
y -= 1
cnt[y] += 1
if ans[x]:
ans[y] = True
cnt[x] -= 1
if cnt[x]==0:
ans[x] = False
c = 0
for i in ans:
if i:
c += 1
print(c)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
89,
2
],
[
89,
11
],
[
95,
13
],
[
87,
17
],
[
22,
19
],
[
96,
20
],
[
92,
24
],
[
87,
28
],
[
31,
30
],
[
90,
33
],
[
101,
35
],
[
101,
44
],
[
51,
46
],
[
96,
47
],
[
99,
49
],
[
96,
52
],
[
102,
54
],
[
62,
57
],
[
93,
58
],
[
102,
60
],
[
69,
64
],
[
93,
65
],
[
99,
67
],
[
93,
73
],
[
102,
75
],
[
96,
82
],
[
89,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
101,
99
],
[
101,
102
]
] | [
"n,m=map(int,input().split())\nans=[False]*n\nans[0]=True\nco=[1]*n\nfor i in range(m):\n x,y=map(int,input().split())\n ans[y-1]|=ans[x-1]\n co[x-1]-=1\n co[y-1]+=1\n if co[x-1]==0:ans[x-1]=False\nprint(ans.count(True))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ans=[False]*n",
"ans",
"[False]*n",
"[False]",
"False",
"n",
"ans[0]=True",
"ans[0]",
"ans",
"0",
"True",
"co=[1]*n",
"co",
"[1]*n",
"[1]",
"1",
"n",
"for i in range(m):\n x,y=map(int,input().split())\n ans[y-1]|=ans[x-1]\n co[x-1]-=1\n co[y-1]+=1\n if co[x-1]==0:ans[x-1]=False",
"i",
"range(m)",
"range",
"m",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"ans[y-1]|=ans[x-1]",
"ans[y-1]",
"ans",
"y-1",
"y",
"1",
"ans[x-1]",
"ans",
"x-1",
"x",
"1",
"co[x-1]-=1",
"co[x-1]",
"co",
"x-1",
"x",
"1",
"1",
"co[y-1]+=1",
"co[y-1]",
"co",
"y-1",
"y",
"1",
"1",
"if co[x-1]==0:ans[x-1]=Fal",
"co[x-1]==0",
"co[x-1]",
"co",
"x-1",
"x",
"1",
"0",
"print(ans.count(True))",
"print",
"ans.count(True)",
"ans.count",
"ans",
"count",
"True",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"co=[1]*n",
"[1]*n",
"co",
"ans=[False]*n",
"[False]*n",
"ans",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x"
] | n,m=map(int,input().split())
ans=[False]*n
ans[0]=True
co=[1]*n
for i in range(m):
x,y=map(int,input().split())
ans[y-1]|=ans[x-1]
co[x-1]-=1
co[y-1]+=1
if co[x-1]==0:ans[x-1]=False
print(ans.count(True)) |
[
7,
15,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13
] | [
[
6,
5
],
[
5,
14
],
[
104,
16
],
[
104,
18
],
[
107,
20
],
[
99,
24
],
[
95,
26
],
[
99,
30
],
[
35,
32
],
[
108,
33
],
[
38,
37
],
[
105,
40
],
[
44,
43
],
[
43,
53
],
[
110,
56
],
[
110,
58
],
[
63,
60
],
[
96,
61
],
[
111,
62
],
[
68,
65
],
[
96,
66
],
[
102,
67
],
[
108,
71
],
[
111,
72
],
[
77,
74
],
[
108,
75
],
[
102,
76
],
[
60,
80
],
[
96,
81
],
[
111,
82
],
[
88,
85
],
[
108,
86
],
[
111,
87
],
[
108,
93
],
[
95,
96
],
[
104,
99
],
[
110,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"import copy\nN,M = [int(hoge) for hoge in input().split()]\nBall = [False]*N\nBallNum = [1] * N\nBall[0] = True\nfor i in range(M):\n x,y = [int(hoge) - 1 for hoge in input().split()]\n BallNum[x] -= 1\n BallNum[y] += 1\n if Ball[x]:\n Ball[y] = True \n if BallNum[x] == 0:\n Ball[x] = False\nprint(sum(Ball))",
"import copy",
"copy",
"int(hoge) for hoge in input().split()",
"for hoge in input().split()",
"hoge",
"input().split()",
"().split",
"()",
"input",
"split",
"for hoge in input().split()",
"int(hoge)",
"int",
"hoge",
"N,M = [int(hoge) for hoge in input().split()]",
"N",
"[int(hoge) for hoge in input().split()]",
"M",
"Ball = [False]*N",
"Ball",
"[False]*N",
"[False]",
"False",
"N",
"BallNum = [1] * N",
"BallNum",
"[1] * N",
"[1]",
"1",
"N",
"Ball[0] = True",
"Ball[0]",
"Ball",
"0",
"True",
"for i in range(M):\n x,y = [int(hoge) - 1 for hoge in input().split()]\n BallNum[x] -= 1\n BallNum[y] += 1\n if Ball[x]:\n Ball[y] = True \n if BallNum[x] == 0:\n Ball[x] = False",
"i",
"range(M)",
"range",
"M",
"int(hoge) - 1 for hoge in input().split()",
"for hoge in input().split()",
"hoge",
"input().split()",
"().split",
"()",
"input",
"split",
"for hoge in input().split()",
"int(hoge) - 1",
"int(hoge)",
"int",
"hoge",
"1",
"x,y = [int(hoge) - 1 for hoge in input().split()]",
"x",
"[int(hoge) - 1 for hoge in input().split()]",
"y",
"BallNum[x] -= 1",
"BallNum[x]",
"BallNum",
"x",
"1",
"BallNum[y] += 1",
"BallNum[y]",
"BallNum",
"y",
"1",
"if Ball[x]:\n Ball[y] = True \n ",
"Ball[x]",
"Ball",
"x",
"Ball[y] = True",
"Ball[y]",
"Ball",
"y",
"True",
"if BallNum[x] == 0:\n Ball[x] = False",
"BallNum[x] == 0",
"BallNum[x]",
"BallNum",
"x",
"0",
"Ball[x] = False",
"Ball[x]",
"Ball",
"x",
"False",
"print(sum(Ball))",
"print",
"sum(Ball)",
"sum",
"Ball",
"BallNum = [1] * N",
"[1] * N",
"BallNum",
"N,M = [int(hoge) for hoge in input().split()]",
"[int(hoge) for hoge in input().split()]",
"N",
"y = [int(hoge) - 1 for hoge in input().split()]",
"[int(hoge) - 1 for hoge in input().split()]",
"y",
"M = [int(hoge) for hoge in input().split()]",
"[int(hoge) for hoge in input().split()]",
"M",
"Ball = [False]*N",
"[False]*N",
"Ball",
"x,y = [int(hoge) - 1 for hoge in input().split()]",
"[int(hoge) - 1 for hoge in input().split()]",
"x"
] | import copy
N,M = [int(hoge) for hoge in input().split()]
Ball = [False]*N
BallNum = [1] * N
Ball[0] = True
for i in range(M):
x,y = [int(hoge) - 1 for hoge in input().split()]
BallNum[x] -= 1
BallNum[y] += 1
if Ball[x]:
Ball[y] = True
if BallNum[x] == 0:
Ball[x] = False
print(sum(Ball)) |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
39,
13,
17,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
18,
18,
13,
13,
17,
17,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
18,
18,
13,
13,
17,
17,
0,
13,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
2,
18,
18,
13,
13,
17,
17,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
2,
18,
18,
13,
13,
17,
17,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
39,
13,
10,
18,
13
] | [
[
195,
4
],
[
195,
13
],
[
204,
15
],
[
19,
18
],
[
196,
21
],
[
198,
23
],
[
205,
36
],
[
199,
38
],
[
177,
40
],
[
54,
49
],
[
178,
51
],
[
57,
56
],
[
187,
59
],
[
66,
61
],
[
178,
63
],
[
56,
64
],
[
183,
68
],
[
189,
71
],
[
75,
74
],
[
196,
77
],
[
201,
79
],
[
205,
83
],
[
74,
84
],
[
192,
88
],
[
205,
92
],
[
74,
93
],
[
102,
97
],
[
178,
99
],
[
202,
100
],
[
184,
100
],
[
109,
104
],
[
178,
106
],
[
193,
107
],
[
190,
107
],
[
178,
115
],
[
193,
116
],
[
190,
116
],
[
178,
122
],
[
202,
123
],
[
184,
123
],
[
132,
127
],
[
178,
129
],
[
193,
130
],
[
190,
130
],
[
178,
138
],
[
202,
139
],
[
184,
139
],
[
178,
145
],
[
202,
146
],
[
184,
146
],
[
155,
150
],
[
178,
152
],
[
202,
153
],
[
184,
153
],
[
180,
157
],
[
161,
160
],
[
187,
163
],
[
207,
165
],
[
178,
168
],
[
160,
169
],
[
208,
175
],
[
181,
175
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
195,
187
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
198,
199
],
[
201,
202
],
[
204,
205
],
[
207,
208
]
] | [
"import numpy as np\n\nn,m = map(int,input().split())\nl = []\nfor _ in range(m):\n a = list(map(int,input().split()))\n l.append(a)\n\nmemo = np.zeros((n,2))\nmemo[0][1] = 1\n\nfor i in range(n):\n memo[i][0] = 1\n\ntmp1 = 0\ntmp2 = 0\n\nfor j in range(m):\n tmp1 = l[j][0]-1\n tmp2 = l[j][1]-1\n memo[tmp1][0] -= 1\n memo[tmp2][0] += 1\n \n if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:\n memo[tmp2][1] = 1\n \n if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:\n memo[tmp1][1] = 0\n\nans = 0\nfor k in range(n):\n ans += memo[k][1]\n\nprint(int(ans))",
"import numpy as np",
"numpy",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"l = []",
"l",
"[]",
"for _ in range(m):\n a = list(map(int,input().split()))\n l.append(a)",
"_",
"range(m)",
"range",
"m",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l.append(a)",
"l.append",
"l",
"append",
"a",
"memo = np.zeros((n,2))",
"memo",
"np.zeros((n,2))",
"np.zeros",
"np",
"zeros",
"(n,2)",
"n",
"2",
"memo[0][1] = 1",
"memo[0][1]",
"[0]",
"memo",
"0",
"1",
"1",
"for i in range(n):\n memo[i][0] = 1",
"i",
"range(n)",
"range",
"n",
"memo[i][0] = 1",
"memo[i][0]",
"[i]",
"memo",
"i",
"0",
"1",
"tmp1 = 0",
"tmp1",
"0",
"tmp2 = 0",
"tmp2",
"0",
"for j in range(m):\n tmp1 = l[j][0]-1\n tmp2 = l[j][1]-1\n memo[tmp1][0] -= 1\n memo[tmp2][0] += 1\n \n if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:\n memo[tmp2][1] = 1\n \n if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:\n memo[tmp1][1] = 0",
"j",
"range(m)",
"range",
"m",
"tmp1 = l[j][0]-1",
"tmp1",
"l[j][0]-1",
"l[j][0]",
"[j]",
"l",
"j",
"0",
"1",
"tmp2 = l[j][1]-1",
"tmp2",
"l[j][1]-1",
"l[j][1]",
"[j]",
"l",
"j",
"1",
"1",
"memo[tmp1][0] -= 1",
"memo[tmp1][0]",
"[tmp1]",
"memo",
"tmp1",
"0",
"1",
"memo[tmp2][0] += 1",
"memo[tmp2][0]",
"[tmp2]",
"memo",
"tmp2",
"0",
"1",
"if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:\n memo[tmp2][1] = 1\n \n ",
"memo[tmp2][1] == 0 and memo[tmp1][1] == 1",
"memo[tmp2][1] == 0",
"memo[tmp2][1]",
"[tmp2]",
"memo",
"tmp2",
"1",
"0",
"memo[tmp1][1] == 1",
"memo[tmp1][1]",
"[tmp1]",
"memo",
"tmp1",
"1",
"1",
"memo[tmp2][1] = 1",
"memo[tmp2][1]",
"[tmp2]",
"memo",
"tmp2",
"1",
"1",
"if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:\n memo[tmp1][1] = 0",
"memo[tmp1][1] == 1 and memo[tmp1][0] == 0",
"memo[tmp1][1] == 1",
"memo[tmp1][1]",
"[tmp1]",
"memo",
"tmp1",
"1",
"1",
"memo[tmp1][0] == 0",
"memo[tmp1][0]",
"[tmp1]",
"memo",
"tmp1",
"0",
"0",
"memo[tmp1][1] = 0",
"memo[tmp1][1]",
"[tmp1]",
"memo",
"tmp1",
"1",
"0",
"ans = 0",
"ans",
"0",
"for k in range(n):\n ans += memo[k][1]",
"k",
"range(n)",
"range",
"n",
"ans += memo[k][1]",
"ans",
"memo[k][1]",
"[k]",
"memo",
"k",
"1",
"print(int(ans))",
"print",
"int(ans)",
"int",
"ans",
"memo = np.zeros((n,2))",
"np.zeros((n,2))",
"memo",
"ans = 0",
"0",
"ans",
"tmp1 = 0",
"0",
"tmp1",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"tmp2 = 0",
"0",
"tmp2",
"tmp2 = l[j][1]-1",
"l[j][1]-1",
"tmp2",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"tmp1 = l[j][0]-1",
"l[j][0]-1",
"tmp1",
"l = []",
"[]",
"l",
"ans += memo[k][1]",
"memo[k][1]",
"ans"
] | import numpy as np
n,m = map(int,input().split())
l = []
for _ in range(m):
a = list(map(int,input().split()))
l.append(a)
memo = np.zeros((n,2))
memo[0][1] = 1
for i in range(n):
memo[i][0] = 1
tmp1 = 0
tmp2 = 0
for j in range(m):
tmp1 = l[j][0]-1
tmp2 = l[j][1]-1
memo[tmp1][0] -= 1
memo[tmp2][0] += 1
if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:
memo[tmp2][1] = 1
if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:
memo[tmp1][1] = 0
ans = 0
for k in range(n):
ans += memo[k][1]
print(int(ans))
|
[
7,
15,
13,
12,
13,
29,
18,
4,
18,
18,
13,
13,
13,
39,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
2,
18,
13,
13,
17,
40,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
17,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
143,
16
],
[
129,
23
],
[
143,
25
],
[
122,
27
],
[
138,
31
],
[
36,
33
],
[
123,
34
],
[
140,
38
],
[
138,
42
],
[
45,
44
],
[
144,
47
],
[
134,
49
],
[
129,
56
],
[
134,
58
],
[
146,
60
],
[
125,
63
],
[
78,
68
],
[
123,
69
],
[
147,
70
],
[
132,
70
],
[
105,
73
],
[
141,
74
],
[
147,
75
],
[
132,
75
],
[
81,
78
],
[
123,
79
],
[
147,
80
],
[
132,
80
],
[
86,
83
],
[
123,
84
],
[
126,
85
],
[
135,
85
],
[
78,
90
],
[
123,
91
],
[
147,
92
],
[
132,
92
],
[
105,
95
],
[
141,
96
],
[
147,
97
],
[
132,
97
],
[
103,
100
],
[
123,
101
],
[
126,
102
],
[
135,
102
],
[
108,
105
],
[
141,
106
],
[
147,
107
],
[
132,
107
],
[
113,
110
],
[
141,
111
],
[
126,
112
],
[
135,
112
],
[
123,
118
],
[
122,
123
],
[
125,
126
],
[
134,
132
],
[
134,
135
],
[
143,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
]
] | [
"import sys\n\n\ndef input():\n return sys.stdin.readline()[:-1]\n\n\nN, M = map(int, input().split())\n\nred = [0]*N\nred[0] = 1\nbox = [1]*N\nfor _ in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n\n if red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n red[x] -= 1\n red[y] = 1\n elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n red[y] = 1\n box[x] -= 1\n box[y] += 1\n\nprint(red.count(1))",
"import sys",
"sys",
"def input():\n return sys.stdin.readline()[:-1]",
"input",
"return sys.stdin.readline()[:-1]",
"sys.stdin.readline()[:-1]",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
":-1",
"-1",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"red = [0]*N",
"red",
"[0]*N",
"[0]",
"0",
"N",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"box = [1]*N",
"box",
"[1]*N",
"[1]",
"1",
"N",
"for _ in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n\n if red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n red[x] -= 1\n red[y] = 1\n elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n red[y] = 1\n box[x] -= 1\n box[y] += 1",
"_",
"range(M)",
"range",
"M",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n red[x] -= 1\n red[y] = 1\n elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n red[y] = 1\n ",
"red[x] == 1 and box[x] == 1",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"box[x] == 1",
"box[x]",
"box",
"x",
"1",
"red[x] -= 1",
"red[x]",
"red",
"x",
"1",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n red[y] = 1\n ",
"red[x] == 1 and box[x] >= 2",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"box[x] >= 2",
"box[x]",
"box",
"x",
"2",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"box[y] += 1",
"box[y]",
"box",
"y",
"1",
"print(red.count(1))",
"print",
"red.count(1)",
"red.count",
"red",
"count",
"1",
"red = [0]*N",
"[0]*N",
"red",
"y -= 1",
"1",
"y",
"def input():\n return sys.stdin.readline()[:-1]",
"def input():\n return sys.stdin.readline()[:-1]",
"input",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"box = [1]*N",
"[1]*N",
"box",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"x -= 1",
"1",
"x"
] | import sys
def input():
return sys.stdin.readline()[:-1]
N, M = map(int, input().split())
red = [0]*N
red[0] = 1
box = [1]*N
for _ in range(M):
x, y = map(int, input().split())
x -= 1
y -= 1
if red[x] == 1 and box[x] == 1:
# 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合
red[x] -= 1
red[y] = 1
elif red[x] == 1 and box[x] >= 2:
# 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合
red[y] = 1
box[x] -= 1
box[y] += 1
print(red.count(1))
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
12,
4,
13,
4,
18,
18,
13,
13,
13,
0,
13,
12,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
12,
4,
13,
4,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
12,
4,
13,
17,
31,
13,
17,
32,
4,
13,
0,
13,
18,
13,
13,
32,
13,
23,
16,
0,
13,
4,
13,
13,
12,
13,
0,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
29,
4,
13,
13,
4,
13,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13
] | [
[
156,
11
],
[
168,
22
],
[
147,
37
],
[
169,
42
],
[
153,
44
],
[
159,
56
],
[
69,
68
],
[
165,
77
],
[
169,
79
],
[
165,
80
],
[
85,
84
],
[
88,
87
],
[
166,
91
],
[
94,
93
],
[
163,
96
],
[
99,
98
],
[
169,
100
],
[
99,
101
],
[
104,
103
],
[
107,
106
],
[
103,
110
],
[
98,
110
],
[
84,
111
],
[
129,
114
],
[
87,
115
],
[
103,
116
],
[
98,
116
],
[
84,
120
],
[
103,
122
],
[
98,
122
],
[
84,
125
],
[
106,
127
],
[
101,
127
],
[
132,
129
],
[
87,
130
],
[
103,
131
],
[
98,
131
],
[
137,
134
],
[
87,
135
],
[
106,
136
],
[
101,
136
],
[
84,
141
],
[
151,
145
],
[
147,
148
],
[
153,
154
],
[
156,
157
],
[
159,
160
],
[
165,
163
],
[
165,
166
],
[
168,
169
]
] | [
"import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninm = lambda: map(int, sys.stdin.readline().split())\ninl = lambda: list(inm())\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\nN, M = inm()\n\n\ndef solve():\n pos = {0}\n count = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if x in pos:\n if count[x] == 1:\n pos.remove(x)\n pos.add(y)\n count[x] -= 1\n count[y] += 1\n return len(pos)\n\n\nprint(solve())",
"import sys",
"sys",
"sys.setrecursionlimit(10 ** 8)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 8",
"10",
"8",
"ini = lambda: int(sys.stdin.readline())",
"ini",
"lambda: int(sys.stdin.readline())",
"int(sys.stdin.readline())",
"int",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"inm = lambda: map(int, sys.stdin.readline().split())",
"inm",
"lambda: map(int, sys.stdin.readline().split())",
"map(int, sys.stdin.readline().split())",
"map",
"int",
"sys.stdin.readline().split()",
"sys.stdin.readline().split",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"split",
"inl = lambda: list(inm())",
"inl",
"lambda: list(inm())",
"list(inm())",
"list",
"inm()",
"inm",
"ins = lambda: sys.stdin.readline().rstrip()",
"ins",
"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",
"debug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))",
"debug",
"lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))",
"print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))",
"print",
"\"\\033[33m\"",
"*a",
"a",
"\"\\033[0m\"",
"**dict(file=sys.stderr, **kw)",
"dict(file=sys.stderr, **kw)",
"dict",
"file=sys.stderr",
"file",
"sys.stderr",
"sys",
"stderr",
"**kw",
"kw",
"*a",
"**kw",
"N, M = inm()",
"N",
"inm()",
"inm",
"M",
"def solve():\n pos = {0}\n count = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if x in pos:\n if count[x] == 1:\n pos.remove(x)\n pos.add(y)\n count[x] -= 1\n count[y] += 1\n return len(pos)",
"solve",
"pos = {0}",
"pos",
"{0}",
"count = [1] * N",
"count",
"[1] * N",
"[1]",
"1",
"N",
"for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if x in pos:\n if count[x] == 1:\n pos.remove(x)\n pos.add(y)\n count[x] -= 1\n count[y] += 1\n ",
"i",
"range(M)",
"range",
"M",
"x, y = inm()",
"x",
"inm()",
"inm",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if x in pos:\n if count[x] == 1:\n pos.remove(x)\n pos.add(y)\n ",
"x in pos",
"x",
"pos",
"if count[x] == 1:\n pos.remove(x)\n ",
"count[x] == 1",
"count[x]",
"count",
"x",
"1",
"pos.remove(x)",
"pos.remove",
"pos",
"remove",
"x",
"pos.add(y)",
"pos.add",
"pos",
"add",
"y",
"count[x] -= 1",
"count[x]",
"count",
"x",
"1",
"count[y] += 1",
"count[y]",
"count",
"y",
"1",
"return len(pos)",
"len(pos)",
"len",
"pos",
"print(solve())",
"print",
"solve()",
"solve",
"inl = lambda: list(inm())",
"lambda: list(inm())",
"inl",
"def solve():\n pos = {0}\n count = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if x in pos:\n if count[x] == 1:\n pos.remove(x)\n pos.add(y)\n count[x] -= 1\n count[y] += 1\n return len(pos)",
"def solve():\n pos = {0}\n count = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if x in pos:\n if count[x] == 1:\n pos.remove(x)\n pos.add(y)\n count[x] -= 1\n count[y] += 1\n return len(pos)",
"solve",
"ins = lambda: sys.stdin.readline().rstrip()",
"lambda: sys.stdin.readline().rstrip()",
"ins",
"ini = lambda: int(sys.stdin.readline())",
"lambda: int(sys.stdin.readline())",
"ini",
"debug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))",
"lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))",
"debug",
"M = inm()",
"inm()",
"M",
"N, M = inm()",
"inm()",
"N",
"inm = lambda: map(int, sys.stdin.readline().split())",
"lambda: map(int, sys.stdin.readline().split())",
"inm"
] | import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
N, M = inm()
def solve():
pos = {0}
count = [1] * N
for i in range(M):
x, y = inm()
x -= 1
y -= 1
if x in pos:
if count[x] == 1:
pos.remove(x)
pos.add(y)
count[x] -= 1
count[y] += 1
return len(pos)
print(solve())
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
18,
13,
2,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
0,
18,
13,
13,
2,
4,
18,
13,
13,
13,
17,
17,
0,
18,
13,
13,
2,
4,
18,
13,
13,
13,
17,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
114,
2
],
[
114,
11
],
[
105,
13
],
[
106,
18
],
[
108,
22
],
[
26,
25
],
[
112,
28
],
[
35,
30
],
[
109,
31
],
[
25,
33
],
[
38,
37
],
[
115,
40
],
[
117,
42
],
[
117,
51
],
[
118,
54
],
[
106,
55
],
[
106,
58
],
[
103,
60
],
[
73,
63
],
[
109,
64
],
[
118,
65
],
[
106,
69
],
[
118,
71
],
[
76,
73
],
[
109,
74
],
[
118,
75
],
[
109,
79
],
[
118,
81
],
[
88,
85
],
[
109,
86
],
[
103,
87
],
[
109,
91
],
[
103,
93
],
[
106,
100
],
[
117,
103
],
[
105,
106
],
[
108,
109
],
[
114,
112
],
[
114,
115
],
[
117,
118
]
] | [
"n,m = map(int,input().split())\n\nin_group = set()\nin_group.add(1)\n\nboll_num = {}\nfor i in range(n):\n boll_num[i+1] = 1\n\n\nfor i in range(m):\n x,y = map(int,input().split())\n if(x in in_group):\n in_group.add(y)\n if(boll_num[x] == 1):\n in_group.remove(x)\n \n boll_num[x] = boll_num.setdefault(x,0) - 1\n boll_num[y] = boll_num.setdefault(y,0) + 1\n\nprint(len(in_group))",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"in_group = set()",
"in_group",
"set()",
"set",
"in_group.add(1)",
"in_group.add",
"in_group",
"add",
"1",
"boll_num = {}",
"boll_num",
"{}",
"for i in range(n):\n boll_num[i+1] = 1",
"i",
"range(n)",
"range",
"n",
"boll_num[i+1] = 1",
"boll_num[i+1]",
"boll_num",
"i+1",
"i",
"1",
"1",
"for i in range(m):\n x,y = map(int,input().split())\n if(x in in_group):\n in_group.add(y)\n if(boll_num[x] == 1):\n in_group.remove(x)\n \n boll_num[x] = boll_num.setdefault(x,0) - 1\n boll_num[y] = boll_num.setdefault(y,0) + 1",
"i",
"range(m)",
"range",
"m",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if(x in in_group):\n in_group.add(y)\n if(boll_num[x] == 1):\n in_group.remove(x)\n \n ",
"x in in_group",
"x",
"in_group",
"in_group.add(y)",
"in_group.add",
"in_group",
"add",
"y",
"if(boll_num[x] == 1):\n in_group.remove(x)\n \n ",
"boll_num[x] == 1",
"boll_num[x]",
"boll_num",
"x",
"1",
"in_group.remove(x)",
"in_group.remove",
"in_group",
"remove",
"x",
"boll_num[x] = boll_num.setdefault(x,0) - 1",
"boll_num[x]",
"boll_num",
"x",
"boll_num.setdefault(x,0) - 1",
"boll_num.setdefault(x,0)",
"boll_num.setdefault",
"boll_num",
"setdefault",
"x",
"0",
"1",
"boll_num[y] = boll_num.setdefault(y,0) + 1",
"boll_num[y]",
"boll_num",
"y",
"boll_num.setdefault(y,0) + 1",
"boll_num.setdefault(y,0)",
"boll_num.setdefault",
"boll_num",
"setdefault",
"y",
"0",
"1",
"print(len(in_group))",
"print",
"len(in_group)",
"len",
"in_group",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"in_group = set()",
"set()",
"in_group",
"boll_num = {}",
"{}",
"boll_num",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x"
] | n,m = map(int,input().split())
in_group = set()
in_group.add(1)
boll_num = {}
for i in range(n):
boll_num[i+1] = 1
for i in range(m):
x,y = map(int,input().split())
if(x in in_group):
in_group.add(y)
if(boll_num[x] == 1):
in_group.remove(x)
boll_num[x] = boll_num.setdefault(x,0) - 1
boll_num[y] = boll_num.setdefault(y,0) + 1
print(len(in_group))
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
4,
13,
4,
18,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
39,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
2,
18,
13,
13,
17,
2,
13,
13,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
138,
4
],
[
138,
20
],
[
126,
22
],
[
26,
25
],
[
139,
28
],
[
132,
30
],
[
132,
46
],
[
127,
49
],
[
133,
53
],
[
130,
56
],
[
141,
59
],
[
142,
64
],
[
70,
69
],
[
124,
72
],
[
135,
76
],
[
82,
79
],
[
127,
79
],
[
87,
84
],
[
136,
85
],
[
133,
86
],
[
92,
89
],
[
136,
90
],
[
130,
91
],
[
133,
95
],
[
142,
96
],
[
142,
99
],
[
130,
101
],
[
84,
105
],
[
136,
106
],
[
133,
107
],
[
133,
110
],
[
142,
111
],
[
142,
114
],
[
133,
116
],
[
142,
121
],
[
138,
124
],
[
126,
127
],
[
132,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
]
] | [
"import sys\n\nN, M = map(int, sys.stdin.readline().rstrip().split())\n\nopes = []\nfor _ in range(M):\n x, y = map(int, sys.stdin.readline().rstrip().split())\n opes.append((x-1, y-1))\n\ntransported = set()\ntransported.add(0)\nboxes = [1 for _ in range(N)]\n\nfor (x, y) in opes:\n boxes[x] -= 1\n boxes[y] += 1\n if x in transported:\n transported.add(y)\n if boxes[x] == 0 and x in transported:\n transported.remove(x)\n\nprint(len(transported))",
"import sys",
"sys",
"N, M = map(int, sys.stdin.readline().rstrip().split())",
"N",
"map(int, sys.stdin.readline().rstrip().split())",
"map",
"int",
"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",
"M",
"opes = []",
"opes",
"[]",
"for _ in range(M):\n x, y = map(int, sys.stdin.readline().rstrip().split())\n opes.append((x-1, y-1))",
"_",
"range(M)",
"range",
"M",
"x, y = map(int, sys.stdin.readline().rstrip().split())",
"x",
"map(int, sys.stdin.readline().rstrip().split())",
"map",
"int",
"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",
"y",
"opes.append((x-1, y-1))",
"opes.append",
"opes",
"append",
"(x-1, y-1)",
"x-1",
"x",
"1",
"y-1",
"y",
"1",
"transported = set()",
"transported",
"set()",
"set",
"transported.add(0)",
"transported.add",
"transported",
"add",
"0",
"1 for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"1",
"boxes = [1 for _ in range(N)]",
"boxes",
"[1 for _ in range(N)]",
"for (x, y) in opes:\n boxes[x] -= 1\n boxes[y] += 1\n if x in transported:\n transported.add(y)\n if boxes[x] == 0 and x in transported:\n transported.remove(x)",
"(x, y)",
"x",
"y",
"opes",
"boxes[x] -= 1",
"boxes[x]",
"boxes",
"x",
"1",
"boxes[y] += 1",
"boxes[y]",
"boxes",
"y",
"1",
"if x in transported:\n transported.add(y)\n ",
"x in transported",
"x",
"transported",
"transported.add(y)",
"transported.add",
"transported",
"add",
"y",
"if boxes[x] == 0 and x in transported:\n transported.remove(x)",
"boxes[x] == 0 and x in transported",
"boxes[x] == 0",
"boxes[x]",
"boxes",
"x",
"0",
"x in transported",
"x",
"transported",
"transported.remove(x)",
"transported.remove",
"transported",
"remove",
"x",
"print(len(transported))",
"print",
"len(transported)",
"len",
"transported",
"N, M = map(int, sys.stdin.readline().rstrip().split())",
"map(int, sys.stdin.readline().rstrip().split())",
"N",
"opes = []",
"[]",
"opes",
"y = map(int, sys.stdin.readline().rstrip().split())",
"map(int, sys.stdin.readline().rstrip().split())",
"y",
"x, y = map(int, sys.stdin.readline().rstrip().split())",
"map(int, sys.stdin.readline().rstrip().split())",
"x",
"boxes = [1 for _ in range(N)]",
"[1 for _ in range(N)]",
"boxes",
"M = map(int, sys.stdin.readline().rstrip().split())",
"map(int, sys.stdin.readline().rstrip().split())",
"M",
"transported = set()",
"set()",
"transported"
] | import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
opes = []
for _ in range(M):
x, y = map(int, sys.stdin.readline().rstrip().split())
opes.append((x-1, y-1))
transported = set()
transported.add(0)
boxes = [1 for _ in range(N)]
for (x, y) in opes:
boxes[x] -= 1
boxes[y] += 1
if x in transported:
transported.add(y)
if boxes[x] == 0 and x in transported:
transported.remove(x)
print(len(transported)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
13,
14,
13,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
114,
2
],
[
114,
11
],
[
108,
13
],
[
112,
17
],
[
22,
19
],
[
109,
20
],
[
117,
24
],
[
112,
28
],
[
31,
30
],
[
115,
33
],
[
120,
35
],
[
120,
44
],
[
102,
46
],
[
96,
49
],
[
109,
53
],
[
103,
54
],
[
106,
54
],
[
59,
56
],
[
109,
57
],
[
97,
58
],
[
121,
58
],
[
64,
61
],
[
118,
62
],
[
97,
63
],
[
121,
63
],
[
69,
66
],
[
118,
67
],
[
103,
68
],
[
106,
68
],
[
66,
72
],
[
118,
73
],
[
103,
74
],
[
106,
74
],
[
80,
77
],
[
109,
78
],
[
103,
79
],
[
106,
79
],
[
99,
82
],
[
86,
85
],
[
109,
85
],
[
123,
90
],
[
124,
94
],
[
100,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
120,
106
],
[
108,
109
],
[
114,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
]
] | [
"n,m=map(int,input().split())\ncheck=[False]*n\ncheck[0]=True\nball=[1]*n\nfor i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n if check[x]:\n check[y]=True\n\n ball[y]+=1\n ball[x]-=1\n if ball[x]==0:\n check[x]=False\n\nans=0\n\nfor chk in check:\n if chk:\n ans+=1\n\nprint(ans)\n",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"check=[False]*n",
"check",
"[False]*n",
"[False]",
"False",
"n",
"check[0]=True",
"check[0]",
"check",
"0",
"True",
"ball=[1]*n",
"ball",
"[1]*n",
"[1]",
"1",
"n",
"for i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n if check[x]:\n check[y]=True\n\n ball[y]+=1\n ball[x]-=1\n if ball[x]==0:\n check[x]=False",
"i",
"range(m)",
"range",
"m",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x-=1",
"x",
"1",
"y-=1",
"y",
"1",
"if check[x]:\n check[y]=True\n\n ",
"check[x]",
"check",
"x",
"check[y]=True",
"check[y]",
"check",
"y",
"True",
"ball[y]+=1",
"ball[y]",
"ball",
"y",
"1",
"ball[x]-=1",
"ball[x]",
"ball",
"x",
"1",
"if ball[x]==0:\n check[x]=False",
"ball[x]==0",
"ball[x]",
"ball",
"x",
"0",
"check[x]=False",
"check[x]",
"check",
"x",
"False",
"ans=0",
"ans",
"0",
"for chk in check:\n if chk:\n ans+=1",
"chk",
"check",
"if chk:\n ans+=1",
"chk",
"ans+=1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"y-=1",
"1",
"y",
"ans=0",
"0",
"ans",
"x-=1",
"1",
"x",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"check=[False]*n",
"[False]*n",
"check",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"ball=[1]*n",
"[1]*n",
"ball",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"ans+=1",
"1",
"ans"
] | n,m=map(int,input().split())
check=[False]*n
check[0]=True
ball=[1]*n
for i in range(m):
x,y=map(int,input().split())
x-=1
y-=1
if check[x]:
check[y]=True
ball[y]+=1
ball[x]-=1
if ball[x]==0:
check[x]=False
ans=0
for chk in check:
if chk:
ans+=1
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
2,
39,
17,
17,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
2,
39,
17,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
13,
14,
2,
18,
13,
18,
13,
17,
17,
0,
18,
13,
18,
13,
17,
17,
14,
2,
18,
13,
18,
13,
17,
17,
0,
18,
13,
18,
13,
17,
17,
0,
18,
13,
18,
13,
17,
17,
0,
18,
13,
18,
13,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
39,
13,
10,
2,
13
] | [
[
123,
2
],
[
123,
11
],
[
15,
14
],
[
124,
18
],
[
132,
23
],
[
32,
31
],
[
124,
34
],
[
126,
38
],
[
129,
44
],
[
48,
47
],
[
121,
50
],
[
130,
53
],
[
67,
66
],
[
130,
66
],
[
133,
71
],
[
66,
73
],
[
82,
77
],
[
133,
78
],
[
66,
80
],
[
127,
86
],
[
66,
88
],
[
97,
92
],
[
133,
93
],
[
66,
95
],
[
104,
99
],
[
127,
100
],
[
66,
102
],
[
111,
106
],
[
127,
107
],
[
66,
109
],
[
133,
116
],
[
123,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
],
[
132,
133
]
] | [
"n, m = map(int, input().split())\nrednow = [-1, 1] + [0 for i in range(n-1)] # maybe there's red ball\nbalnum = [-1] + [1 for i in range(n)] # the number of ball, each box\norder = []\nfor i in range(m):\n order.append(list(map(int, input().split()))) \n\nfor q in order:\n if rednow[q[0]] == 1:\n rednow[q[1]] = 1\n if balnum[q[0]] == 1:\n rednow[q[0]] = 0\n balnum[q[0]] -= 1\n balnum[q[1]] += 1\n\nprint(rednow.count(1))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"0 for i in range(n-1)",
"for i in range(n-1)",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"for i in range(n-1)",
"0",
"rednow = [-1, 1] + [0 for i in range(n-1)]",
"rednow",
"[-1, 1] + [0 for i in range(n-1)]",
"[-1, 1]",
"-1",
"1",
"[0 for i in range(n-1)]",
"1 for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"1",
"balnum = [-1] + [1 for i in range(n)]",
"balnum",
"[-1] + [1 for i in range(n)]",
"[-1]",
"-1",
"[1 for i in range(n)]",
"order = []",
"order",
"[]",
"for i in range(m):\n order.append(list(map(int, input().split()))) ",
"i",
"range(m)",
"range",
"m",
"order.append(list(map(int, input().split())))",
"order.append",
"order",
"append",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for q in order:\n if rednow[q[0]] == 1:\n rednow[q[1]] = 1\n if balnum[q[0]] == 1:\n rednow[q[0]] = 0\n balnum[q[0]] -= 1\n balnum[q[1]] += 1",
"q",
"order",
"if rednow[q[0]] == 1:\n rednow[q[1]] = 1\n if balnum[q[0]] == 1:\n rednow[q[0]] = 0\n ",
"rednow[q[0]] == 1",
"rednow[q[0]]",
"rednow",
"q[0]",
"q",
"0",
"1",
"rednow[q[1]] = 1",
"rednow[q[1]]",
"rednow",
"q[1]",
"q",
"1",
"1",
"if balnum[q[0]] == 1:\n rednow[q[0]] = 0\n ",
"balnum[q[0]] == 1",
"balnum[q[0]]",
"balnum",
"q[0]",
"q",
"0",
"1",
"rednow[q[0]] = 0",
"rednow[q[0]]",
"rednow",
"q[0]",
"q",
"0",
"0",
"balnum[q[0]] -= 1",
"balnum[q[0]]",
"balnum",
"q[0]",
"q",
"0",
"1",
"balnum[q[1]] += 1",
"balnum[q[1]]",
"balnum",
"q[1]",
"q",
"1",
"1",
"print(rednow.count(1))",
"print",
"rednow.count(1)",
"rednow.count",
"rednow",
"count",
"1",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"balnum = [-1] + [1 for i in range(n)]",
"[-1] + [1 for i in range(n)]",
"balnum",
"order = []",
"[]",
"order",
"rednow = [-1, 1] + [0 for i in range(n-1)]",
"[-1, 1] + [0 for i in range(n-1)]",
"rednow"
] | n, m = map(int, input().split())
rednow = [-1, 1] + [0 for i in range(n-1)] # maybe there's red ball
balnum = [-1] + [1 for i in range(n)] # the number of ball, each box
order = []
for i in range(m):
order.append(list(map(int, input().split())))
for q in order:
if rednow[q[0]] == 1:
rednow[q[1]] = 1
if balnum[q[0]] == 1:
rednow[q[0]] = 0
balnum[q[0]] -= 1
balnum[q[1]] += 1
print(rednow.count(1))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
13,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
94,
2
],
[
94,
11
],
[
103,
13
],
[
89,
18
],
[
24,
21
],
[
104,
22
],
[
106,
26
],
[
89,
31
],
[
35,
34
],
[
95,
37
],
[
100,
39
],
[
100,
48
],
[
104,
51
],
[
98,
52
],
[
57,
54
],
[
104,
55
],
[
101,
56
],
[
70,
60
],
[
107,
61
],
[
98,
62
],
[
68,
65
],
[
104,
66
],
[
98,
67
],
[
73,
70
],
[
107,
71
],
[
98,
72
],
[
78,
75
],
[
107,
76
],
[
101,
77
],
[
91,
80
],
[
104,
83
],
[
92,
86
],
[
94,
89
],
[
91,
92
],
[
94,
95
],
[
100,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
]
] | [
"n, m = map(int, input().split())\nC = [0]*(n+1)\nC[1] = 1\nD = [1]*(n+1)\nfor _ in range(m):\n x, y = map(int, input().split())\n if C[x]:\n C[y] = 1\n if D[x] == 1:\n C[x] = 0\n D[x] -= 1\n D[y] += 1\nans = sum(C)\nprint(ans)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"C = [0]*(n+1)",
"C",
"[0]*(n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"C[1] = 1",
"C[1]",
"C",
"1",
"1",
"D = [1]*(n+1)",
"D",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"for _ in range(m):\n x, y = map(int, input().split())\n if C[x]:\n C[y] = 1\n if D[x] == 1:\n C[x] = 0\n D[x] -= 1\n D[y] += 1",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if C[x]:\n C[y] = 1\n if D[x] == 1:\n C[x] = 0\n ",
"C[x]",
"C",
"x",
"C[y] = 1",
"C[y]",
"C",
"y",
"1",
"if D[x] == 1:\n C[x] = 0\n ",
"D[x] == 1",
"D[x]",
"D",
"x",
"1",
"C[x] = 0",
"C[x]",
"C",
"x",
"0",
"D[x] -= 1",
"D[x]",
"D",
"x",
"1",
"D[y] += 1",
"D[y]",
"D",
"y",
"1",
"ans = sum(C)",
"ans",
"sum(C)",
"sum",
"C",
"print(ans)",
"print",
"ans",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"ans = sum(C)",
"sum(C)",
"ans",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"C = [0]*(n+1)",
"[0]*(n+1)",
"C",
"D = [1]*(n+1)",
"[1]*(n+1)",
"D"
] | n, m = map(int, input().split())
C = [0]*(n+1)
C[1] = 1
D = [1]*(n+1)
for _ in range(m):
x, y = map(int, input().split())
if C[x]:
C[y] = 1
if D[x] == 1:
C[x] = 0
D[x] -= 1
D[y] += 1
ans = sum(C)
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
17,
13,
4,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
2,
18,
13,
13,
17,
9,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13
] | [
[
118,
2
],
[
118,
11
],
[
15,
14
],
[
119,
17
],
[
127,
21
],
[
26,
25
],
[
119,
29
],
[
121,
33
],
[
40,
39
],
[
107,
42
],
[
115,
44
],
[
115,
53
],
[
109,
55
],
[
113,
57
],
[
110,
57
],
[
124,
59
],
[
116,
61
],
[
125,
61
],
[
71,
65
],
[
128,
66
],
[
110,
67
],
[
113,
67
],
[
74,
71
],
[
128,
72
],
[
110,
73
],
[
113,
73
],
[
79,
76
],
[
128,
77
],
[
125,
78
],
[
116,
78
],
[
122,
82
],
[
110,
83
],
[
113,
83
],
[
88,
85
],
[
122,
86
],
[
125,
87
],
[
116,
87
],
[
71,
91
],
[
128,
92
],
[
110,
93
],
[
113,
93
],
[
99,
96
],
[
122,
97
],
[
110,
98
],
[
113,
98
],
[
122,
104
],
[
118,
107
],
[
109,
110
],
[
115,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"n,m = map(int,input().split())\n\nballs = [1 for _ in range(n)]\nred = [1] + [0 for _ in range(1,n)]\n\nfor _ in range(m):\n x, y = map(int,input().split())\n x,y = x-1, y-1\n \n if balls[x] ==0:\n continue\n \n balls[x] -= 1\n balls[y] += 1\n if red[x]:\n red[y] = 1\n if balls[x]==0:\n red[x] = 0\nprint(sum(red))\n \n \n",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"1 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"1",
"balls = [1 for _ in range(n)]",
"balls",
"[1 for _ in range(n)]",
"0 for _ in range(1,n)",
"for _ in range(1,n)",
"_",
"range(1,n)",
"range",
"1",
"n",
"for _ in range(1,n)",
"0",
"red = [1] + [0 for _ in range(1,n)]",
"red",
"[1] + [0 for _ in range(1,n)]",
"[1]",
"1",
"[0 for _ in range(1,n)]",
"for _ in range(m):\n x, y = map(int,input().split())\n x,y = x-1, y-1\n \n if balls[x] ==0:\n continue\n \n balls[x] -= 1\n balls[y] += 1\n if red[x]:\n red[y] = 1\n if balls[x]==0:\n red[x] = 0",
"_",
"range(m)",
"range",
"m",
"x, y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x,y = x-1, y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"if balls[x] ==0:\n continue\n \n ",
"balls[x] ==0",
"balls[x]",
"balls",
"x",
"0",
"continue",
"balls[x] -= 1",
"balls[x]",
"balls",
"x",
"1",
"balls[y] += 1",
"balls[y]",
"balls",
"y",
"1",
"if red[x]:\n red[y] = 1\n ",
"red[x]",
"red",
"x",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"if balls[x]==0:\n red[x] = 0",
"balls[x]==0",
"balls[x]",
"balls",
"x",
"0",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"x,y = x-1, y-1",
"x-1",
"x",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"red = [1] + [0 for _ in range(1,n)]",
"[1] + [0 for _ in range(1,n)]",
"red",
"y = x-1, y-1",
"y-1",
"y",
"balls = [1 for _ in range(n)]",
"[1 for _ in range(n)]",
"balls"
] | n,m = map(int,input().split())
balls = [1 for _ in range(n)]
red = [1] + [0 for _ in range(1,n)]
for _ in range(m):
x, y = map(int,input().split())
x,y = x-1, y-1
if balls[x] ==0:
continue
balls[x] -= 1
balls[y] += 1
if red[x]:
red[y] = 1
if balls[x]==0:
red[x] = 0
print(sum(red))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
39,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
95,
2
],
[
95,
11
],
[
98,
13
],
[
83,
19
],
[
90,
23
],
[
26,
25
],
[
96,
28
],
[
32,
31
],
[
31,
41
],
[
92,
44
],
[
92,
46
],
[
51,
48
],
[
84,
49
],
[
93,
50
],
[
56,
53
],
[
84,
54
],
[
87,
55
],
[
93,
59
],
[
99,
60
],
[
99,
63
],
[
87,
65
],
[
48,
68
],
[
84,
69
],
[
93,
70
],
[
99,
74
],
[
93,
76
],
[
99,
81
],
[
83,
84
],
[
92,
87
],
[
95,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
]
] | [
"N,M = map(int, input().split())\n\nans = set([0])\ncnt = [1] * N\nfor _ in range(M):\n x,y = [int(i) - 1 for i in input().split()]\n cnt[x] -= 1; cnt[y] += 1\n \n if x in ans:\n ans.add(y)\n if cnt[x] == 0: # 絶対に赤いボールがyに移される\n ans.remove(x)\n \nprint(len(ans))",
"N,M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"ans = set([0])",
"ans",
"set([0])",
"set",
"[0]",
"0",
"cnt = [1] * N",
"cnt",
"[1] * N",
"[1]",
"1",
"N",
"for _ in range(M):\n x,y = [int(i) - 1 for i in input().split()]\n cnt[x] -= 1; cnt[y] += 1\n \n if x in ans:\n ans.add(y)\n if cnt[x] == 0: # 絶対に赤いボールがyに移される\n ans.remove(x)\n ",
"_",
"range(M)",
"range",
"M",
"int(i) - 1 for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i) - 1",
"int(i)",
"int",
"i",
"1",
"x,y = [int(i) - 1 for i in input().split()]",
"x",
"[int(i) - 1 for i in input().split()]",
"y",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"if x in ans:\n ans.add(y)\n if cnt[x] == 0: # 絶対に赤いボールがyに移される\n ans.remove(x)\n ",
"x in ans",
"x",
"ans",
"ans.add(y)",
"ans.add",
"ans",
"add",
"y",
"if cnt[x] == 0: # 絶対に赤いボールがyに移される\n ans.remove(x)\n ",
"cnt[x] == 0",
"cnt[x]",
"cnt",
"x",
"0",
"ans.remove(x)",
"ans.remove",
"ans",
"remove",
"x",
"print(len(ans))",
"print",
"len(ans)",
"len",
"ans",
"cnt = [1] * N",
"[1] * N",
"cnt",
"y = [int(i) - 1 for i in input().split()]",
"[int(i) - 1 for i in input().split()]",
"y",
"N,M = map(int, input().split())",
"map(int, input().split())",
"N",
"x,y = [int(i) - 1 for i in input().split()]",
"[int(i) - 1 for i in input().split()]",
"x",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"ans = set([0])",
"set([0])",
"ans"
] | N,M = map(int, input().split())
ans = set([0])
cnt = [1] * N
for _ in range(M):
x,y = [int(i) - 1 for i in input().split()]
cnt[x] -= 1; cnt[y] += 1
if x in ans:
ans.add(y)
if cnt[x] == 0: # 絶対に赤いボールがyに移される
ans.remove(x)
print(len(ans)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] | [
[
94,
2
],
[
94,
11
],
[
85,
13
],
[
89,
18
],
[
97,
21
],
[
89,
26
],
[
32,
29
],
[
86,
30
],
[
35,
34
],
[
95,
37
],
[
100,
39
],
[
100,
48
],
[
53,
50
],
[
98,
51
],
[
101,
52
],
[
58,
55
],
[
98,
56
],
[
92,
57
],
[
86,
61
],
[
101,
62
],
[
67,
64
],
[
86,
65
],
[
92,
66
],
[
50,
70
],
[
98,
71
],
[
101,
72
],
[
78,
75
],
[
86,
76
],
[
101,
77
],
[
86,
83
],
[
85,
86
],
[
94,
89
],
[
100,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
]
] | [
"n,m=map(int, input().split())\naka = [0]*(n+1)\nsiroaka = [1]*(n+1)\naka[1] = 1\nfor i in range(m):\n x,y=map(int, input().split())\n siroaka[x]-=1\n siroaka[y]+=1\n if(aka[x]):\n aka[y]=1\n if(siroaka[x]==0):\n aka[x]=0\n\nprint(sum(aka))",
"n,m=map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"aka = [0]*(n+1)",
"aka",
"[0]*(n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"siroaka = [1]*(n+1)",
"siroaka",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"aka[1] = 1",
"aka[1]",
"aka",
"1",
"1",
"for i in range(m):\n x,y=map(int, input().split())\n siroaka[x]-=1\n siroaka[y]+=1\n if(aka[x]):\n aka[y]=1\n if(siroaka[x]==0):\n aka[x]=0",
"i",
"range(m)",
"range",
"m",
"x,y=map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"siroaka[x]-=1",
"siroaka[x]",
"siroaka",
"x",
"1",
"siroaka[y]+=1",
"siroaka[y]",
"siroaka",
"y",
"1",
"if(aka[x]):\n aka[y]=1\n ",
"aka[x]",
"aka",
"x",
"aka[y]=1",
"aka[y]",
"aka",
"y",
"1",
"if(siroaka[x]==0):\n aka[x]=0",
"siroaka[x]==0",
"siroaka[x]",
"siroaka",
"x",
"0",
"aka[x]=0",
"aka[x]",
"aka",
"x",
"0",
"print(sum(aka))",
"print",
"sum(aka)",
"sum",
"aka",
"aka = [0]*(n+1)",
"[0]*(n+1)",
"aka",
"n,m=map(int, input().split())",
"map(int, input().split())",
"n",
"y=map(int, input().split())",
"map(int, input().split())",
"y",
"m=map(int, input().split())",
"map(int, input().split())",
"m",
"siroaka = [1]*(n+1)",
"[1]*(n+1)",
"siroaka",
"x,y=map(int, input().split())",
"map(int, input().split())",
"x"
] | n,m=map(int, input().split())
aka = [0]*(n+1)
siroaka = [1]*(n+1)
aka[1] = 1
for i in range(m):
x,y=map(int, input().split())
siroaka[x]-=1
siroaka[y]+=1
if(aka[x]):
aka[y]=1
if(siroaka[x]==0):
aka[x]=0
print(sum(aka))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
0,
13,
18,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
13,
13,
10,
18,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
18,
13
] | [
[
143,
2
],
[
143,
11
],
[
15,
14
],
[
144,
17
],
[
131,
30
],
[
137,
34
],
[
129,
39
],
[
140,
42
],
[
129,
47
],
[
53,
50
],
[
138,
51
],
[
58,
55
],
[
141,
56
],
[
61,
60
],
[
144,
63
],
[
134,
65
],
[
132,
68
],
[
60,
69
],
[
146,
72
],
[
132,
75
],
[
60,
76
],
[
106,
80
],
[
141,
81
],
[
135,
82
],
[
88,
85
],
[
141,
86
],
[
147,
87
],
[
93,
90
],
[
138,
91
],
[
135,
92
],
[
98,
95
],
[
138,
96
],
[
147,
97
],
[
90,
101
],
[
111,
101
],
[
138,
102
],
[
135,
103
],
[
109,
106
],
[
141,
107
],
[
135,
108
],
[
114,
111
],
[
138,
112
],
[
135,
113
],
[
119,
116
],
[
138,
117
],
[
147,
118
],
[
141,
124
],
[
143,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
]
] | [
"N, M = map(int, input().split())\nXY = [list(map(int, input().split())) for _ in range(M)]\n\n\"\"\"\nボールの数が入ったリストと,赤い玉が一回でもきたことがあるかのリスト\nどちらもが0じゃないのが,終わったときに赤が入っている可能性のあるリスト\nただし,ボールリストが0になる時,seenは0になる\n\"\"\"\nball_list = [1] * (N+1)\nseen = [0] * (N+1)\nball_list[0] = 0\nseen[1] = 1\n\nfor i in range(M):\n x = XY[i][0]\n y = XY[i][1]\n if seen[x] == 1:\n seen[y] = 1\n ball_list[x] -= 1\n ball_list[y] += 1\n if ball_list[x] == 0:\n seen[x] = 0\n else:\n ball_list[x] -= 1\n ball_list[y] += 1\n\nprint(seen.count(1))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"list(map(int, input().split())) for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"XY = [list(map(int, input().split())) for _ in range(M)]",
"XY",
"[list(map(int, input().split())) for _ in range(M)]",
"\"\"\"\nボールの数が入ったリストと,赤い玉が一回でもきたことがあるかのリスト\nどちらもが0じゃないのが,終わったときに赤が入っている可能性のあるリスト\nただし,ボールリストが0になる時,seenは0になる\n\"\"\"",
"ball_list = [1] * (N+1)",
"ball_list",
"[1] * (N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"seen = [0] * (N+1)",
"seen",
"[0] * (N+1)",
"[0]",
"0",
"N+1",
"N",
"1",
"ball_list[0] = 0",
"ball_list[0]",
"ball_list",
"0",
"0",
"seen[1] = 1",
"seen[1]",
"seen",
"1",
"1",
"for i in range(M):\n x = XY[i][0]\n y = XY[i][1]\n if seen[x] == 1:\n seen[y] = 1\n ball_list[x] -= 1\n ball_list[y] += 1\n if ball_list[x] == 0:\n seen[x] = 0\n else:\n ball_list[x] -= 1\n ball_list[y] += 1",
"i",
"range(M)",
"range",
"M",
"x = XY[i][0]",
"x",
"XY[i][0]",
"[i]",
"XY",
"i",
"0",
"y = XY[i][1]",
"y",
"XY[i][1]",
"[i]",
"XY",
"i",
"1",
"if seen[x] == 1:\n seen[y] = 1\n ball_list[x] -= 1\n ball_list[y] += 1\n if ball_list[x] == 0:\n seen[x] = 0\n else:\n ball_list[x] -= 1\n ball_list[y] += 1",
"seen[x] == 1",
"seen[x]",
"seen",
"x",
"1",
"seen[y] = 1",
"seen[y]",
"seen",
"y",
"1",
"ball_list[x] -= 1",
"ball_list[x]",
"ball_list",
"x",
"1",
"ball_list[y] += 1",
"ball_list[y]",
"ball_list",
"y",
"1",
"if ball_list[x] == 0:\n seen[x] = 0\n ",
"ball_list[x] == 0",
"ball_list[x]",
"ball_list",
"x",
"0",
"seen[x] = 0",
"seen[x]",
"seen",
"x",
"0",
"ball_list[x] -= 1",
"ball_list[x]",
"ball_list",
"x",
"1",
"ball_list[y] += 1",
"ball_list[y]",
"ball_list",
"y",
"1",
"print(seen.count(1))",
"print",
"seen.count(1)",
"seen.count",
"seen",
"count",
"1",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"XY = [list(map(int, input().split())) for _ in range(M)]",
"[list(map(int, input().split())) for _ in range(M)]",
"XY",
"x = XY[i][0]",
"XY[i][0]",
"x",
"ball_list = [1] * (N+1)",
"[1] * (N+1)",
"ball_list",
"seen = [0] * (N+1)",
"[0] * (N+1)",
"seen",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"y = XY[i][1]",
"XY[i][1]",
"y"
] | N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]
"""
ボールの数が入ったリストと,赤い玉が一回でもきたことがあるかのリスト
どちらもが0じゃないのが,終わったときに赤が入っている可能性のあるリスト
ただし,ボールリストが0になる時,seenは0になる
"""
ball_list = [1] * (N+1)
seen = [0] * (N+1)
ball_list[0] = 0
seen[1] = 1
for i in range(M):
x = XY[i][0]
y = XY[i][1]
if seen[x] == 1:
seen[y] = 1
ball_list[x] -= 1
ball_list[y] += 1
if ball_list[x] == 0:
seen[x] = 0
else:
ball_list[x] -= 1
ball_list[y] += 1
print(seen.count(1)) |
[
7,
15,
13,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
2,
2,
13,
2,
18,
13,
2,
13,
17,
17,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
2,
13,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
18,
13,
13,
2,
4,
18,
13,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
135,
6
],
[
135,
15
],
[
19,
18
],
[
133,
21
],
[
141,
25
],
[
30,
29
],
[
133,
32
],
[
144,
36
],
[
42,
39
],
[
142,
40
],
[
45,
44
],
[
136,
47
],
[
150,
49
],
[
150,
58
],
[
147,
60
],
[
142,
66
],
[
139,
68
],
[
76,
71
],
[
142,
72
],
[
139,
74
],
[
148,
78
],
[
145,
81
],
[
139,
83
],
[
145,
87
],
[
139,
89
],
[
97,
92
],
[
142,
93
],
[
151,
95
],
[
148,
98
],
[
145,
100
],
[
139,
102
],
[
110,
105
],
[
145,
106
],
[
139,
108
],
[
117,
112
],
[
145,
113
],
[
151,
115
],
[
142,
129
],
[
135,
133
],
[
135,
136
],
[
150,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
]
] | [
"import numpy as np\nimport math\n\nn, m = map(int, input().split())\nprobability = [0 for _ in range(n)]\nball = [1 for _ in range(n)]\nprobability[0] = 1\nfor i in range(m):\n x, y = map(int, input().split())\n prob = math.ceil(probability[x-1])\n probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]\n probability[y-1] += prob / ball[x-1]\n ball[x-1] -= 1\n ball[y-1] += 1\nprint(np.sum(np.array(probability) > 0))",
"import numpy as np",
"numpy",
"import math",
"math",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"0 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"0",
"probability = [0 for _ in range(n)]",
"probability",
"[0 for _ in range(n)]",
"1 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"1",
"ball = [1 for _ in range(n)]",
"ball",
"[1 for _ in range(n)]",
"probability[0] = 1",
"probability[0]",
"probability",
"0",
"1",
"for i in range(m):\n x, y = map(int, input().split())\n prob = math.ceil(probability[x-1])\n probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]\n probability[y-1] += prob / ball[x-1]\n ball[x-1] -= 1\n ball[y-1] += 1",
"i",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"prob = math.ceil(probability[x-1])",
"prob",
"math.ceil(probability[x-1])",
"math.ceil",
"math",
"ceil",
"probability[x-1]",
"probability",
"x-1",
"x",
"1",
"probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]",
"probability[x-1]",
"probability",
"x-1",
"x",
"1",
"prob * (ball[x-1] - 1) / ball[x-1]",
"prob * (ball[x-1] - 1)",
"prob",
"ball[x-1] - 1",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"1",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"probability[y-1] += prob / ball[x-1]",
"probability[y-1]",
"probability",
"y-1",
"y",
"1",
"prob / ball[x-1]",
"prob",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"ball[x-1] -= 1",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"1",
"ball[y-1] += 1",
"ball[y-1]",
"ball",
"y-1",
"y",
"1",
"1",
"print(np.sum(np.array(probability) > 0))",
"print",
"np.sum(np.array(probability) > 0)",
"np.sum",
"np",
"sum",
"np.array(probability) > 0",
"np.array(probability)",
"np.array",
"np",
"array",
"probability",
"0",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"probability = [0 for _ in range(n)]",
"[0 for _ in range(n)]",
"probability",
"ball = [1 for _ in range(n)]",
"[1 for _ in range(n)]",
"ball",
"prob = math.ceil(probability[x-1])",
"math.ceil(probability[x-1])",
"prob",
"y = map(int, input().split())",
"map(int, input().split())",
"y"
] | import numpy as np
import math
n, m = map(int, input().split())
probability = [0 for _ in range(n)]
ball = [1 for _ in range(n)]
probability[0] = 1
for i in range(m):
x, y = map(int, input().split())
prob = math.ceil(probability[x-1])
probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]
probability[y-1] += prob / ball[x-1]
ball[x-1] -= 1
ball[y-1] += 1
print(np.sum(np.array(probability) > 0))
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
13,
17,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
2,
18,
13,
13,
17,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13
] | [
[
114,
2
],
[
114,
13
],
[
111,
15
],
[
109,
19
],
[
24,
21
],
[
112,
22
],
[
126,
26
],
[
109,
30
],
[
33,
32
],
[
115,
35
],
[
123,
37
],
[
123,
48
],
[
129,
50
],
[
117,
53
],
[
91,
58
],
[
127,
59
],
[
130,
60
],
[
121,
60
],
[
66,
62
],
[
112,
63
],
[
130,
64
],
[
121,
64
],
[
69,
66
],
[
112,
67
],
[
130,
68
],
[
121,
68
],
[
74,
71
],
[
112,
72
],
[
118,
73
],
[
124,
73
],
[
91,
78
],
[
127,
79
],
[
130,
80
],
[
121,
80
],
[
66,
82
],
[
112,
83
],
[
130,
84
],
[
121,
84
],
[
89,
86
],
[
112,
87
],
[
118,
88
],
[
124,
88
],
[
94,
91
],
[
127,
92
],
[
130,
93
],
[
121,
93
],
[
99,
96
],
[
127,
97
],
[
118,
98
],
[
124,
98
],
[
112,
104
],
[
114,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
123,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
]
] | [
"n, m = list(map(int, input().split()))\n\nredball = [0]*n\nredball[0] = 1\nball_cnt = [1]*n\n\nfor _ in range(m):\n x, y = list(map(int, input().split()))\n x -= 1\n y -= 1\n\n if ball_cnt[x] == 1 and redball[x]:\n redball[x] = 0\n redball[y] = 1\n\n if ball_cnt[x] > 1 and redball[x]:\n redball[y] = 1\n\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n\nprint(redball.count(1))",
"n, m = list(map(int, input().split()))",
"n",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"redball = [0]*n",
"redball",
"[0]*n",
"[0]",
"0",
"n",
"redball[0] = 1",
"redball[0]",
"redball",
"0",
"1",
"ball_cnt = [1]*n",
"ball_cnt",
"[1]*n",
"[1]",
"1",
"n",
"for _ in range(m):\n x, y = list(map(int, input().split()))\n x -= 1\n y -= 1\n\n if ball_cnt[x] == 1 and redball[x]:\n redball[x] = 0\n redball[y] = 1\n\n if ball_cnt[x] > 1 and redball[x]:\n redball[y] = 1\n\n ball_cnt[x] -= 1\n ball_cnt[y] += 1",
"_",
"range(m)",
"range",
"m",
"x, y = list(map(int, input().split()))",
"x",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if ball_cnt[x] == 1 and redball[x]:\n redball[x] = 0\n redball[y] = 1\n\n ",
"ball_cnt[x] == 1 and redball[x]",
"ball_cnt[x] == 1",
"ball_cnt[x]",
"ball_cnt",
"x",
"1",
"redball[x]",
"redball",
"x",
"redball[x] = 0",
"redball[x]",
"redball",
"x",
"0",
"redball[y] = 1",
"redball[y]",
"redball",
"y",
"1",
"if ball_cnt[x] > 1 and redball[x]:\n redball[y] = 1\n\n ",
"ball_cnt[x] > 1 and redball[x]",
"ball_cnt[x] > 1",
"ball_cnt[x]",
"ball_cnt",
"x",
"1",
"redball[x]",
"redball",
"x",
"redball[y] = 1",
"redball[y]",
"redball",
"y",
"1",
"ball_cnt[x] -= 1",
"ball_cnt[x]",
"ball_cnt",
"x",
"1",
"ball_cnt[y] += 1",
"ball_cnt[y]",
"ball_cnt",
"y",
"1",
"print(redball.count(1))",
"print",
"redball.count(1)",
"redball.count",
"redball",
"count",
"1",
"n, m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"n",
"redball = [0]*n",
"[0]*n",
"redball",
"m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"m",
"y -= 1",
"1",
"y",
"x, y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"x",
"y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"y",
"ball_cnt = [1]*n",
"[1]*n",
"ball_cnt",
"x -= 1",
"1",
"x"
] | n, m = list(map(int, input().split()))
redball = [0]*n
redball[0] = 1
ball_cnt = [1]*n
for _ in range(m):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
if ball_cnt[x] == 1 and redball[x]:
redball[x] = 0
redball[y] = 1
if ball_cnt[x] > 1 and redball[x]:
redball[y] = 1
ball_cnt[x] -= 1
ball_cnt[y] += 1
print(redball.count(1))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13
] | [
[
114,
2
],
[
114,
11
],
[
15,
14
],
[
115,
18
],
[
99,
23
],
[
28,
27
],
[
115,
31
],
[
111,
36
],
[
42,
39
],
[
100,
40
],
[
45,
44
],
[
109,
47
],
[
105,
49
],
[
105,
58
],
[
77,
61
],
[
100,
62
],
[
103,
63
],
[
69,
66
],
[
100,
67
],
[
106,
68
],
[
82,
72
],
[
112,
73
],
[
103,
74
],
[
80,
77
],
[
100,
78
],
[
103,
79
],
[
85,
82
],
[
112,
83
],
[
103,
84
],
[
90,
87
],
[
112,
88
],
[
106,
89
],
[
100,
95
],
[
99,
100
],
[
105,
103
],
[
105,
106
],
[
114,
109
],
[
111,
112
],
[
114,
115
]
] | [
"N, M = map(int, input().split())\n\nR = [0 for _ in range(N+1)] # possibility to include the red ball\nC = [1 for _ in range(N+1)] # number of balls\nR[1] = 1\n\n\nfor i in range(M):\n x, y = map(int, input().split())\n if R[x] == 1:\n R[y] = 1\n if C[x] == 1:\n R[x] = 0\n C[x] -= 1\n C[y] += 1\n# print('R', R)\n# print('C', C)\nprint(R.count(1))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"0 for _ in range(N+1)",
"for _ in range(N+1)",
"_",
"range(N+1)",
"range",
"N+1",
"N",
"1",
"for _ in range(N+1)",
"0",
"R = [0 for _ in range(N+1)]",
"R",
"[0 for _ in range(N+1)]",
"1 for _ in range(N+1)",
"for _ in range(N+1)",
"_",
"range(N+1)",
"range",
"N+1",
"N",
"1",
"for _ in range(N+1)",
"1",
"C = [1 for _ in range(N+1)]",
"C",
"[1 for _ in range(N+1)]",
"R[1] = 1",
"R[1]",
"R",
"1",
"1",
"for i in range(M):\n x, y = map(int, input().split())\n if R[x] == 1:\n R[y] = 1\n if C[x] == 1:\n R[x] = 0\n C[x] -= 1\n C[y] += 1\n# print('R', R)\n# print('C', C)",
"i",
"range(M)",
"range",
"M",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if R[x] == 1:\n R[y] = 1\n if C[x] == 1:\n R[x] = 0\n ",
"R[x] == 1",
"R[x]",
"R",
"x",
"1",
"R[y] = 1",
"R[y]",
"R",
"y",
"1",
"if C[x] == 1:\n R[x] = 0\n ",
"C[x] == 1",
"C[x]",
"C",
"x",
"1",
"R[x] = 0",
"R[x]",
"R",
"x",
"0",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"print(R.count(1))",
"print",
"R.count(1)",
"R.count",
"R",
"count",
"1",
"R = [0 for _ in range(N+1)]",
"[0 for _ in range(N+1)]",
"R",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"C = [1 for _ in range(N+1)]",
"[1 for _ in range(N+1)]",
"C",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N"
] | N, M = map(int, input().split())
R = [0 for _ in range(N+1)] # possibility to include the red ball
C = [1 for _ in range(N+1)] # number of balls
R[1] = 1
for i in range(M):
x, y = map(int, input().split())
if R[x] == 1:
R[y] = 1
if C[x] == 1:
R[x] = 0
C[x] -= 1
C[y] += 1
# print('R', R)
# print('C', C)
print(R.count(1)) |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
0,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
0,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
14,
2,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
0,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
0,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
17,
16
],
[
13,
19
],
[
33,
32
],
[
36,
35
],
[
4,
39
],
[
42,
41
],
[
4,
45
],
[
50,
47
],
[
41,
48
],
[
53,
52
],
[
56,
55
],
[
13,
58
],
[
41,
62
],
[
32,
66
],
[
55,
67
],
[
81,
72
],
[
41,
73
],
[
32,
77
],
[
55,
78
],
[
92,
83
],
[
35,
84
],
[
32,
88
],
[
55,
89
],
[
35,
96
],
[
32,
100
],
[
55,
101
],
[
115,
106
],
[
41,
107
],
[
32,
111
],
[
55,
112
],
[
126,
117
],
[
35,
118
],
[
32,
122
],
[
55,
123
],
[
41,
131
],
[
140,
137
]
] | [
"#!/usr/bin/env python3\n\ndef main():\n N, M = map(int, input().split())\n xy = [list(map(int, input().split())) for i in range(M)]\n box = [1] * N\n red_flag = [0] * N\n red_flag[0] = 1\n ans = 0\n for i in range(M):\n if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1] = 1\n box[xy[i][0] - 1] -= 1\n if box[xy[i][0] - 1] == 0:\n red_flag[xy[i][0] - 1] = 0\n box[xy[i][1] - 1] += 1\n print(sum(red_flag))\n\n\nif __name__ == \"__main__\":\n main()",
"def main():\n N, M = map(int, input().split())\n xy = [list(map(int, input().split())) for i in range(M)]\n box = [1] * N\n red_flag = [0] * N\n red_flag[0] = 1\n ans = 0\n for i in range(M):\n if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1] = 1\n box[xy[i][0] - 1] -= 1\n if box[xy[i][0] - 1] == 0:\n red_flag[xy[i][0] - 1] = 0\n box[xy[i][1] - 1] += 1\n print(sum(red_flag))",
"main",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"list(map(int, input().split())) for i in range(M)",
"for i in range(M)",
"i",
"range(M)",
"range",
"M",
"for i in range(M)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xy = [list(map(int, input().split())) for i in range(M)]",
"xy",
"[list(map(int, input().split())) for i in range(M)]",
"box = [1] * N",
"box",
"[1] * N",
"[1]",
"1",
"N",
"red_flag = [0] * N",
"red_flag",
"[0] * N",
"[0]",
"0",
"N",
"red_flag[0] = 1",
"red_flag[0]",
"red_flag",
"0",
"1",
"ans = 0",
"ans",
"0",
"for i in range(M):\n if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1] = 1\n box[xy[i][0] - 1] -= 1\n if box[xy[i][0] - 1] == 0:\n red_flag[xy[i][0] - 1] = 0\n box[xy[i][1] - 1] += 1\n ",
"i",
"range(M)",
"range",
"M",
"if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1] = 1\n ",
"red_flag[xy[i][0] - 1] == 1",
"red_flag[xy[i][0] - 1]",
"red_flag",
"xy[i][0] - 1",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"1",
"1",
"red_flag[xy[i][1] - 1] = 1",
"red_flag[xy[i][1] - 1]",
"red_flag",
"xy[i][1] - 1",
"xy[i][1]",
"[i]",
"xy",
"i",
"1",
"1",
"1",
"box[xy[i][0] - 1] -= 1",
"box[xy[i][0] - 1]",
"box",
"xy[i][0] - 1",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"1",
"1",
"if box[xy[i][0] - 1] == 0:\n red_flag[xy[i][0] - 1] = 0\n ",
"box[xy[i][0] - 1] == 0",
"box[xy[i][0] - 1]",
"box",
"xy[i][0] - 1",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"1",
"0",
"red_flag[xy[i][0] - 1] = 0",
"red_flag[xy[i][0] - 1]",
"red_flag",
"xy[i][0] - 1",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"1",
"0",
"box[xy[i][1] - 1] += 1",
"box[xy[i][1] - 1]",
"box",
"xy[i][1] - 1",
"xy[i][1]",
"[i]",
"xy",
"i",
"1",
"1",
"1",
"print(sum(red_flag))",
"print",
"sum(red_flag)",
"sum",
"red_flag",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n N, M = map(int, input().split())\n xy = [list(map(int, input().split())) for i in range(M)]\n box = [1] * N\n red_flag = [0] * N\n red_flag[0] = 1\n ans = 0\n for i in range(M):\n if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1] = 1\n box[xy[i][0] - 1] -= 1\n if box[xy[i][0] - 1] == 0:\n red_flag[xy[i][0] - 1] = 0\n box[xy[i][1] - 1] += 1\n print(sum(red_flag))",
"def main():\n N, M = map(int, input().split())\n xy = [list(map(int, input().split())) for i in range(M)]\n box = [1] * N\n red_flag = [0] * N\n red_flag[0] = 1\n ans = 0\n for i in range(M):\n if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1] = 1\n box[xy[i][0] - 1] -= 1\n if box[xy[i][0] - 1] == 0:\n red_flag[xy[i][0] - 1] = 0\n box[xy[i][1] - 1] += 1\n print(sum(red_flag))",
"main"
] | #!/usr/bin/env python3
def main():
N, M = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(M)]
box = [1] * N
red_flag = [0] * N
red_flag[0] = 1
ans = 0
for i in range(M):
if red_flag[xy[i][0] - 1] == 1:
red_flag[xy[i][1] - 1] = 1
box[xy[i][0] - 1] -= 1
if box[xy[i][0] - 1] == 0:
red_flag[xy[i][0] - 1] = 0
box[xy[i][1] - 1] += 1
print(sum(red_flag))
if __name__ == "__main__":
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
110,
2
],
[
110,
11
],
[
104,
13
],
[
96,
17
],
[
98,
19
],
[
96,
23
],
[
28,
25
],
[
99,
26
],
[
31,
30
],
[
111,
33
],
[
107,
35
],
[
107,
44
],
[
99,
48
],
[
102,
50
],
[
59,
54
],
[
99,
55
],
[
108,
57
],
[
66,
61
],
[
105,
62
],
[
102,
64
],
[
73,
68
],
[
105,
69
],
[
108,
71
],
[
105,
77
],
[
102,
79
],
[
88,
83
],
[
99,
84
],
[
102,
86
],
[
99,
93
],
[
110,
96
],
[
98,
99
],
[
107,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"N,M=map(int,input().split())\nli=[1]*N\nri=[0]*N\nri[0]=1\n\nfor i in range(M):\n x,y=map(int,input().split())\n if ri[x-1]==1:\n ri[y-1]=1\n li[x-1]-=1\n li[y-1]+=1\n if li[x-1]==0:\n ri[x-1]=0\nprint(sum(ri))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"li=[1]*N",
"li",
"[1]*N",
"[1]",
"1",
"N",
"ri=[0]*N",
"ri",
"[0]*N",
"[0]",
"0",
"N",
"ri[0]=1",
"ri[0]",
"ri",
"0",
"1",
"for i in range(M):\n x,y=map(int,input().split())\n if ri[x-1]==1:\n ri[y-1]=1\n li[x-1]-=1\n li[y-1]+=1\n if li[x-1]==0:\n ri[x-1]=0",
"i",
"range(M)",
"range",
"M",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if ri[x-1]==1:\n ri[y-1]=1\n ",
"ri[x-1]==1",
"ri[x-1]",
"ri",
"x-1",
"x",
"1",
"1",
"ri[y-1]=1",
"ri[y-1]",
"ri",
"y-1",
"y",
"1",
"1",
"li[x-1]-=1",
"li[x-1]",
"li",
"x-1",
"x",
"1",
"1",
"li[y-1]+=1",
"li[y-1]",
"li",
"y-1",
"y",
"1",
"1",
"if li[x-1]==0:\n ri[x-1]=0",
"li[x-1]==0",
"li[x-1]",
"li",
"x-1",
"x",
"1",
"0",
"ri[x-1]=0",
"ri[x-1]",
"ri",
"x-1",
"x",
"1",
"0",
"print(sum(ri))",
"print",
"sum(ri)",
"sum",
"ri",
"N,M=map(int,input().split())",
"map(int,input().split())",
"N",
"ri=[0]*N",
"[0]*N",
"ri",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"li=[1]*N",
"[1]*N",
"li",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"M=map(int,input().split())",
"map(int,input().split())",
"M"
] | N,M=map(int,input().split())
li=[1]*N
ri=[0]*N
ri[0]=1
for i in range(M):
x,y=map(int,input().split())
if ri[x-1]==1:
ri[y-1]=1
li[x-1]-=1
li[y-1]+=1
if li[x-1]==0:
ri[x-1]=0
print(sum(ri)) |
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
4,
18,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
41,
28,
13,
4,
18,
13,
13,
13,
4,
17,
4,
13,
4,
13,
13,
10,
39,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13
] | [
[
4,
3
],
[
3,
12
],
[
132,
14
],
[
132,
16
],
[
126,
18
],
[
22,
21
],
[
130,
24
],
[
28,
27
],
[
27,
37
],
[
138,
40
],
[
127,
44
],
[
139,
46
],
[
50,
49
],
[
133,
52
],
[
49,
54
],
[
135,
57
],
[
62,
61
],
[
133,
64
],
[
61,
66
],
[
141,
69
],
[
75,
72
],
[
142,
73
],
[
84,
81
],
[
136,
82
],
[
89,
86
],
[
136,
87
],
[
142,
92
],
[
98,
95
],
[
142,
96
],
[
81,
101
],
[
136,
102
],
[
109,
106
],
[
142,
107
],
[
113,
112
],
[
142,
115
],
[
126,
127
],
[
132,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
]
] | [
"n,m = [int(x) for x in input().split()]\nxy = []\nfor _ in range(m):\n tmp = [int(x)-1 for x in input().split()]\n xy.append(tmp)\n\nbox = {x: 1 for x in range(n)}\nred = {x: False for x in range(n)}\nred[0] = True\n\nfor x,y in xy:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = True\n if box[x] == 0:\n red[x] = False\n\nprint(len([1 for x in red.values() if x]))",
"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",
"n,m = [int(x) for x in input().split()]",
"n",
"[int(x) for x in input().split()]",
"m",
"xy = []",
"xy",
"[]",
"for _ in range(m):\n tmp = [int(x)-1 for x in input().split()]\n xy.append(tmp)",
"_",
"range(m)",
"range",
"m",
"int(x)-1 for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)-1",
"int(x)",
"int",
"x",
"1",
"tmp = [int(x)-1 for x in input().split()]",
"tmp",
"[int(x)-1 for x in input().split()]",
"xy.append(tmp)",
"xy.append",
"xy",
"append",
"tmp",
"x: 1 for x in range(n)",
"for x in range(n)",
"x",
"range(n)",
"range",
"n",
"for x in range(n)",
"x",
"1",
"box = {x: 1 for x in range(n)}",
"box",
"{x: 1 for x in range(n)}",
"x: False for x in range(n)",
"for x in range(n)",
"x",
"range(n)",
"range",
"n",
"for x in range(n)",
"x",
"False",
"red = {x: False for x in range(n)}",
"red",
"{x: False for x in range(n)}",
"red[0] = True",
"red[0]",
"red",
"0",
"True",
"for x,y in xy:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = True\n if box[x] == 0:\n red[x] = False",
"x",
"y",
"xy",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"box[y] += 1",
"box[y]",
"box",
"y",
"1",
"if red[x]:\n red[y] = True\n ",
"red[x]",
"red",
"x",
"red[y] = True",
"red[y]",
"red",
"y",
"True",
"if box[x] == 0:\n red[x] = False",
"box[x] == 0",
"box[x]",
"box",
"x",
"0",
"red[x] = False",
"red[x]",
"red",
"x",
"False",
"1 for x in red.values() if x",
"for x in red.values() if x",
"x",
"red.values()",
"red.values",
"red",
"values",
"x",
"if x",
"1",
"print(len([1 for x in red.values() if x]))",
"print",
"len([1 for x in red.values() if x])",
"len",
"[1 for x in red.values() if x]",
"xy = []",
"[]",
"xy",
"m = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"m",
"n,m = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"n",
"box = {x: 1 for x in range(n)}",
"{x: 1 for x in range(n)}",
"box",
"tmp = [int(x)-1 for x in input().split()]",
"[int(x)-1 for x in input().split()]",
"tmp",
"red = {x: False for x in range(n)}",
"{x: False for x in range(n)}",
"red"
] | n,m = [int(x) for x in input().split()]
xy = []
for _ in range(m):
tmp = [int(x)-1 for x in input().split()]
xy.append(tmp)
box = {x: 1 for x in range(n)}
red = {x: False for x in range(n)}
red[0] = True
for x,y in xy:
box[x] -= 1
box[y] += 1
if red[x]:
red[y] = True
if box[x] == 0:
red[x] = False
print(len([1 for x in red.values() if x])) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
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,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
8,
2,
18,
13,
2,
13,
17,
17,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
4,
13,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
18,
13
] | [
[
142,
4
],
[
14,
13
],
[
143,
20
],
[
14,
22
],
[
25,
24
],
[
22,
28
],
[
31,
30
],
[
22,
34
],
[
37,
36
],
[
22,
39
],
[
44,
41
],
[
24,
42
],
[
36,
43
],
[
143,
50
],
[
44,
52
],
[
30,
53
],
[
36,
54
],
[
57,
56
],
[
13,
60
],
[
63,
62
],
[
13,
66
],
[
71,
68
],
[
62,
69
],
[
24,
77
],
[
30,
78
],
[
85,
80
],
[
56,
81
],
[
92,
87
],
[
56,
88
],
[
62,
96
],
[
107,
102
],
[
62,
103
],
[
56,
110
],
[
123,
118
],
[
62,
119
],
[
126,
125
],
[
62,
128
],
[
125,
131
],
[
140,
137
],
[
142,
143
]
] | [
"import sys\ninput = sys.stdin.readline\n\n\ndef main():\n N, M = map(int, input().split())\n x = [0] * M\n y = [0] * M\n for i in range(M):\n x[i], y[i] = map(int, input().split())\n\n ball = [1] * N\n exist = [0] * N\n exist[0] = 1\n for a, b in zip(x, y):\n ball[a-1] -= 1\n ball[b-1] += 1\n if exist[a-1] == 1:\n exist[a-1] = 1 if ball[a-1] > 0 else 0\n exist[b-1] = 1\n\n ans = sum(exist)\n print(ans)\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, M = map(int, input().split())\n x = [0] * M\n y = [0] * M\n for i in range(M):\n x[i], y[i] = map(int, input().split())\n\n ball = [1] * N\n exist = [0] * N\n exist[0] = 1\n for a, b in zip(x, y):\n ball[a-1] -= 1\n ball[b-1] += 1\n if exist[a-1] == 1:\n exist[a-1] = 1 if ball[a-1] > 0 else 0\n exist[b-1] = 1\n\n ans = sum(exist)\n print(ans)",
"main",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"x = [0] * M",
"x",
"[0] * M",
"[0]",
"0",
"M",
"y = [0] * M",
"y",
"[0] * M",
"[0]",
"0",
"M",
"for i in range(M):\n x[i], y[i] = map(int, input().split())\n\n ",
"i",
"range(M)",
"range",
"M",
"x[i], y[i] = map(int, input().split())",
"x[i]",
"x",
"i",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y[i]",
"y",
"i",
"ball = [1] * N",
"ball",
"[1] * N",
"[1]",
"1",
"N",
"exist = [0] * N",
"exist",
"[0] * N",
"[0]",
"0",
"N",
"exist[0] = 1",
"exist[0]",
"exist",
"0",
"1",
"for a, b in zip(x, y):\n ball[a-1] -= 1\n ball[b-1] += 1\n if exist[a-1] == 1:\n exist[a-1] = 1 if ball[a-1] > 0 else 0\n exist[b-1] = 1\n\n ",
"a",
"b",
"zip(x, y)",
"zip",
"x",
"y",
"ball[a-1] -= 1",
"ball[a-1]",
"ball",
"a-1",
"a",
"1",
"1",
"ball[b-1] += 1",
"ball[b-1]",
"ball",
"b-1",
"b",
"1",
"1",
"if exist[a-1] == 1:\n exist[a-1] = 1 if ball[a-1] > 0 else 0\n exist[b-1] = 1\n\n ",
"exist[a-1] == 1",
"exist[a-1]",
"exist",
"a-1",
"a",
"1",
"1",
"exist[a-1] = 1 if ball[a-1] > 0 else 0",
"exist[a-1]",
"exist",
"a-1",
"a",
"1",
"1 if ball[a-1] > 0 else 0",
"ball[a-1] > 0",
"ball[a-1]",
"ball",
"a-1",
"a",
"1",
"0",
"1",
"0",
"exist[b-1] = 1",
"exist[b-1]",
"exist",
"b-1",
"b",
"1",
"1",
"ans = sum(exist)",
"ans",
"sum(exist)",
"sum",
"exist",
"print(ans)",
"print",
"ans",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n N, M = map(int, input().split())\n x = [0] * M\n y = [0] * M\n for i in range(M):\n x[i], y[i] = map(int, input().split())\n\n ball = [1] * N\n exist = [0] * N\n exist[0] = 1\n for a, b in zip(x, y):\n ball[a-1] -= 1\n ball[b-1] += 1\n if exist[a-1] == 1:\n exist[a-1] = 1 if ball[a-1] > 0 else 0\n exist[b-1] = 1\n\n ans = sum(exist)\n print(ans)",
"def main():\n N, M = map(int, input().split())\n x = [0] * M\n y = [0] * M\n for i in range(M):\n x[i], y[i] = map(int, input().split())\n\n ball = [1] * N\n exist = [0] * N\n exist[0] = 1\n for a, b in zip(x, y):\n ball[a-1] -= 1\n ball[b-1] += 1\n if exist[a-1] == 1:\n exist[a-1] = 1 if ball[a-1] > 0 else 0\n exist[b-1] = 1\n\n ans = sum(exist)\n print(ans)",
"main",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input"
] | import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
x = [0] * M
y = [0] * M
for i in range(M):
x[i], y[i] = map(int, input().split())
ball = [1] * N
exist = [0] * N
exist[0] = 1
for a, b in zip(x, y):
ball[a-1] -= 1
ball[b-1] += 1
if exist[a-1] == 1:
exist[a-1] = 1 if ball[a-1] > 0 else 0
exist[b-1] = 1
ans = sum(exist)
print(ans)
if __name__ == "__main__":
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
41,
28,
13,
4,
13,
17,
2,
13,
17,
18,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
110,
2
],
[
110,
11
],
[
107,
13
],
[
111,
18
],
[
119,
21
],
[
111,
26
],
[
32,
29
],
[
120,
30
],
[
35,
34
],
[
105,
39
],
[
116,
42
],
[
116,
51
],
[
120,
54
],
[
117,
55
],
[
60,
57
],
[
120,
58
],
[
114,
59
],
[
65,
62
],
[
108,
63
],
[
117,
64
],
[
70,
67
],
[
108,
68
],
[
114,
69
],
[
62,
73
],
[
108,
74
],
[
117,
75
],
[
81,
78
],
[
120,
79
],
[
117,
80
],
[
85,
84
],
[
111,
89
],
[
120,
92
],
[
84,
93
],
[
120,
96
],
[
84,
97
],
[
110,
105
],
[
107,
108
],
[
110,
111
],
[
116,
114
],
[
116,
117
],
[
119,
120
]
] | [
"n, m = map(int, input().split())\n\nA = [1] * (n + 1)\nred = [False] * (n + 1)\nred[1] = True\n\nfor i in range(1, m + 1):\n\tx, y = map(int, input().split())\n\tif red[x]:\n\t\tred[y] = True\n\tA[x] -= 1\n\tA[y] += 1\n\tif A[x] == 0:\n\t\tred[x] = False\n\nprint(len([red[i] for i in range(1, n + 1) if red[i]]))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"A = [1] * (n + 1)",
"A",
"[1] * (n + 1)",
"[1]",
"1",
"n + 1",
"n",
"1",
"red = [False] * (n + 1)",
"red",
"[False] * (n + 1)",
"[False]",
"False",
"n + 1",
"n",
"1",
"red[1] = True",
"red[1]",
"red",
"1",
"True",
"for i in range(1, m + 1):\n\tx, y = map(int, input().split())\n\tif red[x]:\n\t\tred[y] = True\n\tA[x] -= 1\n\tA[y] += 1\n\tif A[x] == 0:\n\t\tred[x] = False",
"i",
"range(1, m + 1)",
"range",
"1",
"m + 1",
"m",
"1",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if red[x]:\n\t\tred[y] = True\n\t",
"red[x]",
"red",
"x",
"red[y] = True",
"red[y]",
"red",
"y",
"True",
"A[x] -= 1",
"A[x]",
"A",
"x",
"1",
"A[y] += 1",
"A[y]",
"A",
"y",
"1",
"if A[x] == 0:\n\t\tred[x] = False",
"A[x] == 0",
"A[x]",
"A",
"x",
"0",
"red[x] = False",
"red[x]",
"red",
"x",
"False",
"red[i] for i in range(1, n + 1) if red[i]",
"for i in range(1, n + 1) if red[i]",
"i",
"range(1, n + 1)",
"range",
"1",
"n + 1",
"n",
"1",
"red[i]",
"red",
"i",
"if red[i]",
"red[i]",
"red",
"i",
"print(len([red[i] for i in range(1, n + 1) if red[i]]))",
"print",
"len([red[i] for i in range(1, n + 1) if red[i]])",
"len",
"[red[i] for i in range(1, n + 1) if red[i]]",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"A = [1] * (n + 1)",
"[1] * (n + 1)",
"A",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"red = [False] * (n + 1)",
"[False] * (n + 1)",
"red"
] | n, m = map(int, input().split())
A = [1] * (n + 1)
red = [False] * (n + 1)
red[1] = True
for i in range(1, m + 1):
x, y = map(int, input().split())
if red[x]:
red[y] = True
A[x] -= 1
A[y] += 1
if A[x] == 0:
red[x] = False
print(len([red[i] for i in range(1, n + 1) if red[i]])) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
31,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
4,
13,
31,
2,
39,
4,
13,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
4,
13,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
12,
13,
10,
18,
13,
10,
18,
13
] | [
[
134,
4
],
[
131,
11
],
[
125,
18
],
[
28,
27
],
[
135,
34
],
[
28,
36
],
[
28,
37
],
[
41,
40
],
[
27,
44
],
[
49,
46
],
[
40,
47
],
[
52,
51
],
[
27,
55
],
[
74,
69
],
[
51,
70
],
[
81,
76
],
[
51,
77
],
[
40,
84
],
[
94,
89
],
[
40,
90
],
[
51,
98
],
[
109,
104
],
[
40,
105
],
[
112,
111
],
[
40,
114
],
[
111,
117
],
[
129,
123
],
[
125,
126
],
[
131,
132
],
[
134,
135
]
] | [
"import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N,M,*xy = map(int, read().split())\n\n check = [False] * N\n check[0] = True\n num = [1] * N\n\n for x, y in zip(*[iter(xy)]*2):\n num[x-1] -= 1\n num[y-1] += 1\n if check[x-1]:\n check[y-1] = True\n if num[x-1] == 0:\n check[x-1] = False\n\n ans = sum(check)\n print(ans)\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",
"def main():\n N,M,*xy = map(int, read().split())\n\n check = [False] * N\n check[0] = True\n num = [1] * N\n\n for x, y in zip(*[iter(xy)]*2):\n num[x-1] -= 1\n num[y-1] += 1\n if check[x-1]:\n check[y-1] = True\n if num[x-1] == 0:\n check[x-1] = False\n\n ans = sum(check)\n print(ans)",
"main",
"N,M,*xy = map(int, read().split())",
"N",
"map(int, read().split())",
"map",
"int",
"read().split()",
"().split",
"()",
"read",
"split",
"M",
"*xy",
"xy",
"check = [False] * N",
"check",
"[False] * N",
"[False]",
"False",
"N",
"check[0] = True",
"check[0]",
"check",
"0",
"True",
"num = [1] * N",
"num",
"[1] * N",
"[1]",
"1",
"N",
"for x, y in zip(*[iter(xy)]*2):\n num[x-1] -= 1\n num[y-1] += 1\n if check[x-1]:\n check[y-1] = True\n if num[x-1] == 0:\n check[x-1] = False\n\n ",
"x",
"y",
"zip(*[iter(xy)]*2)",
"zip",
"*[iter(xy)]*2",
"[iter(xy)]*2",
"[iter(xy)]",
"iter(xy)",
"iter",
"xy",
"2",
"num[x-1] -= 1",
"num[x-1]",
"num",
"x-1",
"x",
"1",
"1",
"num[y-1] += 1",
"num[y-1]",
"num",
"y-1",
"y",
"1",
"1",
"if check[x-1]:\n check[y-1] = True\n ",
"check[x-1]",
"check",
"x-1",
"x",
"1",
"check[y-1] = True",
"check[y-1]",
"check",
"y-1",
"y",
"1",
"True",
"if num[x-1] == 0:\n check[x-1] = False\n\n ",
"num[x-1] == 0",
"num[x-1]",
"num",
"x-1",
"x",
"1",
"0",
"check[x-1] = False",
"check[x-1]",
"check",
"x-1",
"x",
"1",
"False",
"ans = sum(check)",
"ans",
"sum(check)",
"sum",
"check",
"print(ans)",
"print",
"ans",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"readlines = sys.stdin.readlines",
"sys.stdin.readlines",
"readlines",
"def main():\n N,M,*xy = map(int, read().split())\n\n check = [False] * N\n check[0] = True\n num = [1] * N\n\n for x, y in zip(*[iter(xy)]*2):\n num[x-1] -= 1\n num[y-1] += 1\n if check[x-1]:\n check[y-1] = True\n if num[x-1] == 0:\n check[x-1] = False\n\n ans = sum(check)\n print(ans)",
"def main():\n N,M,*xy = map(int, read().split())\n\n check = [False] * N\n check[0] = True\n num = [1] * N\n\n for x, y in zip(*[iter(xy)]*2):\n num[x-1] -= 1\n num[y-1] += 1\n if check[x-1]:\n check[y-1] = True\n if num[x-1] == 0:\n check[x-1] = False\n\n ans = sum(check)\n print(ans)",
"main",
"readline = sys.stdin.readline",
"sys.stdin.readline",
"readline",
"read = sys.stdin.read",
"sys.stdin.read",
"read"
] | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N,M,*xy = map(int, read().split())
check = [False] * N
check[0] = True
num = [1] * N
for x, y in zip(*[iter(xy)]*2):
num[x-1] -= 1
num[y-1] += 1
if check[x-1]:
check[y-1] = True
if num[x-1] == 0:
check[x-1] = False
ans = sum(check)
print(ans)
if __name__ == "__main__":
main()
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
13,
0,
13,
13,
12,
13,
23,
13,
17,
23,
12,
13,
12,
13,
12,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
29,
4,
13,
4,
13,
13,
4,
13,
31,
13,
23,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
13,
13,
0,
13,
4,
13,
31,
13,
0,
13,
4,
13,
31,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
4,
13,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] | [
[
155,
11
],
[
185,
18
],
[
182,
21
],
[
27,
26
],
[
38,
37
],
[
41,
40
],
[
69,
43
],
[
37,
46
],
[
156,
56
],
[
37,
67
],
[
69,
69
],
[
167,
71
],
[
180,
73
],
[
167,
74
],
[
194,
76
],
[
165,
78
],
[
159,
79
],
[
194,
80
],
[
170,
82
],
[
192,
84
],
[
195,
86
],
[
197,
88
],
[
192,
90
],
[
177,
92
],
[
161,
94
],
[
168,
98
],
[
188,
100
],
[
168,
104
],
[
109,
106
],
[
162,
107
],
[
171,
115
],
[
195,
115
],
[
198,
116
],
[
177,
116
],
[
121,
118
],
[
162,
119
],
[
118,
122
],
[
162,
123
],
[
145,
125
],
[
162,
126
],
[
132,
129
],
[
189,
130
],
[
137,
134
],
[
189,
135
],
[
129,
140
],
[
189,
141
],
[
148,
145
],
[
162,
146
],
[
162,
153
],
[
155,
156
],
[
167,
159
],
[
161,
162
],
[
167,
168
],
[
170,
171
],
[
194,
177
],
[
182,
183
],
[
185,
186
],
[
188,
189
],
[
194,
195
],
[
197,
198
]
] | [
"# https://atcoder.jp/contests/agc002/tasks/agc002_b\nimport sys\nsys.setrecursionlimit(1 << 25)\nread = sys.stdin.readline\nra = range\nenu = enumerate\n\n\ndef mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))\n# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと\n\n\ndef read_a_int(): return int(read())\n\n\ndef read_ints(): return list(map(int, read().split()))\n\n\ndef read_col(H):\n '''H is number of rows\n A列、B列が与えられるようなとき\n ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''\n ret = []\n for _ in range(H):\n ret.append(list(map(int, read().split())))\n return tuple(map(list, zip(*ret)))\n\n\nN, M = read_ints()\nX, Y = read_col(M)\nX = mina(*X)\nY = mina(*Y)\n# 有向グラフでつないで1からbfsで到達するノードの数を記録する?#順序情報が消えてしまう\n# ただ単純に赤の可能性のある配列を用意しておけばいいんじゃない?\n# ボールの個数も管理しないと\nprob = [False] * N\nn_balls = [1] * N\nprob[0] = True\n\nfor x, y in zip(X, Y):\n prob[y] = prob[y] or prob[x]\n n_balls[x] -= 1\n n_balls[y] += 1\n if n_balls[x] == 0:\n prob[x] = False\n\n\nprint(sum(prob))",
"import sys",
"sys",
"sys.setrecursionlimit(1 << 25)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1 << 25",
"1",
"25",
"read = sys.stdin.readline",
"read",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"ra = range",
"ra",
"range",
"enu = enumerate",
"enu",
"enumerate",
"def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))\n# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと",
"mina",
"sub=1",
"sub",
"1",
"*argv",
"def read_a_int(): return int(read())",
"read_a_int",
"def read_ints(): return list(map(int, read().split()))",
"read_ints",
"def read_col(H):\n '''H is number of rows\n A列、B列が与えられるようなとき\n ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''\n ret = []\n for _ in range(H):\n ret.append(list(map(int, read().split())))\n return tuple(map(list, zip(*ret)))",
"read_col",
"'''H is number of rows\n A列、B列が与えられるようなとき\n ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''",
"ret = []",
"ret",
"[]",
"for _ in range(H):\n ret.append(list(map(int, read().split())))\n ",
"_",
"range(H)",
"range",
"H",
"ret.append(list(map(int, read().split())))",
"ret.append",
"ret",
"append",
"list(map(int, read().split()))",
"list",
"map(int, read().split())",
"map",
"int",
"read().split()",
"().split",
"()",
"read",
"split",
"return tuple(map(list, zip(*ret)))",
"tuple(map(list, zip(*ret)))",
"tuple",
"map(list, zip(*ret))",
"map",
"list",
"zip(*ret)",
"zip",
"*ret",
"ret",
"H",
"H",
"N, M = read_ints()",
"N",
"read_ints()",
"read_ints",
"M",
"X, Y = read_col(M)",
"X",
"read_col(M)",
"read_col",
"M",
"Y",
"X = mina(*X)",
"X",
"mina(*X)",
"mina",
"*X",
"X",
"Y = mina(*Y)",
"Y",
"mina(*Y)",
"mina",
"*Y",
"Y",
"prob = [False] * N",
"prob",
"[False] * N",
"[False]",
"False",
"N",
"n_balls = [1] * N",
"n_balls",
"[1] * N",
"[1]",
"1",
"N",
"prob[0] = True",
"prob[0]",
"prob",
"0",
"True",
"for x, y in zip(X, Y):\n prob[y] = prob[y] or prob[x]\n n_balls[x] -= 1\n n_balls[y] += 1\n if n_balls[x] == 0:\n prob[x] = False",
"x",
"y",
"zip(X, Y)",
"zip",
"X",
"Y",
"prob[y] = prob[y] or prob[x]",
"prob[y]",
"prob",
"y",
"prob[y] or prob[x]",
"prob[y]",
"prob",
"y",
"prob[x]",
"prob",
"x",
"n_balls[x] -= 1",
"n_balls[x]",
"n_balls",
"x",
"1",
"n_balls[y] += 1",
"n_balls[y]",
"n_balls",
"y",
"1",
"if n_balls[x] == 0:\n prob[x] = False",
"n_balls[x] == 0",
"n_balls[x]",
"n_balls",
"x",
"0",
"prob[x] = False",
"prob[x]",
"prob",
"x",
"False",
"print(sum(prob))",
"print",
"sum(prob)",
"sum",
"prob",
"read = sys.stdin.readline",
"sys.stdin.readline",
"read",
"M = read_ints()",
"read_ints()",
"M",
"prob = [False] * N",
"[False] * N",
"prob",
"def read_col(H):\n '''H is number of rows\n A列、B列が与えられるようなとき\n ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''\n ret = []\n for _ in range(H):\n ret.append(list(map(int, read().split())))\n return tuple(map(list, zip(*ret)))",
"def read_col(H):\n '''H is number of rows\n A列、B列が与えられるようなとき\n ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''\n ret = []\n for _ in range(H):\n ret.append(list(map(int, read().split())))\n return tuple(map(list, zip(*ret)))",
"read_col",
"N, M = read_ints()",
"read_ints()",
"N",
"X = mina(*X)",
"mina(*X)",
"X",
"def read_a_int(): return int(read())",
"def read_a_int(): return int(read())",
"read_a_int",
"Y = read_col(M)",
"read_col(M)",
"Y",
"def read_ints(): return list(map(int, read().split()))",
"def read_ints(): return list(map(int, read().split()))",
"read_ints",
"enu = enumerate",
"enumerate",
"enu",
"ra = range",
"range",
"ra",
"n_balls = [1] * N",
"[1] * N",
"n_balls",
"def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))\n# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと",
"def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))\n# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと",
"mina",
"X, Y = read_col(M)",
"read_col(M)",
"X",
"Y = mina(*Y)",
"mina(*Y)",
"Y"
] | # https://atcoder.jp/contests/agc002/tasks/agc002_b
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def read_a_int(): return int(read())
def read_ints(): return list(map(int, read().split()))
def read_col(H):
'''H is number of rows
A列、B列が与えられるようなとき
ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''
ret = []
for _ in range(H):
ret.append(list(map(int, read().split())))
return tuple(map(list, zip(*ret)))
N, M = read_ints()
X, Y = read_col(M)
X = mina(*X)
Y = mina(*Y)
# 有向グラフでつないで1からbfsで到達するノードの数を記録する?#順序情報が消えてしまう
# ただ単純に赤の可能性のある配列を用意しておけばいいんじゃない?
# ボールの個数も管理しないと
prob = [False] * N
n_balls = [1] * N
prob[0] = True
for x, y in zip(X, Y):
prob[y] = prob[y] or prob[x]
n_balls[x] -= 1
n_balls[y] += 1
if n_balls[x] == 0:
prob[x] = False
print(sum(prob))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
129,
2
],
[
129,
11
],
[
135,
13
],
[
127,
17
],
[
22,
19
],
[
136,
20
],
[
138,
24
],
[
127,
28
],
[
31,
30
],
[
130,
33
],
[
144,
35
],
[
144,
44
],
[
147,
46
],
[
141,
49
],
[
64,
54
],
[
136,
55
],
[
148,
56
],
[
133,
56
],
[
111,
59
],
[
96,
59
],
[
69,
59
],
[
139,
60
],
[
148,
61
],
[
133,
61
],
[
67,
64
],
[
136,
65
],
[
148,
66
],
[
133,
66
],
[
72,
69
],
[
139,
70
],
[
148,
71
],
[
133,
71
],
[
77,
74
],
[
136,
75
],
[
142,
76
],
[
145,
76
],
[
82,
79
],
[
139,
80
],
[
142,
81
],
[
145,
81
],
[
64,
86
],
[
136,
87
],
[
148,
88
],
[
133,
88
],
[
111,
91
],
[
96,
91
],
[
69,
91
],
[
139,
92
],
[
148,
93
],
[
133,
93
],
[
99,
96
],
[
139,
97
],
[
148,
98
],
[
133,
98
],
[
104,
101
],
[
136,
102
],
[
142,
103
],
[
145,
103
],
[
109,
106
],
[
139,
107
],
[
142,
108
],
[
145,
108
],
[
114,
111
],
[
139,
112
],
[
148,
113
],
[
133,
113
],
[
119,
116
],
[
139,
117
],
[
142,
118
],
[
145,
118
],
[
136,
124
],
[
129,
127
],
[
129,
130
],
[
144,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
]
] | [
"N, M = map(int,input().split())\nred = [0] * N\nred[0] = 1\nboal = [1] * N\n\nfor i in range(M):\n x, y = map(int,input().split())\n x -= 1\n y -= 1\n if red[x] == 1 and boal[x] == 1:\n red[x] = 0\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n elif red[x] == 1 and boal[x] > 1:\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n else:\n boal[x] -= 1\n boal[y] += 1\nprint(sum(red))",
"N, M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"red = [0] * N",
"red",
"[0] * N",
"[0]",
"0",
"N",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"boal = [1] * N",
"boal",
"[1] * N",
"[1]",
"1",
"N",
"for i in range(M):\n x, y = map(int,input().split())\n x -= 1\n y -= 1\n if red[x] == 1 and boal[x] == 1:\n red[x] = 0\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n elif red[x] == 1 and boal[x] > 1:\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n else:\n boal[x] -= 1\n boal[y] += 1",
"i",
"range(M)",
"range",
"M",
"x, y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if red[x] == 1 and boal[x] == 1:\n red[x] = 0\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n elif red[x] == 1 and boal[x] > 1:\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n else:\n boal[x] -= 1\n boal[y] += 1",
"red[x] == 1 and boal[x] == 1",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"boal[x] == 1",
"boal[x]",
"boal",
"x",
"1",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"boal[x] -= 1",
"boal[x]",
"boal",
"x",
"1",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"boal[y] += 1",
"boal[y]",
"boal",
"y",
"1",
"elif red[x] == 1 and boal[x] > 1:\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n ",
"red[x] == 1 and boal[x] > 1",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"boal[x] > 1",
"boal[x]",
"boal",
"x",
"1",
"boal[x] -= 1",
"boal[x]",
"boal",
"x",
"1",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"boal[y] += 1",
"boal[y]",
"boal",
"y",
"1",
"boal[x] -= 1",
"boal[x]",
"boal",
"x",
"1",
"boal[y] += 1",
"boal[y]",
"boal",
"y",
"1",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"N, M = map(int,input().split())",
"map(int,input().split())",
"N",
"M = map(int,input().split())",
"map(int,input().split())",
"M",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x",
"red = [0] * N",
"[0] * N",
"red",
"boal = [1] * N",
"[1] * N",
"boal",
"y -= 1",
"1",
"y",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"x -= 1",
"1",
"x"
] | N, M = map(int,input().split())
red = [0] * N
red[0] = 1
boal = [1] * N
for i in range(M):
x, y = map(int,input().split())
x -= 1
y -= 1
if red[x] == 1 and boal[x] == 1:
red[x] = 0
boal[x] -= 1
red[y] = 1
boal[y] += 1
elif red[x] == 1 and boal[x] > 1:
boal[x] -= 1
red[y] = 1
boal[y] += 1
else:
boal[x] -= 1
boal[y] += 1
print(sum(red)) |
[
7,
15,
12,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
2,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
14,
40,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
17,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
13,
12
],
[
5,
19
],
[
13,
21
],
[
24,
23
],
[
12,
27
],
[
32,
29
],
[
23,
30
],
[
35,
34
],
[
12,
38
],
[
41,
40
],
[
44,
43
],
[
21,
46
],
[
49,
48
],
[
5,
55
],
[
49,
57
],
[
23,
60
],
[
48,
62
],
[
34,
67
],
[
48,
69
],
[
78,
73
],
[
23,
74
],
[
48,
76
],
[
81,
80
],
[
23,
85
],
[
57,
87
],
[
95,
90
],
[
23,
91
],
[
57,
93
],
[
98,
97
],
[
105,
100
],
[
34,
101
],
[
48,
103
],
[
112,
107
],
[
34,
108
],
[
57,
110
],
[
97,
115
],
[
80,
115
],
[
40,
115
],
[
127,
124
]
] | [
"#!/usr/bin/env python3\n\nfrom sys import stdin, setrecursionlimit\n\n\ndef main():\n input = stdin.buffer.readline\n n, m = map(int, input().split())\n red = [False] * n\n red[0] = True\n balls = [1] * n\n ans = 1\n for _ in range(m):\n x, y = map(int, input().split())\n if red[x - 1]:\n if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(ans)\n\n\nif __name__ == \"__main__\":\n setrecursionlimit(10000)\n main()",
"from sys import stdin, setrecursionlimit",
"def main():\n input = stdin.buffer.readline\n n, m = map(int, input().split())\n red = [False] * n\n red[0] = True\n balls = [1] * n\n ans = 1\n for _ in range(m):\n x, y = map(int, input().split())\n if red[x - 1]:\n if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(ans)",
"main",
"input = stdin.buffer.readline",
"input",
"stdin.buffer.readline",
"stdin.buffer",
"stdin",
"buffer",
"readline",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"red = [False] * n",
"red",
"[False] * n",
"[False]",
"False",
"n",
"red[0] = True",
"red[0]",
"red",
"0",
"True",
"balls = [1] * n",
"balls",
"[1] * n",
"[1]",
"1",
"n",
"ans = 1",
"ans",
"1",
"for _ in range(m):\n x, y = map(int, input().split())\n if red[x - 1]:\n if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n balls[x - 1] -= 1\n balls[y - 1] += 1\n ",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if red[x - 1]:\n if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n ",
"red[x - 1]",
"red",
"x - 1",
"x",
"1",
"if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n ",
"balls[x - 1] == 1",
"balls[x - 1]",
"balls",
"x - 1",
"x",
"1",
"1",
"red[x - 1] = False",
"red[x - 1]",
"red",
"x - 1",
"x",
"1",
"False",
"ans -= 1",
"ans",
"1",
"if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n ",
"not red[y - 1]",
"red[y - 1]",
"red",
"y - 1",
"y",
"1",
"red[y - 1] = True",
"red[y - 1]",
"red",
"y - 1",
"y",
"1",
"True",
"ans += 1",
"ans",
"1",
"balls[x - 1] -= 1",
"balls[x - 1]",
"balls",
"x - 1",
"x",
"1",
"1",
"balls[y - 1] += 1",
"balls[y - 1]",
"balls",
"y - 1",
"y",
"1",
"1",
"print(ans)",
"print",
"ans",
"if __name__ == \"__main__\":\n setrecursionlimit(10000)\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"setrecursionlimit(10000)",
"setrecursionlimit",
"10000",
"main()",
"main",
"def main():\n input = stdin.buffer.readline\n n, m = map(int, input().split())\n red = [False] * n\n red[0] = True\n balls = [1] * n\n ans = 1\n for _ in range(m):\n x, y = map(int, input().split())\n if red[x - 1]:\n if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(ans)",
"def main():\n input = stdin.buffer.readline\n n, m = map(int, input().split())\n red = [False] * n\n red[0] = True\n balls = [1] * n\n ans = 1\n for _ in range(m):\n x, y = map(int, input().split())\n if red[x - 1]:\n if balls[x - 1] == 1:\n red[x - 1] = False\n ans -= 1\n if not red[y - 1]:\n red[y - 1] = True\n ans += 1\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(ans)",
"main"
] | #!/usr/bin/env python3
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n, m = map(int, input().split())
red = [False] * n
red[0] = True
balls = [1] * n
ans = 1
for _ in range(m):
x, y = map(int, input().split())
if red[x - 1]:
if balls[x - 1] == 1:
red[x - 1] = False
ans -= 1
if not red[y - 1]:
red[y - 1] = True
ans += 1
balls[x - 1] -= 1
balls[y - 1] += 1
print(ans)
if __name__ == "__main__":
setrecursionlimit(10000)
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
18,
13,
13,
17,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
103,
2
],
[
103,
11
],
[
85,
13
],
[
95,
18
],
[
24,
21
],
[
86,
22
],
[
88,
26
],
[
95,
31
],
[
37,
34
],
[
89,
35
],
[
40,
39
],
[
104,
42
],
[
97,
44
],
[
97,
53
],
[
86,
56
],
[
98,
57
],
[
65,
60
],
[
89,
61
],
[
98,
62
],
[
68,
65
],
[
89,
66
],
[
98,
67
],
[
73,
70
],
[
89,
71
],
[
92,
72
],
[
100,
75
],
[
86,
78
],
[
101,
83
],
[
85,
86
],
[
88,
89
],
[
97,
92
],
[
103,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
]
] | [
"n,m = map(int, input().split())\nredl = [False]*(n+1)\nredl[1] = True\ncnts = [1]*(n+1)\ncnts[0] = 1\n\nfor _ in range(m):\n x,y = map(int, input().split())\n if redl[x]: redl[y] = True\n if cnts[x] == 1: redl[x] = False\n cnts[x] -= 1\n cnts[y] += 1\n\nans = redl.count(True)\nprint(ans)",
"n,m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"redl = [False]*(n+1)",
"redl",
"[False]*(n+1)",
"[False]",
"False",
"n+1",
"n",
"1",
"redl[1] = True",
"redl[1]",
"redl",
"1",
"True",
"cnts = [1]*(n+1)",
"cnts",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"cnts[0] = 1",
"cnts[0]",
"cnts",
"0",
"1",
"for _ in range(m):\n x,y = map(int, input().split())\n if redl[x]: redl[y] = True\n if cnts[x] == 1: redl[x] = False\n cnts[x] -= 1\n cnts[y] += 1",
"_",
"range(m)",
"range",
"m",
"x,y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if redl[x]: redl[y] = True\n ",
"redl[x]",
"redl",
"x",
"if cnts[x] == 1: redl[x] = False\n ",
"cnts[x] == 1",
"cnts[x]",
"cnts",
"x",
"1",
"cnts[x] -= 1",
"cnts[x]",
"cnts",
"x",
"1",
"cnts[y] += 1",
"cnts[y]",
"cnts",
"y",
"1",
"ans = redl.count(True)",
"ans",
"redl.count(True)",
"redl.count",
"redl",
"count",
"True",
"print(ans)",
"print",
"ans",
"redl = [False]*(n+1)",
"[False]*(n+1)",
"redl",
"cnts = [1]*(n+1)",
"[1]*(n+1)",
"cnts",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"n,m = map(int, input().split())",
"map(int, input().split())",
"n",
"x,y = map(int, input().split())",
"map(int, input().split())",
"x",
"ans = redl.count(True)",
"redl.count(True)",
"ans",
"m = map(int, input().split())",
"map(int, input().split())",
"m"
] | n,m = map(int, input().split())
redl = [False]*(n+1)
redl[1] = True
cnts = [1]*(n+1)
cnts[0] = 1
for _ in range(m):
x,y = map(int, input().split())
if redl[x]: redl[y] = True
if cnts[x] == 1: redl[x] = False
cnts[x] -= 1
cnts[y] += 1
ans = redl.count(True)
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
17,
0,
13,
39,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
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,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
18,
13,
13,
17,
9,
0,
18,
13,
18,
13,
13,
17,
0,
18,
13,
18,
13,
13,
17,
14,
2,
18,
13,
18,
13,
13,
17,
0,
18,
13,
18,
13,
13,
17,
14,
2,
18,
13,
18,
13,
13,
17,
0,
18,
13,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
40,
18,
13,
13,
17,
9,
14,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13
] | [
[
177,
2
],
[
177,
11
],
[
174,
13
],
[
165,
17
],
[
183,
21
],
[
160,
26
],
[
162,
29
],
[
160,
34
],
[
38,
37
],
[
178,
40
],
[
171,
42
],
[
171,
51
],
[
175,
54
],
[
169,
56
],
[
166,
59
],
[
172,
61
],
[
66,
63
],
[
163,
64
],
[
69,
68
],
[
178,
73
],
[
85,
77
],
[
184,
78
],
[
175,
80
],
[
68,
81
],
[
90,
85
],
[
184,
86
],
[
175,
88
],
[
68,
89
],
[
97,
92
],
[
184,
93
],
[
166,
95
],
[
68,
96
],
[
122,
100
],
[
163,
101
],
[
175,
103
],
[
68,
104
],
[
112,
107
],
[
163,
108
],
[
166,
110
],
[
68,
111
],
[
85,
115
],
[
184,
116
],
[
175,
118
],
[
68,
119
],
[
127,
122
],
[
163,
123
],
[
175,
125
],
[
68,
126
],
[
180,
129
],
[
133,
132
],
[
160,
137
],
[
184,
142
],
[
132,
143
],
[
163,
149
],
[
132,
150
],
[
186,
153
],
[
187,
157
],
[
181,
157
],
[
177,
160
],
[
162,
163
],
[
165,
166
],
[
171,
169
],
[
171,
172
],
[
174,
175
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
186,
187
]
] | [
"N, M = map(int, input().split())\nx = [0]\ny = [0]\nmemo = [1] * (N + 1) #各箱の中のボールの数\nflag = [0] * (N + 1) #赤ボールがある可能性\nfor _ in range(M):\n _x, _y = map(int, input().split())\n x.append(_x)\n y.append(_y)\n\nflag[1] = 1\nfor i in range(1, M + 1):\n if memo[x[i]] == 0: #移動するボール無し\n continue\n memo[x[i]] -= 1\n memo[y[i]] += 1\n if flag[x[i]] == 1:\n flag[y[i]] = 1\n if memo[x[i]] == 0:\n flag[x[i]] = 0\n\nans = 0\nfor i in range(1, N + 1):\n if memo[i] <= 0:\n continue\n if flag[i] == 1:\n ans += 1\n#print(memo)\n#print(flag)\nprint(ans)",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"x = [0]",
"x",
"[0]",
"0",
"y = [0]",
"y",
"[0]",
"0",
"memo = [1] * (N + 1)",
"memo",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"flag = [0] * (N + 1)",
"flag",
"[0] * (N + 1)",
"[0]",
"0",
"N + 1",
"N",
"1",
"for _ in range(M):\n _x, _y = map(int, input().split())\n x.append(_x)\n y.append(_y)",
"_",
"range(M)",
"range",
"M",
"_x, _y = map(int, input().split())",
"_x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"_y",
"x.append(_x)",
"x.append",
"x",
"append",
"_x",
"y.append(_y)",
"y.append",
"y",
"append",
"_y",
"flag[1] = 1",
"flag[1]",
"flag",
"1",
"1",
"for i in range(1, M + 1):\n if memo[x[i]] == 0: #移動するボール無し\n continue\n memo[x[i]] -= 1\n memo[y[i]] += 1\n if flag[x[i]] == 1:\n flag[y[i]] = 1\n if memo[x[i]] == 0:\n flag[x[i]] = 0",
"i",
"range(1, M + 1)",
"range",
"1",
"M + 1",
"M",
"1",
"if memo[x[i]] == 0: #移動するボール無し\n continue\n ",
"memo[x[i]] == 0",
"memo[x[i]]",
"memo",
"x[i]",
"x",
"i",
"0",
"continue",
"memo[x[i]] -= 1",
"memo[x[i]]",
"memo",
"x[i]",
"x",
"i",
"1",
"memo[y[i]] += 1",
"memo[y[i]]",
"memo",
"y[i]",
"y",
"i",
"1",
"if flag[x[i]] == 1:\n flag[y[i]] = 1\n ",
"flag[x[i]] == 1",
"flag[x[i]]",
"flag",
"x[i]",
"x",
"i",
"1",
"flag[y[i]] = 1",
"flag[y[i]]",
"flag",
"y[i]",
"y",
"i",
"1",
"if memo[x[i]] == 0:\n flag[x[i]] = 0",
"memo[x[i]] == 0",
"memo[x[i]]",
"memo",
"x[i]",
"x",
"i",
"0",
"flag[x[i]] = 0",
"flag[x[i]]",
"flag",
"x[i]",
"x",
"i",
"0",
"ans = 0",
"ans",
"0",
"for i in range(1, N + 1):\n if memo[i] <= 0:\n continue\n if flag[i] == 1:\n ans += 1\n#print(memo)\n#print(flag)",
"i",
"range(1, N + 1)",
"range",
"1",
"N + 1",
"N",
"1",
"if memo[i] <= 0:\n continue\n ",
"memo[i] <= 0",
"memo[i]",
"memo",
"i",
"0",
"continue",
"if flag[i] == 1:\n ans += 1\n#print(memo)\n#print(flag)",
"flag[i] == 1",
"flag[i]",
"flag",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"flag = [0] * (N + 1)",
"[0] * (N + 1)",
"flag",
"y = [0]",
"[0]",
"y",
"_x, _y = map(int, input().split())",
"map(int, input().split())",
"_x",
"_y = map(int, input().split())",
"map(int, input().split())",
"_y",
"x = [0]",
"[0]",
"x",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"ans = 0",
"0",
"ans",
"memo = [1] * (N + 1)",
"[1] * (N + 1)",
"memo",
"ans += 1",
"1",
"ans"
] | N, M = map(int, input().split())
x = [0]
y = [0]
memo = [1] * (N + 1) #各箱の中のボールの数
flag = [0] * (N + 1) #赤ボールがある可能性
for _ in range(M):
_x, _y = map(int, input().split())
x.append(_x)
y.append(_y)
flag[1] = 1
for i in range(1, M + 1):
if memo[x[i]] == 0: #移動するボール無し
continue
memo[x[i]] -= 1
memo[y[i]] += 1
if flag[x[i]] == 1:
flag[y[i]] = 1
if memo[x[i]] == 0:
flag[x[i]] = 0
ans = 0
for i in range(1, N + 1):
if memo[i] <= 0:
continue
if flag[i] == 1:
ans += 1
#print(memo)
#print(flag)
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
13,
39,
41,
28,
13,
4,
13,
13,
4,
13,
17,
0,
13,
13,
0,
13,
4,
13,
39,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
2,
13,
17,
13,
4,
18,
13,
13,
2,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
4,
18,
13,
13,
2,
13,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
39,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13
] | [
[
121,
2
],
[
121,
11
],
[
112,
13
],
[
127,
15
],
[
20,
19
],
[
122,
22
],
[
19,
24
],
[
115,
27
],
[
124,
30
],
[
37,
36
],
[
119,
39
],
[
130,
41
],
[
130,
50
],
[
57,
52
],
[
116,
53
],
[
131,
55
],
[
64,
59
],
[
116,
60
],
[
110,
62
],
[
131,
68
],
[
125,
70
],
[
125,
73
],
[
110,
76
],
[
116,
81
],
[
131,
83
],
[
125,
88
],
[
131,
91
],
[
113,
95
],
[
131,
97
],
[
128,
100
],
[
110,
102
],
[
125,
107
],
[
130,
110
],
[
112,
113
],
[
115,
116
],
[
121,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
],
[
130,
131
]
] | [
"N, M = map(int, input().split())\nX, Y = [], []\nd = {n:1 for n in range(N)}\nr = set([0])\nfor _ in range(M):\n x, y = map(int, input().split())\n d[x-1] -= 1\n d[y-1] += 1\n if x - 1 in r:\n r.add(y - 1)\n if d[x - 1] == 0:\n r.remove(x - 1)\n X.append(x)\n Y.append(y)\n\nprint(len(r))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"X, Y = [], []",
"X",
"[]",
"Y",
"[]",
"n:1 for n in range(N)",
"for n in range(N)",
"n",
"range(N)",
"range",
"N",
"for n in range(N)",
"n",
"1",
"d = {n:1 for n in range(N)}",
"d",
"{n:1 for n in range(N)}",
"r = set([0])",
"r",
"set([0])",
"set",
"[0]",
"0",
"for _ in range(M):\n x, y = map(int, input().split())\n d[x-1] -= 1\n d[y-1] += 1\n if x - 1 in r:\n r.add(y - 1)\n if d[x - 1] == 0:\n r.remove(x - 1)\n X.append(x)\n Y.append(y)",
"_",
"range(M)",
"range",
"M",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"d[x-1] -= 1",
"d[x-1]",
"d",
"x-1",
"x",
"1",
"1",
"d[y-1] += 1",
"d[y-1]",
"d",
"y-1",
"y",
"1",
"1",
"if x - 1 in r:\n r.add(y - 1)\n if d[x - 1] == 0:\n r.remove(x - 1)\n ",
"x - 1 in r",
"x - 1",
"x",
"1",
"r",
"r.add(y - 1)",
"r.add",
"r",
"add",
"y - 1",
"y",
"1",
"if d[x - 1] == 0:\n r.remove(x - 1)\n ",
"d[x - 1] == 0",
"d[x - 1]",
"d",
"x - 1",
"x",
"1",
"0",
"r.remove(x - 1)",
"r.remove",
"r",
"remove",
"x - 1",
"x",
"1",
"X.append(x)",
"X.append",
"X",
"append",
"x",
"Y.append(y)",
"Y.append",
"Y",
"append",
"y",
"print(len(r))",
"print",
"len(r)",
"len",
"r",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"X, Y = [], []",
"[]",
"X",
"d = {n:1 for n in range(N)}",
"{n:1 for n in range(N)}",
"d",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"r = set([0])",
"set([0])",
"r",
"Y = [], []",
"[]",
"Y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x"
] | N, M = map(int, input().split())
X, Y = [], []
d = {n:1 for n in range(N)}
r = set([0])
for _ in range(M):
x, y = map(int, input().split())
d[x-1] -= 1
d[y-1] += 1
if x - 1 in r:
r.add(y - 1)
if d[x - 1] == 0:
r.remove(x - 1)
X.append(x)
Y.append(y)
print(len(r)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
102,
2
],
[
102,
11
],
[
105,
13
],
[
106,
18
],
[
24,
23
],
[
103,
26
],
[
99,
30
],
[
34,
33
],
[
97,
36
],
[
93,
38
],
[
93,
47
],
[
91,
50
],
[
106,
51
],
[
106,
54
],
[
94,
56
],
[
63,
58
],
[
100,
59
],
[
91,
61
],
[
70,
65
],
[
100,
66
],
[
94,
68
],
[
100,
74
],
[
91,
76
],
[
106,
81
],
[
91,
83
],
[
106,
88
],
[
93,
91
],
[
93,
94
],
[
102,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
]
] | [
"n,m = map(int,input().split())\ncanred = set()\ncanred.add(1)\nballs = [1 for i in range(n)]\nfor i in range(m):\n x,y = map(int,input().split())\n if x in canred:\n canred.add(y)\n balls[x-1]-=1\n balls[y-1] += 1\n if balls[x-1] == 0:\n canred.discard(x)\n\n\nprint(len(canred))",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"canred = set()",
"canred",
"set()",
"set",
"canred.add(1)",
"canred.add",
"canred",
"add",
"1",
"1 for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"1",
"balls = [1 for i in range(n)]",
"balls",
"[1 for i in range(n)]",
"for i in range(m):\n x,y = map(int,input().split())\n if x in canred:\n canred.add(y)\n balls[x-1]-=1\n balls[y-1] += 1\n if balls[x-1] == 0:\n canred.discard(x)",
"i",
"range(m)",
"range",
"m",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if x in canred:\n canred.add(y)\n ",
"x in canred",
"x",
"canred",
"canred.add(y)",
"canred.add",
"canred",
"add",
"y",
"balls[x-1]-=1",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"1",
"balls[y-1] += 1",
"balls[y-1]",
"balls",
"y-1",
"y",
"1",
"1",
"if balls[x-1] == 0:\n canred.discard(x)",
"balls[x-1] == 0",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"0",
"canred.discard(x)",
"canred.discard",
"canred",
"discard",
"x",
"print(len(canred))",
"print",
"len(canred)",
"len",
"canred",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"balls = [1 for i in range(n)]",
"[1 for i in range(n)]",
"balls",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"canred = set()",
"set()",
"canred"
] | n,m = map(int,input().split())
canred = set()
canred.add(1)
balls = [1 for i in range(n)]
for i in range(m):
x,y = map(int,input().split())
if x in canred:
canred.add(y)
balls[x-1]-=1
balls[y-1] += 1
if balls[x-1] == 0:
canred.discard(x)
print(len(canred)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
116,
2
],
[
116,
11
],
[
15,
14
],
[
117,
17
],
[
107,
21
],
[
26,
25
],
[
117,
28
],
[
113,
32
],
[
38,
35
],
[
114,
36
],
[
41,
40
],
[
105,
43
],
[
122,
45
],
[
122,
54
],
[
101,
56
],
[
110,
59
],
[
79,
63
],
[
114,
64
],
[
102,
65
],
[
123,
65
],
[
71,
68
],
[
114,
69
],
[
111,
70
],
[
120,
70
],
[
84,
74
],
[
108,
75
],
[
102,
76
],
[
123,
76
],
[
82,
79
],
[
114,
80
],
[
102,
81
],
[
123,
81
],
[
87,
84
],
[
108,
85
],
[
102,
86
],
[
123,
86
],
[
92,
89
],
[
108,
90
],
[
111,
91
],
[
120,
91
],
[
114,
97
],
[
101,
102
],
[
116,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
122,
120
],
[
122,
123
]
] | [
"n,m = map(int,input().split())\nkosu = [1 for _ in range(n)]\naka = [0 for _ in range(n)]\naka[0] += 1\nfor i in range(m):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n if aka[a]==1:\n #論理和\n aka[b] |= 1\n if kosu[a]<2:\n aka[a] -=1\n kosu[a] -=1\n kosu[b] += 1\n # print(\"kosu\",kosu)\n #print(\"aka\",aka)\nprint(aka.count(1))",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"1 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"1",
"kosu = [1 for _ in range(n)]",
"kosu",
"[1 for _ in range(n)]",
"0 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"0",
"aka = [0 for _ in range(n)]",
"aka",
"[0 for _ in range(n)]",
"aka[0] += 1",
"aka[0]",
"aka",
"0",
"1",
"for i in range(m):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n if aka[a]==1:\n #論理和\n aka[b] |= 1\n if kosu[a]<2:\n aka[a] -=1\n kosu[a] -=1\n kosu[b] += 1\n # print(\"kosu\",kosu)\n #print(\"aka\",aka)",
"i",
"range(m)",
"range",
"m",
"a,b = map(int,input().split())",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"a -= 1",
"a",
"1",
"b -= 1",
"b",
"1",
"if aka[a]==1:\n #論理和\n aka[b] |= 1\n if kosu[a]<2:\n aka[a] -=1\n ",
"aka[a]==1",
"aka[a]",
"aka",
"a",
"1",
"aka[b] |= 1",
"aka[b]",
"aka",
"b",
"1",
"if kosu[a]<2:\n aka[a] -=1\n ",
"kosu[a]<2",
"kosu[a]",
"kosu",
"a",
"2",
"aka[a] -=1",
"aka[a]",
"aka",
"a",
"1",
"kosu[a] -=1",
"kosu[a]",
"kosu",
"a",
"1",
"kosu[b] += 1",
"kosu[b]",
"kosu",
"b",
"1",
"print(aka.count(1))",
"print",
"aka.count(1)",
"aka.count",
"aka",
"count",
"1",
"a -= 1",
"1",
"a",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"kosu = [1 for _ in range(n)]",
"[1 for _ in range(n)]",
"kosu",
"b -= 1",
"1",
"b",
"aka = [0 for _ in range(n)]",
"[0 for _ in range(n)]",
"aka",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"b = map(int,input().split())",
"map(int,input().split())",
"b",
"a,b = map(int,input().split())",
"map(int,input().split())",
"a"
] | n,m = map(int,input().split())
kosu = [1 for _ in range(n)]
aka = [0 for _ in range(n)]
aka[0] += 1
for i in range(m):
a,b = map(int,input().split())
a -= 1
b -= 1
if aka[a]==1:
#論理和
aka[b] |= 1
if kosu[a]<2:
aka[a] -=1
kosu[a] -=1
kosu[b] += 1
# print("kosu",kosu)
#print("aka",aka)
print(aka.count(1)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
17,
0,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
17,
0,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
17,
0,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
17,
14,
2,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
17,
0,
18,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
4,
13,
13,
10,
18,
13,
10,
39,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
175,
2
],
[
175,
12
],
[
163,
14
],
[
18,
17
],
[
176,
20
],
[
164,
23
],
[
39,
38
],
[
173,
41
],
[
166,
47
],
[
55,
50
],
[
167,
52
],
[
58,
57
],
[
176,
60
],
[
167,
65
],
[
164,
69
],
[
57,
70
],
[
87,
76
],
[
167,
78
],
[
164,
82
],
[
57,
83
],
[
100,
89
],
[
167,
91
],
[
164,
95
],
[
57,
96
],
[
113,
102
],
[
167,
104
],
[
164,
108
],
[
57,
109
],
[
167,
118
],
[
164,
122
],
[
57,
123
],
[
140,
129
],
[
167,
131
],
[
164,
135
],
[
57,
136
],
[
169,
142
],
[
146,
145
],
[
173,
148
],
[
160,
150
],
[
167,
153
],
[
145,
154
],
[
161,
158
],
[
170,
158
],
[
160,
161
],
[
163,
164
],
[
166,
167
],
[
169,
170
],
[
175,
173
],
[
175,
176
]
] | [
"boxnum, sousanum = map(int, input().split(\" \"))\nsousa = []\nfor i in range(sousanum):\n sousa.append(list(map(int, input().split(\" \"))))\n\n#aka[0][0] ...[ボール個数][赤フラグ]\nball = [[1, 0] for i in range(boxnum)]\nball[0][1] = 1\nfor i in range(sousanum):\n if ball[sousa[i][0] - 1][1] == 1:#赤色あり\n ball[sousa[i][1] - 1][1] = 1\n \n ball[sousa[i][0] - 1][0] -= 1\n ball[sousa[i][1] - 1][0] += 1\n \n if ball[sousa[i][0] - 1][0] == 0:#ボール尽きた\n ball[sousa[i][0] - 1][1] = 0\ntotal = 0\nfor i in range(boxnum):\n total += ball[i][1]\nprint(total)",
"boxnum, sousanum = map(int, input().split(\" \"))",
"boxnum",
"map(int, input().split(\" \"))",
"map",
"int",
"input().split(\" \")",
"().split",
"()",
"input",
"split",
"\" \"",
"sousanum",
"sousa = []",
"sousa",
"[]",
"for i in range(sousanum):\n sousa.append(list(map(int, input().split(\" \"))))\n\n#aka[0][0] ...[ボール個数][赤フラグ]",
"i",
"range(sousanum)",
"range",
"sousanum",
"sousa.append(list(map(int, input().split(\" \"))))",
"sousa.append",
"sousa",
"append",
"list(map(int, input().split(\" \")))",
"list",
"map(int, input().split(\" \"))",
"map",
"int",
"input().split(\" \")",
"().split",
"()",
"input",
"split",
"\" \"",
"[1, 0] for i in range(boxnum)",
"for i in range(boxnum)",
"i",
"range(boxnum)",
"range",
"boxnum",
"for i in range(boxnum)",
"[1, 0]",
"1",
"0",
"ball = [[1, 0] for i in range(boxnum)]",
"ball",
"[[1, 0] for i in range(boxnum)]",
"ball[0][1] = 1",
"ball[0][1]",
"[0]",
"ball",
"0",
"1",
"1",
"for i in range(sousanum):\n if ball[sousa[i][0] - 1][1] == 1:#赤色あり\n ball[sousa[i][1] - 1][1] = 1\n \n ball[sousa[i][0] - 1][0] -= 1\n ball[sousa[i][1] - 1][0] += 1\n \n if ball[sousa[i][0] - 1][0] == 0:#ボール尽きた\n ball[sousa[i][0] - 1][1] = 0",
"i",
"range(sousanum)",
"range",
"sousanum",
"if ball[sousa[i][0] - 1][1] == 1:#赤色あり\n ball[sousa[i][1] - 1][1] = 1\n \n ",
"ball[sousa[i][0] - 1][1] == 1",
"ball[sousa[i][0] - 1][1]",
"[sousa[i][0] - 1]",
"ball",
"sousa[i][0] - 1",
"sousa[i][0]",
"[i]",
"sousa",
"i",
"0",
"1",
"1",
"1",
"ball[sousa[i][1] - 1][1] = 1",
"ball[sousa[i][1] - 1][1]",
"[sousa[i][1] - 1]",
"ball",
"sousa[i][1] - 1",
"sousa[i][1]",
"[i]",
"sousa",
"i",
"1",
"1",
"1",
"1",
"ball[sousa[i][0] - 1][0] -= 1",
"ball[sousa[i][0] - 1][0]",
"[sousa[i][0] - 1]",
"ball",
"sousa[i][0] - 1",
"sousa[i][0]",
"[i]",
"sousa",
"i",
"0",
"1",
"0",
"1",
"ball[sousa[i][1] - 1][0] += 1",
"ball[sousa[i][1] - 1][0]",
"[sousa[i][1] - 1]",
"ball",
"sousa[i][1] - 1",
"sousa[i][1]",
"[i]",
"sousa",
"i",
"1",
"1",
"0",
"1",
"if ball[sousa[i][0] - 1][0] == 0:#ボール尽きた\n ball[sousa[i][0] - 1][1] = 0",
"ball[sousa[i][0] - 1][0] == 0",
"ball[sousa[i][0] - 1][0]",
"[sousa[i][0] - 1]",
"ball",
"sousa[i][0] - 1",
"sousa[i][0]",
"[i]",
"sousa",
"i",
"0",
"1",
"0",
"0",
"ball[sousa[i][0] - 1][1] = 0",
"ball[sousa[i][0] - 1][1]",
"[sousa[i][0] - 1]",
"ball",
"sousa[i][0] - 1",
"sousa[i][0]",
"[i]",
"sousa",
"i",
"0",
"1",
"1",
"0",
"total = 0",
"total",
"0",
"for i in range(boxnum):\n total += ball[i][1]",
"i",
"range(boxnum)",
"range",
"boxnum",
"total += ball[i][1]",
"total",
"ball[i][1]",
"[i]",
"ball",
"i",
"1",
"print(total)",
"print",
"total",
"total += ball[i][1]",
"ball[i][1]",
"total",
"sousa = []",
"[]",
"sousa",
"ball = [[1, 0] for i in range(boxnum)]",
"[[1, 0] for i in range(boxnum)]",
"ball",
"total = 0",
"0",
"total",
"boxnum, sousanum = map(int, input().split(\" \"))",
"map(int, input().split(\" \"))",
"boxnum",
"sousanum = map(int, input().split(\" \"))",
"map(int, input().split(\" \"))",
"sousanum"
] | boxnum, sousanum = map(int, input().split(" "))
sousa = []
for i in range(sousanum):
sousa.append(list(map(int, input().split(" "))))
#aka[0][0] ...[ボール個数][赤フラグ]
ball = [[1, 0] for i in range(boxnum)]
ball[0][1] = 1
for i in range(sousanum):
if ball[sousa[i][0] - 1][1] == 1:#赤色あり
ball[sousa[i][1] - 1][1] = 1
ball[sousa[i][0] - 1][0] -= 1
ball[sousa[i][1] - 1][0] += 1
if ball[sousa[i][0] - 1][0] == 0:#ボール尽きた
ball[sousa[i][0] - 1][1] = 0
total = 0
for i in range(boxnum):
total += ball[i][1]
print(total) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
28,
13,
13,
4,
18,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
126,
2
],
[
126,
11
],
[
117,
13
],
[
124,
17
],
[
114,
19
],
[
23,
22
],
[
124,
27
],
[
33,
30
],
[
115,
31
],
[
22,
32
],
[
38,
35
],
[
115,
36
],
[
41,
40
],
[
127,
43
],
[
129,
45
],
[
129,
54
],
[
61,
56
],
[
118,
57
],
[
130,
59
],
[
77,
64
],
[
115,
65
],
[
130,
66
],
[
118,
71
],
[
130,
73
],
[
80,
77
],
[
115,
78
],
[
130,
79
],
[
85,
82
],
[
115,
83
],
[
121,
84
],
[
92,
87
],
[
118,
88
],
[
121,
90
],
[
132,
94
],
[
115,
101
],
[
135,
108
],
[
136,
112
],
[
133,
112
],
[
114,
115
],
[
117,
118
],
[
129,
121
],
[
126,
124
],
[
126,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
]
] | [
"n,m = map(int,input().split())\n\nball = [1]*n\nd={}\nfor i in range(1,n+1):\n d[i]=0\nd[1]=1\n\nfor _ in range(m):\n x,y = map(int,input().split())\n\n ball[x-1]-=1\n if d[x]==1:\n if ball[x-1]==0:\n d[x]=0\n d[y]=1\n ball[y-1]+=1\n\ncnt=0\nfor _ ,v in d.items():\n if v==1:\n cnt+=1\n\n\nprint(cnt)",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ball = [1]*n",
"ball",
"[1]*n",
"[1]",
"1",
"n",
"d={}",
"d",
"{}",
"for i in range(1,n+1):\n d[i]=0",
"i",
"range(1,n+1)",
"range",
"1",
"n+1",
"n",
"1",
"d[i]=0",
"d[i]",
"d",
"i",
"0",
"d[1]=1",
"d[1]",
"d",
"1",
"1",
"for _ in range(m):\n x,y = map(int,input().split())\n\n ball[x-1]-=1\n if d[x]==1:\n if ball[x-1]==0:\n d[x]=0\n d[y]=1\n ball[y-1]+=1",
"_",
"range(m)",
"range",
"m",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"ball[x-1]-=1",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"1",
"if d[x]==1:\n if ball[x-1]==0:\n d[x]=0\n d[y]=1\n ",
"d[x]==1",
"d[x]",
"d",
"x",
"1",
"if ball[x-1]==0:\n d[x]=0\n ",
"ball[x-1]==0",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"0",
"d[x]=0",
"d[x]",
"d",
"x",
"0",
"d[y]=1",
"d[y]",
"d",
"y",
"1",
"ball[y-1]+=1",
"ball[y-1]",
"ball",
"y-1",
"y",
"1",
"1",
"cnt=0",
"cnt",
"0",
"for _ ,v in d.items():\n if v==1:\n cnt+=1",
"_",
"v",
"d.items()",
"d.items",
"d",
"items",
"if v==1:\n cnt+=1",
"v==1",
"v",
"1",
"cnt+=1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"d={}",
"{}",
"d",
"ball = [1]*n",
"[1]*n",
"ball",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x",
"cnt=0",
"0",
"cnt",
"cnt+=1",
"1",
"cnt"
] | n,m = map(int,input().split())
ball = [1]*n
d={}
for i in range(1,n+1):
d[i]=0
d[1]=1
for _ in range(m):
x,y = map(int,input().split())
ball[x-1]-=1
if d[x]==1:
if ball[x-1]==0:
d[x]=0
d[y]=1
ball[y-1]+=1
cnt=0
for _ ,v in d.items():
if v==1:
cnt+=1
print(cnt) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
4,
13,
39,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
2,
13,
17,
13,
4,
18,
13,
13,
2,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
4,
18,
13,
13,
2,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
100,
2
],
[
100,
11
],
[
91,
13
],
[
101,
17
],
[
94,
19
],
[
26,
25
],
[
98,
28
],
[
103,
30
],
[
103,
39
],
[
46,
41
],
[
92,
42
],
[
104,
44
],
[
53,
48
],
[
92,
49
],
[
89,
51
],
[
104,
57
],
[
95,
59
],
[
95,
62
],
[
89,
65
],
[
92,
70
],
[
104,
72
],
[
95,
77
],
[
104,
80
],
[
95,
86
],
[
103,
89
],
[
91,
92
],
[
94,
95
],
[
100,
98
],
[
100,
101
],
[
103,
104
]
] | [
"n, m = map(int, input().split())\nball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。\nred = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。\nfor _ in range(m):\n x, y = map(int, input().split())\n ball[x-1] -= 1 # x-1番目の箱のボールを1つ減らす\n ball[y-1] += 1 # y-1番目の箱のボールを1つ増やす\n if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。\n \tred.add(y-1)\n if ball[x-1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので\n red.discard(x-1) # 可能性のある箱から削除しとく\nprint(len(red)) # 可能性のある箱の個数を出力",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ball = [1] * n",
"ball",
"[1] * n",
"[1]",
"1",
"n",
"red = set([0])",
"red",
"set([0])",
"set",
"[0]",
"0",
"for _ in range(m):\n x, y = map(int, input().split())\n ball[x-1] -= 1 # x-1番目の箱のボールを1つ減らす\n ball[y-1] += 1 # y-1番目の箱のボールを1つ増やす\n if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。\n \tred.add(y-1)\n if ball[x-1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので\n red.discard(x-1) # 可能性のある箱から削除しとく",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"ball[x-1] -= 1",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"1",
"ball[y-1] += 1",
"ball[y-1]",
"ball",
"y-1",
"y",
"1",
"1",
"if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。\n \tred.add(y-1)\n ",
"x-1 in red",
"x-1",
"x",
"1",
"red",
"red.add(y-1)",
"red.add",
"red",
"add",
"y-1",
"y",
"1",
"if ball[x-1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので\n red.discard(x-1) # 可能性のある箱から削除しとく",
"ball[x-1] == 0",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"0",
"red.discard(x-1)",
"red.discard",
"red",
"discard",
"x-1",
"x",
"1",
"print(len(red))",
"print",
"len(red)",
"len",
"red",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"ball = [1] * n",
"[1] * n",
"ball",
"red = set([0])",
"set([0])",
"red",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x"
] | n, m = map(int, input().split())
ball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。
red = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。
for _ in range(m):
x, y = map(int, input().split())
ball[x-1] -= 1 # x-1番目の箱のボールを1つ減らす
ball[y-1] += 1 # y-1番目の箱のボールを1つ増やす
if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。
red.add(y-1)
if ball[x-1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので
red.discard(x-1) # 可能性のある箱から削除しとく
print(len(red)) # 可能性のある箱の個数を出力 |
[
7,
15,
12,
13,
0,
13,
18,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
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,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
11,
10
],
[
5,
17
],
[
11,
19
],
[
22,
21
],
[
19,
25
],
[
28,
27
],
[
19,
31
],
[
34,
33
],
[
19,
36
],
[
41,
38
],
[
21,
39
],
[
33,
40
],
[
5,
47
],
[
41,
49
],
[
27,
50
],
[
33,
51
],
[
54,
53
],
[
10,
58
],
[
62,
61
],
[
10,
66
],
[
72,
69
],
[
61,
70
],
[
75,
74
],
[
19,
77
],
[
80,
79
],
[
38,
80
],
[
21,
81
],
[
74,
82
],
[
85,
84
],
[
49,
85
],
[
27,
86
],
[
74,
87
],
[
101,
91
],
[
61,
92
],
[
79,
93
],
[
122,
96
],
[
53,
97
],
[
79,
98
],
[
104,
101
],
[
61,
102
],
[
79,
103
],
[
109,
106
],
[
61,
107
],
[
84,
108
],
[
101,
112
],
[
61,
113
],
[
79,
114
],
[
120,
117
],
[
61,
118
],
[
84,
119
],
[
125,
122
],
[
53,
123
],
[
79,
124
],
[
130,
127
],
[
53,
128
],
[
84,
129
],
[
133,
132
],
[
136,
135
],
[
10,
139
],
[
61,
144
],
[
135,
145
],
[
149,
148
],
[
148,
152
],
[
132,
152
],
[
161,
158
]
] | [
"from sys import stdin\ndef main():\n #入力\n readline=stdin.readline\n N,M=map(int,readline().split())\n x=[0]*M\n y=[0]*M\n for i in range(M):\n x[i],y[i]=map(int,readline().split())\n\n box=[1]*(N+1)\n flags=[False]*(N+1)\n flags[1]=True\n\n for i in range(M):\n out=x[i]\n inn=y[i]\n if flags[out]==True and box[out]==1:\n flags[out]=False\n flags[inn]=True\n elif flags[out]==True:\n flags[inn]=True\n box[out]-=1\n box[inn]+=1\n\n res=0\n for i in range(N+1):\n if flags[i]==True:\n res+=1\n print(res)\n \nif __name__==\"__main__\":\n main()",
"from sys import stdin",
"def main():\n #入力\n readline=stdin.readline\n N,M=map(int,readline().split())\n x=[0]*M\n y=[0]*M\n for i in range(M):\n x[i],y[i]=map(int,readline().split())\n\n box=[1]*(N+1)\n flags=[False]*(N+1)\n flags[1]=True\n\n for i in range(M):\n out=x[i]\n inn=y[i]\n if flags[out]==True and box[out]==1:\n flags[out]=False\n flags[inn]=True\n elif flags[out]==True:\n flags[inn]=True\n box[out]-=1\n box[inn]+=1\n\n res=0\n for i in range(N+1):\n if flags[i]==True:\n res+=1\n print(res)\n ",
"main",
"readline=stdin.readline",
"readline",
"stdin.readline",
"stdin",
"readline",
"N,M=map(int,readline().split())",
"N",
"map(int,readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"M",
"x=[0]*M",
"x",
"[0]*M",
"[0]",
"0",
"M",
"y=[0]*M",
"y",
"[0]*M",
"[0]",
"0",
"M",
"for i in range(M):\n x[i],y[i]=map(int,readline().split())\n\n ",
"i",
"range(M)",
"range",
"M",
"x[i],y[i]=map(int,readline().split())",
"x[i]",
"x",
"i",
"map(int,readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"y[i]",
"y",
"i",
"box=[1]*(N+1)",
"box",
"[1]*(N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"flags=[False]*(N+1)",
"flags",
"[False]*(N+1)",
"[False]",
"False",
"N+1",
"N",
"1",
"flags[1]=True",
"flags[1]",
"flags",
"1",
"True",
"for i in range(M):\n out=x[i]\n inn=y[i]\n if flags[out]==True and box[out]==1:\n flags[out]=False\n flags[inn]=True\n elif flags[out]==True:\n flags[inn]=True\n box[out]-=1\n box[inn]+=1\n\n ",
"i",
"range(M)",
"range",
"M",
"out=x[i]",
"out",
"x[i]",
"x",
"i",
"inn=y[i]",
"inn",
"y[i]",
"y",
"i",
"if flags[out]==True and box[out]==1:\n flags[out]=False\n flags[inn]=True\n elif flags[out]==True:\n flags[inn]=True\n ",
"flags[out]==True and box[out]==1",
"flags[out]==True",
"flags[out]",
"flags",
"out",
"True",
"box[out]==1",
"box[out]",
"box",
"out",
"1",
"flags[out]=False",
"flags[out]",
"flags",
"out",
"False",
"flags[inn]=True",
"flags[inn]",
"flags",
"inn",
"True",
"elif flags[out]==True:\n flags[inn]=True\n ",
"flags[out]==True",
"flags[out]",
"flags",
"out",
"True",
"flags[inn]=True",
"flags[inn]",
"flags",
"inn",
"True",
"box[out]-=1",
"box[out]",
"box",
"out",
"1",
"box[inn]+=1",
"box[inn]",
"box",
"inn",
"1",
"res=0",
"res",
"0",
"for i in range(N+1):\n if flags[i]==True:\n res+=1\n ",
"i",
"range(N+1)",
"range",
"N+1",
"N",
"1",
"if flags[i]==True:\n res+=1\n ",
"flags[i]==True",
"flags[i]",
"flags",
"i",
"True",
"res+=1",
"res",
"1",
"print(res)",
"print",
"res",
"if __name__==\"__main__\":\n main()",
"__name__==\"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n #入力\n readline=stdin.readline\n N,M=map(int,readline().split())\n x=[0]*M\n y=[0]*M\n for i in range(M):\n x[i],y[i]=map(int,readline().split())\n\n box=[1]*(N+1)\n flags=[False]*(N+1)\n flags[1]=True\n\n for i in range(M):\n out=x[i]\n inn=y[i]\n if flags[out]==True and box[out]==1:\n flags[out]=False\n flags[inn]=True\n elif flags[out]==True:\n flags[inn]=True\n box[out]-=1\n box[inn]+=1\n\n res=0\n for i in range(N+1):\n if flags[i]==True:\n res+=1\n print(res)\n ",
"def main():\n #入力\n readline=stdin.readline\n N,M=map(int,readline().split())\n x=[0]*M\n y=[0]*M\n for i in range(M):\n x[i],y[i]=map(int,readline().split())\n\n box=[1]*(N+1)\n flags=[False]*(N+1)\n flags[1]=True\n\n for i in range(M):\n out=x[i]\n inn=y[i]\n if flags[out]==True and box[out]==1:\n flags[out]=False\n flags[inn]=True\n elif flags[out]==True:\n flags[inn]=True\n box[out]-=1\n box[inn]+=1\n\n res=0\n for i in range(N+1):\n if flags[i]==True:\n res+=1\n print(res)\n ",
"main"
] | from sys import stdin
def main():
#入力
readline=stdin.readline
N,M=map(int,readline().split())
x=[0]*M
y=[0]*M
for i in range(M):
x[i],y[i]=map(int,readline().split())
box=[1]*(N+1)
flags=[False]*(N+1)
flags[1]=True
for i in range(M):
out=x[i]
inn=y[i]
if flags[out]==True and box[out]==1:
flags[out]=False
flags[inn]=True
elif flags[out]==True:
flags[inn]=True
box[out]-=1
box[inn]+=1
res=0
for i in range(N+1):
if flags[i]==True:
res+=1
print(res)
if __name__=="__main__":
main() |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
112,
2
],
[
112,
11
],
[
106,
13
],
[
104,
17
],
[
100,
19
],
[
104,
27
],
[
31,
30
],
[
113,
33
],
[
109,
35
],
[
109,
44
],
[
51,
46
],
[
107,
47
],
[
98,
49
],
[
58,
53
],
[
107,
54
],
[
110,
56
],
[
101,
62
],
[
98,
64
],
[
73,
68
],
[
101,
69
],
[
110,
71
],
[
107,
77
],
[
98,
79
],
[
88,
83
],
[
101,
84
],
[
98,
86
],
[
101,
93
],
[
109,
98
],
[
100,
101
],
[
112,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
]
] | [
"n,m=map(int,input().split())\ndata=[1]*n\nd=[1]+[0]*(n-1)\nfor i in range(m):\n x,y=map(int,input().split())\n data[x-1]-=1\n data[y-1]+=1\n if d[x-1]==1:\n d[y-1]=1\n if data[x-1]==0:\n d[x-1]=0\nprint(d.count(1))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"data=[1]*n",
"data",
"[1]*n",
"[1]",
"1",
"n",
"d=[1]+[0]*(n-1)",
"d",
"[1]+[0]*(n-1)",
"[1]",
"1",
"[0]*(n-1)",
"[0]",
"0",
"n-1",
"n",
"1",
"for i in range(m):\n x,y=map(int,input().split())\n data[x-1]-=1\n data[y-1]+=1\n if d[x-1]==1:\n d[y-1]=1\n if data[x-1]==0:\n d[x-1]=0",
"i",
"range(m)",
"range",
"m",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"data[x-1]-=1",
"data[x-1]",
"data",
"x-1",
"x",
"1",
"1",
"data[y-1]+=1",
"data[y-1]",
"data",
"y-1",
"y",
"1",
"1",
"if d[x-1]==1:\n d[y-1]=1\n ",
"d[x-1]==1",
"d[x-1]",
"d",
"x-1",
"x",
"1",
"1",
"d[y-1]=1",
"d[y-1]",
"d",
"y-1",
"y",
"1",
"1",
"if data[x-1]==0:\n d[x-1]=0",
"data[x-1]==0",
"data[x-1]",
"data",
"x-1",
"x",
"1",
"0",
"d[x-1]=0",
"d[x-1]",
"d",
"x-1",
"x",
"1",
"0",
"print(d.count(1))",
"print",
"d.count(1)",
"d.count",
"d",
"count",
"1",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"d=[1]+[0]*(n-1)",
"[1]+[0]*(n-1)",
"d",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"data=[1]*n",
"[1]*n",
"data",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"m=map(int,input().split())",
"map(int,input().split())",
"m"
] | n,m=map(int,input().split())
data=[1]*n
d=[1]+[0]*(n-1)
for i in range(m):
x,y=map(int,input().split())
data[x-1]-=1
data[y-1]+=1
if d[x-1]==1:
d[y-1]=1
if data[x-1]==0:
d[x-1]=0
print(d.count(1)) |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
17,
2,
39,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
2,
2,
13,
17,
40,
13,
2,
18,
13,
17,
17,
0,
18,
13,
17,
17,
0,
13,
17,
14,
2,
2,
13,
17,
40,
13,
0,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
13,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] | [
[
168,
2
],
[
168,
13
],
[
144,
15
],
[
166,
20
],
[
147,
23
],
[
166,
32
],
[
156,
35
],
[
39,
38
],
[
169,
41
],
[
171,
43
],
[
171,
54
],
[
148,
57
],
[
151,
58
],
[
63,
60
],
[
148,
61
],
[
172,
62
],
[
151,
68
],
[
157,
71
],
[
160,
71
],
[
154,
71
],
[
145,
74
],
[
81,
78
],
[
148,
79
],
[
153,
83
],
[
172,
88
],
[
154,
91
],
[
157,
91
],
[
160,
91
],
[
159,
93
],
[
99,
96
],
[
145,
97
],
[
151,
98
],
[
104,
101
],
[
145,
102
],
[
172,
103
],
[
96,
107
],
[
145,
108
],
[
151,
109
],
[
115,
112
],
[
148,
113
],
[
151,
114
],
[
162,
117
],
[
121,
120
],
[
166,
125
],
[
148,
130
],
[
120,
131
],
[
145,
134
],
[
120,
135
],
[
174,
138
],
[
175,
142
],
[
163,
142
],
[
144,
145
],
[
147,
148
],
[
171,
151
],
[
153,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
],
[
168,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
]
] | [
"N, M = list(map(int, input().split()))\nC = [1] * (N + 1)\nB = [True, True] + [False] * (N - 1)\nflg = False\nfor _ in range(M):\n x, y = list(map(int, input().split()))\n if B[x]:\n B[y] = True\n if x == 1 and not flg and C[1] == 1:\n B[1] = False\n flg = True\n if y == 1 and not flg:\n flg = True\n C[x] -= 1\n C[y] += 1\n if C[x] == 0:\n B[x] = False\nres = 0\nfor i in range(1, N + 1):\n if B[i] and C[i] > 0:\n res += 1\nprint(res)",
"N, M = list(map(int, input().split()))",
"N",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"C = [1] * (N + 1)",
"C",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"B = [True, True] + [False] * (N - 1)",
"B",
"[True, True] + [False] * (N - 1)",
"[True, True]",
"True",
"True",
"[False] * (N - 1)",
"[False]",
"False",
"N - 1",
"N",
"1",
"flg = False",
"flg",
"False",
"for _ in range(M):\n x, y = list(map(int, input().split()))\n if B[x]:\n B[y] = True\n if x == 1 and not flg and C[1] == 1:\n B[1] = False\n flg = True\n if y == 1 and not flg:\n flg = True\n C[x] -= 1\n C[y] += 1\n if C[x] == 0:\n B[x] = False",
"_",
"range(M)",
"range",
"M",
"x, y = list(map(int, input().split()))",
"x",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"if B[x]:\n B[y] = True\n ",
"B[x]",
"B",
"x",
"B[y] = True",
"B[y]",
"B",
"y",
"True",
"if x == 1 and not flg and C[1] == 1:\n B[1] = False\n flg = True\n ",
"x == 1 and not flg and C[1] == 1",
"x == 1 and not flg",
"x == 1",
"x",
"1",
"not flg",
"flg",
"C[1] == 1",
"C[1]",
"C",
"1",
"1",
"B[1] = False",
"B[1]",
"B",
"1",
"False",
"flg = True",
"flg",
"True",
"if y == 1 and not flg:\n flg = True\n ",
"y == 1 and not flg",
"y == 1",
"y",
"1",
"not flg",
"flg",
"flg = True",
"flg",
"True",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"if C[x] == 0:\n B[x] = False",
"C[x] == 0",
"C[x]",
"C",
"x",
"0",
"B[x] = False",
"B[x]",
"B",
"x",
"False",
"res = 0",
"res",
"0",
"for i in range(1, N + 1):\n if B[i] and C[i] > 0:\n res += 1",
"i",
"range(1, N + 1)",
"range",
"1",
"N + 1",
"N",
"1",
"if B[i] and C[i] > 0:\n res += 1",
"B[i] and C[i] > 0",
"B[i]",
"B",
"i",
"C[i] > 0",
"C[i]",
"C",
"i",
"0",
"res += 1",
"res",
"1",
"print(res)",
"print",
"res",
"C = [1] * (N + 1)",
"[1] * (N + 1)",
"C",
"B = [True, True] + [False] * (N - 1)",
"[True, True] + [False] * (N - 1)",
"B",
"x, y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"x",
"flg = True",
"True",
"flg",
"flg = False",
"False",
"flg",
"flg = True",
"True",
"flg",
"res = 0",
"0",
"res",
"N, M = list(map(int, input().split()))",
"list(map(int, input().split()))",
"N",
"M = list(map(int, input().split()))",
"list(map(int, input().split()))",
"M",
"y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"y",
"res += 1",
"1",
"res"
] | N, M = list(map(int, input().split()))
C = [1] * (N + 1)
B = [True, True] + [False] * (N - 1)
flg = False
for _ in range(M):
x, y = list(map(int, input().split()))
if B[x]:
B[y] = True
if x == 1 and not flg and C[1] == 1:
B[1] = False
flg = True
if y == 1 and not flg:
flg = True
C[x] -= 1
C[y] += 1
if C[x] == 0:
B[x] = False
res = 0
for i in range(1, N + 1):
if B[i] and C[i] > 0:
res += 1
print(res)
|
[
7,
15,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
4,
13,
17,
2,
17,
17,
0,
13,
12,
4,
18,
18,
13,
13,
13,
2,
13,
17,
23,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
4,
13,
39,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
13,
17,
2,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
14,
2,
40,
18,
13,
13,
17,
2,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
12,
13,
10,
4,
13
] | [
[
158,
4
],
[
137,
26
],
[
149,
39
],
[
159,
46
],
[
149,
48
],
[
143,
50
],
[
150,
54
],
[
146,
56
],
[
63,
62
],
[
135,
65
],
[
161,
67
],
[
159,
74
],
[
161,
76
],
[
152,
78
],
[
155,
81
],
[
119,
86
],
[
144,
87
],
[
153,
88
],
[
162,
88
],
[
153,
91
],
[
162,
91
],
[
147,
92
],
[
147,
95
],
[
153,
97
],
[
162,
97
],
[
147,
100
],
[
156,
102
],
[
141,
102
],
[
119,
106
],
[
144,
107
],
[
153,
108
],
[
162,
108
],
[
153,
111
],
[
162,
111
],
[
147,
112
],
[
147,
115
],
[
156,
117
],
[
141,
117
],
[
122,
119
],
[
144,
120
],
[
153,
121
],
[
162,
121
],
[
127,
124
],
[
144,
125
],
[
156,
126
],
[
141,
126
],
[
147,
132
],
[
149,
135
],
[
137,
138
],
[
161,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
],
[
161,
162
]
] | [
"import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn,m = map(int, input().split())\nc = [1]*n\nr = set([0])\nfor i in range(m):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if c[x]==1 and x in r:\n r.remove(x)\n r.add(y)\n elif c[x]>=2 and x in r:\n r.add(y)\n c[x] -= 1\n c[y] += 1\nprint(len(r))",
"import sys",
"sys",
"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",
"sys.setrecursionlimit(max(1000, 10**9))",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"max(1000, 10**9)",
"max",
"1000",
"10**9",
"10",
"9",
"write = lambda x: sys.stdout.write(x+\"\\n\")",
"write",
"lambda x: sys.stdout.write(x+\"\\n\")",
"sys.stdout.write(x+\"\\n\")",
"sys.stdout.write",
"sys.stdout",
"sys",
"stdout",
"write",
"x+\"\\n\"",
"x",
"\"\\n\"",
"x",
"n,m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"c = [1]*n",
"c",
"[1]*n",
"[1]",
"1",
"n",
"r = set([0])",
"r",
"set([0])",
"set",
"[0]",
"0",
"for i in range(m):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if c[x]==1 and x in r:\n r.remove(x)\n r.add(y)\n elif c[x]>=2 and x in r:\n r.add(y)\n c[x] -= 1\n c[y] += 1",
"i",
"range(m)",
"range",
"m",
"x,y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if c[x]==1 and x in r:\n r.remove(x)\n r.add(y)\n elif c[x]>=2 and x in r:\n r.add(y)\n ",
"c[x]==1 and x in r",
"c[x]==1",
"c[x]",
"c",
"x",
"1",
"x in r",
"x",
"r",
"r.remove(x)",
"r.remove",
"r",
"remove",
"x",
"r.add(y)",
"r.add",
"r",
"add",
"y",
"elif c[x]>=2 and x in r:\n r.add(y)\n ",
"c[x]>=2 and x in r",
"c[x]>=2",
"c[x]",
"c",
"x",
"2",
"x in r",
"x",
"r",
"r.add(y)",
"r.add",
"r",
"add",
"y",
"c[x] -= 1",
"c[x]",
"c",
"x",
"1",
"c[y] += 1",
"c[y]",
"c",
"y",
"1",
"print(len(r))",
"print",
"len(r)",
"len",
"r",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"write = lambda x: sys.stdout.write(x+\"\\n\")",
"lambda x: sys.stdout.write(x+\"\\n\")",
"write",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"c = [1]*n",
"[1]*n",
"c",
"r = set([0])",
"set([0])",
"r",
"n,m = map(int, input().split())",
"map(int, input().split())",
"n",
"x -= 1",
"1",
"x",
"y -= 1",
"1",
"y",
"input = lambda : sys.stdin.readline().rstrip()",
"lambda : sys.stdin.readline().rstrip()",
"input",
"x,y = map(int, input().split())",
"map(int, input().split())",
"x"
] | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n,m = map(int, input().split())
c = [1]*n
r = set([0])
for i in range(m):
x,y = map(int, input().split())
x -= 1
y -= 1
if c[x]==1 and x in r:
r.remove(x)
r.add(y)
elif c[x]>=2 and x in r:
r.add(y)
c[x] -= 1
c[y] += 1
print(len(r)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
12,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
23,
13,
23,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
13,
13,
13,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] | [
[
125,
2
],
[
125,
11
],
[
113,
13
],
[
108,
17
],
[
110,
19
],
[
108,
23
],
[
28,
25
],
[
111,
26
],
[
111,
34
],
[
76,
36
],
[
45,
40
],
[
111,
41
],
[
78,
43
],
[
52,
47
],
[
114,
48
],
[
76,
50
],
[
59,
54
],
[
114,
55
],
[
78,
57
],
[
114,
63
],
[
76,
65
],
[
74,
69
],
[
111,
70
],
[
76,
72
],
[
76,
76
],
[
78,
78
],
[
81,
80
],
[
126,
83
],
[
122,
85
],
[
122,
94
],
[
120,
96
],
[
123,
97
],
[
117,
98
],
[
111,
103
],
[
125,
108
],
[
110,
111
],
[
113,
114
],
[
122,
117
],
[
122,
123
],
[
125,
126
]
] | [
"n,m=map(int,input().split())\n\np=[1]*n\nc=['w']*n\nc[0]='r'\n\n\ndef ope(x,y):\n if c[x-1]=='r':\n c[y-1]='r'\n p[x-1] -= 1\n p[y-1] += 1\n if p[x-1]==0:\n c[x-1]='w'\n\nfor i in range(m):\n x,y=map(int,input().split())\n ope(x,y)\n\n\nprint(c.count('r'))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"p=[1]*n",
"p",
"[1]*n",
"[1]",
"1",
"n",
"c=['w']*n",
"c",
"['w']*n",
"['w']",
"'w'",
"n",
"c[0]='r'",
"c[0]",
"c",
"0",
"'r'",
"def ope(x,y):\n if c[x-1]=='r':\n c[y-1]='r'\n p[x-1] -= 1\n p[y-1] += 1\n if p[x-1]==0:\n c[x-1]='w'",
"ope",
"if c[x-1]=='r':\n c[y-1]='r'\n ",
"c[x-1]=='r'",
"c[x-1]",
"c",
"x-1",
"x",
"1",
"'r'",
"c[y-1]='r'",
"c[y-1]",
"c",
"y-1",
"y",
"1",
"'r'",
"p[x-1] -= 1",
"p[x-1]",
"p",
"x-1",
"x",
"1",
"1",
"p[y-1] += 1",
"p[y-1]",
"p",
"y-1",
"y",
"1",
"1",
"if p[x-1]==0:\n c[x-1]='w'",
"p[x-1]==0",
"p[x-1]",
"p",
"x-1",
"x",
"1",
"0",
"c[x-1]='w'",
"c[x-1]",
"c",
"x-1",
"x",
"1",
"'w'",
"x",
"x",
"y",
"y",
"for i in range(m):\n x,y=map(int,input().split())\n ope(x,y)",
"i",
"range(m)",
"range",
"m",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"ope(x,y)",
"ope",
"x",
"y",
"print(c.count('r'))",
"print",
"c.count('r')",
"c.count",
"c",
"count",
"'r'",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"c=['w']*n",
"['w']*n",
"c",
"p=[1]*n",
"[1]*n",
"p",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"def ope(x,y):\n if c[x-1]=='r':\n c[y-1]='r'\n p[x-1] -= 1\n p[y-1] += 1\n if p[x-1]==0:\n c[x-1]='w'",
"def ope(x,y):\n if c[x-1]=='r':\n c[y-1]='r'\n p[x-1] -= 1\n p[y-1] += 1\n if p[x-1]==0:\n c[x-1]='w'",
"ope",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"m=map(int,input().split())",
"map(int,input().split())",
"m"
] | n,m=map(int,input().split())
p=[1]*n
c=['w']*n
c[0]='r'
def ope(x,y):
if c[x-1]=='r':
c[y-1]='r'
p[x-1] -= 1
p[y-1] += 1
if p[x-1]==0:
c[x-1]='w'
for i in range(m):
x,y=map(int,input().split())
ope(x,y)
print(c.count('r'))
|
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
18,
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
] | [
[
108,
4
],
[
30,
29
],
[
130,
31
],
[
30,
32
],
[
35,
34
],
[
29,
39
],
[
43,
42
],
[
29,
47
],
[
53,
50
],
[
42,
51
],
[
56,
55
],
[
32,
58
],
[
61,
60
],
[
130,
62
],
[
61,
63
],
[
68,
65
],
[
34,
66
],
[
60,
67
],
[
73,
70
],
[
34,
71
],
[
63,
72
],
[
92,
76
],
[
42,
77
],
[
60,
78
],
[
84,
81
],
[
42,
82
],
[
63,
83
],
[
65,
87
],
[
34,
88
],
[
60,
89
],
[
95,
92
],
[
42,
93
],
[
60,
94
],
[
42,
100
],
[
115,
106
],
[
108,
109
]
] | [
"import sys\n\ninput=sys.stdin.buffer.readline\n\n\n#sys.setrecursionlimit(10**9)\n#from functools import lru_cache\n\ndef RD(): return sys.stdin.read()\n\n\ndef II(): return int(input())\n\n\ndef MI(): return map(int,input().split())\n\n\ndef MF(): return map(float,input().split())\n\n\ndef LI(): return list(map(int,input().split()))\n\n\ndef LF(): return list(map(float,input().split()))\n\n\ndef TI(): return tuple(map(int,input().split()))\n\n\n# rstrip().decode('utf-8')\n\n\ndef main():\n\tn,m=MI()\n\t\n\tA=[1]*(n+1)\n\tB=[0]*(n+1)\n\tB[1]=1\n\t\n\tfor _ in range(m):\n\t\tx,y=MI()\n\t\tA[x]-=1\n\t\tA[y]+=1\n\t\t\n\t\tif B[x]==1:\n\t\t\tB[y]=1\n\t\tif A[x]==0:\n\t\t\tB[x]=0\n\n\tprint(sum(B))\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\nif __name__==\"__main__\":\n\tmain()",
"import sys",
"sys",
"input=sys.stdin.buffer.readline",
"input",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"def RD(): return sys.stdin.read()",
"RD",
"def II(): return int(input())",
"II",
"def MI(): return map(int,input().split())",
"MI",
"def MF(): return map(float,input().split())",
"MF",
"def LI(): return list(map(int,input().split()))",
"LI",
"def LF(): return list(map(float,input().split()))",
"LF",
"def TI(): return tuple(map(int,input().split()))\n\n\n# rstrip().decode('utf-8')",
"TI",
"def main():\n\tn,m=MI()\n\t\n\tA=[1]*(n+1)\n\tB=[0]*(n+1)\n\tB[1]=1\n\t\n\tfor _ in range(m):\n\t\tx,y=MI()\n\t\tA[x]-=1\n\t\tA[y]+=1\n\t\t\n\t\tif B[x]==1:\n\t\t\tB[y]=1\n\t\tif A[x]==0:\n\t\t\tB[x]=0\n\n\tprint(sum(B))\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\n\n\n\n\n\n\t\n\t\n\t",
"main",
"n,m=MI()",
"n",
"MI()",
"MI",
"m",
"A=[1]*(n+1)",
"A",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"B=[0]*(n+1)",
"B",
"[0]*(n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"B[1]=1",
"B[1]",
"B",
"1",
"1",
"for _ in range(m):\n\t\tx,y=MI()\n\t\tA[x]-=1\n\t\tA[y]+=1\n\t\t\n\t\tif B[x]==1:\n\t\t\tB[y]=1\n\t\tif A[x]==0:\n\t\t\tB[x]=0\n\n\t",
"_",
"range(m)",
"range",
"m",
"x,y=MI()",
"x",
"MI()",
"MI",
"y",
"A[x]-=1",
"A[x]",
"A",
"x",
"1",
"A[y]+=1",
"A[y]",
"A",
"y",
"1",
"if B[x]==1:\n\t\t\tB[y]=1\n\t\t",
"B[x]==1",
"B[x]",
"B",
"x",
"1",
"B[y]=1",
"B[y]",
"B",
"y",
"1",
"if A[x]==0:\n\t\t\tB[x]=0\n\n\t",
"A[x]==0",
"A[x]",
"A",
"x",
"0",
"B[x]=0",
"B[x]",
"B",
"x",
"0",
"print(sum(B))",
"print",
"sum(B)",
"sum",
"B",
"if __name__==\"__main__\":\n\tmain()",
"__name__==\"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"input=sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"input",
"def II(): return int(input())",
"def II(): return int(input())",
"II",
"def main():\n\tn,m=MI()\n\t\n\tA=[1]*(n+1)\n\tB=[0]*(n+1)\n\tB[1]=1\n\t\n\tfor _ in range(m):\n\t\tx,y=MI()\n\t\tA[x]-=1\n\t\tA[y]+=1\n\t\t\n\t\tif B[x]==1:\n\t\t\tB[y]=1\n\t\tif A[x]==0:\n\t\t\tB[x]=0\n\n\tprint(sum(B))\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\n\n\n\n\n\n\t\n\t\n\t",
"def main():\n\tn,m=MI()\n\t\n\tA=[1]*(n+1)\n\tB=[0]*(n+1)\n\tB[1]=1\n\t\n\tfor _ in range(m):\n\t\tx,y=MI()\n\t\tA[x]-=1\n\t\tA[y]+=1\n\t\t\n\t\tif B[x]==1:\n\t\t\tB[y]=1\n\t\tif A[x]==0:\n\t\t\tB[x]=0\n\n\tprint(sum(B))\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\n\n\n\n\n\n\n\n\t\n\t\n\t",
"main",
"def TI(): return tuple(map(int,input().split()))\n\n\n# rstrip().decode('utf-8')",
"def TI(): return tuple(map(int,input().split()))\n\n\n# rstrip().decode('utf-8')",
"TI",
"def LI(): return list(map(int,input().split()))",
"def LI(): return list(map(int,input().split()))",
"LI",
"def MF(): return map(float,input().split())",
"def MF(): return map(float,input().split())",
"MF",
"def RD(): return sys.stdin.read()",
"def RD(): return sys.stdin.read()",
"RD",
"def MI(): return map(int,input().split())",
"def MI(): return map(int,input().split())",
"MI",
"def LF(): return list(map(float,input().split()))",
"def LF(): return list(map(float,input().split()))",
"LF"
] | import sys
input=sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
def main():
n,m=MI()
A=[1]*(n+1)
B=[0]*(n+1)
B[1]=1
for _ in range(m):
x,y=MI()
A[x]-=1
A[y]+=1
if B[x]==1:
B[y]=1
if A[x]==0:
B[x]=0
print(sum(B))
if __name__=="__main__":
main()
|
[
7,
15,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
28,
13,
13,
14,
13,
0,
13,
17,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
7,
6
],
[
7,
9
],
[
12,
11
],
[
6,
15
],
[
18,
17
],
[
6,
21
],
[
26,
23
],
[
17,
24
],
[
29,
28
],
[
9,
31
],
[
34,
33
],
[
34,
36
],
[
17,
39
],
[
33,
41
],
[
49,
44
],
[
17,
45
],
[
36,
47
],
[
56,
51
],
[
11,
52
],
[
33,
54
],
[
63,
58
],
[
11,
59
],
[
36,
61
],
[
11,
67
],
[
33,
69
],
[
78,
73
],
[
17,
74
],
[
33,
76
],
[
81,
80
],
[
84,
83
],
[
17,
83
],
[
89,
88
],
[
88,
92
],
[
80,
92
],
[
133,
124
]
] | [
"# import sys\n# input = sys.stdin.readline\nimport itertools\n\n\n# 持っているビスケットを叩き、1枚増やす\n# ビスケット A枚を 1円に交換する\n# 1円をビスケット B枚に交換する\ndef main():\n n, m = input_list()\n balls = [1] * n\n reds = [False] * n\n reds[0] = True\n for _ in range(m):\n x, y = input_list()\n if reds[x-1]:\n reds[y-1] = True\n balls[x-1] -= 1\n balls[y-1] += 1\n if balls[x-1] == 0:\n reds[x-1] = False\n c = 0\n for v in reds:\n if v:\n c += 1\n print(c)\n\n\ndef input_list():\n return list(map(int, input().split()))\n\n\ndef input_list_str():\n return list(map(str, input().split()))\n\n\nif __name__ == \"__main__\":\n main()",
"import itertools",
"itertools",
"def main():\n n, m = input_list()\n balls = [1] * n\n reds = [False] * n\n reds[0] = True\n for _ in range(m):\n x, y = input_list()\n if reds[x-1]:\n reds[y-1] = True\n balls[x-1] -= 1\n balls[y-1] += 1\n if balls[x-1] == 0:\n reds[x-1] = False\n c = 0\n for v in reds:\n if v:\n c += 1\n print(c)",
"main",
"n, m = input_list()",
"n",
"input_list()",
"input_list",
"m",
"balls = [1] * n",
"balls",
"[1] * n",
"[1]",
"1",
"n",
"reds = [False] * n",
"reds",
"[False] * n",
"[False]",
"False",
"n",
"reds[0] = True",
"reds[0]",
"reds",
"0",
"True",
"for _ in range(m):\n x, y = input_list()\n if reds[x-1]:\n reds[y-1] = True\n balls[x-1] -= 1\n balls[y-1] += 1\n if balls[x-1] == 0:\n reds[x-1] = False\n ",
"_",
"range(m)",
"range",
"m",
"x, y = input_list()",
"x",
"input_list()",
"input_list",
"y",
"if reds[x-1]:\n reds[y-1] = True\n ",
"reds[x-1]",
"reds",
"x-1",
"x",
"1",
"reds[y-1] = True",
"reds[y-1]",
"reds",
"y-1",
"y",
"1",
"True",
"balls[x-1] -= 1",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"1",
"balls[y-1] += 1",
"balls[y-1]",
"balls",
"y-1",
"y",
"1",
"1",
"if balls[x-1] == 0:\n reds[x-1] = False\n ",
"balls[x-1] == 0",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"0",
"reds[x-1] = False",
"reds[x-1]",
"reds",
"x-1",
"x",
"1",
"False",
"c = 0",
"c",
"0",
"for v in reds:\n if v:\n c += 1\n ",
"v",
"reds",
"if v:\n c += 1\n ",
"v",
"c += 1",
"c",
"1",
"print(c)",
"print",
"c",
"def input_list():\n return list(map(int, input().split()))",
"input_list",
"return list(map(int, input().split()))",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def input_list_str():\n return list(map(str, input().split()))",
"input_list_str",
"return list(map(str, input().split()))",
"list(map(str, input().split()))",
"list",
"map(str, input().split())",
"map",
"str",
"input().split()",
"().split",
"()",
"input",
"split",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def input_list():\n return list(map(int, input().split()))",
"def input_list():\n return list(map(int, input().split()))",
"input_list",
"def input_list_str():\n return list(map(str, input().split()))",
"def input_list_str():\n return list(map(str, input().split()))",
"input_list_str",
"def main():\n n, m = input_list()\n balls = [1] * n\n reds = [False] * n\n reds[0] = True\n for _ in range(m):\n x, y = input_list()\n if reds[x-1]:\n reds[y-1] = True\n balls[x-1] -= 1\n balls[y-1] += 1\n if balls[x-1] == 0:\n reds[x-1] = False\n c = 0\n for v in reds:\n if v:\n c += 1\n print(c)",
"def main():\n n, m = input_list()\n balls = [1] * n\n reds = [False] * n\n reds[0] = True\n for _ in range(m):\n x, y = input_list()\n if reds[x-1]:\n reds[y-1] = True\n balls[x-1] -= 1\n balls[y-1] += 1\n if balls[x-1] == 0:\n reds[x-1] = False\n c = 0\n for v in reds:\n if v:\n c += 1\n print(c)",
"main"
] | # import sys
# input = sys.stdin.readline
import itertools
# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
n, m = input_list()
balls = [1] * n
reds = [False] * n
reds[0] = True
for _ in range(m):
x, y = input_list()
if reds[x-1]:
reds[y-1] = True
balls[x-1] -= 1
balls[y-1] += 1
if balls[x-1] == 0:
reds[x-1] = False
c = 0
for v in reds:
if v:
c += 1
print(c)
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
0,
13,
2,
18,
13,
17,
17,
13,
2,
18,
13,
17,
17,
14,
2,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
128,
2
],
[
128,
11
],
[
15,
14
],
[
129,
17
],
[
113,
30
],
[
116,
33
],
[
126,
37
],
[
110,
39
],
[
126,
43
],
[
48,
45
],
[
111,
46
],
[
51,
50
],
[
114,
50
],
[
122,
53
],
[
50,
56
],
[
119,
59
],
[
50,
62
],
[
78,
67
],
[
111,
68
],
[
123,
69
],
[
93,
73
],
[
117,
74
],
[
123,
75
],
[
81,
78
],
[
111,
79
],
[
123,
80
],
[
86,
83
],
[
111,
84
],
[
120,
85
],
[
91,
88
],
[
111,
89
],
[
120,
90
],
[
96,
93
],
[
117,
94
],
[
123,
95
],
[
101,
98
],
[
117,
99
],
[
120,
100
],
[
111,
106
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
128,
126
],
[
128,
129
]
] | [
"N, M = map(int,input().split())\nB = [list(map(int,input().split())) for k in range(M)]\nH = [1]*N\nE = [0]*N\nE[0] = 1\nfor e in B:\n x, y = e[0]-1, e[1]-1\n if E[x] == 1:\n if H[x] == 1:\n E[x] = 0\n E[y] = 1\n else:\n E[y] = 1\n H[x] -= 1\n H[y] += 1\nprint(E.count(1))",
"N, M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"list(map(int,input().split())) for k in range(M)",
"for k in range(M)",
"k",
"range(M)",
"range",
"M",
"for k in range(M)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"B = [list(map(int,input().split())) for k in range(M)]",
"B",
"[list(map(int,input().split())) for k in range(M)]",
"H = [1]*N",
"H",
"[1]*N",
"[1]",
"1",
"N",
"E = [0]*N",
"E",
"[0]*N",
"[0]",
"0",
"N",
"E[0] = 1",
"E[0]",
"E",
"0",
"1",
"for e in B:\n x, y = e[0]-1, e[1]-1\n if E[x] == 1:\n if H[x] == 1:\n E[x] = 0\n E[y] = 1\n else:\n E[y] = 1\n H[x] -= 1\n H[y] += 1",
"e",
"B",
"x, y = e[0]-1, e[1]-1",
"x",
"e[0]-1",
"e[0]",
"e",
"0",
"1",
"y",
"e[1]-1",
"e[1]",
"e",
"1",
"1",
"if E[x] == 1:\n if H[x] == 1:\n E[x] = 0\n E[y] = 1\n else:\n E[y] = 1\n ",
"E[x] == 1",
"E[x]",
"E",
"x",
"1",
"if H[x] == 1:\n E[x] = 0\n E[y] = 1\n else:\n E[y] = 1\n ",
"H[x] == 1",
"H[x]",
"H",
"x",
"1",
"E[x] = 0",
"E[x]",
"E",
"x",
"0",
"E[y] = 1",
"E[y]",
"E",
"y",
"1",
"E[y] = 1",
"E[y]",
"E",
"y",
"1",
"H[x] -= 1",
"H[x]",
"H",
"x",
"1",
"H[y] += 1",
"H[y]",
"H",
"y",
"1",
"print(E.count(1))",
"print",
"E.count(1)",
"E.count",
"E",
"count",
"1",
"E = [0]*N",
"[0]*N",
"E",
"B = [list(map(int,input().split())) for k in range(M)]",
"[list(map(int,input().split())) for k in range(M)]",
"B",
"H = [1]*N",
"[1]*N",
"H",
"y = e[0]-1, e[1]-1",
"e[1]-1",
"y",
"x, y = e[0]-1, e[1]-1",
"e[0]-1",
"x",
"N, M = map(int,input().split())",
"map(int,input().split())",
"N",
"M = map(int,input().split())",
"map(int,input().split())",
"M"
] | N, M = map(int,input().split())
B = [list(map(int,input().split())) for k in range(M)]
H = [1]*N
E = [0]*N
E[0] = 1
for e in B:
x, y = e[0]-1, e[1]-1
if E[x] == 1:
if H[x] == 1:
E[x] = 0
E[y] = 1
else:
E[y] = 1
H[x] -= 1
H[y] += 1
print(E.count(1))
|
[
7,
15,
15,
15,
15,
13,
15,
13,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
18,
13,
13,
0,
13,
17,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13
] | [
[
135,
16
],
[
150,
43
],
[
154,
45
],
[
150,
46
],
[
159,
48
],
[
142,
52
],
[
57,
54
],
[
160,
55
],
[
144,
59
],
[
142,
63
],
[
66,
65
],
[
151,
68
],
[
147,
70
],
[
147,
85
],
[
90,
87
],
[
145,
88
],
[
148,
89
],
[
95,
92
],
[
145,
93
],
[
139,
94
],
[
160,
98
],
[
148,
99
],
[
104,
101
],
[
160,
102
],
[
139,
103
],
[
87,
107
],
[
145,
108
],
[
148,
109
],
[
115,
112
],
[
160,
113
],
[
148,
114
],
[
165,
117
],
[
121,
120
],
[
142,
123
],
[
160,
126
],
[
120,
127
],
[
162,
129
],
[
163,
133
],
[
166,
133
],
[
135,
136
],
[
147,
139
],
[
150,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
159,
160
],
[
162,
163
],
[
165,
166
]
] | [
"#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3回\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\n#import bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# 四捨五入\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nn,m = readInts()\nred = [False] * n\nred[0] = True\nbox = [1] * n\nfor i in range(m):\n x,y = map(lambda x:int(x)-1, input().split())\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = True\n if box[x] == 0:\n red[x] = False\ncnt = 0\nfor i in range(n):\n if red[i]:\n cnt += 1\nprint(cnt)",
"from fractions import gcd",
"from itertools import combinations,permutations,accumulate, product",
"from collections import deque,defaultdict,Counter",
"import decimal",
"decimal",
"import re",
"re",
"import sys",
"sys",
"sys.setrecursionlimit(10000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10000000",
"mod = 10**9 + 7",
"mod",
"10**9 + 7",
"10**9",
"10",
"9",
"7",
"def readInts():\n return list(map(int,input().split()))",
"readInts",
"return list(map(int,input().split()))",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def I():\n return int(input())",
"I",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"n,m = readInts()",
"n",
"readInts()",
"readInts",
"m",
"red = [False] * n",
"red",
"[False] * n",
"[False]",
"False",
"n",
"red[0] = True",
"red[0]",
"red",
"0",
"True",
"box = [1] * n",
"box",
"[1] * n",
"[1]",
"1",
"n",
"for i in range(m):\n x,y = map(lambda x:int(x)-1, input().split())\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = True\n if box[x] == 0:\n red[x] = False",
"i",
"range(m)",
"range",
"m",
"x,y = map(lambda x:int(x)-1, input().split())",
"x",
"map(lambda x:int(x)-1, input().split())",
"map",
"lambda x:int(x)-1",
"int(x)-1",
"int(x)",
"int",
"x",
"1",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"box[y] += 1",
"box[y]",
"box",
"y",
"1",
"if red[x]:\n red[y] = True\n ",
"red[x]",
"red",
"x",
"red[y] = True",
"red[y]",
"red",
"y",
"True",
"if box[x] == 0:\n red[x] = False",
"box[x] == 0",
"box[x]",
"box",
"x",
"0",
"red[x] = False",
"red[x]",
"red",
"x",
"False",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n if red[i]:\n cnt += 1",
"i",
"range(n)",
"range",
"n",
"if red[i]:\n cnt += 1",
"red[i]",
"red",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"mod = 10**9 + 7",
"10**9 + 7",
"mod",
"y = map(lambda x:int(x)-1, input().split())",
"map(lambda x:int(x)-1, input().split())",
"y",
"n,m = readInts()",
"readInts()",
"n",
"box = [1] * n",
"[1] * n",
"box",
"x,y = map(lambda x:int(x)-1, input().split())",
"map(lambda x:int(x)-1, input().split())",
"x",
"m = readInts()",
"readInts()",
"m",
"def readInts():\n return list(map(int,input().split()))",
"def readInts():\n return list(map(int,input().split()))",
"readInts",
"def I():\n return int(input())",
"def I():\n return int(input())",
"I",
"red = [False] * n",
"[False] * n",
"red",
"cnt += 1",
"1",
"cnt",
"cnt = 0",
"0",
"cnt"
] | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
return list(map(int,input().split()))
def I():
return int(input())
n,m = readInts()
red = [False] * n
red[0] = True
box = [1] * n
for i in range(m):
x,y = map(lambda x:int(x)-1, input().split())
box[x] -= 1
box[y] += 1
if red[x]:
red[y] = True
if box[x] == 0:
red[x] = False
cnt = 0
for i in range(n):
if red[i]:
cnt += 1
print(cnt)
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
4,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
2,
13,
17,
4,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
18,
18,
13,
13,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
18,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] | [
[
140,
2
],
[
140,
13
],
[
134,
15
],
[
135,
19
],
[
26,
25
],
[
129,
29
],
[
135,
33
],
[
40,
39
],
[
141,
42
],
[
137,
44
],
[
137,
55
],
[
143,
57
],
[
149,
60
],
[
68,
63
],
[
135,
65
],
[
144,
66
],
[
126,
66
],
[
75,
70
],
[
135,
72
],
[
150,
73
],
[
138,
73
],
[
135,
79
],
[
144,
80
],
[
126,
80
],
[
88,
83
],
[
135,
85
],
[
150,
86
],
[
138,
86
],
[
135,
93
],
[
144,
94
],
[
126,
94
],
[
103,
98
],
[
135,
100
],
[
144,
101
],
[
126,
101
],
[
146,
105
],
[
109,
108
],
[
129,
111
],
[
135,
115
],
[
108,
116
],
[
131,
119
],
[
132,
123
],
[
147,
123
],
[
137,
126
],
[
140,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
]
] | [
"N, M = list(map(int, input().split()))\n\nbox = []\nbox.append([1, True])\nfor _ in range(N - 1):\n box.append([1, False])\n\nfor _ in range(M):\n x, y = list(map(int, input().split()))\n x -= 1\n y -= 1\n\n box[x][0] -= 1\n box[y][0] += 1\n\n if box[x][1]:\n box[y][1] = True\n\n if box[x][0] == 0:\n box[x][1] = False\n \nans = 0\nfor i in range(N):\n if box[i][1]:\n ans += 1\nprint(ans)",
"N, M = list(map(int, input().split()))",
"N",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"box = []",
"box",
"[]",
"box.append([1, True])",
"box.append",
"box",
"append",
"[1, True]",
"1",
"True",
"for _ in range(N - 1):\n box.append([1, False])",
"_",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"box.append([1, False])",
"box.append",
"box",
"append",
"[1, False]",
"1",
"False",
"for _ in range(M):\n x, y = list(map(int, input().split()))\n x -= 1\n y -= 1\n\n box[x][0] -= 1\n box[y][0] += 1\n\n if box[x][1]:\n box[y][1] = True\n\n if box[x][0] == 0:\n box[x][1] = False\n ",
"_",
"range(M)",
"range",
"M",
"x, y = list(map(int, input().split()))",
"x",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"box[x][0] -= 1",
"box[x][0]",
"[x]",
"box",
"x",
"0",
"1",
"box[y][0] += 1",
"box[y][0]",
"[y]",
"box",
"y",
"0",
"1",
"if box[x][1]:\n box[y][1] = True\n\n ",
"box[x][1]",
"[x]",
"box",
"x",
"1",
"box[y][1] = True",
"box[y][1]",
"[y]",
"box",
"y",
"1",
"True",
"if box[x][0] == 0:\n box[x][1] = False\n ",
"box[x][0] == 0",
"box[x][0]",
"[x]",
"box",
"x",
"0",
"0",
"box[x][1] = False",
"box[x][1]",
"[x]",
"box",
"x",
"1",
"False",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if box[i][1]:\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if box[i][1]:\n ans += 1",
"box[i][1]",
"[i]",
"box",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"x, y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"x",
"N, M = list(map(int, input().split()))",
"list(map(int, input().split()))",
"N",
"ans += 1",
"1",
"ans",
"box = []",
"[]",
"box",
"y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"y",
"M = list(map(int, input().split()))",
"list(map(int, input().split()))",
"M",
"x -= 1",
"1",
"x",
"ans = 0",
"0",
"ans",
"y -= 1",
"1",
"y"
] | N, M = list(map(int, input().split()))
box = []
box.append([1, True])
for _ in range(N - 1):
box.append([1, False])
for _ in range(M):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
box[x][0] -= 1
box[y][0] += 1
if box[x][1]:
box[y][1] = True
if box[x][0] == 0:
box[x][1] = False
ans = 0
for i in range(N):
if box[i][1]:
ans += 1
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
39,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
93,
2
],
[
93,
11
],
[
81,
13
],
[
87,
19
],
[
94,
24
],
[
28,
27
],
[
79,
30
],
[
90,
32
],
[
90,
41
],
[
46,
43
],
[
88,
44
],
[
85,
45
],
[
51,
48
],
[
88,
49
],
[
91,
50
],
[
85,
54
],
[
82,
55
],
[
82,
58
],
[
91,
60
],
[
43,
63
],
[
88,
64
],
[
85,
65
],
[
82,
69
],
[
85,
71
],
[
82,
76
],
[
93,
79
],
[
81,
82
],
[
90,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
]
] | [
"n,m=map(int,input().split())\ns=set([1])\nb=[1]*(n+1)\nfor i in range(m):\n x,y=map(int,input().split())\n b[x]-=1\n b[y]+=1\n if x in s:\n s.add(y)\n if b[x]==0:\n s.remove(x)\nprint(len(s))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"s=set([1])",
"s",
"set([1])",
"set",
"[1]",
"1",
"b=[1]*(n+1)",
"b",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"for i in range(m):\n x,y=map(int,input().split())\n b[x]-=1\n b[y]+=1\n if x in s:\n s.add(y)\n if b[x]==0:\n s.remove(x)",
"i",
"range(m)",
"range",
"m",
"x,y=map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"b[x]-=1",
"b[x]",
"b",
"x",
"1",
"b[y]+=1",
"b[y]",
"b",
"y",
"1",
"if x in s:\n s.add(y)\n if b[x]==0:\n s.remove(x)",
"x in s",
"x",
"s",
"s.add(y)",
"s.add",
"s",
"add",
"y",
"if b[x]==0:\n s.remove(x)",
"b[x]==0",
"b[x]",
"b",
"x",
"0",
"s.remove(x)",
"s.remove",
"s",
"remove",
"x",
"print(len(s))",
"print",
"len(s)",
"len",
"s",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"s=set([1])",
"set([1])",
"s",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"b=[1]*(n+1)",
"[1]*(n+1)",
"b",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n"
] | n,m=map(int,input().split())
s=set([1])
b=[1]*(n+1)
for i in range(m):
x,y=map(int,input().split())
b[x]-=1
b[y]+=1
if x in s:
s.add(y)
if b[x]==0:
s.remove(x)
print(len(s)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
13,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] | [
[
123,
2
],
[
123,
11
],
[
105,
13
],
[
121,
17
],
[
117,
19
],
[
121,
23
],
[
28,
25
],
[
106,
26
],
[
31,
30
],
[
124,
33
],
[
129,
35
],
[
129,
44
],
[
111,
46
],
[
130,
48
],
[
112,
48
],
[
126,
50
],
[
109,
52
],
[
127,
52
],
[
72,
56
],
[
106,
57
],
[
112,
58
],
[
130,
58
],
[
64,
61
],
[
106,
62
],
[
127,
63
],
[
109,
63
],
[
87,
67
],
[
77,
67
],
[
118,
68
],
[
112,
69
],
[
130,
69
],
[
75,
72
],
[
106,
73
],
[
112,
74
],
[
130,
74
],
[
80,
77
],
[
118,
78
],
[
112,
79
],
[
130,
79
],
[
85,
82
],
[
118,
83
],
[
127,
84
],
[
109,
84
],
[
90,
87
],
[
118,
88
],
[
112,
89
],
[
130,
89
],
[
95,
92
],
[
118,
93
],
[
127,
94
],
[
109,
94
],
[
114,
97
],
[
106,
100
],
[
115,
103
],
[
105,
106
],
[
129,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
123,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
]
] | [
"n, m = map(int, input().split())\n\nX = [0]*n\nC = [1]*n\nX[0] = 1\n\nfor i in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n if X[x] == 1:\n X[y] = 1\n if C[x] == 1:\n X[x] = 0\n C[x] -= 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += 1\n\nans = sum(X)\nprint(ans)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"X = [0]*n",
"X",
"[0]*n",
"[0]",
"0",
"n",
"C = [1]*n",
"C",
"[1]*n",
"[1]",
"1",
"n",
"X[0] = 1",
"X[0]",
"X",
"0",
"1",
"for i in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n if X[x] == 1:\n X[y] = 1\n if C[x] == 1:\n X[x] = 0\n C[x] -= 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += 1",
"i",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x, y = x-1, y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"if X[x] == 1:\n X[y] = 1\n if C[x] == 1:\n X[x] = 0\n C[x] -= 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += 1",
"X[x] == 1",
"X[x]",
"X",
"x",
"1",
"X[y] = 1",
"X[y]",
"X",
"y",
"1",
"if C[x] == 1:\n X[x] = 0\n ",
"C[x] == 1",
"C[x]",
"C",
"x",
"1",
"X[x] = 0",
"X[x]",
"X",
"x",
"0",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"C[x] -= 1",
"C[x]",
"C",
"x",
"1",
"C[y] += 1",
"C[y]",
"C",
"y",
"1",
"ans = sum(X)",
"ans",
"sum(X)",
"sum",
"X",
"print(ans)",
"print",
"ans",
"X = [0]*n",
"[0]*n",
"X",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"x, y = x-1, y-1",
"x-1",
"x",
"ans = sum(X)",
"sum(X)",
"ans",
"C = [1]*n",
"[1]*n",
"C",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"y = x-1, y-1",
"y-1",
"y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x"
] | n, m = map(int, input().split())
X = [0]*n
C = [1]*n
X[0] = 1
for i in range(m):
x, y = map(int, input().split())
x, y = x-1, y-1
if X[x] == 1:
X[y] = 1
if C[x] == 1:
X[x] = 0
C[x] -= 1
C[y] += 1
else:
C[x] -= 1
C[y] += 1
ans = sum(X)
print(ans)
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
13,
13,
10,
13,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
127,
2
],
[
127,
13
],
[
17,
16
],
[
128,
19
],
[
115,
32
],
[
130,
35
],
[
125,
39
],
[
44,
41
],
[
131,
42
],
[
133,
46
],
[
125,
50
],
[
55,
52
],
[
134,
53
],
[
58,
57
],
[
128,
60
],
[
121,
62
],
[
116,
64
],
[
57,
65
],
[
121,
66
],
[
73,
68
],
[
131,
69
],
[
122,
71
],
[
80,
75
],
[
131,
76
],
[
119,
78
],
[
134,
83
],
[
119,
85
],
[
93,
88
],
[
134,
89
],
[
122,
91
],
[
131,
97
],
[
119,
99
],
[
108,
103
],
[
134,
104
],
[
119,
106
],
[
134,
113
],
[
115,
116
],
[
121,
119
],
[
121,
122
],
[
127,
125
],
[
127,
128
],
[
130,
131
],
[
133,
134
]
] | [
"n, m = list(map(int, input().split()))\nxy = [list(map(int, input().split())) for i in range(m)]\n\nans = [1] * (n)\nans[0] = 1\nball = [0] * (n)\nball[0] = 1\nfor i in range(m):\n x, y = xy[i]\n ans[y-1] += 1\n ans[x-1] -= 1\n if ball[x-1]:\n ball[y-1] = 1\n if ans[x-1] == 0:\n ball[x-1] = 0\n \nprint(sum(ball))",
"n, m = list(map(int, input().split()))",
"n",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"list(map(int, input().split())) for i in range(m)",
"for i in range(m)",
"i",
"range(m)",
"range",
"m",
"for i in range(m)",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xy = [list(map(int, input().split())) for i in range(m)]",
"xy",
"[list(map(int, input().split())) for i in range(m)]",
"ans = [1] * (n)",
"ans",
"[1] * (n)",
"[1]",
"1",
"n",
"ans[0] = 1",
"ans[0]",
"ans",
"0",
"1",
"ball = [0] * (n)",
"ball",
"[0] * (n)",
"[0]",
"0",
"n",
"ball[0] = 1",
"ball[0]",
"ball",
"0",
"1",
"for i in range(m):\n x, y = xy[i]\n ans[y-1] += 1\n ans[x-1] -= 1\n if ball[x-1]:\n ball[y-1] = 1\n if ans[x-1] == 0:\n ball[x-1] = 0\n ",
"i",
"range(m)",
"range",
"m",
"x, y = xy[i]",
"x",
"xy[i]",
"xy",
"i",
"y",
"ans[y-1] += 1",
"ans[y-1]",
"ans",
"y-1",
"y",
"1",
"1",
"ans[x-1] -= 1",
"ans[x-1]",
"ans",
"x-1",
"x",
"1",
"1",
"if ball[x-1]:\n ball[y-1] = 1\n ",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"ball[y-1] = 1",
"ball[y-1]",
"ball",
"y-1",
"y",
"1",
"1",
"if ans[x-1] == 0:\n ball[x-1] = 0\n ",
"ans[x-1] == 0",
"ans[x-1]",
"ans",
"x-1",
"x",
"1",
"0",
"ball[x-1] = 0",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"0",
"print(sum(ball))",
"print",
"sum(ball)",
"sum",
"ball",
"xy = [list(map(int, input().split())) for i in range(m)]",
"[list(map(int, input().split())) for i in range(m)]",
"xy",
"x, y = xy[i]",
"xy[i]",
"x",
"y = xy[i]",
"xy[i]",
"y",
"n, m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"n",
"m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"m",
"ans = [1] * (n)",
"[1] * (n)",
"ans",
"ball = [0] * (n)",
"[0] * (n)",
"ball"
] | n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]
ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
x, y = xy[i]
ans[y-1] += 1
ans[x-1] -= 1
if ball[x-1]:
ball[y-1] = 1
if ans[x-1] == 0:
ball[x-1] = 0
print(sum(ball)) |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
2,
18,
13,
2,
13,
17,
18,
13,
2,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
118,
2
],
[
118,
13
],
[
103,
15
],
[
119,
19
],
[
112,
21
],
[
119,
25
],
[
30,
27
],
[
113,
28
],
[
33,
32
],
[
110,
35
],
[
115,
37
],
[
115,
48
],
[
55,
50
],
[
113,
51
],
[
107,
53
],
[
113,
57
],
[
107,
59
],
[
113,
62
],
[
116,
64
],
[
104,
69
],
[
116,
71
],
[
80,
75
],
[
113,
76
],
[
116,
78
],
[
87,
82
],
[
104,
83
],
[
116,
85
],
[
94,
89
],
[
104,
90
],
[
107,
92
],
[
113,
99
],
[
103,
104
],
[
115,
107
],
[
118,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
]
] | [
"n, m = list(map(int, input().split()))\ncnt = [1] * n\nhas_red = [False] * n\nhas_red[0] = True\nfor i in range(m):\n a, b = list(map(int, input().split()))\n has_red[b - 1] = has_red[b - 1] or has_red[a - 1]\n if cnt[a - 1] == 1:\n has_red[a - 1] = False\n cnt[a - 1] -= 1\n cnt[b - 1] += 1\nprint(has_red.count(True))",
"n, m = list(map(int, input().split()))",
"n",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"cnt = [1] * n",
"cnt",
"[1] * n",
"[1]",
"1",
"n",
"has_red = [False] * n",
"has_red",
"[False] * n",
"[False]",
"False",
"n",
"has_red[0] = True",
"has_red[0]",
"has_red",
"0",
"True",
"for i in range(m):\n a, b = list(map(int, input().split()))\n has_red[b - 1] = has_red[b - 1] or has_red[a - 1]\n if cnt[a - 1] == 1:\n has_red[a - 1] = False\n cnt[a - 1] -= 1\n cnt[b - 1] += 1",
"i",
"range(m)",
"range",
"m",
"a, b = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"has_red[b - 1] = has_red[b - 1] or has_red[a - 1]",
"has_red[b - 1]",
"has_red",
"b - 1",
"b",
"1",
"has_red[b - 1] or has_red[a - 1]",
"has_red[b - 1]",
"has_red",
"b - 1",
"b",
"1",
"has_red[a - 1]",
"has_red",
"a - 1",
"a",
"1",
"if cnt[a - 1] == 1:\n has_red[a - 1] = False\n ",
"cnt[a - 1] == 1",
"cnt[a - 1]",
"cnt",
"a - 1",
"a",
"1",
"1",
"has_red[a - 1] = False",
"has_red[a - 1]",
"has_red",
"a - 1",
"a",
"1",
"False",
"cnt[a - 1] -= 1",
"cnt[a - 1]",
"cnt",
"a - 1",
"a",
"1",
"1",
"cnt[b - 1] += 1",
"cnt[b - 1]",
"cnt",
"b - 1",
"b",
"1",
"1",
"print(has_red.count(True))",
"print",
"has_red.count(True)",
"has_red.count",
"has_red",
"count",
"True",
"cnt = [1] * n",
"[1] * n",
"cnt",
"b = list(map(int, input().split()))",
"list(map(int, input().split()))",
"b",
"m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"m",
"has_red = [False] * n",
"[False] * n",
"has_red",
"a, b = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"n, m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"n"
] | n, m = list(map(int, input().split()))
cnt = [1] * n
has_red = [False] * n
has_red[0] = True
for i in range(m):
a, b = list(map(int, input().split()))
has_red[b - 1] = has_red[b - 1] or has_red[a - 1]
if cnt[a - 1] == 1:
has_red[a - 1] = False
cnt[a - 1] -= 1
cnt[b - 1] += 1
print(has_red.count(True))
|
[
7,
12,
13,
0,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
40,
2,
4,
13,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
2,
2,
2,
4,
13,
18,
13,
13,
17,
18,
13,
13,
4,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
13,
4,
13,
4,
13,
12,
2,
13,
17,
23,
13,
29,
13,
4,
13,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
8,
7
],
[
8,
16
],
[
19,
18
],
[
7,
22
],
[
27,
24
],
[
18,
25
],
[
30,
29
],
[
16,
32
],
[
35,
34
],
[
35,
43
],
[
46,
45
],
[
49,
48
],
[
106,
52
],
[
69,
52
],
[
18,
53
],
[
45,
54
],
[
34,
54
],
[
60,
57
],
[
18,
58
],
[
48,
59
],
[
43,
59
],
[
85,
64
],
[
80,
64
],
[
57,
64
],
[
18,
65
],
[
48,
66
],
[
43,
66
],
[
72,
69
],
[
18,
70
],
[
45,
71
],
[
34,
71
],
[
85,
75
],
[
80,
75
],
[
57,
75
],
[
18,
76
],
[
48,
77
],
[
43,
77
],
[
83,
80
],
[
18,
81
],
[
48,
82
],
[
43,
82
],
[
88,
85
],
[
18,
86
],
[
48,
87
],
[
43,
87
],
[
85,
93
],
[
80,
93
],
[
57,
93
],
[
18,
94
],
[
48,
95
],
[
43,
95
],
[
85,
97
],
[
80,
97
],
[
57,
97
],
[
18,
98
],
[
48,
99
],
[
43,
99
],
[
85,
102
],
[
80,
102
],
[
57,
102
],
[
18,
103
],
[
48,
104
],
[
43,
104
],
[
109,
106
],
[
18,
107
],
[
45,
108
],
[
34,
108
],
[
112,
111
],
[
18,
121
],
[
111,
123
],
[
4,
123
],
[
130,
127
]
] | [
"def solve():\n ans = 0\n N, M = map(int, input().split())\n lis = [1]*N\n lis[0] = -1 #赤が入っている可能性があればマイナス\n for _ in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:\n if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n lis[x] -= 1\n ans = sum(map(lambda x:x<0,lis))\n return ans\nprint(solve())",
"def solve():\n ans = 0\n N, M = map(int, input().split())\n lis = [1]*N\n lis[0] = -1 #赤が入っている可能性があればマイナス\n for _ in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:\n if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n lis[x] -= 1\n ans = sum(map(lambda x:x<0,lis))\n return ans",
"solve",
"ans = 0",
"ans",
"0",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"lis = [1]*N",
"lis",
"[1]*N",
"[1]",
"1",
"N",
"lis[0] = -1",
"lis[0]",
"lis",
"0",
"-1",
"for _ in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:\n if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n lis[x] -= 1\n ",
"_",
"range(M)",
"range",
"M",
"x,y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:\n if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n lis[x] -= 1\n ",
"lis[x]<0",
"lis[x]",
"lis",
"x",
"0",
"lis[y] = -(abs(lis[y])+1)",
"lis[y]",
"lis",
"y",
"-(abs(lis[y])+1)",
"abs(lis[y])+1",
"abs(lis[y])",
"abs",
"lis[y]",
"lis",
"y",
"1",
"lis[x] += 1",
"lis[x]",
"lis",
"x",
"1",
"if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n ",
"lis[y]==0",
"lis[y]",
"lis",
"y",
"0",
"lis[y] = 1",
"lis[y]",
"lis",
"y",
"1",
"lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])",
"lis[y]",
"lis",
"y",
"(abs(lis[y])+1)*lis[y]//abs(lis[y])",
"(abs(lis[y])+1)*lis[y]",
"abs(lis[y])+1",
"abs(lis[y])",
"abs",
"lis[y]",
"lis",
"y",
"1",
"lis[y]",
"lis",
"y",
"abs(lis[y])",
"abs",
"lis[y]",
"lis",
"y",
"lis[x] -= 1",
"lis[x]",
"lis",
"x",
"1",
"ans = sum(map(lambda x:x<0,lis))",
"ans",
"sum(map(lambda x:x<0,lis))",
"sum",
"map(lambda x:x<0,lis)",
"map",
"lambda x:x<0",
"x<0",
"x",
"0",
"x",
"lis",
"return ans",
"ans",
"print(solve())",
"print",
"solve()",
"solve",
"def solve():\n ans = 0\n N, M = map(int, input().split())\n lis = [1]*N\n lis[0] = -1 #赤が入っている可能性があればマイナス\n for _ in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:\n if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n lis[x] -= 1\n ans = sum(map(lambda x:x<0,lis))\n return ans",
"def solve():\n ans = 0\n N, M = map(int, input().split())\n lis = [1]*N\n lis[0] = -1 #赤が入っている可能性があればマイナス\n for _ in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:\n if lis[y]==0:\n lis[y] = 1\n else:\n lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])\n lis[x] -= 1\n ans = sum(map(lambda x:x<0,lis))\n return ans",
"solve"
] | def solve():
ans = 0
N, M = map(int, input().split())
lis = [1]*N
lis[0] = -1 #赤が入っている可能性があればマイナス
for _ in range(M):
x,y = map(int, input().split())
x -= 1
y -= 1
if lis[x]<0:
lis[y] = -(abs(lis[y])+1)
lis[x] += 1
else:
if lis[y]==0:
lis[y] = 1
else:
lis[y] = (abs(lis[y])+1)*lis[y]//abs(lis[y])
lis[x] -= 1
ans = sum(map(lambda x:x<0,lis))
return ans
print(solve()) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
18,
13,
13,
17,
14,
40,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13
] | [
[
157,
2
],
[
157,
11
],
[
15,
14
],
[
158,
17
],
[
160,
21
],
[
26,
25
],
[
158,
28
],
[
163,
32
],
[
38,
35
],
[
161,
36
],
[
41,
40
],
[
146,
43
],
[
166,
45
],
[
166,
54
],
[
142,
56
],
[
148,
59
],
[
99,
63
],
[
161,
64
],
[
143,
65
],
[
140,
65
],
[
109,
69
],
[
89,
69
],
[
74,
69
],
[
164,
70
],
[
143,
71
],
[
140,
71
],
[
77,
74
],
[
164,
75
],
[
143,
76
],
[
140,
76
],
[
82,
79
],
[
164,
80
],
[
149,
81
],
[
167,
81
],
[
87,
84
],
[
161,
85
],
[
149,
86
],
[
167,
86
],
[
92,
89
],
[
164,
90
],
[
143,
91
],
[
140,
91
],
[
97,
94
],
[
164,
95
],
[
149,
96
],
[
167,
96
],
[
102,
99
],
[
161,
100
],
[
143,
101
],
[
140,
101
],
[
107,
104
],
[
161,
105
],
[
149,
106
],
[
167,
106
],
[
112,
109
],
[
164,
110
],
[
143,
111
],
[
140,
111
],
[
117,
114
],
[
164,
115
],
[
149,
116
],
[
167,
116
],
[
151,
119
],
[
123,
122
],
[
158,
125
],
[
161,
129
],
[
122,
130
],
[
154,
133
],
[
155,
137
],
[
152,
137
],
[
166,
140
],
[
142,
143
],
[
157,
146
],
[
148,
149
],
[
151,
152
],
[
154,
155
],
[
157,
158
],
[
160,
161
],
[
163,
164
],
[
166,
167
]
] | [
"N,M = map(int, input().split())\nred = [0 for i in range(N)]\ncnt = [1 for i in range(N)]\nred[0] = 1\nfor i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if red[x] > 0:\n if cnt[x] >= 2:\n cnt[x] -= 1\n cnt[y] += 1\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1\n red[x] = 0\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1\n\nans = 0\nfor i in range(N):\n if red[i] > 0:\n ans += 1\n\nprint(ans)",
"N,M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"0 for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"0",
"red = [0 for i in range(N)]",
"red",
"[0 for i in range(N)]",
"1 for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"1",
"cnt = [1 for i in range(N)]",
"cnt",
"[1 for i in range(N)]",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"for i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if red[x] > 0:\n if cnt[x] >= 2:\n cnt[x] -= 1\n cnt[y] += 1\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1\n red[x] = 0\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1",
"i",
"range(M)",
"range",
"M",
"x,y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if red[x] > 0:\n if cnt[x] >= 2:\n cnt[x] -= 1\n cnt[y] += 1\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1\n red[x] = 0\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1",
"red[x] > 0",
"red[x]",
"red",
"x",
"0",
"if cnt[x] >= 2:\n cnt[x] -= 1\n cnt[y] += 1\n red[y] = 1\n else:\n cnt[x] -= 1\n cnt[y] += 1\n red[x] = 0\n red[y] = 1\n ",
"cnt[x] >= 2",
"cnt[x]",
"cnt",
"x",
"2",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if red[i] > 0:\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if red[i] > 0:\n ans += 1",
"red[i] > 0",
"red[i]",
"red",
"i",
"0",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"x,y = map(int, input().split())",
"map(int, input().split())",
"x",
"x -= 1",
"1",
"x",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"y -= 1",
"1",
"y",
"ans = 0",
"0",
"ans",
"ans += 1",
"1",
"ans",
"N,M = map(int, input().split())",
"map(int, input().split())",
"N",
"red = [0 for i in range(N)]",
"[0 for i in range(N)]",
"red",
"cnt = [1 for i in range(N)]",
"[1 for i in range(N)]",
"cnt",
"y = map(int, input().split())",
"map(int, input().split())",
"y"
] | N,M = map(int, input().split())
red = [0 for i in range(N)]
cnt = [1 for i in range(N)]
red[0] = 1
for i in range(M):
x,y = map(int, input().split())
x -= 1
y -= 1
if red[x] > 0:
if cnt[x] >= 2:
cnt[x] -= 1
cnt[y] += 1
red[y] = 1
else:
cnt[x] -= 1
cnt[y] += 1
red[x] = 0
red[y] = 1
else:
cnt[x] -= 1
cnt[y] += 1
ans = 0
for i in range(N):
if red[i] > 0:
ans += 1
print(ans) |
[
7,
41,
28,
13,
4,
13,
17,
4,
39,
31,
4,
13,
13,
4,
18,
13,
13,
0,
39,
13,
13,
13,
31,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13
] | [
[
4,
3
],
[
3,
15
],
[
21,
18
],
[
21,
22
],
[
81,
25
],
[
36,
33
],
[
82,
34
],
[
84,
38
],
[
53,
50
],
[
85,
51
],
[
58,
55
],
[
85,
56
],
[
63,
60
],
[
82,
61
],
[
67,
63
],
[
82,
64
],
[
70,
67
],
[
82,
68
],
[
50,
71
],
[
85,
72
],
[
82,
79
],
[
81,
82
],
[
84,
85
]
] | [
"(n, m), *q = [[*map(int, i.split())] for i in open(0)]\nb = [0] * (n + 1)\nb[1] = 1\nc = [1] * (n + 1)\nfor x, y in q:\n c[x] -= 1\n c[y] += 1\n b[y] |= b[x]\n b[x] *= c[x] > 0\nprint(sum(b))",
"[*map(int, i.split())] for i in open(0)",
"for i in open(0)",
"i",
"open(0)",
"open",
"0",
"for i in open(0)",
"[*map(int, i.split())]",
"*map(int, i.split())",
"map(int, i.split())",
"map",
"int",
"i.split()",
"i.split",
"i",
"split",
"(n, m), *q = [[*map(int, i.split())] for i in open(0)]",
"(n, m)",
"n",
"m",
"[[*map(int, i.split())] for i in open(0)]",
"*q",
"q",
"b = [0] * (n + 1)",
"b",
"[0] * (n + 1)",
"[0]",
"0",
"n + 1",
"n",
"1",
"b[1] = 1",
"b[1]",
"b",
"1",
"1",
"c = [1] * (n + 1)",
"c",
"[1] * (n + 1)",
"[1]",
"1",
"n + 1",
"n",
"1",
"for x, y in q:\n c[x] -= 1\n c[y] += 1\n b[y] |= b[x]\n b[x] *= c[x] > 0",
"x",
"y",
"q",
"c[x] -= 1",
"c[x]",
"c",
"x",
"1",
"c[y] += 1",
"c[y]",
"c",
"y",
"1",
"b[y] |= b[x]",
"b[y]",
"b",
"y",
"b[x]",
"b",
"x",
"b[x] *= c[x] > 0",
"b[x]",
"b",
"x",
"c[x] > 0",
"c[x]",
"c",
"x",
"0",
"print(sum(b))",
"print",
"sum(b)",
"sum",
"b",
"b = [0] * (n + 1)",
"[0] * (n + 1)",
"b",
"c = [1] * (n + 1)",
"[1] * (n + 1)",
"c"
] | (n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [0] * (n + 1)
b[1] = 1
c = [1] * (n + 1)
for x, y in q:
c[x] -= 1
c[y] += 1
b[y] |= b[x]
b[x] *= c[x] > 0
print(sum(b))
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
13,
28,
13,
18,
4,
13,
2,
13,
17,
13,
39,
17,
4,
13,
13,
4,
18,
13,
13,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
101,
4
],
[
101,
20
],
[
98,
22
],
[
42,
41
],
[
96,
45
],
[
99,
51
],
[
41,
52
],
[
99,
54
],
[
41,
56
],
[
102,
58
],
[
64,
63
],
[
41,
68
],
[
63,
72
],
[
75,
74
],
[
41,
79
],
[
96,
81
],
[
74,
86
],
[
101,
96
],
[
98,
99
],
[
101,
102
]
] | [
"import sys\n\nN, L = map(int, sys.stdin.readline().rstrip().split())\nA = list(map(int, sys.stdin.readline().rstrip().split()))\n\nfor i in range(N-1):\n if A[i] + A[i+1] >= L:\n print(\"Possible\")\n for j in range(1, i+1):\n print(j)\n for j in range(i+1, N)[::-1]:\n print(j)\n sys.exit()\n\nprint(\"Impossible\")",
"import sys",
"sys",
"N, L = map(int, sys.stdin.readline().rstrip().split())",
"N",
"map(int, sys.stdin.readline().rstrip().split())",
"map",
"int",
"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",
"L",
"A = list(map(int, sys.stdin.readline().rstrip().split()))",
"A",
"list(map(int, sys.stdin.readline().rstrip().split()))",
"list",
"map(int, sys.stdin.readline().rstrip().split())",
"map",
"int",
"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 i in range(N-1):\n if A[i] + A[i+1] >= L:\n print(\"Possible\")\n for j in range(1, i+1):\n print(j)\n for j in range(i+1, N)[::-1]:\n print(j)\n sys.exit()",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"if A[i] + A[i+1] >= L:\n print(\"Possible\")\n for j in range(1, i+1):\n print(j)\n for j in range(i+1, N)[::-1]:\n print(j)\n sys.exit()",
"A[i] + A[i+1] >= L",
"A[i] + A[i+1]",
"A[i]",
"A",
"i",
"A[i+1]",
"A",
"i+1",
"i",
"1",
"L",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for j in range(1, i+1):\n print(j)\n ",
"j",
"range(1, i+1)",
"range",
"1",
"i+1",
"i",
"1",
"print(j)",
"print",
"j",
"for j in range(i+1, N)[::-1]:\n print(j)\n ",
"j",
"range(i+1, N)[::-1]",
"(i+1, N)",
"range",
"i+1",
"i",
"1",
"N",
"::-1",
"-1",
"print(j)",
"print",
"j",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"N, L = map(int, sys.stdin.readline().rstrip().split())",
"map(int, sys.stdin.readline().rstrip().split())",
"N",
"A = list(map(int, sys.stdin.readline().rstrip().split()))",
"list(map(int, sys.stdin.readline().rstrip().split()))",
"A",
"L = map(int, sys.stdin.readline().rstrip().split())",
"map(int, sys.stdin.readline().rstrip().split())",
"L"
] | import sys
N, L = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
for i in range(N-1):
if A[i] + A[i+1] >= L:
print("Possible")
for j in range(1, i+1):
print(j)
for j in range(i+1, N)[::-1]:
print(j)
sys.exit()
print("Impossible") |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
13,
3,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
28,
13,
4,
13,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
2,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] | [
[
93,
2
],
[
93,
11
],
[
96,
13
],
[
102,
25
],
[
29,
28
],
[
91,
32
],
[
97,
38
],
[
28,
39
],
[
97,
41
],
[
28,
43
],
[
94,
45
],
[
99,
47
],
[
28,
48
],
[
100,
52
],
[
103,
52
],
[
62,
61
],
[
100,
64
],
[
103,
64
],
[
61,
68
],
[
72,
71
],
[
91,
75
],
[
100,
77
],
[
103,
77
],
[
71,
82
],
[
100,
87
],
[
103,
87
],
[
93,
91
],
[
93,
94
],
[
96,
97
],
[
28,
99
],
[
99,
100
],
[
102,
103
]
] | [
"n,l = map(int,input().split())\na = list(map(int,input().split()))\nx = -1\nfor i in range(n-1):\n if a[i]+a[i+1] >= l:\n x = i\n break\nif x == -1:\n print('Impossible')\nelse:\n print('Possible')\n for i in range(x):\n print(i+1)\n for i in range(n-2,x,-1):\n print(i+1)\n print(x+1)",
"n,l = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"x = -1",
"x",
"-1",
"for i in range(n-1):\n if a[i]+a[i+1] >= l:\n x = i\n break",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if a[i]+a[i+1] >= l:\n x = i\n break",
"a[i]+a[i+1] >= l",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"l",
"x = i",
"x",
"i",
"break",
"if x == -1:\n print('Impossible')\nelse:\n print('Possible')\n for i in range(x):\n print(i+1)\n for i in range(n-2,x,-1):\n print(i+1)\n print(x+1)",
"x == -1",
"x",
"-1",
"print('Impossible')",
"print",
"'Impossible'",
"print('Possible')",
"print",
"'Possible'",
"for i in range(x):\n print(i+1)\n ",
"i",
"range(x)",
"range",
"x",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"for i in range(n-2,x,-1):\n print(i+1)\n ",
"i",
"range(n-2,x,-1)",
"range",
"n-2",
"n",
"2",
"x",
"-1",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"print(x+1)",
"print",
"x+1",
"x",
"1",
"n,l = map(int,input().split())",
"map(int,input().split())",
"n",
"l = map(int,input().split())",
"map(int,input().split())",
"l",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"x = i",
"i",
"x",
"x = -1",
"-1",
"x"
] | n,l = map(int,input().split())
a = list(map(int,input().split()))
x = -1
for i in range(n-1):
if a[i]+a[i+1] >= l:
x = i
break
if x == -1:
print('Impossible')
else:
print('Possible')
for i in range(x):
print(i+1)
for i in range(n-2,x,-1):
print(i+1)
print(x+1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
3,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
13,
4,
18,
13,
13,
13,
28,
13,
18,
13,
39,
17,
4,
13,
13,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] | [
[
121,
2
],
[
121,
11
],
[
115,
13
],
[
127,
25
],
[
29,
28
],
[
122,
32
],
[
116,
38
],
[
28,
39
],
[
116,
41
],
[
28,
43
],
[
113,
45
],
[
124,
47
],
[
125,
52
],
[
128,
52
],
[
66,
65
],
[
65,
74
],
[
122,
80
],
[
118,
82
],
[
86,
85
],
[
122,
91
],
[
119,
94
],
[
85,
96
],
[
99,
98
],
[
119,
100
],
[
98,
105
],
[
121,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"n,l=map(int,input().split())\na=list(map(int,input().split()))\n\nflag=0\nfor i in range(n-1):\n if a[i]+a[i+1]>=l:\n flag=1\n break\n\nif flag==0:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n if i>0:\n for j in range(1,i+1):\n print(j)\n if i+2<n:\n tmp=[]\n for j in range(i+2,n):\n tmp.append(j)\n for item in tmp[::-1]:\n print(item)\n print(i+1)\n\n",
"n,l=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"flag=0",
"flag",
"0",
"for i in range(n-1):\n if a[i]+a[i+1]>=l:\n flag=1\n break",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if a[i]+a[i+1]>=l:\n flag=1\n break",
"a[i]+a[i+1]>=l",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"l",
"flag=1",
"flag",
"1",
"break",
"if flag==0:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n if i>0:\n for j in range(1,i+1):\n print(j)\n if i+2<n:\n tmp=[]\n for j in range(i+2,n):\n tmp.append(j)\n for item in tmp[::-1]:\n print(item)\n print(i+1)",
"flag==0",
"flag",
"0",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"if i>0:\n for j in range(1,i+1):\n print(j)\n ",
"i>0",
"i",
"0",
"for j in range(1,i+1):\n print(j)\n ",
"j",
"range(1,i+1)",
"range",
"1",
"i+1",
"i",
"1",
"print(j)",
"print",
"j",
"if i+2<n:\n tmp=[]\n for j in range(i+2,n):\n tmp.append(j)\n for item in tmp[::-1]:\n print(item)\n ",
"i+2<n",
"i+2",
"i",
"2",
"n",
"tmp=[]",
"tmp",
"[]",
"for j in range(i+2,n):\n tmp.append(j)\n ",
"j",
"range(i+2,n)",
"range",
"i+2",
"i",
"2",
"n",
"tmp.append(j)",
"tmp.append",
"tmp",
"append",
"j",
"for item in tmp[::-1]:\n print(item)\n ",
"item",
"tmp[::-1]",
"tmp",
"::-1",
"-1",
"print(item)",
"print",
"item",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"l=map(int,input().split())",
"map(int,input().split())",
"l",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"tmp=[]",
"[]",
"tmp",
"n,l=map(int,input().split())",
"map(int,input().split())",
"n",
"flag=1",
"1",
"flag",
"flag=0",
"0",
"flag"
] | n,l=map(int,input().split())
a=list(map(int,input().split()))
flag=0
for i in range(n-1):
if a[i]+a[i+1]>=l:
flag=1
break
if flag==0:
print("Impossible")
else:
print("Possible")
if i>0:
for j in range(1,i+1):
print(j)
if i+2<n:
tmp=[]
for j in range(i+2,n):
tmp.append(j)
for item in tmp[::-1]:
print(item)
print(i+1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
13,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
28,
13,
4,
13,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
2,
13,
17,
17,
4,
13,
13,
4,
13,
2,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13
] | [
[
115,
2
],
[
115,
11
],
[
106,
13
],
[
103,
25
],
[
121,
28
],
[
32,
31
],
[
116,
35
],
[
107,
41
],
[
31,
42
],
[
107,
44
],
[
31,
46
],
[
104,
48
],
[
119,
48
],
[
118,
50
],
[
107,
53
],
[
31,
54
],
[
107,
56
],
[
31,
58
],
[
112,
61
],
[
31,
62
],
[
119,
65
],
[
104,
65
],
[
110,
66
],
[
75,
74
],
[
113,
77
],
[
122,
77
],
[
74,
81
],
[
85,
84
],
[
116,
88
],
[
113,
91
],
[
122,
91
],
[
84,
96
],
[
113,
100
],
[
122,
100
],
[
103,
104
],
[
106,
107
],
[
115,
110
],
[
31,
112
],
[
112,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
]
] | [
"n,l=map(int,input().split())\na=list(map(int,input().split()))\nm=0\nx=0\nfor i in range(n-1):\n if((a[i]+a[i+1])>=m):\n m=a[i]+a[i+1]\n x=i\nif(m<l):\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for j in range(x):\n print(j+1)\n for k in range(n-1,x+1,-1):\n print(k)\n print(x+1)",
"n,l=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m=0",
"m",
"0",
"x=0",
"x",
"0",
"for i in range(n-1):\n if((a[i]+a[i+1])>=m):\n m=a[i]+a[i+1]\n x=i",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if((a[i]+a[i+1])>=m):\n m=a[i]+a[i+1]\n x=i",
"(a[i]+a[i+1])>=m",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"m",
"m=a[i]+a[i+1]",
"m",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"x=i",
"x",
"i",
"if(m<l):\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for j in range(x):\n print(j+1)\n for k in range(n-1,x+1,-1):\n print(k)\n print(x+1)",
"m<l",
"m",
"l",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for j in range(x):\n print(j+1)\n ",
"j",
"range(x)",
"range",
"x",
"print(j+1)",
"print",
"j+1",
"j",
"1",
"for k in range(n-1,x+1,-1):\n print(k)\n ",
"k",
"range(n-1,x+1,-1)",
"range",
"n-1",
"n",
"1",
"x+1",
"x",
"1",
"-1",
"print(k)",
"print",
"k",
"print(x+1)",
"print",
"x+1",
"x",
"1",
"m=0",
"0",
"m",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"l=map(int,input().split())",
"map(int,input().split())",
"l",
"x=i",
"i",
"x",
"n,l=map(int,input().split())",
"map(int,input().split())",
"n",
"m=a[i]+a[i+1]",
"a[i]+a[i+1]",
"m",
"x=0",
"0",
"x"
] | n,l=map(int,input().split())
a=list(map(int,input().split()))
m=0
x=0
for i in range(n-1):
if((a[i]+a[i+1])>=m):
m=a[i]+a[i+1]
x=i
if(m<l):
print("Impossible")
else:
print("Possible")
for j in range(x):
print(j+1)
for k in range(n-1,x+1,-1):
print(k)
print(x+1) |
[
7,
15,
12,
13,
0,
13,
39,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
13,
3,
29,
39,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
18,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
2,
13,
17,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
2,
13,
17,
29,
13,
4,
13,
31,
4,
13,
0,
13,
17,
10,
12,
13
] | [
[
6,
5
],
[
10,
9
],
[
10,
18
],
[
21,
20
],
[
33,
32
],
[
9,
36
],
[
20,
42
],
[
32,
43
],
[
20,
45
],
[
32,
47
],
[
18,
49
],
[
52,
51
],
[
32,
52
],
[
59,
58
],
[
51,
63
],
[
5,
67
],
[
58,
69
],
[
72,
71
],
[
9,
75
],
[
51,
78
],
[
5,
83
],
[
71,
85
],
[
5,
88
],
[
51,
91
],
[
5,
94
],
[
105,
99
],
[
102,
101
]
] | [
"from collections import deque\ndef solve():\n ans = ['Possible']\n N, L = map(int, input().split())\n A = list(map(int, input().split()))\n for i in range(N-1):\n if A[i]+A[i+1]>=L:\n ind = i\n break\n else:\n return ['Impossible']\n for i in range(1,ind+1):\n ans.append(i)\n for i in range(N-1,ind+1,-1):\n ans.append(i)\n ans.append(ind+1)\n return ans\nprint(*solve(),sep='\\n')",
"from collections import deque",
"def solve():\n ans = ['Possible']\n N, L = map(int, input().split())\n A = list(map(int, input().split()))\n for i in range(N-1):\n if A[i]+A[i+1]>=L:\n ind = i\n break\n else:\n return ['Impossible']\n for i in range(1,ind+1):\n ans.append(i)\n for i in range(N-1,ind+1,-1):\n ans.append(i)\n ans.append(ind+1)\n return ans",
"solve",
"ans = ['Possible']",
"ans",
"['Possible']",
"'Possible'",
"N, L = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(N-1):\n if A[i]+A[i+1]>=L:\n ind = i\n break\n else:\n return ['Impossible']\n ",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"if A[i]+A[i+1]>=L:\n ind = i\n break\n ",
"A[i]+A[i+1]>=L",
"A[i]+A[i+1]",
"A[i]",
"A",
"i",
"A[i+1]",
"A",
"i+1",
"i",
"1",
"L",
"ind = i",
"ind",
"i",
"break",
"return ['Impossible']",
"['Impossible']",
"'Impossible'",
"for i in range(1,ind+1):\n ans.append(i)\n ",
"i",
"range(1,ind+1)",
"range",
"1",
"ind+1",
"ind",
"1",
"ans.append(i)",
"ans.append",
"ans",
"append",
"i",
"for i in range(N-1,ind+1,-1):\n ans.append(i)\n ",
"i",
"range(N-1,ind+1,-1)",
"range",
"N-1",
"N",
"1",
"ind+1",
"ind",
"1",
"-1",
"ans.append(i)",
"ans.append",
"ans",
"append",
"i",
"ans.append(ind+1)",
"ans.append",
"ans",
"append",
"ind+1",
"ind",
"1",
"return ans",
"ans",
"print(*solve(),sep='\\n')",
"print",
"*solve()",
"solve()",
"solve",
"sep='\\n'",
"sep",
"'\\n'",
"def solve():\n ans = ['Possible']\n N, L = map(int, input().split())\n A = list(map(int, input().split()))\n for i in range(N-1):\n if A[i]+A[i+1]>=L:\n ind = i\n break\n else:\n return ['Impossible']\n for i in range(1,ind+1):\n ans.append(i)\n for i in range(N-1,ind+1,-1):\n ans.append(i)\n ans.append(ind+1)\n return ans",
"def solve():\n ans = ['Possible']\n N, L = map(int, input().split())\n A = list(map(int, input().split()))\n for i in range(N-1):\n if A[i]+A[i+1]>=L:\n ind = i\n break\n else:\n return ['Impossible']\n for i in range(1,ind+1):\n ans.append(i)\n for i in range(N-1,ind+1,-1):\n ans.append(i)\n ans.append(ind+1)\n return ans",
"solve"
] | from collections import deque
def solve():
ans = ['Possible']
N, L = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N-1):
if A[i]+A[i+1]>=L:
ind = i
break
else:
return ['Impossible']
for i in range(1,ind+1):
ans.append(i)
for i in range(N-1,ind+1,-1):
ans.append(i)
ans.append(ind+1)
return ans
print(*solve(),sep='\n') |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
13,
13,
4,
18,
17,
13,
4,
13,
13,
2,
2,
4,
13,
17,
2,
13,
17,
4,
13,
2,
13,
17,
2,
13,
17,
17,
39,
2,
13,
17,
3,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
77,
2
],
[
77,
11
],
[
80,
13
],
[
24,
23
],
[
78,
27
],
[
81,
33
],
[
23,
34
],
[
81,
36
],
[
23,
38
],
[
75,
40
],
[
23,
56
],
[
78,
61
],
[
23,
64
],
[
23,
69
],
[
77,
75
],
[
77,
78
],
[
80,
81
]
] | [
"n, l = map(int, raw_input().split())\nA = map(int, raw_input().split())\n\nfor i in xrange(n-1):\n if A[i]+A[i+1] >= l:\n print \"Possible\"\n print \"\\n\".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))\n break\nelse:\n print \"Impossible\"",
"n, l = map(int, raw_input().split())",
"n",
"map(int, raw_input().split())",
"map",
"int",
"raw_input().split()",
"().split",
"()",
"raw_input",
"split",
"l",
"A = map(int, raw_input().split())",
"A",
"map(int, raw_input().split())",
"map",
"int",
"raw_input().split()",
"().split",
"()",
"raw_input",
"split",
"for i in xrange(n-1):\n if A[i]+A[i+1] >= l:\n print \"Possible\"\n print \"\\n\".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))\n break\nelse:\n print \"Impossible\"",
"i",
"xrange(n-1)",
"xrange",
"n-1",
"n",
"1",
"if A[i]+A[i+1] >= l:\n print \"Possible\"\n print \"\\n\".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))\n break",
"A[i]+A[i+1] >= l",
"A[i]+A[i+1]",
"A[i]",
"A",
"i",
"A[i+1]",
"A",
"i+1",
"i",
"1",
"l",
"print",
"print",
"\"\\n\".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))",
"\"\\n\".join",
"\"\\n\"",
"join",
"map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1])",
"map",
"str",
"range(1, i+1) + range(n-1, i+1, -1) + [i+1]",
"range(1, i+1) + range(n-1, i+1, -1)",
"range(1, i+1)",
"range",
"1",
"i+1",
"i",
"1",
"range(n-1, i+1, -1)",
"range",
"n-1",
"n",
"1",
"i+1",
"i",
"1",
"-1",
"[i+1]",
"i+1",
"i",
"1",
"break",
"print",
"l = map(int, raw_input().split())",
"map(int, raw_input().split())",
"l",
"n, l = map(int, raw_input().split())",
"map(int, raw_input().split())",
"n",
"A = map(int, raw_input().split())",
"map(int, raw_input().split())",
"A"
] | n, l = map(int, raw_input().split())
A = map(int, raw_input().split())
for i in xrange(n-1):
if A[i]+A[i+1] >= l:
print "Possible"
print "\n".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))
break
else:
print "Impossible"
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
13,
17,
13,
2,
13,
17,
13,
39,
13,
17,
13,
17,
28,
13,
4,
13,
2,
13,
17,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
14,
2,
13,
13,
14,
40,
13,
13,
4,
13,
17,
28,
13,
4,
13,
17,
13,
28,
13,
4,
13,
2,
13,
17,
2,
13,
17,
17,
10,
13,
13,
10,
13,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
39,
13,
10,
2,
13,
10,
4,
13
] | [
[
4,
3
],
[
3,
12
],
[
105,
14
],
[
105,
16
],
[
20,
19
],
[
19,
28
],
[
96,
30
],
[
123,
33
],
[
97,
36
],
[
114,
37
],
[
108,
39
],
[
106,
41
],
[
117,
43
],
[
102,
45
],
[
111,
47
],
[
51,
50
],
[
106,
54
],
[
120,
57
],
[
97,
60
],
[
50,
61
],
[
97,
63
],
[
50,
65
],
[
103,
69
],
[
121,
70
],
[
103,
73
],
[
100,
74
],
[
80,
79
],
[
112,
83
],
[
86,
85
],
[
106,
89
],
[
112,
92
],
[
96,
97
],
[
105,
100
],
[
102,
103
],
[
105,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
]
] | [
"n,l = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\ns,x,y,ans,num,z = sum(a),0,n-1,[],0,0\nfor i in range(n-1):\n\tnum2 = a[i]+a[i+1]\n\tif num<num2: num,z = num2,i+1\nif num>=l:\n\tprint(\"Possible\")\n\tfor i in range(1,z): print(i)\n\tfor i in range(n-1,z-1,-1): print(i)\nelse: print(\"Impossible\")",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"n,l = (int(i) for i in input().split())",
"n",
"(int(i) for i in input().split())",
"l",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"a = [int(i) for i in input().split()]",
"a",
"[int(i) for i in input().split()]",
"s,x,y,ans,num,z = sum(a),0,n-1,[],0,0",
"s",
"sum(a)",
"sum",
"a",
"x",
"0",
"y",
"n-1",
"n",
"1",
"ans",
"[]",
"num",
"0",
"z",
"0",
"for i in range(n-1):\n\tnum2 = a[i]+a[i+1]\n\tif num<num2: num,z = num2,i+1",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"num2 = a[i]+a[i+1]",
"num2",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"if num<num2: num,z = num2,i+",
"num<num2",
"num",
"num2",
"if num>=l:\n\tprint(\"Possible\")\n\tfor i in range(1,z): print(i)\n\tfor i in range(n-1,z-1,-1): print(i)\nelse: print(\"Impossible\")",
"num>=l",
"num",
"l",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(1,z): print(i)\n\t",
"i",
"range(1,z)",
"range",
"1",
"z",
"for i in range(n-1,z-1,-1): print(i",
"i",
"range(n-1,z-1,-1)",
"range",
"n-1",
"n",
"1",
"z-1",
"z",
"1",
"-1",
"a = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"a",
"l = (int(i) for i in input().split())",
"(int(i) for i in input().split())",
"l",
"num,z = sum(a),0,n-1,[],0,0",
"0",
"num",
"n,l = (int(i) for i in input().split())",
"(int(i) for i in input().split())",
"n",
"y,ans,num,z = sum(a),0,n-1,[],0,0",
"n-1",
"y",
"z = sum(a),0,n-1,[],0,0",
"0",
"z",
"x,y,ans,num,z = sum(a),0,n-1,[],0,0",
"0",
"x",
"ans,num,z = sum(a),0,n-1,[],0,0",
"[]",
"ans",
"num2 = a[i]+a[i+1]",
"a[i]+a[i+1]",
"num2",
"s,x,y,ans,num,z = sum(a),0,n-1,[],0,0",
"sum(a)",
"s"
] | n,l = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
s,x,y,ans,num,z = sum(a),0,n-1,[],0,0
for i in range(n-1):
num2 = a[i]+a[i+1]
if num<num2: num,z = num2,i+1
if num>=l:
print("Possible")
for i in range(1,z): print(i)
for i in range(n-1,z-1,-1): print(i)
else: print("Impossible") |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
18,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
40,
2,
13,
18,
13,
13,
13,
0,
13,
13,
3,
0,
13,
18,
13,
13,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
0,
13,
17,
42,
2,
13,
13,
4,
13,
13,
0,
13,
17,
0,
13,
2,
13,
17,
42,
2,
2,
13,
17,
13,
4,
13,
13,
0,
13,
17,
10,
2,
13,
10,
18,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] | [
[
120,
2
],
[
120,
11
],
[
123,
13
],
[
114,
25
],
[
124,
27
],
[
102,
30
],
[
34,
33
],
[
112,
37
],
[
115,
41
],
[
100,
41
],
[
124,
43
],
[
33,
44
],
[
121,
45
],
[
105,
47
],
[
33,
48
],
[
99,
51
],
[
124,
53
],
[
33,
54
],
[
106,
57
],
[
103,
57
],
[
126,
66
],
[
127,
70
],
[
109,
70
],
[
106,
71
],
[
103,
71
],
[
127,
74
],
[
109,
74
],
[
108,
76
],
[
96,
79
],
[
112,
81
],
[
106,
86
],
[
103,
86
],
[
97,
88
],
[
109,
88
],
[
127,
88
],
[
118,
88
],
[
97,
91
],
[
109,
91
],
[
127,
91
],
[
118,
91
],
[
117,
93
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
33,
105
],
[
105,
106
],
[
108,
109
],
[
120,
112
],
[
114,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
126,
127
]
] | [
"N, L = map(int, input().split())\nA = list(map(int, input().split()))\npre = A[0]\nindex = -1\nfor i in range(1, N):\n if pre + A[i] >= L:\n index = i\n break\n pre = A[i]\n\nif index == -1:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n i = 1\n while i < index:\n print(i)\n i += 1\n i = N - 1\n while index - 1 < i:\n print(i)\n i -= 1",
"N, L = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"pre = A[0]",
"pre",
"A[0]",
"A",
"0",
"index = -1",
"index",
"-1",
"for i in range(1, N):\n if pre + A[i] >= L:\n index = i\n break\n pre = A[i]",
"i",
"range(1, N)",
"range",
"1",
"N",
"if pre + A[i] >= L:\n index = i\n break\n ",
"pre + A[i] >= L",
"pre + A[i]",
"pre",
"A[i]",
"A",
"i",
"L",
"index = i",
"index",
"i",
"break",
"pre = A[i]",
"pre",
"A[i]",
"A",
"i",
"if index == -1:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n i = 1\n while i < index:\n print(i)\n i += 1\n i = N - 1\n while index - 1 < i:\n print(i)\n i -= 1",
"index == -1",
"index",
"-1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"i = 1",
"i",
"1",
"while i < index:\n print(i)\n i += 1\n ",
"i < index",
"i",
"index",
"print(i)",
"print",
"i",
"i += 1",
"i",
"1",
"i = N - 1",
"i",
"N - 1",
"N",
"1",
"while index - 1 < i:\n print(i)\n i -= 1",
"index - 1 < i",
"index - 1",
"index",
"1",
"i",
"print(i)",
"print",
"i",
"i -= 1",
"i",
"1",
"i = N - 1",
"N - 1",
"i",
"pre = A[i]",
"A[i]",
"pre",
"index = -1",
"-1",
"index",
"index = i",
"i",
"index",
"i += 1",
"1",
"i",
"N, L = map(int, input().split())",
"map(int, input().split())",
"N",
"pre = A[0]",
"A[0]",
"pre",
"i -= 1",
"1",
"i",
"L = map(int, input().split())",
"map(int, input().split())",
"L",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"i = 1",
"1",
"i"
] | N, L = map(int, input().split())
A = list(map(int, input().split()))
pre = A[0]
index = -1
for i in range(1, N):
if pre + A[i] >= L:
index = i
break
pre = A[i]
if index == -1:
print("Impossible")
else:
print("Possible")
i = 1
while i < index:
print(i)
i += 1
i = N - 1
while index - 1 < i:
print(i)
i -= 1 |
[
7,
0,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
18,
13,
17,
0,
13,
4,
13,
18,
13,
17,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
13,
17,
0,
13,
17,
4,
18,
13,
13,
13,
3,
4,
13,
17,
14,
2,
13,
17,
42,
2,
18,
13,
17,
17,
4,
18,
13,
13,
2,
18,
13,
17,
17,
14,
2,
18,
13,
17,
2,
13,
17,
4,
18,
13,
13,
2,
18,
13,
17,
17,
42,
2,
18,
13,
17,
2,
13,
17,
4,
18,
13,
13,
2,
18,
13,
17,
17,
28,
13,
4,
13,
2,
13,
17,
17,
17,
4,
13,
2,
18,
13,
13,
17,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] | [
[
159,
2
],
[
156,
9
],
[
160,
13
],
[
150,
16
],
[
160,
20
],
[
25,
24
],
[
24,
33
],
[
162,
35
],
[
165,
38
],
[
153,
41
],
[
45,
44
],
[
157,
48
],
[
163,
54
],
[
44,
55
],
[
163,
57
],
[
44,
59
],
[
151,
61
],
[
147,
66
],
[
154,
70
],
[
44,
72
],
[
148,
79
],
[
166,
79
],
[
154,
84
],
[
154,
89
],
[
154,
93
],
[
154,
99
],
[
157,
102
],
[
154,
106
],
[
154,
110
],
[
154,
116
],
[
157,
119
],
[
154,
123
],
[
154,
127
],
[
132,
131
],
[
157,
135
],
[
154,
143
],
[
131,
144
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
],
[
165,
166
]
] | [
"temp=input().split()\nN=int(temp[0])\nL=int(temp[1])\na=[int(i) for i in input().split()]\nflag=False\nans=[]\n\nfor i in range(N-1):\n\tif a[i]+a[i+1]>=L:\n\t\tprint(\"Possible\")\n\t\tflag=True\n\t\tans.append(i)\n\t\tbreak\nelse:\n\tprint(\"Impossible\")\n\nif flag==True:\n\twhile ans[-1]>0:\n\t\tans.append(ans[-1]-1)\n\tif ans[0]<N-1:\n\t\tans.append(ans[0]+1)\n\t\twhile ans[-1]<N-2:\n\t\t\tans.append(ans[-1]+1)\n\tfor i in range(N-2,-1,-1):\n\t\tprint(ans[i]+1)",
"temp=input().split()",
"temp",
"input().split()",
"().split",
"()",
"input",
"split",
"N=int(temp[0])",
"N",
"int(temp[0])",
"int",
"temp[0]",
"temp",
"0",
"L=int(temp[1])",
"L",
"int(temp[1])",
"int",
"temp[1]",
"temp",
"1",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"a=[int(i) for i in input().split()]",
"a",
"[int(i) for i in input().split()]",
"flag=False",
"flag",
"False",
"ans=[]",
"ans",
"[]",
"for i in range(N-1):\n\tif a[i]+a[i+1]>=L:\n\t\tprint(\"Possible\")\n\t\tflag=True\n\t\tans.append(i)\n\t\tbreak\nelse:\n\tprint(\"Impossible\")",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"if a[i]+a[i+1]>=L:\n\t\tprint(\"Possible\")\n\t\tflag=True\n\t\tans.append(i)\n\t\tbreak",
"a[i]+a[i+1]>=L",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"L",
"print(\"Possible\")",
"print",
"\"Possible\"",
"flag=True",
"flag",
"True",
"ans.append(i)",
"ans.append",
"ans",
"append",
"i",
"break",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"if flag==True:\n\twhile ans[-1]>0:\n\t\tans.append(ans[-1]-1)\n\tif ans[0]<N-1:\n\t\tans.append(ans[0]+1)\n\t\twhile ans[-1]<N-2:\n\t\t\tans.append(ans[-1]+1)\n\tfor i in range(N-2,-1,-1):\n\t\tprint(ans[i]+1)",
"flag==True",
"flag",
"True",
"while ans[-1]>0:\n\t\tans.append(ans[-1]-1)\n\t",
"ans[-1]>0",
"ans[-1]",
"ans",
"-1",
"0",
"ans.append(ans[-1]-1)",
"ans.append",
"ans",
"append",
"ans[-1]-1",
"ans[-1]",
"ans",
"-1",
"1",
"if ans[0]<N-1:\n\t\tans.append(ans[0]+1)\n\t\twhile ans[-1]<N-2:\n\t\t\tans.append(ans[-1]+1)\n\t",
"ans[0]<N-1",
"ans[0]",
"ans",
"0",
"N-1",
"N",
"1",
"ans.append(ans[0]+1)",
"ans.append",
"ans",
"append",
"ans[0]+1",
"ans[0]",
"ans",
"0",
"1",
"while ans[-1]<N-2:\n\t\t\tans.append(ans[-1]+1)\n\t",
"ans[-1]<N-2",
"ans[-1]",
"ans",
"-1",
"N-2",
"N",
"2",
"ans.append(ans[-1]+1)",
"ans.append",
"ans",
"append",
"ans[-1]+1",
"ans[-1]",
"ans",
"-1",
"1",
"for i in range(N-2,-1,-1):\n\t\tprint(ans[i]+1)",
"i",
"range(N-2,-1,-1)",
"range",
"N-2",
"N",
"2",
"-1",
"-1",
"print(ans[i]+1)",
"print",
"ans[i]+1",
"ans[i]",
"ans",
"i",
"1",
"flag=True",
"True",
"flag",
"L=int(temp[1])",
"int(temp[1])",
"L",
"ans=[]",
"[]",
"ans",
"N=int(temp[0])",
"int(temp[0])",
"N",
"temp=input().split()",
"input().split()",
"temp",
"a=[int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"a",
"flag=False",
"False",
"flag"
] | temp=input().split()
N=int(temp[0])
L=int(temp[1])
a=[int(i) for i in input().split()]
flag=False
ans=[]
for i in range(N-1):
if a[i]+a[i+1]>=L:
print("Possible")
flag=True
ans.append(i)
break
else:
print("Impossible")
if flag==True:
while ans[-1]>0:
ans.append(ans[-1]-1)
if ans[0]<N-1:
ans.append(ans[0]+1)
while ans[-1]<N-2:
ans.append(ans[-1]+1)
for i in range(N-2,-1,-1):
print(ans[i]+1) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
13,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
28,
13,
4,
13,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
2,
13,
17,
17,
4,
13,
2,
13,
17,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] | [
[
115,
2
],
[
115,
11
],
[
106,
13
],
[
100,
25
],
[
118,
28
],
[
32,
31
],
[
116,
35
],
[
107,
41
],
[
31,
42
],
[
107,
44
],
[
31,
46
],
[
101,
48
],
[
104,
48
],
[
103,
50
],
[
107,
53
],
[
31,
54
],
[
107,
56
],
[
31,
58
],
[
109,
61
],
[
31,
62
],
[
104,
65
],
[
101,
65
],
[
113,
66
],
[
75,
74
],
[
110,
77
],
[
119,
77
],
[
74,
81
],
[
85,
84
],
[
116,
88
],
[
110,
91
],
[
119,
91
],
[
84,
97
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
31,
109
],
[
109,
110
],
[
115,
113
],
[
115,
116
],
[
118,
119
]
] | [
"N,L=map(int,input().split())\na=list(map(int,input().split()))\n\naa_max=-1\naa_i=-1\nfor i in range(N-1):\n if a[i]+a[i+1]>aa_max:\n aa_max=a[i]+a[i+1]\n aa_i=i\n#print(aa_max,aa_i)\n\nif aa_max<L:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(aa_i):\n print(i+1)\n for i in range(N-2,aa_i-1,-1):\n print(i+1)",
"N,L=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"aa_max=-1",
"aa_max",
"-1",
"aa_i=-1",
"aa_i",
"-1",
"for i in range(N-1):\n if a[i]+a[i+1]>aa_max:\n aa_max=a[i]+a[i+1]\n aa_i=i\n#print(aa_max,aa_i)",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"if a[i]+a[i+1]>aa_max:\n aa_max=a[i]+a[i+1]\n aa_i=i\n#print(aa_max,aa_i)",
"a[i]+a[i+1]>aa_max",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"aa_max",
"aa_max=a[i]+a[i+1]",
"aa_max",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"aa_i=i",
"aa_i",
"i",
"if aa_max<L:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(aa_i):\n print(i+1)\n for i in range(N-2,aa_i-1,-1):\n print(i+1)",
"aa_max<L",
"aa_max",
"L",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(aa_i):\n print(i+1)\n ",
"i",
"range(aa_i)",
"range",
"aa_i",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"for i in range(N-2,aa_i-1,-1):\n print(i+1)",
"i",
"range(N-2,aa_i-1,-1)",
"range",
"N-2",
"N",
"2",
"aa_i-1",
"aa_i",
"1",
"-1",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"aa_max=-1",
"-1",
"aa_max",
"aa_max=a[i]+a[i+1]",
"a[i]+a[i+1]",
"aa_max",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"aa_i=i",
"i",
"aa_i",
"L=map(int,input().split())",
"map(int,input().split())",
"L",
"N,L=map(int,input().split())",
"map(int,input().split())",
"N",
"aa_i=-1",
"-1",
"aa_i"
] | N,L=map(int,input().split())
a=list(map(int,input().split()))
aa_max=-1
aa_i=-1
for i in range(N-1):
if a[i]+a[i+1]>aa_max:
aa_max=a[i]+a[i+1]
aa_i=i
#print(aa_max,aa_i)
if aa_max<L:
print("Impossible")
else:
print("Possible")
for i in range(aa_i):
print(i+1)
for i in range(N-2,aa_i-1,-1):
print(i+1) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
2,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
28,
13,
4,
13,
17,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
115,
2
],
[
115,
11
],
[
106,
13
],
[
109,
25
],
[
112,
28
],
[
32,
31
],
[
104,
35
],
[
107,
41
],
[
31,
42
],
[
107,
44
],
[
31,
46
],
[
110,
48
],
[
119,
48
],
[
118,
50
],
[
107,
53
],
[
31,
54
],
[
107,
56
],
[
31,
58
],
[
100,
61
],
[
31,
63
],
[
119,
67
],
[
110,
67
],
[
116,
68
],
[
77,
76
],
[
101,
80
],
[
113,
80
],
[
76,
83
],
[
86,
85
],
[
104,
89
],
[
101,
91
],
[
113,
91
],
[
85,
95
],
[
101,
98
],
[
113,
98
],
[
100,
101
],
[
115,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
]
] | [
"N, L = map(int,input().split())\n\nA = list(map(int,input().split()))\n\nMAX = 0\nindex = -1\n\nfor i in range(N-1):\n if A[i] + A[i+1] > MAX:\n MAX = A[i] + A[i+1]\n index = i+1\n\nif MAX < L:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(1,index):\n print(i)\n for i in range(N-1,index,-1):\n print(i)\n print(index)",
"N, L = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"A = list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"MAX = 0",
"MAX",
"0",
"index = -1",
"index",
"-1",
"for i in range(N-1):\n if A[i] + A[i+1] > MAX:\n MAX = A[i] + A[i+1]\n index = i+1",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"if A[i] + A[i+1] > MAX:\n MAX = A[i] + A[i+1]\n index = i+1",
"A[i] + A[i+1] > MAX",
"A[i] + A[i+1]",
"A[i]",
"A",
"i",
"A[i+1]",
"A",
"i+1",
"i",
"1",
"MAX",
"MAX = A[i] + A[i+1]",
"MAX",
"A[i] + A[i+1]",
"A[i]",
"A",
"i",
"A[i+1]",
"A",
"i+1",
"i",
"1",
"index = i+1",
"index",
"i+1",
"i",
"1",
"if MAX < L:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(1,index):\n print(i)\n for i in range(N-1,index,-1):\n print(i)\n print(index)",
"MAX < L",
"MAX",
"L",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(1,index):\n print(i)\n ",
"i",
"range(1,index)",
"range",
"1",
"index",
"print(i)",
"print",
"i",
"for i in range(N-1,index,-1):\n print(i)\n ",
"i",
"range(N-1,index,-1)",
"range",
"N-1",
"N",
"1",
"index",
"-1",
"print(i)",
"print",
"i",
"print(index)",
"print",
"index",
"index = i+1",
"i+1",
"index",
"N, L = map(int,input().split())",
"map(int,input().split())",
"N",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"MAX = 0",
"0",
"MAX",
"index = -1",
"-1",
"index",
"L = map(int,input().split())",
"map(int,input().split())",
"L",
"MAX = A[i] + A[i+1]",
"A[i] + A[i+1]",
"MAX"
] | N, L = map(int,input().split())
A = list(map(int,input().split()))
MAX = 0
index = -1
for i in range(N-1):
if A[i] + A[i+1] > MAX:
MAX = A[i] + A[i+1]
index = i+1
if MAX < L:
print("Impossible")
else:
print("Possible")
for i in range(1,index):
print(i)
for i in range(N-1,index,-1):
print(i)
print(index) |
[
7,
15,
13,
15,
15,
13,
15,
13,
12,
13,
14,
2,
13,
17,
29,
13,
29,
18,
13,
13,
23,
13,
12,
13,
14,
2,
4,
13,
18,
13,
13,
17,
0,
13,
4,
13,
18,
18,
13,
13,
17,
0,
13,
17,
0,
13,
4,
13,
13,
0,
13,
4,
18,
4,
18,
4,
13,
13,
13,
0,
39,
13,
13,
39,
4,
13,
18,
13,
17,
4,
13,
18,
13,
17,
0,
13,
4,
18,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
18,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
0,
13,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
2,
13,
13,
13,
29,
14,
2,
18,
13,
2,
4,
13,
13,
17,
13,
4,
18,
13,
13,
0,
13,
18,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
4,
18,
13,
13,
0,
13,
18,
13,
2,
13,
17,
4,
18,
13,
13,
13,
0,
13,
17,
14,
2,
4,
13,
13,
2,
13,
17,
3,
13,
28,
13,
4,
13,
4,
13,
13,
13,
18,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
21,
12
],
[
21,
18
],
[
21,
21
],
[
34,
33
],
[
43,
42
],
[
46,
45
],
[
229,
47
],
[
42,
48
],
[
33,
48
],
[
51,
50
],
[
45,
56
],
[
63,
60
],
[
50,
67
],
[
50,
72
],
[
76,
75
],
[
45,
81
],
[
87,
86
],
[
75,
94
],
[
50,
94
],
[
86,
95
],
[
98,
97
],
[
102,
101
],
[
97,
110
],
[
101,
111
],
[
97,
113
],
[
101,
115
],
[
119,
118
],
[
124,
123
],
[
97,
126
],
[
129,
128
],
[
132,
131
],
[
118,
134
],
[
137,
136
],
[
140,
139
],
[
123,
147
],
[
183,
147
],
[
166,
147
],
[
118,
154
],
[
118,
158
],
[
118,
163
],
[
167,
166
],
[
97,
168
],
[
131,
169
],
[
176,
169
],
[
136,
172
],
[
131,
174
],
[
176,
174
],
[
177,
176
],
[
118,
180
],
[
184,
183
],
[
97,
185
],
[
128,
187
],
[
195,
187
],
[
136,
191
],
[
128,
193
],
[
195,
193
],
[
196,
195
],
[
136,
201
],
[
209,
208
],
[
136,
213
],
[
136,
216
],
[
208,
217
],
[
226,
223
]
] | [
"import sys\nfrom collections import deque\nimport copy\nimport math\ndef get_read_func(fileobject):\n if fileobject == None :\n return raw_input\n else:\n return fileobject.readline\n\n\ndef main():\n if len(sys.argv) > 1:\n f = open(sys.argv[1])\n else:\n f = None\n read_func = get_read_func(f);\n input_raw = read_func().strip().split()\n [N, L] = [int(input_raw[0]), int(input_raw[1])]\n input_raw = read_func().strip().split()\n A = [int(input_raw[i]) for i in range(N)]\n B = deque([A[i] + A[i + 1] for i in range(N - 1)])\n sumA = sum(A)\n s_idx = 1\n t_idx = len(B)\n seq = []\n for i in range(N - 1):\n if sumA < L:\n print \"Impossible\"\n return\n if B[len(B) - 1] < L:\n B.pop()\n sumA -= A[t_idx]\n seq.append(t_idx)\n t_idx -= 1\n\n else :\n B.popleft()\n sumA -= A[s_idx - 1]\n seq.append(s_idx)\n s_idx += 1\n if len(seq) == N - 1:\n break\n\n print \"Possible\"\n for i in range(len(seq)):\n print seq[i]\n\n\n\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"from collections import deque",
"import copy",
"copy",
"import math",
"math",
"def get_read_func(fileobject):\n if fileobject == None :\n return raw_input\n else:\n return fileobject.readline",
"get_read_func",
"if fileobject == None :\n return raw_input\n else:\n return fileobject.readline",
"fileobject == None",
"fileobject",
"None",
"return raw_input",
"raw_input",
"return fileobject.readline",
"fileobject.readline",
"fileobject",
"readline",
"fileobject",
"fileobject",
"def main():\n if len(sys.argv) > 1:\n f = open(sys.argv[1])\n else:\n f = None\n read_func = get_read_func(f);\n input_raw = read_func().strip().split()\n [N, L] = [int(input_raw[0]), int(input_raw[1])]\n input_raw = read_func().strip().split()\n A = [int(input_raw[i]) for i in range(N)]\n B = deque([A[i] + A[i + 1] for i in range(N - 1)])\n sumA = sum(A)\n s_idx = 1\n t_idx = len(B)\n seq = []\n for i in range(N - 1):\n if sumA < L:\n print \"Impossible\"\n return\n if B[len(B) - 1] < L:\n B.pop()\n sumA -= A[t_idx]\n seq.append(t_idx)\n t_idx -= 1\n\n else :\n B.popleft()\n sumA -= A[s_idx - 1]\n seq.append(s_idx)\n s_idx += 1\n if len(seq) == N - 1:\n break\n\n print \"Possible\"\n for i in range(len(seq)):\n print seq[i]",
"main",
"if len(sys.argv) > 1:\n f = open(sys.argv[1])\n else:\n f = None\n ",
"len(sys.argv) > 1",
"len(sys.argv)",
"len",
"sys.argv",
"sys",
"argv",
"1",
"f = open(sys.argv[1])",
"f",
"open(sys.argv[1])",
"open",
"sys.argv[1]",
"sys.argv",
"sys",
"argv",
"1",
"f = None",
"f",
"None",
"read_func = get_read_func(f)",
"read_func",
"get_read_func(f)",
"get_read_func",
"f",
"input_raw = read_func().strip().split()",
"input_raw",
"read_func().strip().split()",
"().strip().split",
"().strip()",
"().strip",
"()",
"read_func",
"strip",
"split",
"[N, L] = [int(input_raw[0]), int(input_raw[1])]",
"[N, L]",
"N",
"L",
"[int(input_raw[0]), int(input_raw[1])]",
"int(input_raw[0])",
"int",
"input_raw[0]",
"input_raw",
"0",
"int(input_raw[1])",
"int",
"input_raw[1]",
"input_raw",
"1",
"input_raw = read_func().strip().split()",
"input_raw",
"read_func().strip().split()",
"().strip().split",
"().strip()",
"().strip",
"()",
"read_func",
"strip",
"split",
"int(input_raw[i]) for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"int(input_raw[i])",
"int",
"input_raw[i]",
"input_raw",
"i",
"A = [int(input_raw[i]) for i in range(N)]",
"A",
"[int(input_raw[i]) for i in range(N)]",
"A[i] + A[i + 1] for i in range(N - 1)",
"for i in range(N - 1)",
"i",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"for i in range(N - 1)",
"A[i] + A[i + 1]",
"A[i]",
"A",
"i",
"A[i + 1]",
"A",
"i + 1",
"i",
"1",
"B = deque([A[i] + A[i + 1] for i in range(N - 1)])",
"B",
"deque([A[i] + A[i + 1] for i in range(N - 1)])",
"deque",
"[A[i] + A[i + 1] for i in range(N - 1)]",
"sumA = sum(A)",
"sumA",
"sum(A)",
"sum",
"A",
"s_idx = 1",
"s_idx",
"1",
"t_idx = len(B)",
"t_idx",
"len(B)",
"len",
"B",
"seq = []",
"seq",
"[]",
"for i in range(N - 1):\n if sumA < L:\n print \"Impossible\"\n return\n if B[len(B) - 1] < L:\n B.pop()\n sumA -= A[t_idx]\n seq.append(t_idx)\n t_idx -= 1\n\n else :\n B.popleft()\n sumA -= A[s_idx - 1]\n seq.append(s_idx)\n s_idx += 1\n if len(seq) == N - 1:\n break\n\n ",
"i",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"if sumA < L:\n print \"Impossible\"\n return\n ",
"sumA < L",
"sumA",
"L",
"print",
"return",
"if B[len(B) - 1] < L:\n B.pop()\n sumA -= A[t_idx]\n seq.append(t_idx)\n t_idx -= 1\n\n else :\n B.popleft()\n sumA -= A[s_idx - 1]\n seq.append(s_idx)\n s_idx += 1\n ",
"B[len(B) - 1] < L",
"B[len(B) - 1]",
"B",
"len(B) - 1",
"len(B)",
"len",
"B",
"1",
"L",
"B.pop()",
"B.pop",
"B",
"pop",
"sumA -= A[t_idx]",
"sumA",
"A[t_idx]",
"A",
"t_idx",
"seq.append(t_idx)",
"seq.append",
"seq",
"append",
"t_idx",
"t_idx -= 1",
"t_idx",
"1",
"B.popleft()",
"B.popleft",
"B",
"popleft",
"sumA -= A[s_idx - 1]",
"sumA",
"A[s_idx - 1]",
"A",
"s_idx - 1",
"s_idx",
"1",
"seq.append(s_idx)",
"seq.append",
"seq",
"append",
"s_idx",
"s_idx += 1",
"s_idx",
"1",
"if len(seq) == N - 1:\n break\n\n ",
"len(seq) == N - 1",
"len(seq)",
"len",
"seq",
"N - 1",
"N",
"1",
"break",
"print",
"for i in range(len(seq)):\n print seq[i]",
"i",
"range(len(seq))",
"range",
"len(seq)",
"len",
"seq",
"print",
"seq[i]",
"seq",
"i",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n if len(sys.argv) > 1:\n f = open(sys.argv[1])\n else:\n f = None\n read_func = get_read_func(f);\n input_raw = read_func().strip().split()\n [N, L] = [int(input_raw[0]), int(input_raw[1])]\n input_raw = read_func().strip().split()\n A = [int(input_raw[i]) for i in range(N)]\n B = deque([A[i] + A[i + 1] for i in range(N - 1)])\n sumA = sum(A)\n s_idx = 1\n t_idx = len(B)\n seq = []\n for i in range(N - 1):\n if sumA < L:\n print \"Impossible\"\n return\n if B[len(B) - 1] < L:\n B.pop()\n sumA -= A[t_idx]\n seq.append(t_idx)\n t_idx -= 1\n\n else :\n B.popleft()\n sumA -= A[s_idx - 1]\n seq.append(s_idx)\n s_idx += 1\n if len(seq) == N - 1:\n break\n\n print \"Possible\"\n for i in range(len(seq)):\n print seq[i]",
"def main():\n if len(sys.argv) > 1:\n f = open(sys.argv[1])\n else:\n f = None\n read_func = get_read_func(f);\n input_raw = read_func().strip().split()\n [N, L] = [int(input_raw[0]), int(input_raw[1])]\n input_raw = read_func().strip().split()\n A = [int(input_raw[i]) for i in range(N)]\n B = deque([A[i] + A[i + 1] for i in range(N - 1)])\n sumA = sum(A)\n s_idx = 1\n t_idx = len(B)\n seq = []\n for i in range(N - 1):\n if sumA < L:\n print \"Impossible\"\n return\n if B[len(B) - 1] < L:\n B.pop()\n sumA -= A[t_idx]\n seq.append(t_idx)\n t_idx -= 1\n\n else :\n B.popleft()\n sumA -= A[s_idx - 1]\n seq.append(s_idx)\n s_idx += 1\n if len(seq) == N - 1:\n break\n\n print \"Possible\"\n for i in range(len(seq)):\n print seq[i]",
"main",
"def get_read_func(fileobject):\n if fileobject == None :\n return raw_input\n else:\n return fileobject.readline",
"def get_read_func(fileobject):\n if fileobject == None :\n return raw_input\n else:\n return fileobject.readline",
"get_read_func"
] | import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
if fileobject == None :
return raw_input
else:
return fileobject.readline
def main():
if len(sys.argv) > 1:
f = open(sys.argv[1])
else:
f = None
read_func = get_read_func(f);
input_raw = read_func().strip().split()
[N, L] = [int(input_raw[0]), int(input_raw[1])]
input_raw = read_func().strip().split()
A = [int(input_raw[i]) for i in range(N)]
B = deque([A[i] + A[i + 1] for i in range(N - 1)])
sumA = sum(A)
s_idx = 1
t_idx = len(B)
seq = []
for i in range(N - 1):
if sumA < L:
print "Impossible"
return
if B[len(B) - 1] < L:
B.pop()
sumA -= A[t_idx]
seq.append(t_idx)
t_idx -= 1
else :
B.popleft()
sumA -= A[s_idx - 1]
seq.append(s_idx)
s_idx += 1
if len(seq) == N - 1:
break
print "Possible"
for i in range(len(seq)):
print seq[i]
if __name__ == '__main__':
main()
|
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
13,
17,
0,
13,
2,
13,
17,
28,
13,
4,
13,
17,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
13,
4,
13,
13,
29,
4,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
28,
27
],
[
4,
31
],
[
15,
37
],
[
27,
38
],
[
15,
40
],
[
27,
42
],
[
13,
44
],
[
50,
49
],
[
27,
51
],
[
55,
54
],
[
49,
58
],
[
54,
61
],
[
64,
63
],
[
4,
67
],
[
49,
69
],
[
63,
73
],
[
49,
76
],
[
85,
82
]
] | [
"#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\ndef solve():\n N,L = map(int,input().split())\n As = list(map(int,input().split()))\n for i in range(N-1):\n if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n print(n)\n for n in range(N-1, keep, -1):\n print(n)\n print(keep)\n return\n print(\"Impossible\")\n \nsolve()\n",
"def solve():\n N,L = map(int,input().split())\n As = list(map(int,input().split()))\n for i in range(N-1):\n if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n print(n)\n for n in range(N-1, keep, -1):\n print(n)\n print(keep)\n return\n print(\"Impossible\")\n ",
"solve",
"N,L = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"As = list(map(int,input().split()))",
"As",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(N-1):\n if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n print(n)\n for n in range(N-1, keep, -1):\n print(n)\n print(keep)\n return\n ",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n print(n)\n for n in range(N-1, keep, -1):\n print(n)\n print(keep)\n return\n ",
"As[i] + As[i+1] >= L",
"As[i] + As[i+1]",
"As[i]",
"As",
"i",
"As[i+1]",
"As",
"i+1",
"i",
"1",
"L",
"print(\"Possible\")",
"print",
"\"Possible\"",
"keep = i + 1",
"keep",
"i + 1",
"i",
"1",
"for n in range(1,keep):\n print(n)\n ",
"n",
"range(1,keep)",
"range",
"1",
"keep",
"print(n)",
"print",
"n",
"for n in range(N-1, keep, -1):\n print(n)\n ",
"n",
"range(N-1, keep, -1)",
"range",
"N-1",
"N",
"1",
"keep",
"-1",
"print(n)",
"print",
"n",
"print(keep)",
"print",
"keep",
"return",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"solve()",
"solve",
"def solve():\n N,L = map(int,input().split())\n As = list(map(int,input().split()))\n for i in range(N-1):\n if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n print(n)\n for n in range(N-1, keep, -1):\n print(n)\n print(keep)\n return\n print(\"Impossible\")\n ",
"def solve():\n N,L = map(int,input().split())\n As = list(map(int,input().split()))\n for i in range(N-1):\n if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n print(n)\n for n in range(N-1, keep, -1):\n print(n)\n print(keep)\n return\n print(\"Impossible\")\n ",
"solve"
] | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def solve():
N,L = map(int,input().split())
As = list(map(int,input().split()))
for i in range(N-1):
if As[i] + As[i+1] >= L:
print("Possible")
keep = i + 1
for n in range(1,keep):
print(n)
for n in range(N-1, keep, -1):
print(n)
print(keep)
return
print("Impossible")
solve()
|
[
7,
15,
15,
15,
15,
15,
0,
13,
2,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
3,
4,
13,
17,
29,
4,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
12,
13
] | [
[
93,
7
],
[
15,
14
],
[
15,
23
],
[
26,
25
],
[
38,
37
],
[
14,
41
],
[
25,
47
],
[
37,
48
],
[
25,
50
],
[
37,
52
],
[
23,
54
],
[
65,
64
],
[
64,
73
],
[
76,
75
],
[
14,
79
],
[
75,
85
],
[
97,
91
],
[
93,
94
]
] | [
"from collections import defaultdict, Counter\nfrom itertools import product, groupby, count, permutations, combinations\nfrom math import pi, sqrt\nfrom collections import deque\nfrom bisect import bisect, bisect_left, bisect_right\nINF = 10 ** 10\n\n\ndef main():\n N, L = map(int, input().split())\n a_list = list(map(int, input().split()))\n\n for i in range(N - 1):\n if a_list[i] + a_list[i + 1] >= L:\n break\n else:\n print(\"Impossible\")\n return\n\n print(\"Possible\")\n for x in range(1, i + 1):\n print(x)\n for x in range(N - 1, i, -1):\n print(x)\n\n\nif __name__ == '__main__':\n main()",
"from collections import defaultdict, Counter",
"from itertools import product, groupby, count, permutations, combinations",
"from math import pi, sqrt",
"from collections import deque",
"from bisect import bisect, bisect_left, bisect_right",
"INF = 10 ** 10",
"INF",
"10 ** 10",
"10",
"10",
"def main():\n N, L = map(int, input().split())\n a_list = list(map(int, input().split()))\n\n for i in range(N - 1):\n if a_list[i] + a_list[i + 1] >= L:\n break\n else:\n print(\"Impossible\")\n return\n\n print(\"Possible\")\n for x in range(1, i + 1):\n print(x)\n for x in range(N - 1, i, -1):\n print(x)",
"main",
"N, L = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"a_list = list(map(int, input().split()))",
"a_list",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(N - 1):\n if a_list[i] + a_list[i + 1] >= L:\n break\n else:\n print(\"Impossible\")\n return\n\n ",
"i",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"if a_list[i] + a_list[i + 1] >= L:\n break\n ",
"a_list[i] + a_list[i + 1] >= L",
"a_list[i] + a_list[i + 1]",
"a_list[i]",
"a_list",
"i",
"a_list[i + 1]",
"a_list",
"i + 1",
"i",
"1",
"L",
"break",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"return",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for x in range(1, i + 1):\n print(x)\n ",
"x",
"range(1, i + 1)",
"range",
"1",
"i + 1",
"i",
"1",
"print(x)",
"print",
"x",
"for x in range(N - 1, i, -1):\n print(x)",
"x",
"range(N - 1, i, -1)",
"range",
"N - 1",
"N",
"1",
"i",
"-1",
"print(x)",
"print",
"x",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"INF = 10 ** 10",
"10 ** 10",
"INF",
"def main():\n N, L = map(int, input().split())\n a_list = list(map(int, input().split()))\n\n for i in range(N - 1):\n if a_list[i] + a_list[i + 1] >= L:\n break\n else:\n print(\"Impossible\")\n return\n\n print(\"Possible\")\n for x in range(1, i + 1):\n print(x)\n for x in range(N - 1, i, -1):\n print(x)",
"def main():\n N, L = map(int, input().split())\n a_list = list(map(int, input().split()))\n\n for i in range(N - 1):\n if a_list[i] + a_list[i + 1] >= L:\n break\n else:\n print(\"Impossible\")\n return\n\n print(\"Possible\")\n for x in range(1, i + 1):\n print(x)\n for x in range(N - 1, i, -1):\n print(x)",
"main"
] | from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
def main():
N, L = map(int, input().split())
a_list = list(map(int, input().split()))
for i in range(N - 1):
if a_list[i] + a_list[i + 1] >= L:
break
else:
print("Impossible")
return
print("Possible")
for x in range(1, i + 1):
print(x)
for x in range(N - 1, i, -1):
print(x)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
13,
0,
13,
39,
42,
2,
13,
13,
14,
2,
13,
13,
3,
14,
2,
2,
13,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
18,
13,
13,
4,
18,
13,
13,
2,
13,
17,
0,
13,
17,
9,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
18,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
9,
14,
2,
18,
13,
13,
18,
13,
13,
4,
18,
13,
13,
2,
13,
17,
0,
13,
18,
13,
13,
0,
13,
17,
4,
18,
13,
13,
13,
0,
13,
18,
13,
13,
0,
13,
17,
14,
2,
4,
13,
13,
2,
13,
17,
4,
13,
17,
28,
13,
13,
4,
13,
13,
4,
13,
17,
10,
17,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13
] | [
[
211,
2
],
[
211,
11
],
[
15,
14
],
[
14,
23
],
[
208,
25
],
[
202,
28
],
[
199,
31
],
[
179,
33
],
[
190,
36
],
[
209,
39
],
[
184,
41
],
[
203,
45
],
[
182,
45
],
[
206,
45
],
[
200,
46
],
[
170,
46
],
[
188,
46
],
[
191,
49
],
[
197,
49
],
[
176,
49
],
[
173,
49
],
[
194,
49
],
[
212,
50
],
[
200,
55
],
[
170,
55
],
[
188,
55
],
[
203,
56
],
[
182,
56
],
[
206,
56
],
[
209,
62
],
[
203,
63
],
[
182,
63
],
[
206,
63
],
[
209,
65
],
[
203,
67
],
[
182,
67
],
[
206,
67
],
[
212,
69
],
[
193,
71
],
[
209,
73
],
[
203,
74
],
[
182,
74
],
[
206,
74
],
[
185,
77
],
[
203,
80
],
[
182,
80
],
[
206,
80
],
[
205,
83
],
[
209,
90
],
[
200,
91
],
[
170,
91
],
[
188,
91
],
[
209,
93
],
[
200,
95
],
[
170,
95
],
[
188,
95
],
[
212,
97
],
[
172,
99
],
[
209,
101
],
[
200,
102
],
[
170,
102
],
[
188,
102
],
[
185,
105
],
[
200,
107
],
[
170,
107
],
[
188,
107
],
[
187,
109
],
[
209,
115
],
[
206,
116
],
[
203,
116
],
[
182,
116
],
[
209,
118
],
[
188,
119
],
[
200,
119
],
[
170,
119
],
[
185,
122
],
[
206,
125
],
[
203,
125
],
[
182,
125
],
[
175,
128
],
[
209,
130
],
[
206,
131
],
[
203,
131
],
[
182,
131
],
[
181,
133
],
[
185,
137
],
[
188,
139
],
[
200,
139
],
[
170,
139
],
[
196,
141
],
[
209,
143
],
[
188,
144
],
[
200,
144
],
[
170,
144
],
[
169,
146
],
[
185,
152
],
[
179,
154
],
[
161,
160
],
[
185,
160
],
[
160,
164
],
[
169,
170
],
[
172,
173
],
[
175,
176
],
[
211,
179
],
[
181,
182
],
[
184,
185
],
[
187,
188
],
[
190,
191
],
[
193,
194
],
[
196,
197
],
[
199,
200
],
[
202,
203
],
[
205,
206
],
[
208,
209
],
[
211,
212
]
] | [
"N,L = map(int, input().split())\nA = [int(a) for a in input().split()]\n\nl = 0\nr = N-1\ns = sum(A)\nans = []\nwhile l < r:\n if s < L:\n break\n if r-l > 1:\n if A[l]+A[l+1] < L:\n s -= A[l]\n ans.append(l+1)\n l += 1\n continue\n if A[r]+A[r-1] < L:\n s -= A[r]\n ans.append(r)\n r -= 1\n continue\n if A[l] < A[r]:\n ans.append(l+1)\n s -= A[l]\n l += 1\n else:\n ans.append(r)\n s -= A[r]\n r -= 1\n \nif len(ans) == N-1:\n print(\"Possible\")\n for a in ans:\n print(a)\nelse:\n print(\"Impossible\")",
"N,L = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"int(a) for a in input().split()",
"for a in input().split()",
"a",
"input().split()",
"().split",
"()",
"input",
"split",
"for a in input().split()",
"int(a)",
"int",
"a",
"A = [int(a) for a in input().split()]",
"A",
"[int(a) for a in input().split()]",
"l = 0",
"l",
"0",
"r = N-1",
"r",
"N-1",
"N",
"1",
"s = sum(A)",
"s",
"sum(A)",
"sum",
"A",
"ans = []",
"ans",
"[]",
"while l < r:\n if s < L:\n break\n if r-l > 1:\n if A[l]+A[l+1] < L:\n s -= A[l]\n ans.append(l+1)\n l += 1\n continue\n if A[r]+A[r-1] < L:\n s -= A[r]\n ans.append(r)\n r -= 1\n continue\n if A[l] < A[r]:\n ans.append(l+1)\n s -= A[l]\n l += 1\n else:\n ans.append(r)\n s -= A[r]\n r -= 1\n ",
"l < r",
"l",
"r",
"if s < L:\n break\n ",
"s < L",
"s",
"L",
"break",
"if r-l > 1:\n if A[l]+A[l+1] < L:\n s -= A[l]\n ans.append(l+1)\n l += 1\n continue\n if A[r]+A[r-1] < L:\n s -= A[r]\n ans.append(r)\n r -= 1\n continue\n ",
"r-l > 1",
"r-l",
"r",
"l",
"1",
"if A[l]+A[l+1] < L:\n s -= A[l]\n ans.append(l+1)\n l += 1\n continue\n ",
"A[l]+A[l+1] < L",
"A[l]+A[l+1]",
"A[l]",
"A",
"l",
"A[l+1]",
"A",
"l+1",
"l",
"1",
"L",
"s -= A[l]",
"s",
"A[l]",
"A",
"l",
"ans.append(l+1)",
"ans.append",
"ans",
"append",
"l+1",
"l",
"1",
"l += 1",
"l",
"1",
"continue",
"if A[r]+A[r-1] < L:\n s -= A[r]\n ans.append(r)\n r -= 1\n continue\n ",
"A[r]+A[r-1] < L",
"A[r]+A[r-1]",
"A[r]",
"A",
"r",
"A[r-1]",
"A",
"r-1",
"r",
"1",
"L",
"s -= A[r]",
"s",
"A[r]",
"A",
"r",
"ans.append(r)",
"ans.append",
"ans",
"append",
"r",
"r -= 1",
"r",
"1",
"continue",
"if A[l] < A[r]:\n ans.append(l+1)\n s -= A[l]\n l += 1\n else:\n ans.append(r)\n s -= A[r]\n r -= 1\n ",
"A[l] < A[r]",
"A[l]",
"A",
"l",
"A[r]",
"A",
"r",
"ans.append(l+1)",
"ans.append",
"ans",
"append",
"l+1",
"l",
"1",
"s -= A[l]",
"s",
"A[l]",
"A",
"l",
"l += 1",
"l",
"1",
"ans.append(r)",
"ans.append",
"ans",
"append",
"r",
"s -= A[r]",
"s",
"A[r]",
"A",
"r",
"r -= 1",
"r",
"1",
"if len(ans) == N-1:\n print(\"Possible\")\n for a in ans:\n print(a)\nelse:\n print(\"Impossible\")",
"len(ans) == N-1",
"len(ans)",
"len",
"ans",
"N-1",
"N",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for a in ans:\n print(a)",
"a",
"ans",
"print(a)",
"print",
"a",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"r -= 1",
"1",
"r",
"s -= A[r]",
"A[r]",
"s",
"s -= A[l]",
"A[l]",
"s",
"N,L = map(int, input().split())",
"map(int, input().split())",
"N",
"l += 1",
"1",
"l",
"ans = []",
"[]",
"ans",
"r -= 1",
"1",
"r",
"s = sum(A)",
"sum(A)",
"s",
"s -= A[l]",
"A[l]",
"s",
"s -= A[r]",
"A[r]",
"s",
"r = N-1",
"N-1",
"r",
"l = 0",
"0",
"l",
"l += 1",
"1",
"l",
"A = [int(a) for a in input().split()]",
"[int(a) for a in input().split()]",
"A",
"L = map(int, input().split())",
"map(int, input().split())",
"L"
] | N,L = map(int, input().split())
A = [int(a) for a in input().split()]
l = 0
r = N-1
s = sum(A)
ans = []
while l < r:
if s < L:
break
if r-l > 1:
if A[l]+A[l+1] < L:
s -= A[l]
ans.append(l+1)
l += 1
continue
if A[r]+A[r-1] < L:
s -= A[r]
ans.append(r)
r -= 1
continue
if A[l] < A[r]:
ans.append(l+1)
s -= A[l]
l += 1
else:
ans.append(r)
s -= A[r]
r -= 1
if len(ans) == N-1:
print("Possible")
for a in ans:
print(a)
else:
print("Impossible") |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
18,
13,
13,
2,
13,
17,
3,
14,
4,
13,
13,
0,
13,
2,
18,
13,
17,
17,
42,
2,
13,
17,
4,
18,
13,
13,
13,
0,
13,
17,
0,
13,
2,
18,
13,
17,
17,
42,
2,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
4,
13,
17,
28,
13,
4,
13,
2,
13,
17,
17,
17,
4,
13,
18,
13,
13,
4,
13,
17,
10,
18,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13
] | [
[
128,
4
],
[
143,
13
],
[
129,
20
],
[
143,
22
],
[
152,
24
],
[
129,
33
],
[
140,
36
],
[
40,
39
],
[
135,
43
],
[
153,
49
],
[
39,
50
],
[
153,
52
],
[
39,
54
],
[
144,
56
],
[
141,
59
],
[
39,
62
],
[
141,
68
],
[
131,
70
],
[
141,
73
],
[
132,
78
],
[
150,
78
],
[
141,
82
],
[
132,
84
],
[
150,
84
],
[
149,
86
],
[
146,
89
],
[
141,
92
],
[
147,
97
],
[
150,
97
],
[
132,
97
],
[
138,
97
],
[
135,
98
],
[
141,
101
],
[
147,
103
],
[
150,
103
],
[
132,
103
],
[
138,
103
],
[
137,
105
],
[
112,
111
],
[
135,
115
],
[
141,
122
],
[
111,
123
],
[
128,
129
],
[
131,
132
],
[
143,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
]
] | [
"import sys\ninput = sys.stdin.buffer.readline\nN, L = map(int, input().split())\na = list(map(int, input().split()))\nres = []\nfor i in range(N - 1):\n if a[i] + a[i + 1] >= L:\n res.append(i + 1)\n break\nif len(res):\n i = res[0] - 1\n while i > 0:\n res.append(i)\n i -= 1\n i = res[0] + 1\n while i < N:\n res.append(i)\n i += 1\n print(\"Possible\")\n for i in range(N - 2, -1, -1):\n print(res[i])\nelse:\n print(\"Impossible\")",
"import sys",
"sys",
"input = sys.stdin.buffer.readline",
"input",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"N, L = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"res = []",
"res",
"[]",
"for i in range(N - 1):\n if a[i] + a[i + 1] >= L:\n res.append(i + 1)\n break",
"i",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"if a[i] + a[i + 1] >= L:\n res.append(i + 1)\n break",
"a[i] + a[i + 1] >= L",
"a[i] + a[i + 1]",
"a[i]",
"a",
"i",
"a[i + 1]",
"a",
"i + 1",
"i",
"1",
"L",
"res.append(i + 1)",
"res.append",
"res",
"append",
"i + 1",
"i",
"1",
"break",
"if len(res):\n i = res[0] - 1\n while i > 0:\n res.append(i)\n i -= 1\n i = res[0] + 1\n while i < N:\n res.append(i)\n i += 1\n print(\"Possible\")\n for i in range(N - 2, -1, -1):\n print(res[i])\nelse:\n print(\"Impossible\")",
"len(res)",
"len",
"res",
"i = res[0] - 1",
"i",
"res[0] - 1",
"res[0]",
"res",
"0",
"1",
"while i > 0:\n res.append(i)\n i -= 1\n ",
"i > 0",
"i",
"0",
"res.append(i)",
"res.append",
"res",
"append",
"i",
"i -= 1",
"i",
"1",
"i = res[0] + 1",
"i",
"res[0] + 1",
"res[0]",
"res",
"0",
"1",
"while i < N:\n res.append(i)\n i += 1\n ",
"i < N",
"i",
"N",
"res.append(i)",
"res.append",
"res",
"append",
"i",
"i += 1",
"i",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(N - 2, -1, -1):\n print(res[i])",
"i",
"range(N - 2, -1, -1)",
"range",
"N - 2",
"N",
"2",
"-1",
"-1",
"print(res[i])",
"print",
"res[i]",
"res",
"i",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"input = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"input",
"i = res[0] - 1",
"res[0] - 1",
"i",
"N, L = map(int, input().split())",
"map(int, input().split())",
"N",
"i += 1",
"1",
"i",
"res = []",
"[]",
"res",
"L = map(int, input().split())",
"map(int, input().split())",
"L",
"i = res[0] + 1",
"res[0] + 1",
"i",
"i -= 1",
"1",
"i",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a"
] | import sys
input = sys.stdin.buffer.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in range(N - 1):
if a[i] + a[i + 1] >= L:
res.append(i + 1)
break
if len(res):
i = res[0] - 1
while i > 0:
res.append(i)
i -= 1
i = res[0] + 1
while i < N:
res.append(i)
i += 1
print("Possible")
for i in range(N - 2, -1, -1):
print(res[i])
else:
print("Impossible") |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
17,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
14,
40,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
13,
0,
13,
17,
3,
14,
2,
13,
17,
28,
13,
4,
13,
13,
4,
18,
13,
13,
2,
13,
17,
28,
13,
18,
4,
13,
2,
13,
17,
13,
39,
17,
4,
18,
13,
13,
13,
4,
13,
13,
28,
13,
4,
13,
4,
13,
13,
4,
13,
18,
13,
13,
4,
13,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13
] | [
[
130,
2
],
[
130,
13
],
[
121,
15
],
[
122,
28
],
[
112,
32
],
[
115,
35
],
[
39,
38
],
[
131,
41
],
[
119,
44
],
[
122,
47
],
[
38,
48
],
[
122,
50
],
[
38,
52
],
[
127,
55
],
[
38,
56
],
[
124,
58
],
[
125,
63
],
[
116,
63
],
[
67,
66
],
[
128,
69
],
[
113,
72
],
[
66,
75
],
[
79,
78
],
[
128,
83
],
[
131,
85
],
[
113,
90
],
[
78,
92
],
[
125,
95
],
[
116,
95
],
[
98,
97
],
[
113,
102
],
[
113,
106
],
[
97,
107
],
[
125,
110
],
[
116,
110
],
[
112,
113
],
[
115,
116
],
[
130,
119
],
[
121,
122
],
[
124,
125
],
[
38,
127
],
[
127,
128
],
[
130,
131
]
] | [
"N,L = list(map(int,input().split()))\na = list(map(int,input().split()))\na.append(0)\nb = []\nres = \"Impossible\"\n\nfor i in range(N):\n if L <= (a[i]+a[i+1]):\n count = i\n res = \"Possible\"\n break\n\nif res ==\"Possible\":\n for j in range(count):\n b.append(j+1)\n for k in range(count+1,N)[::-1]:\n b.append(k)\n \n print(res)\n for l in range(len(b)):\n print(b[l])\nelse:\n print(res)\n",
"N,L = list(map(int,input().split()))",
"N",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"L",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a.append(0)",
"a.append",
"a",
"append",
"0",
"b = []",
"b",
"[]",
"res = \"Impossible\"",
"res",
"\"Impossible\"",
"for i in range(N):\n if L <= (a[i]+a[i+1]):\n count = i\n res = \"Possible\"\n break",
"i",
"range(N)",
"range",
"N",
"if L <= (a[i]+a[i+1]):\n count = i\n res = \"Possible\"\n break",
"L <= (a[i]+a[i+1])",
"L",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"count = i",
"count",
"i",
"res = \"Possible\"",
"res",
"\"Possible\"",
"break",
"if res ==\"Possible\":\n for j in range(count):\n b.append(j+1)\n for k in range(count+1,N)[::-1]:\n b.append(k)\n \n print(res)\n for l in range(len(b)):\n print(b[l])\nelse:\n print(res)",
"res ==\"Possible\"",
"res",
"\"Possible\"",
"for j in range(count):\n b.append(j+1)\n ",
"j",
"range(count)",
"range",
"count",
"b.append(j+1)",
"b.append",
"b",
"append",
"j+1",
"j",
"1",
"for k in range(count+1,N)[::-1]:\n b.append(k)\n \n ",
"k",
"range(count+1,N)[::-1]",
"(count+1,N)",
"range",
"count+1",
"count",
"1",
"N",
"::-1",
"-1",
"b.append(k)",
"b.append",
"b",
"append",
"k",
"print(res)",
"print",
"res",
"for l in range(len(b)):\n print(b[l])",
"l",
"range(len(b))",
"range",
"len(b)",
"len",
"b",
"print(b[l])",
"print",
"b[l]",
"b",
"l",
"print(res)",
"print",
"res",
"b = []",
"[]",
"b",
"res = \"Impossible\"",
"\"Impossible\"",
"res",
"L = list(map(int,input().split()))",
"list(map(int,input().split()))",
"L",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"res = \"Possible\"",
"\"Possible\"",
"res",
"count = i",
"i",
"count",
"N,L = list(map(int,input().split()))",
"list(map(int,input().split()))",
"N"
] | N,L = list(map(int,input().split()))
a = list(map(int,input().split()))
a.append(0)
b = []
res = "Impossible"
for i in range(N):
if L <= (a[i]+a[i+1]):
count = i
res = "Possible"
break
if res =="Possible":
for j in range(count):
b.append(j+1)
for k in range(count+1,N)[::-1]:
b.append(k)
print(res)
for l in range(len(b)):
print(b[l])
else:
print(res)
|
[
7,
12,
13,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
13,
14,
40,
13,
29,
39,
17,
0,
13,
39,
13,
28,
13,
4,
13,
2,
13,
17,
13,
4,
18,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
17,
17,
4,
18,
13,
13,
13,
29,
2,
39,
17,
18,
13,
39,
17,
23,
13,
23,
13,
23,
13,
14,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
13,
13,
4,
13,
31,
13,
0,
13,
17,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
5,
4
],
[
8,
7
],
[
76,
11
],
[
80,
16
],
[
7,
17
],
[
80,
19
],
[
7,
21
],
[
78,
23
],
[
26,
25
],
[
29,
28
],
[
7,
29
],
[
25,
32
],
[
4,
32
],
[
38,
37
],
[
42,
41
],
[
28,
45
],
[
76,
47
],
[
37,
50
],
[
41,
52
],
[
55,
54
],
[
28,
58
],
[
37,
64
],
[
54,
66
],
[
37,
72
],
[
76,
76
],
[
78,
78
],
[
80,
80
],
[
132,
86
],
[
132,
95
],
[
129,
97
],
[
135,
109
],
[
127,
111
],
[
124,
112
],
[
133,
113
],
[
130,
114
],
[
136,
118
],
[
121,
120
],
[
132,
124
],
[
129,
130
],
[
132,
133
],
[
135,
136
]
] | [
"\ndef know(N, K, A):\n isOK = False\n for i in range(1, N):\n if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n if not isOK:\n return [\"Impossible\"]\n\n ans = [first]\n for i in range(first + 1, N):\n ans.append(i)\n for i in range(first - 1, 0, -1):\n ans.append(i)\n return [\"Possible\"] + ans[::-1]\n\n\nif __name__ == \"__main__\":\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n ans = know(N, K, A)\n print(*ans, sep=\"\\n\")",
"def know(N, K, A):\n isOK = False\n for i in range(1, N):\n if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n if not isOK:\n return [\"Impossible\"]\n\n ans = [first]\n for i in range(first + 1, N):\n ans.append(i)\n for i in range(first - 1, 0, -1):\n ans.append(i)\n return [\"Possible\"] + ans[::-1]",
"know",
"isOK = False",
"isOK",
"False",
"for i in range(1, N):\n if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n ",
"i",
"range(1, N)",
"range",
"1",
"N",
"if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n ",
"A[i] + A[i - 1] >= K",
"A[i] + A[i - 1]",
"A[i]",
"A",
"i",
"A[i - 1]",
"A",
"i - 1",
"i",
"1",
"K",
"isOK = True",
"isOK",
"True",
"first = i",
"first",
"i",
"if not isOK:\n return [\"Impossible\"]\n\n ",
"not isOK",
"isOK",
"return [\"Impossible\"]",
"[\"Impossible\"]",
"\"Impossible\"",
"ans = [first]",
"ans",
"[first]",
"first",
"for i in range(first + 1, N):\n ans.append(i)\n ",
"i",
"range(first + 1, N)",
"range",
"first + 1",
"first",
"1",
"N",
"ans.append(i)",
"ans.append",
"ans",
"append",
"i",
"for i in range(first - 1, 0, -1):\n ans.append(i)\n ",
"i",
"range(first - 1, 0, -1)",
"range",
"first - 1",
"first",
"1",
"0",
"-1",
"ans.append(i)",
"ans.append",
"ans",
"append",
"i",
"return [\"Possible\"] + ans[::-1]",
"[\"Possible\"] + ans[::-1]",
"[\"Possible\"]",
"\"Possible\"",
"ans[::-1]",
"ans",
"::-1",
"-1",
"N",
"N",
"K",
"K",
"A",
"A",
"if __name__ == \"__main__\":\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n ans = know(N, K, A)\n print(*ans, sep=\"\\n\")",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"N, K = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"K",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans = know(N, K, A)",
"ans",
"know(N, K, A)",
"know",
"N",
"K",
"A",
"print(*ans, sep=\"\\n\")",
"print",
"*ans",
"ans",
"sep=\"\\n\"",
"sep",
"\"\\n\"",
"N, K = map(int, input().split())",
"map(int, input().split())",
"N",
"def know(N, K, A):\n isOK = False\n for i in range(1, N):\n if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n if not isOK:\n return [\"Impossible\"]\n\n ans = [first]\n for i in range(first + 1, N):\n ans.append(i)\n for i in range(first - 1, 0, -1):\n ans.append(i)\n return [\"Possible\"] + ans[::-1]",
"def know(N, K, A):\n isOK = False\n for i in range(1, N):\n if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n if not isOK:\n return [\"Impossible\"]\n\n ans = [first]\n for i in range(first + 1, N):\n ans.append(i)\n for i in range(first - 1, 0, -1):\n ans.append(i)\n return [\"Possible\"] + ans[::-1]",
"know",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"K = map(int, input().split())",
"map(int, input().split())",
"K",
"ans = know(N, K, A)",
"know(N, K, A)",
"ans"
] |
def know(N, K, A):
isOK = False
for i in range(1, N):
if A[i] + A[i - 1] >= K:
isOK = True
first = i
if not isOK:
return ["Impossible"]
ans = [first]
for i in range(first + 1, N):
ans.append(i)
for i in range(first - 1, 0, -1):
ans.append(i)
return ["Possible"] + ans[::-1]
if __name__ == "__main__":
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = know(N, K, A)
print(*ans, sep="\n")
|
[
7,
15,
15,
15,
15,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
0,
13,
17,
0,
13,
17,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
13,
38,
5,
4,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
2,
13,
17,
17,
4,
18,
13,
13,
2,
13,
17,
4,
13,
17,
4,
13,
4,
18,
17,
13,
4,
13,
13,
13,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13
] | [
[
240,
17
],
[
279,
24
],
[
45,
44
],
[
235,
50
],
[
54,
54
],
[
58,
57
],
[
283,
63
],
[
67,
67
],
[
71,
70
],
[
271,
76
],
[
80,
80
],
[
84,
83
],
[
283,
89
],
[
93,
93
],
[
97,
96
],
[
262,
102
],
[
106,
106
],
[
110,
109
],
[
265,
115
],
[
119,
119
],
[
123,
122
],
[
250,
128
],
[
132,
132
],
[
255,
134
],
[
267,
137
],
[
143,
142
],
[
283,
144
],
[
143,
145
],
[
148,
147
],
[
283,
149
],
[
152,
151
],
[
142,
155
],
[
147,
161
],
[
151,
162
],
[
147,
164
],
[
151,
166
],
[
145,
168
],
[
171,
170
],
[
151,
171
],
[
179,
178
],
[
182,
181
],
[
170,
184
],
[
178,
187
],
[
181,
190
],
[
194,
193
],
[
142,
197
],
[
170,
200
],
[
178,
205
],
[
193,
208
],
[
178,
222
],
[
247,
229
],
[
240,
241
],
[
255,
256
],
[
267,
268
],
[
279,
280
]
] | [
"#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n, l = LI()\n a = LI()\n for i in range(n - 1):\n if a[i] + a[i + 1] >= l:\n x = i\n try:\n ans = []\n for j in range(x):\n ans.append(j + 1)\n for j in range(n - 2, x - 1, -1):\n ans.append(j + 1)\n print(\"Possible\")\n print(\"\\n\".join(map(str, ans)))\n except:\n print(\"Impossible\")\n return\n\n\n#main\nif __name__ == '__main__':\n solve()",
"from collections import defaultdict,deque",
"from heapq import heappush, heappop",
"from bisect import bisect_left, bisect_right",
"import sys, random, itertools, math",
"sys",
"random",
"itertools",
"math",
"sys.setrecursionlimit(10**5)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**5",
"10",
"5",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"sqrt = math.sqrt",
"sqrt",
"math.sqrt",
"math",
"sqrt",
"def LI(): return list(map(int, input().split()))",
"LI",
"def LF(): return list(map(float, input().split()))",
"LF",
"def LI_(): return list(map(lambda x: int(x)-1, input().split()))",
"LI_",
"def II(): return int(input())",
"II",
"def IF(): return float(input())",
"IF",
"def S(): return input().rstrip()",
"S",
"def LS(): return S().split()",
"LS",
"II() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"II()",
"II",
"def IR(n): return [II() for _ in range(n)]",
"IR",
"n",
"n",
"LI() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LI()",
"LI",
"def LIR(n): return [LI() for _ in range(n)]",
"LIR",
"n",
"n",
"IF() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"IF()",
"IF",
"def FR(n): return [IF() for _ in range(n)]",
"FR",
"n",
"n",
"LI() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LI()",
"LI",
"def LFR(n): return [LI() for _ in range(n)]",
"LFR",
"n",
"n",
"LI_() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LI_()",
"LI_",
"def LIR_(n): return [LI_() for _ in range(n)]",
"LIR_",
"n",
"n",
"S() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"S()",
"S",
"def SR(n): return [S() for _ in range(n)]",
"SR",
"n",
"n",
"LS() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LS()",
"LS",
"def LSR(n): return [LS() for _ in range(n)]",
"LSR",
"n",
"n",
"mod = 1000000007",
"mod",
"1000000007",
"inf = 1e10",
"inf",
"1e10",
"def solve():\n n, l = LI()\n a = LI()\n for i in range(n - 1):\n if a[i] + a[i + 1] >= l:\n x = i\n try:\n ans = []\n for j in range(x):\n ans.append(j + 1)\n for j in range(n - 2, x - 1, -1):\n ans.append(j + 1)\n print(\"Possible\")\n print(\"\\n\".join(map(str, ans)))\n except:\n print(\"Impossible\")\n return\n\n\n#main",
"solve",
"n, l = LI()",
"n",
"LI()",
"LI",
"l",
"a = LI()",
"a",
"LI()",
"LI",
"for i in range(n - 1):\n if a[i] + a[i + 1] >= l:\n x = i\n ",
"i",
"range(n - 1)",
"range",
"n - 1",
"n",
"1",
"if a[i] + a[i + 1] >= l:\n x = i\n ",
"a[i] + a[i + 1] >= l",
"a[i] + a[i + 1]",
"a[i]",
"a",
"i",
"a[i + 1]",
"a",
"i + 1",
"i",
"1",
"l",
"x = i",
"x",
"i",
"try:\n ans = []\n for j in range(x):\n ans.append(j + 1)\n for j in range(n - 2, x - 1, -1):\n ans.append(j + 1)\n print(\"Possible\")\n print(\"\\n\".join(map(str, ans)))\n except:\n print(\"Impossible\")\n ",
"except:\n print(\"Impossible\")\n ",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"ans = []",
"ans",
"[]",
"for j in range(x):\n ans.append(j + 1)\n ",
"j",
"range(x)",
"range",
"x",
"ans.append(j + 1)",
"ans.append",
"ans",
"append",
"j + 1",
"j",
"1",
"for j in range(n - 2, x - 1, -1):\n ans.append(j + 1)\n ",
"j",
"range(n - 2, x - 1, -1)",
"range",
"n - 2",
"n",
"2",
"x - 1",
"x",
"1",
"-1",
"ans.append(j + 1)",
"ans.append",
"ans",
"append",
"j + 1",
"j",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"\\n\".join(map(str, ans)))",
"print",
"\"\\n\".join(map(str, ans))",
"\"\\n\".join",
"\"\\n\"",
"join",
"map(str, ans)",
"map",
"str",
"ans",
"return",
"if __name__ == '__main__':\n solve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"solve()",
"solve",
"def LF(): return list(map(float, input().split()))",
"def LF(): return list(map(float, input().split()))",
"LF",
"def II(): return int(input())",
"def II(): return int(input())",
"II",
"def IR(n): return [II() for _ in range(n)]",
"def IR(n): return [II() for _ in range(n)]",
"IR",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def LIR_(n): return [LI_() for _ in range(n)]",
"def LIR_(n): return [LI_() for _ in range(n)]",
"LIR_",
"def solve():\n n, l = LI()\n a = LI()\n for i in range(n - 1):\n if a[i] + a[i + 1] >= l:\n x = i\n try:\n ans = []\n for j in range(x):\n ans.append(j + 1)\n for j in range(n - 2, x - 1, -1):\n ans.append(j + 1)\n print(\"Possible\")\n print(\"\\n\".join(map(str, ans)))\n except:\n print(\"Impossible\")\n return\n\n\n#main",
"def solve():\n n, l = LI()\n a = LI()\n for i in range(n - 1):\n if a[i] + a[i + 1] >= l:\n x = i\n try:\n ans = []\n for j in range(x):\n ans.append(j + 1)\n for j in range(n - 2, x - 1, -1):\n ans.append(j + 1)\n print(\"Possible\")\n print(\"\\n\".join(map(str, ans)))\n except:\n print(\"Impossible\")\n return\n\n\n#main",
"solve",
"def LS(): return S().split()",
"def LS(): return S().split()",
"LS",
"def SR(n): return [S() for _ in range(n)]",
"def SR(n): return [S() for _ in range(n)]",
"SR",
"mod = 1000000007",
"1000000007",
"mod",
"def FR(n): return [IF() for _ in range(n)]",
"def FR(n): return [IF() for _ in range(n)]",
"FR",
"def LI_(): return list(map(lambda x: int(x)-1, input().split()))",
"def LI_(): return list(map(lambda x: int(x)-1, input().split()))",
"LI_",
"def S(): return input().rstrip()",
"def S(): return input().rstrip()",
"S",
"inf = 1e10",
"1e10",
"inf",
"def IF(): return float(input())",
"def IF(): return float(input())",
"IF",
"def LFR(n): return [LI() for _ in range(n)]",
"def LFR(n): return [LI() for _ in range(n)]",
"LFR",
"def LSR(n): return [LS() for _ in range(n)]",
"def LSR(n): return [LS() for _ in range(n)]",
"LSR",
"sqrt = math.sqrt",
"math.sqrt",
"sqrt",
"def LI(): return list(map(int, input().split()))",
"def LI(): return list(map(int, input().split()))",
"LI",
"def LIR(n): return [LI() for _ in range(n)]",
"def LIR(n): return [LI() for _ in range(n)]",
"LIR"
] | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
#solve
def solve():
n, l = LI()
a = LI()
for i in range(n - 1):
if a[i] + a[i + 1] >= l:
x = i
try:
ans = []
for j in range(x):
ans.append(j + 1)
for j in range(n - 2, x - 1, -1):
ans.append(j + 1)
print("Possible")
print("\n".join(map(str, ans)))
except:
print("Impossible")
return
#main
if __name__ == '__main__':
solve()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
0,
13,
17,
0,
13,
17,
28,
13,
39,
13,
13,
4,
13,
4,
13,
13,
18,
13,
39,
17,
17,
14,
2,
2,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
4,
13,
31,
4,
13,
17,
13,
4,
13,
31,
4,
13,
2,
13,
17,
13,
17,
4,
13,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13
] | [
[
96,
2
],
[
96,
15
],
[
96,
16
],
[
99,
19
],
[
99,
22
],
[
88,
44
],
[
85,
44
],
[
84,
46
],
[
93,
51
],
[
85,
55
],
[
88,
55
],
[
97,
56
],
[
94,
69
],
[
100,
69
],
[
91,
76
],
[
94,
78
],
[
100,
78
],
[
94,
82
],
[
100,
82
],
[
84,
85
],
[
99,
88
],
[
96,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
]
] | [
"n,l,*a=map(int,open(0).read().split())\ni=m=0\nfor j,(x,y)in enumerate(zip(a,a[1:]),1):\n if x+y>m:\n m=x+y\n i=j\nif m<l:\n print('Impossible')\nelse:\n print('Possible')\n print(*range(1,i))\n print(*range(n-1,i,-1))\n print(i)",
"n,l,*a=map(int,open(0).read().split())",
"n",
"map(int,open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"l",
"*a",
"a",
"i=m=0",
"i",
"0",
"=m=0",
"m",
"0",
"for j,(x,y)in enumerate(zip(a,a[1:]),1):\n if x+y>m:\n m=x+y\n i=j",
"j",
"(x,y)",
"x",
"y",
"enumerate(zip(a,a[1:]),1)",
"enumerate",
"zip(a,a[1:])",
"zip",
"a",
"a[1:]",
"a",
"1:",
"1",
"1",
"if x+y>m:\n m=x+y\n i=j",
"x+y>m",
"x+y",
"x",
"y",
"m",
"m=x+y",
"m",
"x+y",
"x",
"y",
"i=j",
"i",
"j",
"if m<l:\n print('Impossible')\nelse:\n print('Possible')\n print(*range(1,i))\n print(*range(n-1,i,-1))\n print(i)",
"m<l",
"m",
"l",
"print('Impossible')",
"print",
"'Impossible'",
"print('Possible')",
"print",
"'Possible'",
"print(*range(1,i))",
"print",
"*range(1,i)",
"range(1,i)",
"range",
"1",
"i",
"print(*range(n-1,i,-1))",
"print",
"*range(n-1,i,-1)",
"range(n-1,i,-1)",
"range",
"n-1",
"n",
"1",
"i",
"-1",
"print(i)",
"print",
"i",
"m=x+y",
"x+y",
"m",
"m=0",
"0",
"m",
"n,l,*a=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"n",
"i=j",
"j",
"i",
"l,*a=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"l",
"i=m=0",
"0",
"i"
] | n,l,*a=map(int,open(0).read().split())
i=m=0
for j,(x,y)in enumerate(zip(a,a[1:]),1):
if x+y>m:
m=x+y
i=j
if m<l:
print('Impossible')
else:
print('Possible')
print(*range(1,i))
print(*range(n-1,i,-1))
print(i) |
[
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,
13,
4,
18,
4,
13,
13,
13,
31,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
13,
4,
13,
13,
18,
13,
39,
17,
4,
40,
2,
13,
13,
13,
0,
13,
13,
14,
40,
4,
13,
13,
4,
13,
17,
29,
4,
13,
17,
0,
13,
4,
18,
13,
13,
17,
0,
13,
2,
4,
13,
4,
13,
17,
2,
13,
17,
4,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
31,
13,
0,
13,
17,
23,
13,
23,
13,
4,
13,
13,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13,
10,
12,
13,
10,
18,
13,
10,
4,
13
] | [
[
128,
4
],
[
137,
13
],
[
131,
22
],
[
140,
31
],
[
129,
38
],
[
140,
40
],
[
140,
41
],
[
47,
46
],
[
119,
49
],
[
119,
56
],
[
119,
58
],
[
117,
66
],
[
69,
68
],
[
68,
74
],
[
84,
83
],
[
68,
86
],
[
91,
90
],
[
83,
98
],
[
46,
105
],
[
141,
105
],
[
83,
107
],
[
90,
112
],
[
115,
114
],
[
117,
117
],
[
119,
119
],
[
135,
121
],
[
126,
122
],
[
140,
126
],
[
128,
129
],
[
131,
132
],
[
137,
138
],
[
140,
141
]
] | [
"import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, L, *A = map(int, read().split())\n\ndef main(L, A):\n N = len(A)\n is_long = [x + y >= L for x, y in zip(A, A[1:])]\n if not any(is_long):\n print('Impossible')\n return\n print('Possible')\n i = is_long.index(True)\n nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))\n print(*nums, sep='\\n')\n\nmain(L, A)",
"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, L, *A = map(int, read().split())",
"N",
"map(int, read().split())",
"map",
"int",
"read().split()",
"().split",
"()",
"read",
"split",
"L",
"*A",
"A",
"def main(L, A):\n N = len(A)\n is_long = [x + y >= L for x, y in zip(A, A[1:])]\n if not any(is_long):\n print('Impossible')\n return\n print('Possible')\n i = is_long.index(True)\n nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))\n print(*nums, sep='\\n')",
"main",
"N = len(A)",
"N",
"len(A)",
"len",
"A",
"x + y >= L for x, y in zip(A, A[1:])",
"for x, y in zip(A, A[1:])",
"x",
"y",
"zip(A, A[1:])",
"zip",
"A",
"A[1:]",
"A",
"1:",
"1",
"for x, y in zip(A, A[1:])",
"x + y >= L",
"x + y",
"x",
"y",
"L",
"is_long = [x + y >= L for x, y in zip(A, A[1:])]",
"is_long",
"[x + y >= L for x, y in zip(A, A[1:])]",
"if not any(is_long):\n print('Impossible')\n return\n ",
"not any(is_long)",
"any(is_long)",
"any",
"is_long",
"print('Impossible')",
"print",
"'Impossible'",
"return",
"print('Possible')",
"print",
"'Possible'",
"i = is_long.index(True)",
"i",
"is_long.index(True)",
"is_long.index",
"is_long",
"index",
"True",
"nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))",
"nums",
"list(range(1, i + 1)) + list(range(N - 1, i, -1))",
"list(range(1, i + 1))",
"list",
"range(1, i + 1)",
"range",
"1",
"i + 1",
"i",
"1",
"list(range(N - 1, i, -1))",
"list",
"range(N - 1, i, -1)",
"range",
"N - 1",
"N",
"1",
"i",
"-1",
"print(*nums, sep='\\n')",
"print",
"*nums",
"nums",
"sep='\\n'",
"sep",
"'\\n'",
"L",
"L",
"A",
"A",
"main(L, A)",
"main",
"L",
"A",
"L, *A = map(int, read().split())",
"map(int, read().split())",
"L",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"def main(L, A):\n N = len(A)\n is_long = [x + y >= L for x, y in zip(A, A[1:])]\n if not any(is_long):\n print('Impossible')\n return\n print('Possible')\n i = is_long.index(True)\n nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))\n print(*nums, sep='\\n')",
"def main(L, A):\n N = len(A)\n is_long = [x + y >= L for x, y in zip(A, A[1:])]\n if not any(is_long):\n print('Impossible')\n return\n print('Possible')\n i = is_long.index(True)\n nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))\n print(*nums, sep='\\n')",
"main",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"N, L, *A = map(int, read().split())",
"map(int, read().split())",
"N"
] | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, L, *A = map(int, read().split())
def main(L, A):
N = len(A)
is_long = [x + y >= L for x, y in zip(A, A[1:])]
if not any(is_long):
print('Impossible')
return
print('Possible')
i = is_long.index(True)
nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))
print(*nums, sep='\n')
main(L, A) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
17,
15,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
15,
13,
0,
13,
2,
17,
17,
12,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
13,
39,
13,
42,
13,
0,
13,
4,
18,
13,
13,
28,
13,
13,
18,
13,
13,
14,
40,
2,
18,
13,
13,
13,
18,
13,
13,
14,
40,
18,
13,
13,
13,
29,
17,
0,
18,
13,
13,
2,
18,
13,
13,
13,
14,
40,
18,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
13,
17,
29,
17,
23,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
2,
17,
13,
3,
14,
40,
13,
4,
13,
17,
29,
4,
13,
17,
28,
13,
4,
13,
17,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
213,
4
],
[
214,
22
],
[
214,
34
],
[
210,
39
],
[
49,
46
],
[
122,
47
],
[
126,
48
],
[
54,
51
],
[
124,
52
],
[
126,
53
],
[
57,
56
],
[
65,
64
],
[
56,
67
],
[
120,
73
],
[
64,
74
],
[
124,
79
],
[
64,
80
],
[
94,
82
],
[
124,
83
],
[
94,
87
],
[
124,
88
],
[
211,
90
],
[
97,
94
],
[
124,
95
],
[
124,
99
],
[
64,
100
],
[
113,
104
],
[
122,
105
],
[
56,
109
],
[
116,
113
],
[
122,
114
],
[
120,
120
],
[
122,
122
],
[
124,
124
],
[
126,
126
],
[
131,
130
],
[
220,
132
],
[
131,
133
],
[
136,
135
],
[
220,
137
],
[
140,
139
],
[
143,
142
],
[
130,
146
],
[
135,
152
],
[
142,
153
],
[
135,
155
],
[
142,
157
],
[
133,
159
],
[
162,
161
],
[
165,
164
],
[
142,
167
],
[
161,
171
],
[
139,
171
],
[
181,
180
],
[
164,
184
],
[
180,
187
],
[
190,
189
],
[
130,
193
],
[
164,
195
],
[
189,
199
],
[
164,
202
],
[
223,
208
],
[
210,
211
],
[
213,
214
]
] | [
"import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nfrom collections import deque, Counter\ndef getN():\n return int(input())\ndef getList():\n return list(map(int, input().split()))\nimport math\nINF = 10**10\ndef bfs(graph, visited, position, root):\n visited[root] = 1\n position[root] = 0\n deq = deque([root])\n while(deq):\n cur = deq.pop()\n # print(cur)\n for nxt, dist in graph[cur]:\n if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n return True\n\ndef main():\n n, l = getList()\n nums = getList()\n flag = False\n for i in range(n - 1):\n if nums[i] + nums[i + 1] >= l:\n flag = True\n index = 1 + i\n break\n\n if not flag:\n print(\"Impossible\")\n return\n\n else:\n print(\"Possible\")\n for i in range(1, index):\n print(i)\n for i in range(n-1, index, -1):\n print(i)\n \n print(index)\nif __name__ == \"__main__\":\n\n main()",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"sys.setrecursionlimit(1000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1000000",
"from collections import deque, Counter",
"def getN():\n return int(input())",
"getN",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"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",
"import math",
"math",
"INF = 10**10",
"INF",
"10**10",
"10",
"10",
"def bfs(graph, visited, position, root):\n visited[root] = 1\n position[root] = 0\n deq = deque([root])\n while(deq):\n cur = deq.pop()\n # print(cur)\n for nxt, dist in graph[cur]:\n if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n return True",
"bfs",
"visited[root] = 1",
"visited[root]",
"visited",
"root",
"1",
"position[root] = 0",
"position[root]",
"position",
"root",
"0",
"deq = deque([root])",
"deq",
"deque([root])",
"deque",
"[root]",
"root",
"while(deq):\n cur = deq.pop()\n # print(cur)\n for nxt, dist in graph[cur]:\n if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n ",
"deq",
"cur = deq.pop()",
"cur",
"deq.pop()",
"deq.pop",
"deq",
"pop",
"for nxt, dist in graph[cur]:\n if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n ",
"nxt",
"dist",
"graph[cur]",
"graph",
"cur",
"if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n ",
"position[cur] + dist != position[nxt]",
"position[cur] + dist",
"position[cur]",
"position",
"cur",
"dist",
"position[nxt]",
"position",
"nxt",
"if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n ",
"position[nxt] != INF",
"position[nxt]",
"position",
"nxt",
"INF",
"return False",
"False",
"position[nxt] = position[cur] + dist",
"position[nxt]",
"position",
"nxt",
"position[cur] + dist",
"position[cur]",
"position",
"cur",
"dist",
"if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n ",
"not visited[nxt]",
"visited[nxt]",
"visited",
"nxt",
"deq.append(nxt)",
"deq.append",
"deq",
"append",
"nxt",
"visited[nxt] = 1",
"visited[nxt]",
"visited",
"nxt",
"1",
"return True",
"True",
"graph",
"graph",
"visited",
"visited",
"position",
"position",
"root",
"root",
"def main():\n n, l = getList()\n nums = getList()\n flag = False\n for i in range(n - 1):\n if nums[i] + nums[i + 1] >= l:\n flag = True\n index = 1 + i\n break\n\n if not flag:\n print(\"Impossible\")\n return\n\n else:\n print(\"Possible\")\n for i in range(1, index):\n print(i)\n for i in range(n-1, index, -1):\n print(i)\n \n print(index)",
"main",
"n, l = getList()",
"n",
"getList()",
"getList",
"l",
"nums = getList()",
"nums",
"getList()",
"getList",
"flag = False",
"flag",
"False",
"for i in range(n - 1):\n if nums[i] + nums[i + 1] >= l:\n flag = True\n index = 1 + i\n break\n\n ",
"i",
"range(n - 1)",
"range",
"n - 1",
"n",
"1",
"if nums[i] + nums[i + 1] >= l:\n flag = True\n index = 1 + i\n break\n\n ",
"nums[i] + nums[i + 1] >= l",
"nums[i] + nums[i + 1]",
"nums[i]",
"nums",
"i",
"nums[i + 1]",
"nums",
"i + 1",
"i",
"1",
"l",
"flag = True",
"flag",
"True",
"index = 1 + i",
"index",
"1 + i",
"1",
"i",
"break",
"if not flag:\n print(\"Impossible\")\n return\n\n else:\n print(\"Possible\")\n for i in range(1, index):\n print(i)\n for i in range(n-1, index, -1):\n print(i)\n \n print(index)",
"not flag",
"flag",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"return",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(1, index):\n print(i)\n ",
"i",
"range(1, index)",
"range",
"1",
"index",
"print(i)",
"print",
"i",
"for i in range(n-1, index, -1):\n print(i)\n \n ",
"i",
"range(n-1, index, -1)",
"range",
"n-1",
"n",
"1",
"index",
"-1",
"print(i)",
"print",
"i",
"print(index)",
"print",
"index",
"if __name__ == \"__main__\":\n\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"INF = 10**10",
"10**10",
"INF",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"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 main():\n n, l = getList()\n nums = getList()\n flag = False\n for i in range(n - 1):\n if nums[i] + nums[i + 1] >= l:\n flag = True\n index = 1 + i\n break\n\n if not flag:\n print(\"Impossible\")\n return\n\n else:\n print(\"Possible\")\n for i in range(1, index):\n print(i)\n for i in range(n-1, index, -1):\n print(i)\n \n print(index)",
"def main():\n n, l = getList()\n nums = getList()\n flag = False\n for i in range(n - 1):\n if nums[i] + nums[i + 1] >= l:\n flag = True\n index = 1 + i\n break\n\n if not flag:\n print(\"Impossible\")\n return\n\n else:\n print(\"Possible\")\n for i in range(1, index):\n print(i)\n for i in range(n-1, index, -1):\n print(i)\n \n print(index)",
"main",
"def bfs(graph, visited, position, root):\n visited[root] = 1\n position[root] = 0\n deq = deque([root])\n while(deq):\n cur = deq.pop()\n # print(cur)\n for nxt, dist in graph[cur]:\n if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n return True",
"def bfs(graph, visited, position, root):\n visited[root] = 1\n position[root] = 0\n deq = deque([root])\n while(deq):\n cur = deq.pop()\n # print(cur)\n for nxt, dist in graph[cur]:\n if position[cur] + dist != position[nxt]:\n if position[nxt] != INF:\n return False\n else:\n position[nxt] = position[cur] + dist\n if not visited[nxt]:\n deq.append(nxt)\n visited[nxt] = 1\n\n return True",
"bfs"
] | import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
return int(input())
def getList():
return list(map(int, input().split()))
import math
INF = 10**10
def bfs(graph, visited, position, root):
visited[root] = 1
position[root] = 0
deq = deque([root])
while(deq):
cur = deq.pop()
# print(cur)
for nxt, dist in graph[cur]:
if position[cur] + dist != position[nxt]:
if position[nxt] != INF:
return False
else:
position[nxt] = position[cur] + dist
if not visited[nxt]:
deq.append(nxt)
visited[nxt] = 1
return True
def main():
n, l = getList()
nums = getList()
flag = False
for i in range(n - 1):
if nums[i] + nums[i + 1] >= l:
flag = True
index = 1 + i
break
if not flag:
print("Impossible")
return
else:
print("Possible")
for i in range(1, index):
print(i)
for i in range(n-1, index, -1):
print(i)
print(index)
if __name__ == "__main__":
main() |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
13,
3,
14,
13,
4,
13,
17,
28,
13,
4,
13,
17,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
2,
13,
17,
4,
13,
2,
13,
17,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13
] | [
[
107,
2
],
[
107,
11
],
[
95,
13
],
[
101,
25
],
[
98,
28
],
[
32,
31
],
[
108,
35
],
[
96,
41
],
[
31,
42
],
[
96,
44
],
[
31,
46
],
[
105,
48
],
[
110,
50
],
[
113,
53
],
[
31,
54
],
[
63,
62
],
[
114,
66
],
[
99,
66
],
[
62,
70
],
[
74,
73
],
[
108,
77
],
[
114,
79
],
[
99,
79
],
[
73,
84
],
[
114,
89
],
[
99,
89
],
[
95,
96
],
[
98,
99
],
[
101,
102
],
[
107,
105
],
[
107,
108
],
[
110,
111
],
[
31,
113
],
[
113,
114
]
] | [
"n,l=map(int,input().split())\narr=list(map(int,input().split()))\npsbl=False\npos=0\nfor i in range(n-1):\n if arr[i]+arr[i+1]>=l:\n psbl=True\n pos=i\n break\nif psbl:\n print(\"Possible\")\n for i in range(0,pos):\n print(i+1)\n for i in range(n-2,pos,-1):\n print(i+1)\n print(pos+1)\nelse:\n print(\"Impossible\")",
"n,l=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l",
"arr=list(map(int,input().split()))",
"arr",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"psbl=False",
"psbl",
"False",
"pos=0",
"pos",
"0",
"for i in range(n-1):\n if arr[i]+arr[i+1]>=l:\n psbl=True\n pos=i\n break",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if arr[i]+arr[i+1]>=l:\n psbl=True\n pos=i\n break",
"arr[i]+arr[i+1]>=l",
"arr[i]+arr[i+1]",
"arr[i]",
"arr",
"i",
"arr[i+1]",
"arr",
"i+1",
"i",
"1",
"l",
"psbl=True",
"psbl",
"True",
"pos=i",
"pos",
"i",
"break",
"if psbl:\n print(\"Possible\")\n for i in range(0,pos):\n print(i+1)\n for i in range(n-2,pos,-1):\n print(i+1)\n print(pos+1)\nelse:\n print(\"Impossible\")",
"psbl",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(0,pos):\n print(i+1)\n ",
"i",
"range(0,pos)",
"range",
"0",
"pos",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"for i in range(n-2,pos,-1):\n print(i+1)\n ",
"i",
"range(n-2,pos,-1)",
"range",
"n-2",
"n",
"2",
"pos",
"-1",
"print(i+1)",
"print",
"i+1",
"i",
"1",
"print(pos+1)",
"print",
"pos+1",
"pos",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"arr=list(map(int,input().split()))",
"list(map(int,input().split()))",
"arr",
"pos=0",
"0",
"pos",
"psbl=False",
"False",
"psbl",
"l=map(int,input().split())",
"map(int,input().split())",
"l",
"n,l=map(int,input().split())",
"map(int,input().split())",
"n",
"psbl=True",
"True",
"psbl",
"pos=i",
"i",
"pos"
] | n,l=map(int,input().split())
arr=list(map(int,input().split()))
psbl=False
pos=0
for i in range(n-1):
if arr[i]+arr[i+1]>=l:
psbl=True
pos=i
break
if psbl:
print("Possible")
for i in range(0,pos):
print(i+1)
for i in range(n-2,pos,-1):
print(i+1)
print(pos+1)
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
40,
2,
18,
13,
2,
13,
17,
18,
13,
13,
13,
0,
13,
13,
3,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
28,
13,
4,
13,
17,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
13,
17,
4,
13,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] | [
[
90,
2
],
[
90,
11
],
[
84,
13
],
[
96,
25
],
[
29,
28
],
[
91,
32
],
[
85,
37
],
[
28,
39
],
[
85,
42
],
[
28,
43
],
[
88,
44
],
[
93,
46
],
[
28,
47
],
[
94,
51
],
[
97,
51
],
[
61,
60
],
[
94,
64
],
[
97,
64
],
[
60,
67
],
[
70,
69
],
[
91,
73
],
[
94,
75
],
[
97,
75
],
[
69,
79
],
[
94,
82
],
[
97,
82
],
[
84,
85
],
[
90,
88
],
[
90,
91
],
[
28,
93
],
[
93,
94
],
[
96,
97
]
] | [
"n,k=map(int,input().split())\nl=list(map(int,input().split()))\ntmp=0\nfor i in range(1,n):\n if l[i-1]+l[i]>=k:\n tmp=i\n break\nif tmp==0:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(1,tmp):\n print(i)\n for i in range(n-1,tmp,-1):\n print(i)\n print(tmp)",
"n,k=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"k",
"l=list(map(int,input().split()))",
"l",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"tmp=0",
"tmp",
"0",
"for i in range(1,n):\n if l[i-1]+l[i]>=k:\n tmp=i\n break",
"i",
"range(1,n)",
"range",
"1",
"n",
"if l[i-1]+l[i]>=k:\n tmp=i\n break",
"l[i-1]+l[i]>=k",
"l[i-1]+l[i]",
"l[i-1]",
"l",
"i-1",
"i",
"1",
"l[i]",
"l",
"i",
"k",
"tmp=i",
"tmp",
"i",
"break",
"if tmp==0:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(1,tmp):\n print(i)\n for i in range(n-1,tmp,-1):\n print(i)\n print(tmp)",
"tmp==0",
"tmp",
"0",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in range(1,tmp):\n print(i)\n ",
"i",
"range(1,tmp)",
"range",
"1",
"tmp",
"print(i)",
"print",
"i",
"for i in range(n-1,tmp,-1):\n print(i)\n ",
"i",
"range(n-1,tmp,-1)",
"range",
"n-1",
"n",
"1",
"tmp",
"-1",
"print(i)",
"print",
"i",
"print(tmp)",
"print",
"tmp",
"l=list(map(int,input().split()))",
"list(map(int,input().split()))",
"l",
"k=map(int,input().split())",
"map(int,input().split())",
"k",
"n,k=map(int,input().split())",
"map(int,input().split())",
"n",
"tmp=i",
"i",
"tmp",
"tmp=0",
"0",
"tmp"
] | n,k=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
for i in range(1,n):
if l[i-1]+l[i]>=k:
tmp=i
break
if tmp==0:
print("Impossible")
else:
print("Possible")
for i in range(1,tmp):
print(i)
for i in range(n-1,tmp,-1):
print(i)
print(tmp) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
0,
13,
39,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
13,
4,
18,
13,
13,
2,
13,
17,
9,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
18,
13,
13,
2,
13,
17,
14,
40,
13,
0,
13,
13,
0,
13,
17,
14,
40,
13,
4,
13,
17,
4,
13,
14,
13,
28,
13,
18,
13,
39,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
2,
13,
17,
4,
13,
17,
4,
13,
31,
13,
0,
13,
17,
10,
4,
13,
10,
39,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
39,
13,
10,
17,
13
] | [
[
132,
2
],
[
132,
11
],
[
120,
13
],
[
123,
25
],
[
141,
28
],
[
135,
31
],
[
144,
34
],
[
38,
37
],
[
130,
41
],
[
142,
47
],
[
37,
50
],
[
121,
57
],
[
37,
58
],
[
121,
60
],
[
37,
62
],
[
133,
64
],
[
124,
67
],
[
37,
70
],
[
145,
74
],
[
139,
74
],
[
126,
76
],
[
37,
77
],
[
138,
79
],
[
139,
83
],
[
145,
83
],
[
93,
92
],
[
142,
94
],
[
124,
99
],
[
92,
101
],
[
124,
104
],
[
127,
107
],
[
136,
107
],
[
124,
115
],
[
118,
117
],
[
120,
121
],
[
123,
124
],
[
37,
126
],
[
126,
127
],
[
132,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
]
] | [
"# 2019/09/18\n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nans=[]\nres=[]\nlast=0\n\nflag=False\nfor i in range(n-1):\n if flag:\n res.append(i+1)\n continue\n if a[i]+a[i+1]<k:\n ans.append(i+1)\n elif not flag:\n last=i\n flag=True\n\nif not flag:\n print('Impossible')\n exit()\nif res:\n for e in res[::-1]:\n ans.append(e)\nans.append(last+1)\n\nprint('Possible')\nprint(*ans,sep='\\n')",
"n,k=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"k",
"a=list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"ans=[]",
"ans",
"[]",
"res=[]",
"res",
"[]",
"last=0",
"last",
"0",
"flag=False",
"flag",
"False",
"for i in range(n-1):\n if flag:\n res.append(i+1)\n continue\n if a[i]+a[i+1]<k:\n ans.append(i+1)\n elif not flag:\n last=i\n flag=True",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if flag:\n res.append(i+1)\n continue\n ",
"flag",
"res.append(i+1)",
"res.append",
"res",
"append",
"i+1",
"i",
"1",
"continue",
"if a[i]+a[i+1]<k:\n ans.append(i+1)\n elif not flag:\n last=i\n flag=True",
"a[i]+a[i+1]<k",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"k",
"ans.append(i+1)",
"ans.append",
"ans",
"append",
"i+1",
"i",
"1",
"elif not flag:\n last=i\n flag=True",
"not flag",
"flag",
"last=i",
"last",
"i",
"flag=True",
"flag",
"True",
"if not flag:\n print('Impossible')\n exit()",
"not flag",
"flag",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"if res:\n for e in res[::-1]:\n ans.append(e)",
"res",
"for e in res[::-1]:\n ans.append(e)",
"e",
"res[::-1]",
"res",
"::-1",
"-1",
"ans.append(e)",
"ans.append",
"ans",
"append",
"e",
"ans.append(last+1)",
"ans.append",
"ans",
"append",
"last+1",
"last",
"1",
"print('Possible')",
"print",
"'Possible'",
"print(*ans,sep='\\n')",
"print",
"*ans",
"ans",
"sep='\\n'",
"sep",
"'\\n'",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"ans=[]",
"[]",
"ans",
"last=i",
"i",
"last",
"n,k=map(int,input().split())",
"map(int,input().split())",
"n",
"k=map(int,input().split())",
"map(int,input().split())",
"k",
"last=0",
"0",
"last",
"flag=True",
"True",
"flag",
"res=[]",
"[]",
"res",
"flag=False",
"False",
"flag"
] | # 2019/09/18
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[]
res=[]
last=0
flag=False
for i in range(n-1):
if flag:
res.append(i+1)
continue
if a[i]+a[i+1]<k:
ans.append(i+1)
elif not flag:
last=i
flag=True
if not flag:
print('Impossible')
exit()
if res:
for e in res[::-1]:
ans.append(e)
ans.append(last+1)
print('Possible')
print(*ans,sep='\n') |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
31,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
18,
13,
13,
2,
13,
17,
3,
4,
13,
17,
14,
13,
0,
13,
18,
13,
17,
0,
13,
4,
13,
18,
4,
13,
17,
13,
39,
17,
0,
13,
4,
13,
4,
13,
2,
13,
17,
13,
4,
13,
17,
28,
13,
18,
13,
39,
17,
4,
13,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
113,
3
],
[
113,
12
],
[
16,
14
],
[
98,
25
],
[
29,
28
],
[
114,
32
],
[
28,
39
],
[
28,
43
],
[
102,
45
],
[
99,
48
],
[
28,
51
],
[
107,
60
],
[
99,
62
],
[
110,
65
],
[
108,
72
],
[
104,
76
],
[
108,
82
],
[
114,
84
],
[
90,
89
],
[
105,
91
],
[
111,
91
],
[
99,
91
],
[
89,
96
],
[
98,
99
],
[
113,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
]
] | [
"from itertools import accumulate as ac\n\nn,l=map(int,input().split())\n*a,=map(int,input().split())\nv=[]\n\nfor i in range(n-1):\n if a[i]+a[i+1]>=l:\n v.append(i+1)\n break\nelse:\n print(\"Impossible\")\n\nif v:\n st=v[0]\n v+=list(range(1,st)[::-1])\n v+=list(range(st+1,n))\n print(\"Possible\")\n for i in v[::-1]:\n print(i)",
"from itertools import accumulate as ac",
"n,l=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"l",
"*a,=map(int,input().split())",
"*a",
"a",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"v=[]",
"v",
"[]",
"for i in range(n-1):\n if a[i]+a[i+1]>=l:\n v.append(i+1)\n break\nelse:\n print(\"Impossible\")",
"i",
"range(n-1)",
"range",
"n-1",
"n",
"1",
"if a[i]+a[i+1]>=l:\n v.append(i+1)\n break",
"a[i]+a[i+1]>=l",
"a[i]+a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"l",
"v.append(i+1)",
"v.append",
"v",
"append",
"i+1",
"i",
"1",
"break",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"if v:\n st=v[0]\n v+=list(range(1,st)[::-1])\n v+=list(range(st+1,n))\n print(\"Possible\")\n for i in v[::-1]:\n print(i)",
"v",
"st=v[0]",
"st",
"v[0]",
"v",
"0",
"v+=list(range(1,st)[::-1])",
"v",
"list(range(1,st)[::-1])",
"list",
"range(1,st)[::-1]",
"(1,st)",
"range",
"1",
"st",
"::-1",
"-1",
"v+=list(range(st+1,n))",
"v",
"list(range(st+1,n))",
"list",
"range(st+1,n)",
"range",
"st+1",
"st",
"1",
"n",
"print(\"Possible\")",
"print",
"\"Possible\"",
"for i in v[::-1]:\n print(i)",
"i",
"v[::-1]",
"v",
"::-1",
"-1",
"print(i)",
"print",
"i",
"v=[]",
"[]",
"v",
"l=map(int,input().split())",
"map(int,input().split())",
"l",
"v+=list(range(st+1,n))",
"list(range(st+1,n))",
"v",
"st=v[0]",
"v[0]",
"st",
"v+=list(range(1,st)[::-1])",
"list(range(1,st)[::-1])",
"v",
"n,l=map(int,input().split())",
"map(int,input().split())",
"n"
] | from itertools import accumulate as ac
n,l=map(int,input().split())
*a,=map(int,input().split())
v=[]
for i in range(n-1):
if a[i]+a[i+1]>=l:
v.append(i+1)
break
else:
print("Impossible")
if v:
st=v[0]
v+=list(range(1,st)[::-1])
v+=list(range(st+1,n))
print("Possible")
for i in v[::-1]:
print(i) |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.