node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
12,
13,
0,
13,
4,
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,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
2,
18,
13,
2,
13,
17,
17,
2,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
15
],
[
18,
17
],
[
24,
23
],
[
4,
27
],
[
30,
29
],
[
15,
32
],
[
35,
34
],
[
35,
45
],
[
34,
48
],
[
17,
49
],
[
17,
52
],
[
45,
54
],
[
23,
59
],
[
34,
61
],
[
34,
65
],
[
17,
66
],
[
17,
69
],
[
34,
71
],
[
78,
73
],
[
23,
74
],
[
34,
76
],
[
85,
80
],
[
23,
81
],
[
45,
83
],
[
17,
90
],
[
99,
96
]
] | [
"def main():\n n, m = list(map(int, input().split()))\n ans = set([1, ])\n balls = [1] * n\n for _ in range(m):\n x, y = list(map(int, input().split()))\n if x in ans:\n ans.add(y)\n if balls[x - 1] == 1 and x in ans:\n ans.remove(x)\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(len(ans))\n\nif __name__ == '__main__':\n main()",
"def main():\n n, m = list(map(int, input().split()))\n ans = set([1, ])\n balls = [1] * n\n for _ in range(m):\n x, y = list(map(int, input().split()))\n if x in ans:\n ans.add(y)\n if balls[x - 1] == 1 and x in ans:\n ans.remove(x)\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(len(ans))",
"main",
"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",
"ans = set([1, ])",
"ans",
"set([1, ])",
"set",
"[1, ]",
"1",
"balls = [1] * n",
"balls",
"[1] * n",
"[1]",
"1",
"n",
"for _ in range(m):\n x, y = list(map(int, input().split()))\n if x in ans:\n ans.add(y)\n if balls[x - 1] == 1 and x in ans:\n ans.remove(x)\n balls[x - 1] -= 1\n balls[y - 1] += 1\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",
"if x in ans:\n ans.add(y)\n ",
"x in ans",
"x",
"ans",
"ans.add(y)",
"ans.add",
"ans",
"add",
"y",
"if balls[x - 1] == 1 and x in ans:\n ans.remove(x)\n ",
"balls[x - 1] == 1 and x in ans",
"balls[x - 1] == 1",
"balls[x - 1]",
"balls",
"x - 1",
"x",
"1",
"1",
"x in ans",
"x",
"ans",
"ans.remove(x)",
"ans.remove",
"ans",
"remove",
"x",
"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(len(ans))",
"print",
"len(ans)",
"len",
"ans",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n n, m = list(map(int, input().split()))\n ans = set([1, ])\n balls = [1] * n\n for _ in range(m):\n x, y = list(map(int, input().split()))\n if x in ans:\n ans.add(y)\n if balls[x - 1] == 1 and x in ans:\n ans.remove(x)\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(len(ans))",
"def main():\n n, m = list(map(int, input().split()))\n ans = set([1, ])\n balls = [1] * n\n for _ in range(m):\n x, y = list(map(int, input().split()))\n if x in ans:\n ans.add(y)\n if balls[x - 1] == 1 and x in ans:\n ans.remove(x)\n balls[x - 1] -= 1\n balls[y - 1] += 1\n print(len(ans))",
"main"
] | def main():
n, m = list(map(int, input().split()))
ans = set([1, ])
balls = [1] * n
for _ in range(m):
x, y = list(map(int, input().split()))
if x in ans:
ans.add(y)
if balls[x - 1] == 1 and x in ans:
ans.remove(x)
balls[x - 1] -= 1
balls[y - 1] += 1
print(len(ans))
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
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,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
99,
2
],
[
99,
11
],
[
87,
13
],
[
18,
17
],
[
97,
20
],
[
90,
24
],
[
28,
27
],
[
100,
30
],
[
93,
32
],
[
93,
41
],
[
48,
43
],
[
91,
44
],
[
94,
46
],
[
55,
50
],
[
91,
51
],
[
85,
53
],
[
94,
58
],
[
88,
59
],
[
88,
62
],
[
85,
64
],
[
91,
68
],
[
94,
70
],
[
88,
75
],
[
94,
77
],
[
88,
82
],
[
93,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
],
[
99,
97
],
[
99,
100
]
] | [
"n, m = map(int, input().split())\nred = {1, }\nl = [1 for _ in range(n)]\nfor _ in range(m):\n x, y = map(int, input().split())\n l[x - 1] -= 1\n l[y - 1] += 1\n if x in red:\n red.add(y)\n if l[x - 1] == 0:\n red.discard(x)\nprint(len(red))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"red = {1, }",
"red",
"{1, }",
"1 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"1",
"l = [1 for _ in range(n)]",
"l",
"[1 for _ in range(n)]",
"for _ in range(m):\n x, y = map(int, input().split())\n l[x - 1] -= 1\n l[y - 1] += 1\n if x in red:\n red.add(y)\n if l[x - 1] == 0:\n red.discard(x)",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"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 x in red:\n red.add(y)\n if l[x - 1] == 0:\n red.discard(x)",
"x in red",
"x",
"red",
"red.add(y)",
"red.add",
"red",
"add",
"y",
"if l[x - 1] == 0:\n red.discard(x)",
"l[x - 1] == 0",
"l[x - 1]",
"l",
"x - 1",
"x",
"1",
"0",
"red.discard(x)",
"red.discard",
"red",
"discard",
"x",
"print(len(red))",
"print",
"len(red)",
"len",
"red",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"red = {1, }",
"{1, }",
"red",
"l = [1 for _ in range(n)]",
"[1 for _ in range(n)]",
"l",
"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"
] | n, m = map(int, input().split())
red = {1, }
l = [1 for _ in range(n)]
for _ in range(m):
x, y = map(int, input().split())
l[x - 1] -= 1
l[y - 1] += 1
if x in red:
red.add(y)
if l[x - 1] == 0:
red.discard(x)
print(len(red))
|
[
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,
14,
2,
18,
13,
13,
17,
0,
13,
17,
28,
13,
13,
4,
13,
13,
13,
0,
13,
2,
40,
13,
17,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
105,
2
],
[
105,
11
],
[
111,
13
],
[
106,
18
],
[
93,
21
],
[
106,
26
],
[
32,
29
],
[
94,
30
],
[
35,
34
],
[
91,
37
],
[
102,
39
],
[
102,
48
],
[
53,
50
],
[
112,
51
],
[
103,
52
],
[
58,
55
],
[
112,
56
],
[
100,
57
],
[
94,
61
],
[
103,
62
],
[
50,
65
],
[
112,
66
],
[
103,
67
],
[
96,
70
],
[
112,
77
],
[
94,
78
],
[
108,
80
],
[
109,
88
],
[
97,
88
],
[
105,
91
],
[
93,
94
],
[
96,
97
],
[
102,
100
],
[
102,
103
],
[
105,
106
],
[
108,
109
],
[
111,
112
]
] | [
"n,m=map(int,input().split())\na=[1]*(n+1)\nb=[0]*(n+1)\nb[1]=1\nfor _ in range(m):\n x,y=map(int,input().split())\n a[x]-=1\n a[y]+=1\n if b[x]:b[y]=1\n if a[x]==0:b[x]=0\nans=0\nfor i,j in zip(a,b):\n ans+=(i!=0)*j\nprint(ans)",
"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",
"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 x,y=map(int,input().split())\n a[x]-=1\n a[y]+=1\n if b[x]:b[y]=1\n if a[x]==0:b[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",
"a[x]-=1",
"a[x]",
"a",
"x",
"1",
"a[y]+=1",
"a[y]",
"a",
"y",
"1",
"if b[x]:b[y]=1\n ",
"b[x]",
"b",
"x",
"if a[x]==0:b[x]",
"a[x]==0",
"a[x]",
"a",
"x",
"0",
"ans=0",
"ans",
"0",
"for i,j in zip(a,b):\n ans+=(i!=0)*j",
"i",
"j",
"zip(a,b)",
"zip",
"a",
"b",
"ans+=(i!=0)*j",
"ans",
"(i!=0)*j",
"i!=0",
"i",
"0",
"j",
"print(ans)",
"print",
"ans",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"b=[0]*(n+1)",
"[0]*(n+1)",
"b",
"ans=0",
"0",
"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())",
"map(int,input().split())",
"n",
"ans+=(i!=0)*j",
"(i!=0)*j",
"ans",
"a=[1]*(n+1)",
"[1]*(n+1)",
"a"
] | n,m=map(int,input().split())
a=[1]*(n+1)
b=[0]*(n+1)
b[1]=1
for _ in range(m):
x,y=map(int,input().split())
a[x]-=1
a[y]+=1
if b[x]:b[y]=1
if a[x]==0:b[x]=0
ans=0
for i,j in zip(a,b):
ans+=(i!=0)*j
print(ans) |
[
7,
12,
13,
0,
13,
4,
13,
39,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
4,
13,
13,
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,
18,
13,
13,
17,
13,
4,
18,
13,
13,
18,
18,
13,
13,
17,
14,
2,
18,
13,
2,
18,
18,
13,
13,
17,
17,
17,
4,
18,
13,
13,
18,
18,
13,
13,
17,
29,
4,
13,
13,
23,
13,
23,
13,
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,
4,
13,
13,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
5,
4
],
[
12,
11
],
[
94,
14
],
[
19,
18
],
[
22,
21
],
[
92,
26
],
[
37,
28
],
[
18,
29
],
[
92,
33
],
[
21,
34
],
[
48,
39
],
[
18,
40
],
[
92,
44
],
[
21,
45
],
[
92,
53
],
[
21,
54
],
[
4,
56
],
[
4,
59
],
[
92,
63
],
[
21,
64
],
[
18,
69
],
[
92,
73
],
[
21,
74
],
[
4,
80
],
[
92,
84
],
[
21,
85
],
[
4,
90
],
[
92,
92
],
[
94,
94
],
[
99,
98
],
[
99,
107
],
[
111,
110
],
[
107,
113
],
[
127,
126
],
[
130,
129
],
[
145,
131
],
[
126,
132
],
[
98,
133
],
[
129,
136
],
[
148,
142
]
] | [
"def mov(xy,N):\n Box_red = set([1])\n Box = [1 for _ in range(N)]\n\n for i in range(len(xy)):\n Box[xy[i][0]-1] -= 1\n Box[xy[i][1]-1] += 1\n if xy[i][0] in Box_red:\n Box_red.add(xy[i][1])\n if Box[xy[i][0]-1] == 0:\n Box_red.discard(xy[i][0])\n\n return len(Box_red)\n\ndef main():\n N,M = map(int,input().split())\n xy = [list(map(int,input().split())) for _ in range(M)]\n ans = mov(xy,N)\n print(ans)\n\nif __name__ == \"__main__\":\n main()",
"def mov(xy,N):\n Box_red = set([1])\n Box = [1 for _ in range(N)]\n\n for i in range(len(xy)):\n Box[xy[i][0]-1] -= 1\n Box[xy[i][1]-1] += 1\n if xy[i][0] in Box_red:\n Box_red.add(xy[i][1])\n if Box[xy[i][0]-1] == 0:\n Box_red.discard(xy[i][0])\n\n return len(Box_red)",
"mov",
"Box_red = set([1])",
"Box_red",
"set([1])",
"set",
"[1]",
"1",
"1 for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"1",
"Box = [1 for _ in range(N)]",
"Box",
"[1 for _ in range(N)]",
"for i in range(len(xy)):\n Box[xy[i][0]-1] -= 1\n Box[xy[i][1]-1] += 1\n if xy[i][0] in Box_red:\n Box_red.add(xy[i][1])\n if Box[xy[i][0]-1] == 0:\n Box_red.discard(xy[i][0])\n\n ",
"i",
"range(len(xy))",
"range",
"len(xy)",
"len",
"xy",
"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",
"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",
"if xy[i][0] in Box_red:\n Box_red.add(xy[i][1])\n ",
"xy[i][0] in Box_red",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"Box_red",
"Box_red.add(xy[i][1])",
"Box_red.add",
"Box_red",
"add",
"xy[i][1]",
"[i]",
"xy",
"i",
"1",
"if Box[xy[i][0]-1] == 0:\n Box_red.discard(xy[i][0])\n\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",
"Box_red.discard(xy[i][0])",
"Box_red.discard",
"Box_red",
"discard",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"return len(Box_red)",
"len(Box_red)",
"len",
"Box_red",
"xy",
"xy",
"N",
"N",
"def main():\n N,M = map(int,input().split())\n xy = [list(map(int,input().split())) for _ in range(M)]\n ans = mov(xy,N)\n print(ans)",
"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 _ 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)]",
"ans = mov(xy,N)",
"ans",
"mov(xy,N)",
"mov",
"xy",
"N",
"print(ans)",
"print",
"ans",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def mov(xy,N):\n Box_red = set([1])\n Box = [1 for _ in range(N)]\n\n for i in range(len(xy)):\n Box[xy[i][0]-1] -= 1\n Box[xy[i][1]-1] += 1\n if xy[i][0] in Box_red:\n Box_red.add(xy[i][1])\n if Box[xy[i][0]-1] == 0:\n Box_red.discard(xy[i][0])\n\n return len(Box_red)",
"def mov(xy,N):\n Box_red = set([1])\n Box = [1 for _ in range(N)]\n\n for i in range(len(xy)):\n Box[xy[i][0]-1] -= 1\n Box[xy[i][1]-1] += 1\n if xy[i][0] in Box_red:\n Box_red.add(xy[i][1])\n if Box[xy[i][0]-1] == 0:\n Box_red.discard(xy[i][0])\n\n return len(Box_red)",
"mov",
"def main():\n N,M = map(int,input().split())\n xy = [list(map(int,input().split())) for _ in range(M)]\n ans = mov(xy,N)\n print(ans)",
"def main():\n N,M = map(int,input().split())\n xy = [list(map(int,input().split())) for _ in range(M)]\n ans = mov(xy,N)\n print(ans)",
"main"
] | def mov(xy,N):
Box_red = set([1])
Box = [1 for _ in range(N)]
for i in range(len(xy)):
Box[xy[i][0]-1] -= 1
Box[xy[i][1]-1] += 1
if xy[i][0] in Box_red:
Box_red.add(xy[i][1])
if Box[xy[i][0]-1] == 0:
Box_red.discard(xy[i][0])
return len(Box_red)
def main():
N,M = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(M)]
ans = mov(xy,N)
print(ans)
if __name__ == "__main__":
main()
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
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,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
13,
14,
2,
18,
13,
13,
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,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
41,
28,
13,
13,
13,
4,
13,
4,
13,
4,
13,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13
] | [
[
4,
3
],
[
3,
12
],
[
125,
14
],
[
125,
16
],
[
113,
18
],
[
126,
22
],
[
27,
24
],
[
114,
25
],
[
122,
29
],
[
126,
33
],
[
36,
35
],
[
120,
38
],
[
42,
41
],
[
41,
51
],
[
116,
54
],
[
116,
56
],
[
93,
59
],
[
114,
60
],
[
111,
61
],
[
73,
63
],
[
123,
64
],
[
111,
65
],
[
71,
68
],
[
114,
69
],
[
117,
70
],
[
76,
73
],
[
123,
74
],
[
111,
75
],
[
81,
78
],
[
123,
79
],
[
117,
80
],
[
93,
84
],
[
114,
85
],
[
111,
86
],
[
73,
88
],
[
123,
89
],
[
111,
90
],
[
96,
93
],
[
114,
94
],
[
111,
95
],
[
100,
99
],
[
114,
99
],
[
99,
103
],
[
116,
111
],
[
113,
114
],
[
116,
117
],
[
125,
120
],
[
122,
123
],
[
125,
126
]
] | [
"n, m = [int(w) for w in input().split()]\n\nlb = [False] * n\nlb[0] = True\nlbn = [1] * n\n\nfor i in range(m):\n x, y = [int(w)-1 for w in input().split()]\n if lb[x] and lbn[x] > 0:\n lb[y] = True\n lbn[x] -= 1\n lbn[y] += 1\n\n if lb[x] and lbn[x] == 0:\n lb[x] = False\n\nprint(len([_ for _ in lb if _]))",
"int(w) for w in input().split()",
"for w in input().split()",
"w",
"input().split()",
"().split",
"()",
"input",
"split",
"for w in input().split()",
"int(w)",
"int",
"w",
"n, m = [int(w) for w in input().split()]",
"n",
"[int(w) for w in input().split()]",
"m",
"lb = [False] * n",
"lb",
"[False] * n",
"[False]",
"False",
"n",
"lb[0] = True",
"lb[0]",
"lb",
"0",
"True",
"lbn = [1] * n",
"lbn",
"[1] * n",
"[1]",
"1",
"n",
"for i in range(m):\n x, y = [int(w)-1 for w in input().split()]\n if lb[x] and lbn[x] > 0:\n lb[y] = True\n lbn[x] -= 1\n lbn[y] += 1\n\n if lb[x] and lbn[x] == 0:\n lb[x] = False",
"i",
"range(m)",
"range",
"m",
"int(w)-1 for w in input().split()",
"for w in input().split()",
"w",
"input().split()",
"().split",
"()",
"input",
"split",
"for w in input().split()",
"int(w)-1",
"int(w)",
"int",
"w",
"1",
"x, y = [int(w)-1 for w in input().split()]",
"x",
"[int(w)-1 for w in input().split()]",
"y",
"if lb[x] and lbn[x] > 0:\n lb[y] = True\n ",
"lb[x] and lbn[x] > 0",
"lb[x]",
"lb",
"x",
"lbn[x] > 0",
"lbn[x]",
"lbn",
"x",
"0",
"lb[y] = True",
"lb[y]",
"lb",
"y",
"True",
"lbn[x] -= 1",
"lbn[x]",
"lbn",
"x",
"1",
"lbn[y] += 1",
"lbn[y]",
"lbn",
"y",
"1",
"if lb[x] and lbn[x] == 0:\n lb[x] = False",
"lb[x] and lbn[x] == 0",
"lb[x]",
"lb",
"x",
"lbn[x] == 0",
"lbn[x]",
"lbn",
"x",
"0",
"lb[x] = False",
"lb[x]",
"lb",
"x",
"False",
"_ for _ in lb if _",
"for _ in lb if _",
"_",
"lb",
"_",
"if _",
"_",
"print(len([_ for _ in lb if _]))",
"print",
"len([_ for _ in lb if _])",
"len",
"[_ for _ in lb if _]",
"x, y = [int(w)-1 for w in input().split()]",
"[int(w)-1 for w in input().split()]",
"x",
"lb = [False] * n",
"[False] * n",
"lb",
"y = [int(w)-1 for w in input().split()]",
"[int(w)-1 for w in input().split()]",
"y",
"m = [int(w) for w in input().split()]",
"[int(w) for w in input().split()]",
"m",
"lbn = [1] * n",
"[1] * n",
"lbn",
"n, m = [int(w) for w in input().split()]",
"[int(w) for w in input().split()]",
"n"
] | n, m = [int(w) for w in input().split()]
lb = [False] * n
lb[0] = True
lbn = [1] * n
for i in range(m):
x, y = [int(w)-1 for w in input().split()]
if lb[x] and lbn[x] > 0:
lb[y] = True
lbn[x] -= 1
lbn[y] += 1
if lb[x] and lbn[x] == 0:
lb[x] = False
print(len([_ for _ in lb if _]))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
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,
14,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
13,
4,
13,
18,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
115,
2
],
[
115,
11
],
[
15,
14
],
[
110,
19
],
[
14,
22
],
[
112,
27
],
[
35,
30
],
[
113,
32
],
[
38,
37
],
[
116,
40
],
[
121,
42
],
[
121,
51
],
[
58,
53
],
[
113,
55
],
[
122,
56
],
[
65,
60
],
[
113,
62
],
[
119,
63
],
[
113,
70
],
[
122,
71
],
[
80,
75
],
[
113,
77
],
[
119,
78
],
[
113,
85
],
[
122,
86
],
[
95,
90
],
[
113,
92
],
[
122,
93
],
[
124,
97
],
[
113,
102
],
[
125,
107
],
[
115,
110
],
[
112,
113
],
[
115,
116
],
[
121,
119
],
[
121,
122
],
[
124,
125
]
] | [
"n, m = map(int, input().split())\nd = {i: [1, 0] for i in range(1, n+1)}\nd[1][1] = 1\nfor _ in range(m):\n x, y = map(int, input().split())\n d[x][0] -= 1\n d[y][0] += 1\n if d[x][1] == 1:\n d[y][1] = 1\n if d[x][0] == 0:\n d[x][1] = 0\nans = sum(d[i][1] for i in range(1, n+1))\nprint(ans)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"i: [1, 0] 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, 0]",
"1",
"0",
"d = {i: [1, 0] for i in range(1, n+1)}",
"d",
"{i: [1, 0] for i in range(1, n+1)}",
"d[1][1] = 1",
"d[1][1]",
"[1]",
"d",
"1",
"1",
"1",
"for _ in range(m):\n x, y = map(int, input().split())\n d[x][0] -= 1\n d[y][0] += 1\n if d[x][1] == 1:\n d[y][1] = 1\n if d[x][0] == 0:\n d[x][1] = 0",
"_",
"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][0] -= 1",
"d[x][0]",
"[x]",
"d",
"x",
"0",
"1",
"d[y][0] += 1",
"d[y][0]",
"[y]",
"d",
"y",
"0",
"1",
"if d[x][1] == 1:\n d[y][1] = 1\n ",
"d[x][1] == 1",
"d[x][1]",
"[x]",
"d",
"x",
"1",
"1",
"d[y][1] = 1",
"d[y][1]",
"[y]",
"d",
"y",
"1",
"1",
"if d[x][0] == 0:\n d[x][1] = 0",
"d[x][0] == 0",
"d[x][0]",
"[x]",
"d",
"x",
"0",
"0",
"d[x][1] = 0",
"d[x][1]",
"[x]",
"d",
"x",
"1",
"0",
"ans = sum(d[i][1] for i in range(1, n+1))",
"ans",
"sum(d[i][1] for i in range(1, n+1))",
"sum",
"d[i][1]",
"[i]",
"d",
"i",
"1",
"print(ans)",
"print",
"ans",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"d = {i: [1, 0] for i in range(1, n+1)}",
"{i: [1, 0] for i in range(1, n+1)}",
"d",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"ans = sum(d[i][1] for i in range(1, n+1))",
"sum(d[i][1] for i in range(1, n+1))",
"ans"
] | n, m = map(int, input().split())
d = {i: [1, 0] for i in range(1, n+1)}
d[1][1] = 1
for _ in range(m):
x, y = map(int, input().split())
d[x][0] -= 1
d[y][0] += 1
if d[x][1] == 1:
d[y][1] = 1
if d[x][0] == 0:
d[x][1] = 0
ans = sum(d[i][1] for i in range(1, n+1))
print(ans)
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
23,
13,
23,
13,
12,
13,
23,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
17,
0,
13,
17,
0,
13,
4,
13,
13,
0,
13,
39,
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,
18,
13,
13,
13,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
14,
18,
13,
2,
18,
13,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
14,
40,
18,
13,
2,
18,
13,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
4,
13,
4,
13,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
17,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13,
10,
39,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13
] | [
[
29,
29
],
[
31,
31
],
[
162,
43
],
[
171,
50
],
[
183,
53
],
[
192,
56
],
[
154,
58
],
[
192,
59
],
[
195,
61
],
[
189,
64
],
[
193,
68
],
[
180,
70
],
[
193,
74
],
[
79,
76
],
[
181,
77
],
[
82,
81
],
[
157,
84
],
[
201,
86
],
[
199,
88
],
[
196,
91
],
[
202,
93
],
[
102,
95
],
[
190,
96
],
[
202,
99
],
[
111,
104
],
[
190,
105
],
[
202,
108
],
[
181,
114
],
[
202,
117
],
[
128,
121
],
[
181,
122
],
[
202,
125
],
[
190,
132
],
[
202,
135
],
[
146,
139
],
[
181,
140
],
[
202,
143
],
[
181,
151
],
[
192,
157
],
[
162,
163
],
[
171,
172
],
[
180,
181
],
[
183,
184
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
201,
202
]
] | [
"import sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\ndef s(): return input()\ndef i(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\ndef gcd(*numbers): reduce(math.gcd, numbers)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncount = 0\nans = 0\n\nN, M = I()\na = []\nc = [1]*N\nred = [0]*N\nred[0] = 1\n\nfor i in range(M):\n x = l()\n a.append(x)\n c[x[0]-1] -= 1\n c[x[1]-1] += 1\n if red[x[0]-1]:\n red[x[1]-1] = 1\n if not c[x[0]-1]:\n red[x[0]-1] = 0\n\n\nprint(sum(red))",
"import sys",
"sys",
"import math",
"math",
"import itertools",
"itertools",
"import bisect",
"bisect",
"from copy import copy",
"from collections import deque,Counter",
"from decimal import Decimal",
"def s(): return input()",
"s",
"def i(): return int(input())",
"i",
"def S(): return input().split()",
"S",
"def I(): return map(int,input().split())",
"I",
"def X(): return list(input())",
"X",
"def L(): return list(input().split())",
"L",
"def l(): return list(map(int,input().split()))",
"l",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"lcm",
"a",
"a",
"b",
"b",
"def gcd(*numbers): reduce(math.gcd, numbers)",
"gcd",
"*numbers",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"mod = 10**9+7",
"mod",
"10**9+7",
"10**9",
"10",
"9",
"7",
"count = 0",
"count",
"0",
"ans = 0",
"ans",
"0",
"N, M = I()",
"N",
"I()",
"I",
"M",
"a = []",
"a",
"[]",
"c = [1]*N",
"c",
"[1]*N",
"[1]",
"1",
"N",
"red = [0]*N",
"red",
"[0]*N",
"[0]",
"0",
"N",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"for i in range(M):\n x = l()\n a.append(x)\n c[x[0]-1] -= 1\n c[x[1]-1] += 1\n if red[x[0]-1]:\n red[x[1]-1] = 1\n if not c[x[0]-1]:\n red[x[0]-1] = 0",
"i",
"range(M)",
"range",
"M",
"x = l()",
"x",
"l()",
"l",
"a.append(x)",
"a.append",
"a",
"append",
"x",
"c[x[0]-1] -= 1",
"c[x[0]-1]",
"c",
"x[0]-1",
"x[0]",
"x",
"0",
"1",
"1",
"c[x[1]-1] += 1",
"c[x[1]-1]",
"c",
"x[1]-1",
"x[1]",
"x",
"1",
"1",
"1",
"if red[x[0]-1]:\n red[x[1]-1] = 1\n ",
"red[x[0]-1]",
"red",
"x[0]-1",
"x[0]",
"x",
"0",
"1",
"red[x[1]-1] = 1",
"red[x[1]-1]",
"red",
"x[1]-1",
"x[1]",
"x",
"1",
"1",
"1",
"if not c[x[0]-1]:\n red[x[0]-1] = 0",
"not c[x[0]-1]",
"c[x[0]-1]",
"c",
"x[0]-1",
"x[0]",
"x",
"0",
"1",
"red[x[0]-1] = 0",
"red[x[0]-1]",
"red",
"x[0]-1",
"x[0]",
"x",
"0",
"1",
"0",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"def I(): return map(int,input().split())",
"def I(): return map(int,input().split())",
"I",
"M = I()",
"I()",
"M",
"def S(): return input().split()",
"def S(): return input().split()",
"S",
"mod = 10**9+7",
"10**9+7",
"mod",
"def s(): return input()",
"def s(): return input()",
"s",
"def gcd(*numbers): reduce(math.gcd, numbers)",
"def gcd(*numbers): reduce(math.gcd, numbers)",
"gcd",
"count = 0",
"0",
"count",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"lcm",
"def X(): return list(input())",
"def X(): return list(input())",
"X",
"red = [0]*N",
"[0]*N",
"red",
"ans = 0",
"0",
"ans",
"def i(): return int(input())",
"def i(): return int(input())",
"i",
"c = [1]*N",
"[1]*N",
"c",
"N, M = I()",
"I()",
"N",
"a = []",
"[]",
"a",
"def l(): return list(map(int,input().split()))",
"def l(): return list(map(int,input().split()))",
"l",
"x = l()",
"l()",
"x",
"def L(): return list(input().split())",
"def L(): return list(input().split())",
"L"
] | import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
N, M = I()
a = []
c = [1]*N
red = [0]*N
red[0] = 1
for i in range(M):
x = l()
a.append(x)
c[x[0]-1] -= 1
c[x[1]-1] += 1
if red[x[0]-1]:
red[x[1]-1] = 1
if not c[x[0]-1]:
red[x[0]-1] = 0
print(sum(red))
|
[
7,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
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,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
8,
2,
18,
13,
13,
39,
17,
17,
17,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
8,
2,
18,
13,
13,
17,
17,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
13,
39,
17,
17,
0,
13,
17,
4,
13,
13,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
5,
14
],
[
17,
16
],
[
17,
18
],
[
21,
20
],
[
16,
25
],
[
29,
28
],
[
16,
33
],
[
39,
36
],
[
20,
37
],
[
42,
41
],
[
18,
44
],
[
48,
47
],
[
47,
56
],
[
59,
58
],
[
59,
60
],
[
65,
62
],
[
28,
63
],
[
58,
64
],
[
70,
67
],
[
28,
68
],
[
60,
69
],
[
20,
74
],
[
58,
75
],
[
81,
78
],
[
20,
79
],
[
60,
80
],
[
110,
83
],
[
98,
83
],
[
78,
83
],
[
20,
84
],
[
60,
85
],
[
20,
94
],
[
58,
95
],
[
101,
98
],
[
20,
99
],
[
60,
100
],
[
110,
103
],
[
98,
103
],
[
78,
103
],
[
20,
104
],
[
60,
105
],
[
113,
110
],
[
20,
111
],
[
60,
112
],
[
62,
116
],
[
28,
117
],
[
58,
118
],
[
122,
121
],
[
125,
124
],
[
16,
129
],
[
20,
134
],
[
124,
135
],
[
141,
140
],
[
140,
144
],
[
121,
144
],
[
154,
151
]
] | [
"def main():\n N, M = (int(_) for _ in input().split())\n haco = [1] * (N+1)\n # 0:空, 1:白のみ取り出せる, 2:赤のみ, 3:どっちもあり得る\n cc = [1] * (N+1)\n haco[1] = 2\n for i in range(M):\n x, y = (int(_) for _ in input().split())\n cc[x] -= 1\n cc[y] += 1\n if haco[x] == 1:\n haco[y] = 3 if haco[y] in (2, 3) else 1\n elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n else:\n haco[y] = 3\n if cc[x] == 0: haco[x] = 0\n output = 0\n for i in range(1, N+1):\n if haco[i] in (2, 3):\n output += 1\n print(output)\n return\n\nif __name__ == '__main__':\n main()",
"def main():\n N, M = (int(_) for _ in input().split())\n haco = [1] * (N+1)\n # 0:空, 1:白のみ取り出せる, 2:赤のみ, 3:どっちもあり得る\n cc = [1] * (N+1)\n haco[1] = 2\n for i in range(M):\n x, y = (int(_) for _ in input().split())\n cc[x] -= 1\n cc[y] += 1\n if haco[x] == 1:\n haco[y] = 3 if haco[y] in (2, 3) else 1\n elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n else:\n haco[y] = 3\n if cc[x] == 0: haco[x] = 0\n output = 0\n for i in range(1, N+1):\n if haco[i] in (2, 3):\n output += 1\n print(output)\n return",
"main",
"int(_) for _ in input().split()",
"for _ in input().split()",
"_",
"input().split()",
"().split",
"()",
"input",
"split",
"for _ in input().split()",
"int(_)",
"int",
"_",
"N, M = (int(_) for _ in input().split())",
"N",
"(int(_) for _ in input().split())",
"M",
"haco = [1] * (N+1)",
"haco",
"[1] * (N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"cc = [1] * (N+1)",
"cc",
"[1] * (N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"haco[1] = 2",
"haco[1]",
"haco",
"1",
"2",
"for i in range(M):\n x, y = (int(_) for _ in input().split())\n cc[x] -= 1\n cc[y] += 1\n if haco[x] == 1:\n haco[y] = 3 if haco[y] in (2, 3) else 1\n elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n else:\n haco[y] = 3\n if cc[x] == 0: haco[x] = 0\n ",
"i",
"range(M)",
"range",
"M",
"int(_) for _ in input().split()",
"for _ in input().split()",
"_",
"input().split()",
"().split",
"()",
"input",
"split",
"for _ in input().split()",
"int(_)",
"int",
"_",
"x, y = (int(_) for _ in input().split())",
"x",
"(int(_) for _ in input().split())",
"y",
"cc[x] -= 1",
"cc[x]",
"cc",
"x",
"1",
"cc[y] += 1",
"cc[y]",
"cc",
"y",
"1",
"if haco[x] == 1:\n haco[y] = 3 if haco[y] in (2, 3) else 1\n elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n else:\n haco[y] = 3\n ",
"haco[x] == 1",
"haco[x]",
"haco",
"x",
"1",
"haco[y] = 3 if haco[y] in (2, 3) else 1",
"haco[y]",
"haco",
"y",
"3 if haco[y] in (2, 3) else 1",
"haco[y] in (2, 3)",
"haco[y]",
"haco",
"y",
"(2, 3)",
"2",
"3",
"3",
"1",
"elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n ",
"haco[x] == 2",
"haco[x]",
"haco",
"x",
"2",
"haco[y] = 2 if haco[y] == 0 else 3",
"haco[y]",
"haco",
"y",
"2 if haco[y] == 0 else 3",
"haco[y] == 0",
"haco[y]",
"haco",
"y",
"0",
"2",
"3",
"haco[y] = 3",
"haco[y]",
"haco",
"y",
"3",
"if cc[x] == 0: haco[x] = 0\n ",
"cc[x] == 0",
"cc[x]",
"cc",
"x",
"0",
"output = 0",
"output",
"0",
"for i in range(1, N+1):\n if haco[i] in (2, 3):\n output += 1\n ",
"i",
"range(1, N+1)",
"range",
"1",
"N+1",
"N",
"1",
"if haco[i] in (2, 3):\n output += 1\n ",
"haco[i] in (2, 3)",
"haco[i]",
"haco",
"i",
"(2, 3)",
"2",
"3",
"output += 1",
"output",
"1",
"print(output)",
"print",
"output",
"return",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n N, M = (int(_) for _ in input().split())\n haco = [1] * (N+1)\n # 0:空, 1:白のみ取り出せる, 2:赤のみ, 3:どっちもあり得る\n cc = [1] * (N+1)\n haco[1] = 2\n for i in range(M):\n x, y = (int(_) for _ in input().split())\n cc[x] -= 1\n cc[y] += 1\n if haco[x] == 1:\n haco[y] = 3 if haco[y] in (2, 3) else 1\n elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n else:\n haco[y] = 3\n if cc[x] == 0: haco[x] = 0\n output = 0\n for i in range(1, N+1):\n if haco[i] in (2, 3):\n output += 1\n print(output)\n return",
"def main():\n N, M = (int(_) for _ in input().split())\n haco = [1] * (N+1)\n # 0:空, 1:白のみ取り出せる, 2:赤のみ, 3:どっちもあり得る\n cc = [1] * (N+1)\n haco[1] = 2\n for i in range(M):\n x, y = (int(_) for _ in input().split())\n cc[x] -= 1\n cc[y] += 1\n if haco[x] == 1:\n haco[y] = 3 if haco[y] in (2, 3) else 1\n elif haco[x] == 2:\n haco[y] = 2 if haco[y] == 0 else 3\n else:\n haco[y] = 3\n if cc[x] == 0: haco[x] = 0\n output = 0\n for i in range(1, N+1):\n if haco[i] in (2, 3):\n output += 1\n print(output)\n return",
"main"
] | def main():
N, M = (int(_) for _ in input().split())
haco = [1] * (N+1)
# 0:空, 1:白のみ取り出せる, 2:赤のみ, 3:どっちもあり得る
cc = [1] * (N+1)
haco[1] = 2
for i in range(M):
x, y = (int(_) for _ in input().split())
cc[x] -= 1
cc[y] += 1
if haco[x] == 1:
haco[y] = 3 if haco[y] in (2, 3) else 1
elif haco[x] == 2:
haco[y] = 2 if haco[y] == 0 else 3
else:
haco[y] = 3
if cc[x] == 0: haco[x] = 0
output = 0
for i in range(1, N+1):
if haco[i] in (2, 3):
output += 1
print(output)
return
if __name__ == '__main__':
main()
|
[
7,
15,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
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,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
40,
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,
13,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] | [
[
123,
4
],
[
126,
16
],
[
124,
23
],
[
126,
25
],
[
29,
28
],
[
127,
32
],
[
114,
37
],
[
42,
41
],
[
127,
45
],
[
111,
50
],
[
56,
53
],
[
115,
54
],
[
59,
58
],
[
121,
61
],
[
129,
63
],
[
124,
70
],
[
129,
72
],
[
77,
74
],
[
112,
75
],
[
118,
76
],
[
82,
79
],
[
112,
80
],
[
130,
81
],
[
101,
85
],
[
115,
86
],
[
118,
87
],
[
93,
90
],
[
115,
91
],
[
130,
92
],
[
74,
96
],
[
112,
97
],
[
118,
98
],
[
104,
101
],
[
115,
102
],
[
118,
103
],
[
115,
109
],
[
111,
112
],
[
114,
115
],
[
129,
118
],
[
126,
121
],
[
123,
124
],
[
126,
127
],
[
129,
130
]
] | [
"import sys\ninput = lambda: sys.stdin.readline().rstrip()\nn, m = map(int, input().split())\nmay_contain_red = [0 for _ in range(n + 1)]\nnum_of_ball = [1 for _ in range(n + 1)]\nmay_contain_red[1] = 1\nfor i in range(m):\n x, y = map(int, input().split())\n num_of_ball[x] -= 1\n num_of_ball[y] += 1\n if may_contain_red[x] != 0:\n may_contain_red[y] = 1\n if num_of_ball[x] == 0:\n may_contain_red[x] = 0\n\nprint(sum(may_contain_red))",
"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",
"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",
"may_contain_red = [0 for _ in range(n + 1)]",
"may_contain_red",
"[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",
"num_of_ball = [1 for _ in range(n + 1)]",
"num_of_ball",
"[1 for _ in range(n + 1)]",
"may_contain_red[1] = 1",
"may_contain_red[1]",
"may_contain_red",
"1",
"1",
"for i in range(m):\n x, y = map(int, input().split())\n num_of_ball[x] -= 1\n num_of_ball[y] += 1\n if may_contain_red[x] != 0:\n may_contain_red[y] = 1\n if num_of_ball[x] == 0:\n may_contain_red[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",
"num_of_ball[x] -= 1",
"num_of_ball[x]",
"num_of_ball",
"x",
"1",
"num_of_ball[y] += 1",
"num_of_ball[y]",
"num_of_ball",
"y",
"1",
"if may_contain_red[x] != 0:\n may_contain_red[y] = 1\n ",
"may_contain_red[x] != 0",
"may_contain_red[x]",
"may_contain_red",
"x",
"0",
"may_contain_red[y] = 1",
"may_contain_red[y]",
"may_contain_red",
"y",
"1",
"if num_of_ball[x] == 0:\n may_contain_red[x] = 0",
"num_of_ball[x] == 0",
"num_of_ball[x]",
"num_of_ball",
"x",
"0",
"may_contain_red[x] = 0",
"may_contain_red[x]",
"may_contain_red",
"x",
"0",
"print(sum(may_contain_red))",
"print",
"sum(may_contain_red)",
"sum",
"may_contain_red",
"num_of_ball = [1 for _ in range(n + 1)]",
"[1 for _ in range(n + 1)]",
"num_of_ball",
"may_contain_red = [0 for _ in range(n + 1)]",
"[0 for _ in range(n + 1)]",
"may_contain_red",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"input = lambda: sys.stdin.readline().rstrip()",
"lambda: sys.stdin.readline().rstrip()",
"input",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"y = map(int, input().split())",
"map(int, input().split())",
"y"
] | import sys
input = lambda: sys.stdin.readline().rstrip()
n, m = map(int, input().split())
may_contain_red = [0 for _ in range(n + 1)]
num_of_ball = [1 for _ in range(n + 1)]
may_contain_red[1] = 1
for i in range(m):
x, y = map(int, input().split())
num_of_ball[x] -= 1
num_of_ball[y] += 1
if may_contain_red[x] != 0:
may_contain_red[y] = 1
if num_of_ball[x] == 0:
may_contain_red[x] = 0
print(sum(may_contain_red))
|
[
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,
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,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
106,
2
],
[
106,
11
],
[
112,
13
],
[
101,
17
],
[
22,
19
],
[
113,
20
],
[
115,
24
],
[
101,
28
],
[
33,
30
],
[
116,
31
],
[
36,
35
],
[
107,
38
],
[
109,
40
],
[
109,
49
],
[
113,
53
],
[
104,
55
],
[
64,
59
],
[
113,
60
],
[
110,
62
],
[
71,
66
],
[
116,
67
],
[
104,
69
],
[
78,
73
],
[
116,
74
],
[
110,
76
],
[
116,
82
],
[
104,
84
],
[
93,
88
],
[
113,
89
],
[
104,
91
],
[
113,
98
],
[
106,
101
],
[
109,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
]
] | [
"N,M=map(int, input().split())\n\nprob=[0]*N\nprob[0]=1\nnum=[1]*N\nnum[0]=1\n\nfor i in range(M):\n x,y=map(int, input().split())\n if prob[x-1]==1:\n prob[y-1]=1\n num[x-1]-=1\n num[y-1]+=1\n if num[x-1]==0:\n prob[x-1]=0\nprint(sum(prob))",
"N,M=map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"prob=[0]*N",
"prob",
"[0]*N",
"[0]",
"0",
"N",
"prob[0]=1",
"prob[0]",
"prob",
"0",
"1",
"num=[1]*N",
"num",
"[1]*N",
"[1]",
"1",
"N",
"num[0]=1",
"num[0]",
"num",
"0",
"1",
"for i in range(M):\n x,y=map(int, input().split())\n if prob[x-1]==1:\n prob[y-1]=1\n num[x-1]-=1\n num[y-1]+=1\n if num[x-1]==0:\n prob[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 prob[x-1]==1:\n prob[y-1]=1\n ",
"prob[x-1]==1",
"prob[x-1]",
"prob",
"x-1",
"x",
"1",
"1",
"prob[y-1]=1",
"prob[y-1]",
"prob",
"y-1",
"y",
"1",
"1",
"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 num[x-1]==0:\n prob[x-1]=0",
"num[x-1]==0",
"num[x-1]",
"num",
"x-1",
"x",
"1",
"0",
"prob[x-1]=0",
"prob[x-1]",
"prob",
"x-1",
"x",
"1",
"0",
"print(sum(prob))",
"print",
"sum(prob)",
"sum",
"prob",
"N,M=map(int, input().split())",
"map(int, input().split())",
"N",
"x,y=map(int, input().split())",
"map(int, input().split())",
"x",
"M=map(int, input().split())",
"map(int, input().split())",
"M",
"y=map(int, input().split())",
"map(int, input().split())",
"y",
"prob=[0]*N",
"[0]*N",
"prob",
"num=[1]*N",
"[1]*N",
"num"
] | N,M=map(int, input().split())
prob=[0]*N
prob[0]=1
num=[1]*N
num[0]=1
for i in range(M):
x,y=map(int, input().split())
if prob[x-1]==1:
prob[y-1]=1
num[x-1]-=1
num[y-1]+=1
if num[x-1]==0:
prob[x-1]=0
print(sum(prob)) |
[
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,
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,
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,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
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,
12,
13,
10,
12,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
17,
13
] | [
[
176,
16
],
[
170,
43
],
[
162,
45
],
[
170,
46
],
[
173,
48
],
[
168,
52
],
[
149,
54
],
[
168,
58
],
[
63,
60
],
[
150,
61
],
[
66,
65
],
[
171,
68
],
[
155,
70
],
[
162,
72
],
[
155,
73
],
[
150,
76
],
[
153,
78
],
[
86,
81
],
[
174,
82
],
[
153,
84
],
[
174,
90
],
[
153,
92
],
[
101,
96
],
[
150,
97
],
[
153,
99
],
[
108,
103
],
[
174,
104
],
[
156,
106
],
[
115,
110
],
[
150,
111
],
[
156,
113
],
[
122,
117
],
[
174,
118
],
[
153,
120
],
[
129,
124
],
[
174,
125
],
[
156,
127
],
[
164,
131
],
[
135,
134
],
[
168,
137
],
[
150,
140
],
[
134,
141
],
[
179,
143
],
[
180,
147
],
[
165,
147
],
[
149,
150
],
[
155,
153
],
[
155,
156
],
[
164,
165
],
[
170,
168
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
]
] | [
"#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 # (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()\nbox = [1] * n\nIn = [False] * n\nIn[0] = True\nfor i in range(m):\n x,y = readInts()\n if In[x-1]:\n box[x-1] -= 1\n if box[x-1] == 0:\n In[x-1] = False\n box[y-1] += 1\n In[y-1] = True\n else:\n box[x-1] -= 1\n box[y-1] += 1\ncnt = 0\nfor i in range(n):\n if In[i]:\n cnt += 1\nprint(cnt)",
"from fractions import gcd",
"from itertools import combinations,permutations,accumulate",
"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",
"box = [1] * n",
"box",
"[1] * n",
"[1]",
"1",
"n",
"In = [False] * n",
"In",
"[False] * n",
"[False]",
"False",
"n",
"In[0] = True",
"In[0]",
"In",
"0",
"True",
"for i in range(m):\n x,y = readInts()\n if In[x-1]:\n box[x-1] -= 1\n if box[x-1] == 0:\n In[x-1] = False\n box[y-1] += 1\n In[y-1] = True\n else:\n box[x-1] -= 1\n box[y-1] += 1",
"i",
"range(m)",
"range",
"m",
"x,y = readInts()",
"x",
"readInts()",
"readInts",
"y",
"if In[x-1]:\n box[x-1] -= 1\n if box[x-1] == 0:\n In[x-1] = False\n box[y-1] += 1\n In[y-1] = True\n else:\n box[x-1] -= 1\n box[y-1] += 1",
"In[x-1]",
"In",
"x-1",
"x",
"1",
"box[x-1] -= 1",
"box[x-1]",
"box",
"x-1",
"x",
"1",
"1",
"if box[x-1] == 0:\n In[x-1] = False\n ",
"box[x-1] == 0",
"box[x-1]",
"box",
"x-1",
"x",
"1",
"0",
"In[x-1] = False",
"In[x-1]",
"In",
"x-1",
"x",
"1",
"False",
"box[y-1] += 1",
"box[y-1]",
"box",
"y-1",
"y",
"1",
"1",
"In[y-1] = True",
"In[y-1]",
"In",
"y-1",
"y",
"1",
"True",
"box[x-1] -= 1",
"box[x-1]",
"box",
"x-1",
"x",
"1",
"1",
"box[y-1] += 1",
"box[y-1]",
"box",
"y-1",
"y",
"1",
"1",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n if In[i]:\n cnt += 1",
"i",
"range(n)",
"range",
"n",
"if In[i]:\n cnt += 1",
"In[i]",
"In",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"In = [False] * n",
"[False] * n",
"In",
"x,y = readInts()",
"readInts()",
"x",
"y = readInts()",
"readInts()",
"y",
"def I():\n return int(input())",
"def I():\n return int(input())",
"I",
"def readInts():\n return list(map(int,input().split()))",
"def readInts():\n return list(map(int,input().split()))",
"readInts",
"cnt = 0",
"0",
"cnt",
"n,m = readInts()",
"readInts()",
"n",
"m = readInts()",
"readInts()",
"m",
"box = [1] * n",
"[1] * n",
"box",
"mod = 10**9 + 7",
"10**9 + 7",
"mod",
"cnt += 1",
"1",
"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 # (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()
box = [1] * n
In = [False] * n
In[0] = True
for i in range(m):
x,y = readInts()
if In[x-1]:
box[x-1] -= 1
if box[x-1] == 0:
In[x-1] = False
box[y-1] += 1
In[y-1] = True
else:
box[x-1] -= 1
box[y-1] += 1
cnt = 0
for i in range(n):
if In[i]:
cnt += 1
print(cnt)
|
[
7,
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,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
40,
18,
13,
2,
13,
17,
4,
13,
4,
18,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
89,
2
],
[
89,
11
],
[
95,
13
],
[
81,
21
],
[
86,
24
],
[
81,
28
],
[
31,
30
],
[
90,
33
],
[
92,
35
],
[
92,
44
],
[
96,
47
],
[
84,
49
],
[
57,
52
],
[
87,
53
],
[
84,
55
],
[
64,
59
],
[
87,
60
],
[
93,
62
],
[
87,
68
],
[
84,
70
],
[
96,
76
],
[
89,
81
],
[
92,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
]
] | [
"n,m=map(int,input().split())\nl=[1]+[0]*(n+1)\na=[1]*n\nfor i in range(m):\n x,y=map(int,input().split())\n if l[x-1]:l[y-1]=1\n a[x-1]-=1;a[y-1]+=1\n if not a[x-1]:l[x-1]=0\nprint(l.count(1))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"l=[1]+[0]*(n+1)",
"l",
"[1]+[0]*(n+1)",
"[1]",
"1",
"[0]*(n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"a=[1]*n",
"a",
"[1]*n",
"[1]",
"1",
"n",
"for i in range(m):\n x,y=map(int,input().split())\n if l[x-1]:l[y-1]=1\n a[x-1]-=1;a[y-1]+=1\n if not a[x-1]:l[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 l[x-1]:l[y-1]=1\n ",
"l[x-1]",
"l",
"x-1",
"x",
"1",
"a[x-1]-=1",
"a[x-1]",
"a",
"x-1",
"x",
"1",
"1",
"a[y-1]+=1",
"a[y-1]",
"a",
"y-1",
"y",
"1",
"1",
"if not a[x-1]:l[x-1]=",
"not a[x-1]",
"a[x-1]",
"a",
"x-1",
"x",
"1",
"print(l.count(1))",
"print",
"l.count(1)",
"l.count",
"l",
"count",
"1",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"a=[1]*n",
"[1]*n",
"a",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"l=[1]+[0]*(n+1)",
"[1]+[0]*(n+1)",
"l"
] | n,m=map(int,input().split())
l=[1]+[0]*(n+1)
a=[1]*n
for i in range(m):
x,y=map(int,input().split())
if l[x-1]:l[y-1]=1
a[x-1]-=1;a[y-1]+=1
if not a[x-1]:l[x-1]=0
print(l.count(1)) |
[
7,
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,
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,
0,
13,
4,
18,
13,
13,
17,
29,
13,
4,
13,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
4,
19
],
[
22,
21
],
[
4,
25
],
[
30,
27
],
[
15,
28
],
[
33,
32
],
[
13,
35
],
[
38,
37
],
[
38,
46
],
[
49,
48
],
[
52,
51
],
[
71,
55
],
[
15,
56
],
[
48,
57
],
[
37,
57
],
[
63,
60
],
[
15,
61
],
[
51,
62
],
[
46,
62
],
[
76,
66
],
[
21,
67
],
[
48,
68
],
[
37,
68
],
[
74,
71
],
[
15,
72
],
[
48,
73
],
[
37,
73
],
[
79,
76
],
[
21,
77
],
[
48,
78
],
[
37,
78
],
[
84,
81
],
[
21,
82
],
[
51,
83
],
[
46,
83
],
[
87,
86
],
[
15,
89
],
[
86,
93
],
[
100,
97
]
] | [
"def solve():\n N, M = map(int, input().split())\n lis = [False]*N\n cnt = [1]*N\n lis[0] = True\n for i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]==True:\n lis[y]=True\n if cnt[x]==1:\n lis[x]=False\n cnt[x] -= 1\n cnt[y] += 1\n ans = lis.count(True)\n return ans\nprint(solve())",
"def solve():\n N, M = map(int, input().split())\n lis = [False]*N\n cnt = [1]*N\n lis[0] = True\n for i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]==True:\n lis[y]=True\n if cnt[x]==1:\n lis[x]=False\n cnt[x] -= 1\n cnt[y] += 1\n ans = lis.count(True)\n return ans",
"solve",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"lis = [False]*N",
"lis",
"[False]*N",
"[False]",
"False",
"N",
"cnt = [1]*N",
"cnt",
"[1]*N",
"[1]",
"1",
"N",
"lis[0] = True",
"lis[0]",
"lis",
"0",
"True",
"for i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]==True:\n lis[y]=True\n if cnt[x]==1:\n lis[x]=False\n cnt[x] -= 1\n cnt[y] += 1\n ",
"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 lis[x]==True:\n lis[y]=True\n if cnt[x]==1:\n lis[x]=False\n ",
"lis[x]==True",
"lis[x]",
"lis",
"x",
"True",
"lis[y]=True",
"lis[y]",
"lis",
"y",
"True",
"if cnt[x]==1:\n lis[x]=False\n ",
"cnt[x]==1",
"cnt[x]",
"cnt",
"x",
"1",
"lis[x]=False",
"lis[x]",
"lis",
"x",
"False",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"ans = lis.count(True)",
"ans",
"lis.count(True)",
"lis.count",
"lis",
"count",
"True",
"return ans",
"ans",
"print(solve())",
"print",
"solve()",
"solve",
"def solve():\n N, M = map(int, input().split())\n lis = [False]*N\n cnt = [1]*N\n lis[0] = True\n for i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]==True:\n lis[y]=True\n if cnt[x]==1:\n lis[x]=False\n cnt[x] -= 1\n cnt[y] += 1\n ans = lis.count(True)\n return ans",
"def solve():\n N, M = map(int, input().split())\n lis = [False]*N\n cnt = [1]*N\n lis[0] = True\n for i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]==True:\n lis[y]=True\n if cnt[x]==1:\n lis[x]=False\n cnt[x] -= 1\n cnt[y] += 1\n ans = lis.count(True)\n return ans",
"solve"
] | def solve():
N, M = map(int, input().split())
lis = [False]*N
cnt = [1]*N
lis[0] = True
for i in range(M):
x,y = map(int, input().split())
x -= 1
y -= 1
if lis[x]==True:
lis[y]=True
if cnt[x]==1:
lis[x]=False
cnt[x] -= 1
cnt[y] += 1
ans = lis.count(True)
return ans
print(solve()) |
[
7,
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,
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,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
98,
2
],
[
98,
11
],
[
110,
13
],
[
99,
21
],
[
107,
24
],
[
99,
28
],
[
31,
30
],
[
96,
33
],
[
104,
35
],
[
104,
44
],
[
111,
47
],
[
105,
49
],
[
57,
52
],
[
111,
53
],
[
102,
55
],
[
64,
59
],
[
108,
60
],
[
105,
62
],
[
71,
66
],
[
108,
67
],
[
102,
69
],
[
108,
75
],
[
105,
77
],
[
86,
81
],
[
111,
82
],
[
105,
84
],
[
111,
91
],
[
98,
96
],
[
98,
99
],
[
104,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"N,M=map(int,input().split())\nR=[True]+[False]*(N-1)\nB=[1]*N\nfor i in range(M):\n x,y=map(int,input().split())\n if R[x-1]:\n R[y-1]=True\n B[x-1]-=1\n B[y-1]+=1\n if B[x-1]==0:\n R[x-1]=False\nprint(R.count(True))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"R=[True]+[False]*(N-1)",
"R",
"[True]+[False]*(N-1)",
"[True]",
"True",
"[False]*(N-1)",
"[False]",
"False",
"N-1",
"N",
"1",
"B=[1]*N",
"B",
"[1]*N",
"[1]",
"1",
"N",
"for i in range(M):\n x,y=map(int,input().split())\n if R[x-1]:\n R[y-1]=True\n B[x-1]-=1\n B[y-1]+=1\n if B[x-1]==0:\n R[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",
"if R[x-1]:\n R[y-1]=True\n ",
"R[x-1]",
"R",
"x-1",
"x",
"1",
"R[y-1]=True",
"R[y-1]",
"R",
"y-1",
"y",
"1",
"True",
"B[x-1]-=1",
"B[x-1]",
"B",
"x-1",
"x",
"1",
"1",
"B[y-1]+=1",
"B[y-1]",
"B",
"y-1",
"y",
"1",
"1",
"if B[x-1]==0:\n R[x-1]=False",
"B[x-1]==0",
"B[x-1]",
"B",
"x-1",
"x",
"1",
"0",
"R[x-1]=False",
"R[x-1]",
"R",
"x-1",
"x",
"1",
"False",
"print(R.count(True))",
"print",
"R.count(True)",
"R.count",
"R",
"count",
"True",
"M=map(int,input().split())",
"map(int,input().split())",
"M",
"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",
"B=[1]*N",
"[1]*N",
"B",
"R=[True]+[False]*(N-1)",
"[True]+[False]*(N-1)",
"R"
] | N,M=map(int,input().split())
R=[True]+[False]*(N-1)
B=[1]*N
for i in range(M):
x,y=map(int,input().split())
if R[x-1]:
R[y-1]=True
B[x-1]-=1
B[y-1]+=1
if B[x-1]==0:
R[x-1]=False
print(R.count(True)) |
[
7,
15,
13,
13,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
15,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
13,
17,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
18,
13,
2,
13,
17,
13,
0,
13,
18,
13,
2,
13,
17,
13,
14,
2,
40,
13,
17,
40,
13,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
14,
2,
13,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
18,
18,
13,
2,
13,
17,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
18,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
18,
13,
10,
12,
13,
10,
2,
13,
10,
13,
13,
10,
18,
13
] | [
[
26,
25
],
[
195,
31
],
[
35,
35
],
[
230,
44
],
[
239,
49
],
[
215,
57
],
[
195,
59
],
[
215,
60
],
[
64,
63
],
[
216,
66
],
[
242,
72
],
[
78,
75
],
[
243,
76
],
[
83,
82
],
[
210,
85
],
[
212,
87
],
[
195,
89
],
[
212,
90
],
[
221,
92
],
[
243,
94
],
[
213,
96
],
[
221,
98
],
[
245,
100
],
[
243,
102
],
[
198,
104
],
[
245,
106
],
[
204,
110
],
[
222,
113
],
[
123,
116
],
[
243,
118
],
[
213,
120
],
[
132,
125
],
[
243,
127
],
[
198,
129
],
[
204,
135
],
[
145,
138
],
[
243,
140
],
[
213,
142
],
[
154,
147
],
[
243,
149
],
[
198,
151
],
[
163,
156
],
[
243,
158
],
[
213,
160
],
[
172,
165
],
[
243,
167
],
[
198,
169
],
[
200,
174
],
[
178,
177
],
[
216,
180
],
[
243,
184
],
[
177,
185
],
[
218,
188
],
[
219,
192
],
[
201,
192
],
[
212,
198
],
[
200,
201
],
[
221,
204
],
[
215,
210
],
[
212,
213
],
[
215,
216
],
[
218,
219
],
[
221,
222
],
[
230,
231
],
[
245,
234
],
[
239,
240
],
[
242,
243
],
[
245,
246
]
] | [
"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom decimal import Decimal\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10**9 + 7\nfrom decimal import *\n\nN, M = MAP()\nballs = [[1, 0] for _ in range(N)] #[white, red]の個数\nballs[0] = [0, 1]\n\nfor _ in range(M):\n\tx, y = MAP()\n\n\tw_x, r_x = balls[x-1]\n\tw_y, r_y = balls[y-1]\n\n\tif w_x >= 1 and r_x >= 1: \n\t\tballs[x-1][0] -= 1\n\t\tballs[y-1][1] += 1\n\n\telif w_x == 0:\n\t\tballs[x-1][1] -= 1\n\t\tballs[y-1][1] += 1\n\n\telse:\n\t\tballs[x-1][0] -= 1\n\t\tballs[y-1][0] += 1\n\nans = 0\nfor i in range(N):\n\tif balls[i][1]:\n\t\tans += 1\nprint(ans)",
"import sys, re",
"sys",
"re",
"from collections import deque, defaultdict, Counter",
"from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees",
"from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby",
"from operator import itemgetter, mul",
"from copy import deepcopy",
"from string import ascii_lowercase, ascii_uppercase, digits",
"from bisect import bisect, bisect_left, insort, insort_left",
"from fractions import gcd",
"from heapq import heappush, heappop",
"from functools import reduce",
"from decimal import Decimal",
"def input(): return sys.stdin.readline().strip()",
"input",
"def INT(): return int(input())",
"INT",
"def MAP(): return map(int, input().split())",
"MAP",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"MAP() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"MAP()",
"MAP",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"n",
"n",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"mod = 10**9 + 7",
"mod",
"10**9 + 7",
"10**9",
"10",
"9",
"7",
"from decimal import *",
"N, M = MAP()",
"N",
"MAP()",
"MAP",
"M",
"[1, 0] for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"[1, 0]",
"1",
"0",
"balls = [[1, 0] for _ in range(N)]",
"balls",
"[[1, 0] for _ in range(N)]",
"balls[0] = [0, 1]",
"balls[0]",
"balls",
"0",
"[0, 1]",
"0",
"1",
"for _ in range(M):\n\tx, y = MAP()\n\n\tw_x, r_x = balls[x-1]\n\tw_y, r_y = balls[y-1]\n\n\tif w_x >= 1 and r_x >= 1: \n\t\tballs[x-1][0] -= 1\n\t\tballs[y-1][1] += 1\n\n\telif w_x == 0:\n\t\tballs[x-1][1] -= 1\n\t\tballs[y-1][1] += 1\n\n\telse:\n\t\tballs[x-1][0] -= 1\n\t\tballs[y-1][0] += 1",
"_",
"range(M)",
"range",
"M",
"x, y = MAP()",
"x",
"MAP()",
"MAP",
"y",
"w_x, r_x = balls[x-1]",
"w_x",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"r_x",
"w_y, r_y = balls[y-1]",
"w_y",
"balls[y-1]",
"balls",
"y-1",
"y",
"1",
"r_y",
"if w_x >= 1 and r_x >= 1: \n\t\tballs[x-1][0] -= 1\n\t\tballs[y-1][1] += 1\n\n\telif w_x == 0:\n\t\tballs[x-1][1] -= 1\n\t\tballs[y-1][1] += 1\n\n\telse:\n\t\tballs[x-1][0] -= 1\n\t\tballs[y-1][0] += 1",
"w_x >= 1 and r_x >= 1",
"w_x >= 1",
"w_x",
"1",
"r_x >= 1",
"r_x",
"1",
"balls[x-1][0] -= 1",
"balls[x-1][0]",
"[x-1]",
"balls",
"x-1",
"x",
"1",
"0",
"1",
"balls[y-1][1] += 1",
"balls[y-1][1]",
"[y-1]",
"balls",
"y-1",
"y",
"1",
"1",
"1",
"elif w_x == 0:\n\t\tballs[x-1][1] -= 1\n\t\tballs[y-1][1] += 1\n\n\t",
"w_x == 0",
"w_x",
"0",
"balls[x-1][1] -= 1",
"balls[x-1][1]",
"[x-1]",
"balls",
"x-1",
"x",
"1",
"1",
"1",
"balls[y-1][1] += 1",
"balls[y-1][1]",
"[y-1]",
"balls",
"y-1",
"y",
"1",
"1",
"1",
"balls[x-1][0] -= 1",
"balls[x-1][0]",
"[x-1]",
"balls",
"x-1",
"x",
"1",
"0",
"1",
"balls[y-1][0] += 1",
"balls[y-1][0]",
"[y-1]",
"balls",
"y-1",
"y",
"1",
"0",
"1",
"ans = 0",
"ans",
"0",
"for i in range(N):\n\tif balls[i][1]:\n\t\tans += 1",
"i",
"range(N)",
"range",
"N",
"if balls[i][1]:\n\t\tans += 1",
"balls[i][1]",
"[i]",
"balls",
"i",
"1",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"def MAP(): return map(int, input().split())",
"def MAP(): return map(int, input().split())",
"MAP",
"y = MAP()",
"MAP()",
"y",
"ans = 0",
"0",
"ans",
"w_x, r_x = balls[x-1]",
"balls[x-1]",
"w_x",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"M = MAP()",
"MAP()",
"M",
"x, y = MAP()",
"MAP()",
"x",
"N, M = MAP()",
"MAP()",
"N",
"ans += 1",
"1",
"ans",
"r_x = balls[x-1]",
"balls[x-1]",
"r_x",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input",
"def LIST(): return list(map(int, input().split()))",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"INF = float('inf')",
"float('inf')",
"INF",
"w_y, r_y = balls[y-1]",
"balls[y-1]",
"w_y",
"def INT(): return int(input())",
"def INT(): return int(input())",
"INT",
"mod = 10**9 + 7",
"10**9 + 7",
"mod",
"balls = [[1, 0] for _ in range(N)]",
"[[1, 0] for _ in range(N)]",
"balls",
"r_y = balls[y-1]",
"balls[y-1]",
"r_y"
] | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
N, M = MAP()
balls = [[1, 0] for _ in range(N)] #[white, red]の個数
balls[0] = [0, 1]
for _ in range(M):
x, y = MAP()
w_x, r_x = balls[x-1]
w_y, r_y = balls[y-1]
if w_x >= 1 and r_x >= 1:
balls[x-1][0] -= 1
balls[y-1][1] += 1
elif w_x == 0:
balls[x-1][1] -= 1
balls[y-1][1] += 1
else:
balls[x-1][0] -= 1
balls[y-1][0] += 1
ans = 0
for i in range(N):
if balls[i][1]:
ans += 1
print(ans) |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
12,
2,
4,
13,
13,
17,
23,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
12,
13,
23,
13,
23,
13,
17,
0,
13,
4,
13,
17,
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,
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,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13
] | [
[
160,
11
],
[
32,
31
],
[
170,
37
],
[
41,
41
],
[
45,
45
],
[
48,
47
],
[
175,
50
],
[
58,
57
],
[
155,
59
],
[
58,
60
],
[
63,
62
],
[
57,
66
],
[
69,
68
],
[
57,
72
],
[
77,
74
],
[
68,
75
],
[
80,
79
],
[
60,
82
],
[
85,
84
],
[
158,
86
],
[
85,
87
],
[
101,
90
],
[
68,
91
],
[
84,
92
],
[
127,
96
],
[
106,
96
],
[
62,
97
],
[
84,
98
],
[
104,
101
],
[
68,
102
],
[
84,
103
],
[
109,
106
],
[
62,
107
],
[
84,
108
],
[
114,
111
],
[
68,
112
],
[
87,
113
],
[
119,
116
],
[
62,
117
],
[
87,
118
],
[
127,
122
],
[
106,
122
],
[
62,
123
],
[
84,
124
],
[
130,
127
],
[
62,
128
],
[
84,
129
],
[
135,
132
],
[
62,
133
],
[
87,
134
],
[
68,
140
],
[
149,
146
],
[
160,
161
],
[
175,
176
]
] | [
"import sys\nsys.setrecursionlimit(10 ** 6)\n# input = sys.stdin.readline ####\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\ndef printlist(lst, k='\\n'): print(k.join(list(map(str, lst))))\nINF = float('inf')\n\ndef solve():\n n, m = MI()\n\n B = [1] * n\n J = [False] * n\n J[0] = True\n\n for i in range(m):\n x, y = MI1()\n\n if J[x] == True:\n if B[x] == 1:\n J[x] = False\n B[x] -= 1\n J[y] = True\n B[y] += 1\n else:\n if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n print(sum(J))\n\n\n\n\n\nif __name__ == '__main__':\n solve()",
"import sys",
"sys",
"sys.setrecursionlimit(10 ** 6)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 6",
"10",
"6",
"int1 = lambda x: int(x) - 1",
"int1",
"lambda x: int(x) - 1",
"int(x) - 1",
"int(x)",
"int",
"x",
"1",
"x",
"def II(): return int(input())",
"II",
"def MI(): return map(int, input().split())",
"MI",
"def MI1(): return map(int1, input().split())",
"MI1",
"def LI(): return list(map(int, input().split()))",
"LI",
"def LI1(): return list(map(int1, input().split()))",
"LI1",
"LI() for _ in range(rows_number)",
"for _ in range(rows_number)",
"_",
"range(rows_number)",
"range",
"rows_number",
"for _ in range(rows_number)",
"LI()",
"LI",
"def LLI(rows_number): return [LI() for _ in range(rows_number)]",
"LLI",
"rows_number",
"rows_number",
"def printlist(lst, k='\\n'): print(k.join(list(map(str, lst))))",
"printlist",
"lst",
"lst",
"k='\\n'",
"k",
"'\\n'",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"def solve():\n n, m = MI()\n\n B = [1] * n\n J = [False] * n\n J[0] = True\n\n for i in range(m):\n x, y = MI1()\n\n if J[x] == True:\n if B[x] == 1:\n J[x] = False\n B[x] -= 1\n J[y] = True\n B[y] += 1\n else:\n if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n print(sum(J))",
"solve",
"n, m = MI()",
"n",
"MI()",
"MI",
"m",
"B = [1] * n",
"B",
"[1] * n",
"[1]",
"1",
"n",
"J = [False] * n",
"J",
"[False] * n",
"[False]",
"False",
"n",
"J[0] = True",
"J[0]",
"J",
"0",
"True",
"for i in range(m):\n x, y = MI1()\n\n if J[x] == True:\n if B[x] == 1:\n J[x] = False\n B[x] -= 1\n J[y] = True\n B[y] += 1\n else:\n if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n ",
"i",
"range(m)",
"range",
"m",
"x, y = MI1()",
"x",
"MI1()",
"MI1",
"y",
"if J[x] == True:\n if B[x] == 1:\n J[x] = False\n B[x] -= 1\n J[y] = True\n B[y] += 1\n else:\n if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n ",
"J[x] == True",
"J[x]",
"J",
"x",
"True",
"if B[x] == 1:\n J[x] = False\n ",
"B[x] == 1",
"B[x]",
"B",
"x",
"1",
"J[x] = False",
"J[x]",
"J",
"x",
"False",
"B[x] -= 1",
"B[x]",
"B",
"x",
"1",
"J[y] = True",
"J[y]",
"J",
"y",
"True",
"B[y] += 1",
"B[y]",
"B",
"y",
"1",
"if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n ",
"B[x] > 0",
"B[x]",
"B",
"x",
"0",
"B[x] -= 1",
"B[x]",
"B",
"x",
"1",
"B[y] += 1",
"B[y]",
"B",
"y",
"1",
"print(sum(J))",
"print",
"sum(J)",
"sum",
"J",
"if __name__ == '__main__':\n solve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"solve()",
"solve",
"def solve():\n n, m = MI()\n\n B = [1] * n\n J = [False] * n\n J[0] = True\n\n for i in range(m):\n x, y = MI1()\n\n if J[x] == True:\n if B[x] == 1:\n J[x] = False\n B[x] -= 1\n J[y] = True\n B[y] += 1\n else:\n if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n print(sum(J))",
"def solve():\n n, m = MI()\n\n B = [1] * n\n J = [False] * n\n J[0] = True\n\n for i in range(m):\n x, y = MI1()\n\n if J[x] == True:\n if B[x] == 1:\n J[x] = False\n B[x] -= 1\n J[y] = True\n B[y] += 1\n else:\n if B[x] > 0:\n B[x] -= 1\n B[y] += 1\n print(sum(J))",
"solve",
"def LI1(): return list(map(int1, input().split()))",
"def LI1(): return list(map(int1, input().split()))",
"LI1",
"def MI(): return map(int, input().split())",
"def MI(): return map(int, input().split())",
"MI",
"def MI1(): return map(int1, input().split())",
"def MI1(): return map(int1, input().split())",
"MI1",
"int1 = lambda x: int(x) - 1",
"lambda x: int(x) - 1",
"int1",
"def printlist(lst, k='\\n'): print(k.join(list(map(str, lst))))",
"def printlist(lst, k='\\n'): print(k.join(list(map(str, lst))))",
"printlist",
"def II(): return int(input())",
"def II(): return int(input())",
"II",
"def LI(): return list(map(int, input().split()))",
"def LI(): return list(map(int, input().split()))",
"LI",
"def LLI(rows_number): return [LI() for _ in range(rows_number)]",
"def LLI(rows_number): return [LI() for _ in range(rows_number)]",
"LLI",
"INF = float('inf')",
"float('inf')",
"INF"
] | import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')
def solve():
n, m = MI()
B = [1] * n
J = [False] * n
J[0] = True
for i in range(m):
x, y = MI1()
if J[x] == True:
if B[x] == 1:
J[x] = False
B[x] -= 1
J[y] = True
B[y] += 1
else:
if B[x] > 0:
B[x] -= 1
B[y] += 1
print(sum(J))
if __name__ == '__main__':
solve()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
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,
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,
4,
13,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
99,
2
],
[
99,
11
],
[
87,
13
],
[
102,
16
],
[
88,
20
],
[
94,
20
],
[
90,
22
],
[
88,
26
],
[
94,
26
],
[
31,
28
],
[
91,
29
],
[
34,
33
],
[
100,
36
],
[
96,
38
],
[
96,
47
],
[
91,
50
],
[
85,
51
],
[
56,
53
],
[
91,
54
],
[
97,
55
],
[
69,
59
],
[
103,
60
],
[
85,
61
],
[
67,
64
],
[
91,
65
],
[
85,
66
],
[
72,
69
],
[
103,
70
],
[
85,
71
],
[
77,
74
],
[
103,
75
],
[
97,
76
],
[
91,
82
],
[
96,
85
],
[
87,
88
],
[
90,
91
],
[
99,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
]
] | [
"n,m = map(int,input().split())\nn += 1\np = [1]*n\nr = [0]*n\nr[1] = 1\nfor i in range(m):\n x,y = map(int,input().split())\n if r[x]:\n r[y] = 1\n if p[x] == 1:\n r[x] = 0\n p[x] -= 1\n p[y] += 1\n \nprint(sum(r))",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"n += 1",
"n",
"1",
"p = [1]*n",
"p",
"[1]*n",
"[1]",
"1",
"n",
"r = [0]*n",
"r",
"[0]*n",
"[0]",
"0",
"n",
"r[1] = 1",
"r[1]",
"r",
"1",
"1",
"for i in range(m):\n x,y = map(int,input().split())\n if r[x]:\n r[y] = 1\n if p[x] == 1:\n r[x] = 0\n p[x] -= 1\n p[y] += 1\n ",
"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]:\n r[y] = 1\n if p[x] == 1:\n r[x] = 0\n ",
"r[x]",
"r",
"x",
"r[y] = 1",
"r[y]",
"r",
"y",
"1",
"if p[x] == 1:\n r[x] = 0\n ",
"p[x] == 1",
"p[x]",
"p",
"x",
"1",
"r[x] = 0",
"r[x]",
"r",
"x",
"0",
"p[x] -= 1",
"p[x]",
"p",
"x",
"1",
"p[y] += 1",
"p[y]",
"p",
"y",
"1",
"print(sum(r))",
"print",
"sum(r)",
"sum",
"r",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x",
"n += 1",
"1",
"n",
"r = [0]*n",
"[0]*n",
"r",
"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",
"p = [1]*n",
"[1]*n",
"p"
] | n,m = map(int,input().split())
n += 1
p = [1]*n
r = [0]*n
r[1] = 1
for i in range(m):
x,y = map(int,input().split())
if r[x]:
r[y] = 1
if p[x] == 1:
r[x] = 0
p[x] -= 1
p[y] += 1
print(sum(r)) |
[
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,
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,
13,
14,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
105,
2
],
[
105,
11
],
[
96,
13
],
[
103,
18
],
[
24,
21
],
[
97,
22
],
[
99,
26
],
[
103,
31
],
[
37,
34
],
[
100,
35
],
[
40,
39
],
[
106,
42
],
[
114,
44
],
[
114,
53
],
[
100,
56
],
[
109,
57
],
[
62,
59
],
[
100,
60
],
[
115,
61
],
[
75,
65
],
[
97,
66
],
[
109,
67
],
[
73,
70
],
[
100,
71
],
[
109,
72
],
[
78,
75
],
[
97,
76
],
[
109,
77
],
[
83,
80
],
[
97,
81
],
[
115,
82
],
[
111,
85
],
[
89,
88
],
[
100,
88
],
[
112,
94
],
[
96,
97
],
[
99,
100
],
[
105,
103
],
[
105,
106
],
[
114,
109
],
[
111,
112
],
[
114,
115
]
] | [
"n,m = map(int, input().split())\nball_cnts = [1]*(n+1)\nball_cnts[0] = 0\nred_flag = [False]*(n+1)\nred_flag[1] = True\n\nfor _ in range(m):\n x,y = map(int, input().split())\n if red_flag[x]:\n red_flag[y] = True\n if ball_cnts[x] == 1:\n red_flag[x] = False\n ball_cnts[x] -= 1\n ball_cnts[y] += 1\n\nans = 0\nfor v in red_flag:\n if v: ans += 1\n\nprint(ans)",
"n,m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ball_cnts = [1]*(n+1)",
"ball_cnts",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"ball_cnts[0] = 0",
"ball_cnts[0]",
"ball_cnts",
"0",
"0",
"red_flag = [False]*(n+1)",
"red_flag",
"[False]*(n+1)",
"[False]",
"False",
"n+1",
"n",
"1",
"red_flag[1] = True",
"red_flag[1]",
"red_flag",
"1",
"True",
"for _ in range(m):\n x,y = map(int, input().split())\n if red_flag[x]:\n red_flag[y] = True\n if ball_cnts[x] == 1:\n red_flag[x] = False\n ball_cnts[x] -= 1\n ball_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 red_flag[x]:\n red_flag[y] = True\n ",
"red_flag[x]",
"red_flag",
"x",
"red_flag[y] = True",
"red_flag[y]",
"red_flag",
"y",
"True",
"if ball_cnts[x] == 1:\n red_flag[x] = False\n ",
"ball_cnts[x] == 1",
"ball_cnts[x]",
"ball_cnts",
"x",
"1",
"red_flag[x] = False",
"red_flag[x]",
"red_flag",
"x",
"False",
"ball_cnts[x] -= 1",
"ball_cnts[x]",
"ball_cnts",
"x",
"1",
"ball_cnts[y] += 1",
"ball_cnts[y]",
"ball_cnts",
"y",
"1",
"ans = 0",
"ans",
"0",
"for v in red_flag:\n if v: ans += 1",
"v",
"red_flag",
"if v: ans ",
"v",
"print(ans)",
"print",
"ans",
"ball_cnts = [1]*(n+1)",
"[1]*(n+1)",
"ball_cnts",
"red_flag = [False]*(n+1)",
"[False]*(n+1)",
"red_flag",
"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",
"ans = 0",
"0",
"ans",
"y = map(int, input().split())",
"map(int, input().split())",
"y"
] | n,m = map(int, input().split())
ball_cnts = [1]*(n+1)
ball_cnts[0] = 0
red_flag = [False]*(n+1)
red_flag[1] = True
for _ in range(m):
x,y = map(int, input().split())
if red_flag[x]:
red_flag[y] = True
if ball_cnts[x] == 1:
red_flag[x] = False
ball_cnts[x] -= 1
ball_cnts[y] += 1
ans = 0
for v in red_flag:
if v: ans += 1
print(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,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
40,
18,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
18,
13,
13,
17,
0,
13,
2,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
157,
2
],
[
157,
11
],
[
145,
13
],
[
155,
18
],
[
151,
21
],
[
155,
26
],
[
32,
29
],
[
146,
30
],
[
37,
34
],
[
152,
35
],
[
40,
39
],
[
158,
42
],
[
148,
44
],
[
148,
53
],
[
76,
56
],
[
146,
57
],
[
149,
58
],
[
64,
61
],
[
146,
62
],
[
137,
63
],
[
61,
65
],
[
146,
66
],
[
137,
67
],
[
103,
71
],
[
85,
71
],
[
152,
72
],
[
149,
73
],
[
79,
76
],
[
146,
77
],
[
149,
78
],
[
76,
80
],
[
146,
81
],
[
149,
82
],
[
88,
85
],
[
152,
86
],
[
149,
87
],
[
103,
89
],
[
85,
89
],
[
152,
90
],
[
149,
91
],
[
97,
94
],
[
152,
95
],
[
137,
96
],
[
94,
98
],
[
152,
99
],
[
137,
100
],
[
106,
103
],
[
152,
104
],
[
149,
105
],
[
103,
107
],
[
85,
107
],
[
152,
108
],
[
149,
109
],
[
142,
112
],
[
116,
115
],
[
155,
119
],
[
146,
124
],
[
115,
125
],
[
139,
128
],
[
143,
130
],
[
140,
130
],
[
140,
134
],
[
143,
134
],
[
148,
137
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
148,
149
],
[
151,
152
],
[
157,
155
],
[
157,
158
]
] | [
"# 2020/08/09\n# AtCoder Grand Contest 002 - A\n\n# Input\nn, m = map(int,input().split())\nrlist = [0] * (n+1)\nwlist = [1] * (n+1) \nrlist[1] = 1\nwlist[1] = 0\n\n# Calc\nfor i in range(m):\n x, y = map(int,input().split())\n if rlist[x] >= 1:\n rlist[y] = rlist[y] + 1\n # if rlist[x] == 1 and wlist[x] == 0:\n if wlist[x] == 0:\n rlist[x] = rlist[x] - 1\n else:\n wlist[x] = wlist[x] - 1\n else:\n wlist[y] = wlist[y] + 1\n wlist[x] = wlist[x] - 1\n\nans = 0\nfor i in range(n+1):\n if rlist[i] >= 1:\n ans = ans + 1\n\n# Output\nprint(ans)",
"n, m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"rlist = [0] * (n+1)",
"rlist",
"[0] * (n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"wlist = [1] * (n+1)",
"wlist",
"[1] * (n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"rlist[1] = 1",
"rlist[1]",
"rlist",
"1",
"1",
"wlist[1] = 0",
"wlist[1]",
"wlist",
"1",
"0",
"for i in range(m):\n x, y = map(int,input().split())\n if rlist[x] >= 1:\n rlist[y] = rlist[y] + 1\n # if rlist[x] == 1 and wlist[x] == 0:\n if wlist[x] == 0:\n rlist[x] = rlist[x] - 1\n else:\n wlist[x] = wlist[x] - 1\n else:\n wlist[y] = wlist[y] + 1\n wlist[x] = wlist[x] - 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 rlist[x] >= 1:\n rlist[y] = rlist[y] + 1\n # if rlist[x] == 1 and wlist[x] == 0:\n if wlist[x] == 0:\n rlist[x] = rlist[x] - 1\n else:\n wlist[x] = wlist[x] - 1\n else:\n wlist[y] = wlist[y] + 1\n wlist[x] = wlist[x] - 1",
"rlist[x] >= 1",
"rlist[x]",
"rlist",
"x",
"1",
"rlist[y] = rlist[y] + 1",
"rlist[y]",
"rlist",
"y",
"rlist[y] + 1",
"rlist[y]",
"rlist",
"y",
"1",
"if wlist[x] == 0:\n rlist[x] = rlist[x] - 1\n else:\n wlist[x] = wlist[x] - 1\n ",
"wlist[x] == 0",
"wlist[x]",
"wlist",
"x",
"0",
"rlist[x] = rlist[x] - 1",
"rlist[x]",
"rlist",
"x",
"rlist[x] - 1",
"rlist[x]",
"rlist",
"x",
"1",
"wlist[x] = wlist[x] - 1",
"wlist[x]",
"wlist",
"x",
"wlist[x] - 1",
"wlist[x]",
"wlist",
"x",
"1",
"wlist[y] = wlist[y] + 1",
"wlist[y]",
"wlist",
"y",
"wlist[y] + 1",
"wlist[y]",
"wlist",
"y",
"1",
"wlist[x] = wlist[x] - 1",
"wlist[x]",
"wlist",
"x",
"wlist[x] - 1",
"wlist[x]",
"wlist",
"x",
"1",
"ans = 0",
"ans",
"0",
"for i in range(n+1):\n if rlist[i] >= 1:\n ans = ans + 1\n\n# Output",
"i",
"range(n+1)",
"range",
"n+1",
"n",
"1",
"if rlist[i] >= 1:\n ans = ans + 1\n\n# Output",
"rlist[i] >= 1",
"rlist[i]",
"rlist",
"i",
"1",
"ans = ans + 1",
"ans",
"ans + 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"ans = ans + 1",
"ans + 1",
"ans",
"ans = 0",
"0",
"ans",
"rlist = [0] * (n+1)",
"[0] * (n+1)",
"rlist",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x",
"wlist = [1] * (n+1)",
"[1] * (n+1)",
"wlist",
"n, m = map(int,input().split())",
"map(int,input().split())",
"n",
"m = map(int,input().split())",
"map(int,input().split())",
"m"
] | # 2020/08/09
# AtCoder Grand Contest 002 - A
# Input
n, m = map(int,input().split())
rlist = [0] * (n+1)
wlist = [1] * (n+1)
rlist[1] = 1
wlist[1] = 0
# Calc
for i in range(m):
x, y = map(int,input().split())
if rlist[x] >= 1:
rlist[y] = rlist[y] + 1
# if rlist[x] == 1 and wlist[x] == 0:
if wlist[x] == 0:
rlist[x] = rlist[x] - 1
else:
wlist[x] = wlist[x] - 1
else:
wlist[y] = wlist[y] + 1
wlist[x] = wlist[x] - 1
ans = 0
for i in range(n+1):
if rlist[i] >= 1:
ans = ans + 1
# Output
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,
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,
0,
13,
17,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13
] | [
[
115,
2
],
[
115,
11
],
[
121,
13
],
[
107,
17
],
[
127,
19
],
[
107,
23
],
[
28,
25
],
[
128,
26
],
[
31,
30
],
[
116,
33
],
[
112,
35
],
[
112,
44
],
[
124,
46
],
[
100,
49
],
[
55,
52
],
[
122,
53
],
[
125,
54
],
[
110,
54
],
[
60,
57
],
[
122,
58
],
[
101,
59
],
[
113,
59
],
[
79,
63
],
[
128,
64
],
[
125,
65
],
[
110,
65
],
[
71,
68
],
[
128,
69
],
[
101,
70
],
[
113,
70
],
[
52,
74
],
[
122,
75
],
[
125,
76
],
[
110,
76
],
[
82,
79
],
[
128,
80
],
[
125,
81
],
[
110,
81
],
[
118,
84
],
[
88,
87
],
[
128,
87
],
[
87,
91
],
[
103,
94
],
[
104,
98
],
[
119,
98
],
[
100,
101
],
[
103,
104
],
[
115,
107
],
[
112,
110
],
[
112,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"n,m = map(int,input().split())\nball = [1]*n\nans = [0]*n\nans[0] = 1\n\nfor i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n ball[x] -= 1\n ball[y] += 1\n if ans[x] == 1:\n ans[y] = 1\n if ball[x] == 0:\n ans[x] = 0\n\na = 0\nfor an in ans:\n if an == 1:\n a += 1\n\nprint(a)",
"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",
"ans = [0]*n",
"ans",
"[0]*n",
"[0]",
"0",
"n",
"ans[0] = 1",
"ans[0]",
"ans",
"0",
"1",
"for i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n ball[x] -= 1\n ball[y] += 1\n if ans[x] == 1:\n ans[y] = 1\n if ball[x] == 0:\n ans[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",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"ball[x] -= 1",
"ball[x]",
"ball",
"x",
"1",
"ball[y] += 1",
"ball[y]",
"ball",
"y",
"1",
"if ans[x] == 1:\n ans[y] = 1\n ",
"ans[x] == 1",
"ans[x]",
"ans",
"x",
"1",
"ans[y] = 1",
"ans[y]",
"ans",
"y",
"1",
"if ball[x] == 0:\n ans[x] = 0",
"ball[x] == 0",
"ball[x]",
"ball",
"x",
"0",
"ans[x] = 0",
"ans[x]",
"ans",
"x",
"0",
"a = 0",
"a",
"0",
"for an in ans:\n if an == 1:\n a += 1",
"an",
"ans",
"if an == 1:\n a += 1",
"an == 1",
"an",
"1",
"a += 1",
"a",
"1",
"print(a)",
"print",
"a",
"y -= 1",
"1",
"y",
"a += 1",
"1",
"a",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"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",
"a = 0",
"0",
"a",
"ball = [1]*n",
"[1]*n",
"ball",
"x -= 1",
"1",
"x",
"ans = [0]*n",
"[0]*n",
"ans"
] | n,m = map(int,input().split())
ball = [1]*n
ans = [0]*n
ans[0] = 1
for i in range(m):
x,y = map(int,input().split())
x -= 1
y -= 1
ball[x] -= 1
ball[y] += 1
if ans[x] == 1:
ans[y] = 1
if ball[x] == 0:
ans[x] = 0
a = 0
for an in ans:
if an == 1:
a += 1
print(a) |
[
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,
40,
40,
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,
2,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] | [
[
98,
2
],
[
98,
11
],
[
83,
13
],
[
81,
17
],
[
95,
19
],
[
81,
28
],
[
31,
30
],
[
99,
33
],
[
92,
35
],
[
92,
44
],
[
101,
46
],
[
89,
49
],
[
96,
53
],
[
102,
54
],
[
87,
54
],
[
59,
56
],
[
84,
57
],
[
102,
58
],
[
87,
58
],
[
64,
61
],
[
84,
62
],
[
90,
63
],
[
93,
63
],
[
69,
66
],
[
96,
67
],
[
102,
68
],
[
87,
68
],
[
56,
70
],
[
84,
71
],
[
102,
72
],
[
87,
72
],
[
96,
78
],
[
98,
81
],
[
83,
84
],
[
92,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
]
] | [
"#!/usr/bin/env python3\nn, m = map(int, input().split())\nL = [1]*n\nR = [1] + [0]*~-n\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1;y -= 1\n if R[x]:R[y] = 1\n L[x] -= 1;L[y] += 1\n R[x] *= (L[x] > 0)\nprint(sum(R))",
"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",
"R = [1] + [0]*~-n",
"R",
"[1] + [0]*~-n",
"[1]",
"1",
"[0]*~-n",
"[0]",
"0",
"~-n",
"-n",
"n",
"for _ in range(m):\n x, y = map(int, input().split())\n x -= 1;y -= 1\n if R[x]:R[y] = 1\n L[x] -= 1;L[y] += 1\n R[x] *= (L[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 -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if R[x]:R[y] = 1\n ",
"R[x]",
"R",
"x",
"L[x] -= 1",
"L[x]",
"L",
"x",
"1",
"L[y] += 1",
"L[y]",
"L",
"y",
"1",
"R[x] *= (L[x] > 0)",
"R[x]",
"R",
"x",
"L[x] > 0",
"L[x]",
"L",
"x",
"0",
"print(sum(R))",
"print",
"sum(R)",
"sum",
"R",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"L = [1]*n",
"[1]*n",
"L",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y -= 1",
"1",
"y",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"R = [1] + [0]*~-n",
"[1] + [0]*~-n",
"R",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"x -= 1",
"1",
"x"
] | #!/usr/bin/env python3
n, m = map(int, input().split())
L = [1]*n
R = [1] + [0]*~-n
for _ in range(m):
x, y = map(int, input().split())
x -= 1;y -= 1
if R[x]:R[y] = 1
L[x] -= 1;L[y] += 1
R[x] *= (L[x] > 0)
print(sum(R)) |
[
7,
15,
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,
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,
13,
13,
4,
18,
13,
13,
13,
14,
2,
2,
13,
13,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
107,
4
],
[
110,
11
],
[
108,
18
],
[
110,
20
],
[
98,
22
],
[
111,
26
],
[
113,
28
],
[
32,
31
],
[
96,
34
],
[
116,
36
],
[
108,
43
],
[
116,
45
],
[
119,
47
],
[
102,
49
],
[
120,
49
],
[
104,
51
],
[
117,
53
],
[
105,
53
],
[
59,
56
],
[
99,
57
],
[
120,
58
],
[
102,
58
],
[
64,
61
],
[
99,
62
],
[
105,
63
],
[
117,
63
],
[
120,
67
],
[
102,
67
],
[
114,
68
],
[
114,
71
],
[
105,
73
],
[
117,
73
],
[
120,
77
],
[
102,
77
],
[
114,
78
],
[
56,
80
],
[
99,
81
],
[
120,
82
],
[
102,
82
],
[
114,
86
],
[
120,
88
],
[
102,
88
],
[
114,
93
],
[
110,
96
],
[
98,
99
],
[
116,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
]
] | [
"import sys\nreadline = sys.stdin.readline\n\nN,M = map(int,readline().split())\nB = [1] * N\npossible = {0}\nfor i in range(M):\n x,y = map(int,readline().split())\n x,y = x - 1,y - 1\n B[x] -= 1\n B[y] += 1\n if x in possible:\n possible.add(y)\n if x in possible and B[x] == 0:\n possible.remove(x)\n\nprint(len(possible))",
"import sys",
"sys",
"readline = sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N,M = map(int,readline().split())",
"N",
"map(int,readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"M",
"B = [1] * N",
"B",
"[1] * N",
"[1]",
"1",
"N",
"possible = {0}",
"possible",
"{0}",
"for i in range(M):\n x,y = map(int,readline().split())\n x,y = x - 1,y - 1\n B[x] -= 1\n B[y] += 1\n if x in possible:\n possible.add(y)\n if x in possible and B[x] == 0:\n possible.remove(x)",
"i",
"range(M)",
"range",
"M",
"x,y = map(int,readline().split())",
"x",
"map(int,readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"y",
"x,y = x - 1,y - 1",
"x",
"x - 1",
"x",
"1",
"y",
"y - 1",
"y",
"1",
"B[x] -= 1",
"B[x]",
"B",
"x",
"1",
"B[y] += 1",
"B[y]",
"B",
"y",
"1",
"if x in possible:\n possible.add(y)\n ",
"x in possible",
"x",
"possible",
"possible.add(y)",
"possible.add",
"possible",
"add",
"y",
"if x in possible and B[x] == 0:\n possible.remove(x)",
"x in possible and B[x] == 0",
"x in possible",
"x",
"possible",
"B[x] == 0",
"B[x]",
"B",
"x",
"0",
"possible.remove(x)",
"possible.remove",
"possible",
"remove",
"x",
"print(len(possible))",
"print",
"len(possible)",
"len",
"possible",
"M = map(int,readline().split())",
"map(int,readline().split())",
"M",
"B = [1] * N",
"[1] * N",
"B",
"x,y = map(int,readline().split())",
"map(int,readline().split())",
"x",
"y = x - 1,y - 1",
"y - 1",
"y",
"readline = sys.stdin.readline",
"sys.stdin.readline",
"readline",
"N,M = map(int,readline().split())",
"map(int,readline().split())",
"N",
"possible = {0}",
"{0}",
"possible",
"y = map(int,readline().split())",
"map(int,readline().split())",
"y",
"x,y = x - 1,y - 1",
"x - 1",
"x"
] | import sys
readline = sys.stdin.readline
N,M = map(int,readline().split())
B = [1] * N
possible = {0}
for i in range(M):
x,y = map(int,readline().split())
x,y = x - 1,y - 1
B[x] -= 1
B[y] += 1
if x in possible:
possible.add(y)
if x in possible and B[x] == 0:
possible.remove(x)
print(len(possible)) |
[
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,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
13,
14,
2,
2,
18,
13,
18,
13,
17,
17,
2,
18,
13,
18,
13,
17,
17,
0,
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,
14,
2,
2,
18,
13,
18,
13,
17,
17,
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,
0,
18,
13,
18,
13,
17,
17,
0,
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,
4,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13
] | [
[
208,
2
],
[
208,
11
],
[
15,
14
],
[
209,
17
],
[
202,
30
],
[
205,
33
],
[
200,
38
],
[
196,
41
],
[
200,
46
],
[
52,
49
],
[
206,
50
],
[
57,
54
],
[
197,
55
],
[
193,
59
],
[
200,
64
],
[
68,
67
],
[
203,
67
],
[
197,
73
],
[
67,
75
],
[
206,
80
],
[
67,
82
],
[
91,
86
],
[
206,
87
],
[
67,
89
],
[
98,
93
],
[
206,
94
],
[
67,
96
],
[
206,
102
],
[
67,
104
],
[
113,
108
],
[
206,
109
],
[
67,
111
],
[
197,
118
],
[
67,
120
],
[
194,
125
],
[
67,
127
],
[
136,
131
],
[
197,
132
],
[
67,
134
],
[
143,
138
],
[
197,
139
],
[
67,
141
],
[
150,
145
],
[
197,
146
],
[
67,
148
],
[
157,
152
],
[
197,
153
],
[
67,
155
],
[
164,
159
],
[
194,
160
],
[
67,
162
],
[
171,
166
],
[
194,
167
],
[
67,
169
],
[
194,
175
],
[
67,
177
],
[
186,
181
],
[
206,
182
],
[
67,
184
],
[
206,
191
],
[
193,
194
],
[
196,
197
],
[
208,
200
],
[
202,
203
],
[
205,
206
],
[
208,
209
]
] | [
"N, M = map(int, input().split())\nXYs = [list(map(int, input().split())) for _ in range(M)]\n\nflag = [0]*(N+1)\nflag2 = [0]*(N+1)\nflag[1] = 1\nflag2[1] = 1\nnum = [1]*(N+1)\n\nfor xy in XYs:\n if flag2[xy[0]]==1 and flag[xy[0]]==1:\n flag[xy[0]]=0\n flag[xy[1]]=1\n elif flag[xy[0]]==1:\n flag[xy[1]]=1\n \n if flag2[xy[0]]==1 and num[xy[1]] == 0:\n flag2[xy[0]]=0\n flag2[xy[1]]=1\n else:\n flag2[xy[0]]=0\n flag2[xy[1]]=0\n num[xy[0]] -= 1\n num[xy[1]] += 1\n if num[xy[0]] == 0:\n flag[xy[0]] = 0\n \nprint(sum(flag))",
"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",
"XYs = [list(map(int, input().split())) for _ in range(M)]",
"XYs",
"[list(map(int, input().split())) for _ in range(M)]",
"flag = [0]*(N+1)",
"flag",
"[0]*(N+1)",
"[0]",
"0",
"N+1",
"N",
"1",
"flag2 = [0]*(N+1)",
"flag2",
"[0]*(N+1)",
"[0]",
"0",
"N+1",
"N",
"1",
"flag[1] = 1",
"flag[1]",
"flag",
"1",
"1",
"flag2[1] = 1",
"flag2[1]",
"flag2",
"1",
"1",
"num = [1]*(N+1)",
"num",
"[1]*(N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"for xy in XYs:\n if flag2[xy[0]]==1 and flag[xy[0]]==1:\n flag[xy[0]]=0\n flag[xy[1]]=1\n elif flag[xy[0]]==1:\n flag[xy[1]]=1\n \n if flag2[xy[0]]==1 and num[xy[1]] == 0:\n flag2[xy[0]]=0\n flag2[xy[1]]=1\n else:\n flag2[xy[0]]=0\n flag2[xy[1]]=0\n num[xy[0]] -= 1\n num[xy[1]] += 1\n if num[xy[0]] == 0:\n flag[xy[0]] = 0\n ",
"xy",
"XYs",
"if flag2[xy[0]]==1 and flag[xy[0]]==1:\n flag[xy[0]]=0\n flag[xy[1]]=1\n elif flag[xy[0]]==1:\n flag[xy[1]]=1\n \n ",
"flag2[xy[0]]==1 and flag[xy[0]]==1",
"flag2[xy[0]]==1",
"flag2[xy[0]]",
"flag2",
"xy[0]",
"xy",
"0",
"1",
"flag[xy[0]]==1",
"flag[xy[0]]",
"flag",
"xy[0]",
"xy",
"0",
"1",
"flag[xy[0]]=0",
"flag[xy[0]]",
"flag",
"xy[0]",
"xy",
"0",
"0",
"flag[xy[1]]=1",
"flag[xy[1]]",
"flag",
"xy[1]",
"xy",
"1",
"1",
"elif flag[xy[0]]==1:\n flag[xy[1]]=1\n \n ",
"flag[xy[0]]==1",
"flag[xy[0]]",
"flag",
"xy[0]",
"xy",
"0",
"1",
"flag[xy[1]]=1",
"flag[xy[1]]",
"flag",
"xy[1]",
"xy",
"1",
"1",
"if flag2[xy[0]]==1 and num[xy[1]] == 0:\n flag2[xy[0]]=0\n flag2[xy[1]]=1\n else:\n flag2[xy[0]]=0\n flag2[xy[1]]=0\n ",
"flag2[xy[0]]==1 and num[xy[1]] == 0",
"flag2[xy[0]]==1",
"flag2[xy[0]]",
"flag2",
"xy[0]",
"xy",
"0",
"1",
"num[xy[1]] == 0",
"num[xy[1]]",
"num",
"xy[1]",
"xy",
"1",
"0",
"flag2[xy[0]]=0",
"flag2[xy[0]]",
"flag2",
"xy[0]",
"xy",
"0",
"0",
"flag2[xy[1]]=1",
"flag2[xy[1]]",
"flag2",
"xy[1]",
"xy",
"1",
"1",
"flag2[xy[0]]=0",
"flag2[xy[0]]",
"flag2",
"xy[0]",
"xy",
"0",
"0",
"flag2[xy[1]]=0",
"flag2[xy[1]]",
"flag2",
"xy[1]",
"xy",
"1",
"0",
"num[xy[0]] -= 1",
"num[xy[0]]",
"num",
"xy[0]",
"xy",
"0",
"1",
"num[xy[1]] += 1",
"num[xy[1]]",
"num",
"xy[1]",
"xy",
"1",
"1",
"if num[xy[0]] == 0:\n flag[xy[0]] = 0\n ",
"num[xy[0]] == 0",
"num[xy[0]]",
"num",
"xy[0]",
"xy",
"0",
"0",
"flag[xy[0]] = 0",
"flag[xy[0]]",
"flag",
"xy[0]",
"xy",
"0",
"0",
"print(sum(flag))",
"print",
"sum(flag)",
"sum",
"flag",
"num = [1]*(N+1)",
"[1]*(N+1)",
"num",
"flag2 = [0]*(N+1)",
"[0]*(N+1)",
"flag2",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"XYs = [list(map(int, input().split())) for _ in range(M)]",
"[list(map(int, input().split())) for _ in range(M)]",
"XYs",
"flag = [0]*(N+1)",
"[0]*(N+1)",
"flag",
"M = map(int, input().split())",
"map(int, input().split())",
"M"
] | N, M = map(int, input().split())
XYs = [list(map(int, input().split())) for _ in range(M)]
flag = [0]*(N+1)
flag2 = [0]*(N+1)
flag[1] = 1
flag2[1] = 1
num = [1]*(N+1)
for xy in XYs:
if flag2[xy[0]]==1 and flag[xy[0]]==1:
flag[xy[0]]=0
flag[xy[1]]=1
elif flag[xy[0]]==1:
flag[xy[1]]=1
if flag2[xy[0]]==1 and num[xy[1]] == 0:
flag2[xy[0]]=0
flag2[xy[1]]=1
else:
flag2[xy[0]]=0
flag2[xy[1]]=0
num[xy[0]] -= 1
num[xy[1]] += 1
if num[xy[0]] == 0:
flag[xy[0]] = 0
print(sum(flag)) |
[
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,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
40,
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
] | [
[
101,
2
],
[
101,
11
],
[
86,
13
],
[
102,
18
],
[
24,
21
],
[
87,
22
],
[
98,
26
],
[
102,
31
],
[
37,
34
],
[
99,
35
],
[
40,
39
],
[
96,
42
],
[
92,
44
],
[
92,
53
],
[
58,
55
],
[
99,
56
],
[
90,
57
],
[
72,
58
],
[
99,
59
],
[
93,
60
],
[
65,
62
],
[
87,
63
],
[
93,
64
],
[
70,
67
],
[
87,
68
],
[
90,
69
],
[
75,
72
],
[
99,
73
],
[
93,
74
],
[
62,
76
],
[
87,
77
],
[
93,
78
],
[
99,
84
],
[
86,
87
],
[
92,
90
],
[
92,
93
],
[
101,
96
],
[
98,
99
],
[
101,
102
]
] | [
"N,M=map(int,input().split())\nZ=[1]*(N+1)\nZ[0]=0\n\nH=[False]*(N+1)\nH[1]=True\n\nfor _ in range(M):\n X,Y=map(int,input().split())\n\n H[Y]|=H[X]\n\n Z[X]-=1\n Z[Y]+=1\n\n H[X]&=(Z[X]!=0)\nprint(sum(H))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"Z=[1]*(N+1)",
"Z",
"[1]*(N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"Z[0]=0",
"Z[0]",
"Z",
"0",
"0",
"H=[False]*(N+1)",
"H",
"[False]*(N+1)",
"[False]",
"False",
"N+1",
"N",
"1",
"H[1]=True",
"H[1]",
"H",
"1",
"True",
"for _ in range(M):\n X,Y=map(int,input().split())\n\n H[Y]|=H[X]\n\n Z[X]-=1\n Z[Y]+=1\n\n H[X]&=(Z[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",
"H[Y]|=H[X]",
"H[Y]",
"H",
"Y",
"H[X]",
"H",
"X",
"Z[X]-=1",
"Z[X]",
"Z",
"X",
"1",
"Z[Y]+=1",
"Z[Y]",
"Z",
"Y",
"1",
"H[X]&=(Z[X]!=0)",
"H[X]",
"H",
"X",
"Z[X]!=0",
"Z[X]",
"Z",
"X",
"0",
"print(sum(H))",
"print",
"sum(H)",
"sum",
"H",
"Z=[1]*(N+1)",
"[1]*(N+1)",
"Z",
"Y=map(int,input().split())",
"map(int,input().split())",
"Y",
"X,Y=map(int,input().split())",
"map(int,input().split())",
"X",
"M=map(int,input().split())",
"map(int,input().split())",
"M",
"H=[False]*(N+1)",
"[False]*(N+1)",
"H",
"N,M=map(int,input().split())",
"map(int,input().split())",
"N"
] | N,M=map(int,input().split())
Z=[1]*(N+1)
Z[0]=0
H=[False]*(N+1)
H[1]=True
for _ in range(M):
X,Y=map(int,input().split())
H[Y]|=H[X]
Z[X]-=1
Z[Y]+=1
H[X]&=(Z[X]!=0)
print(sum(H))
|
[
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,
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,
17,
28,
13,
13,
14,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
106,
2
],
[
106,
11
],
[
91,
13
],
[
107,
18
],
[
97,
21
],
[
107,
26
],
[
32,
29
],
[
98,
30
],
[
35,
34
],
[
95,
37
],
[
109,
39
],
[
109,
48
],
[
98,
51
],
[
110,
52
],
[
57,
54
],
[
98,
55
],
[
101,
56
],
[
70,
60
],
[
92,
61
],
[
110,
62
],
[
68,
65
],
[
98,
66
],
[
110,
67
],
[
73,
70
],
[
92,
71
],
[
110,
72
],
[
78,
75
],
[
92,
76
],
[
101,
77
],
[
103,
80
],
[
84,
83
],
[
98,
83
],
[
104,
89
],
[
91,
92
],
[
106,
95
],
[
97,
98
],
[
109,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
]
] | [
"n,m = map(int, input().split())\n\nboxl = [1]*(n+1)\nredl = [False]*(n+1)\nredl[1] = True\n\nfor _ in range(m):\n x,y = map(int, input().split())\n if redl[x]:\n redl[y] = True\n if boxl[x] == 1:\n redl[x] = False\n boxl[x] -= 1\n boxl[y] += 1\n\nans = 0\nfor r in redl:\n if r: ans += 1\n\nprint(ans)",
"n,m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"boxl = [1]*(n+1)",
"boxl",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"redl = [False]*(n+1)",
"redl",
"[False]*(n+1)",
"[False]",
"False",
"n+1",
"n",
"1",
"redl[1] = True",
"redl[1]",
"redl",
"1",
"True",
"for _ in range(m):\n x,y = map(int, input().split())\n if redl[x]:\n redl[y] = True\n if boxl[x] == 1:\n redl[x] = False\n boxl[x] -= 1\n boxl[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]:\n redl[y] = True\n ",
"redl[x]",
"redl",
"x",
"redl[y] = True",
"redl[y]",
"redl",
"y",
"True",
"if boxl[x] == 1:\n redl[x] = False\n ",
"boxl[x] == 1",
"boxl[x]",
"boxl",
"x",
"1",
"redl[x] = False",
"redl[x]",
"redl",
"x",
"False",
"boxl[x] -= 1",
"boxl[x]",
"boxl",
"x",
"1",
"boxl[y] += 1",
"boxl[y]",
"boxl",
"y",
"1",
"ans = 0",
"ans",
"0",
"for r in redl:\n if r: ans += 1",
"r",
"redl",
"if r: ans ",
"r",
"print(ans)",
"print",
"ans",
"boxl = [1]*(n+1)",
"[1]*(n+1)",
"boxl",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"redl = [False]*(n+1)",
"[False]*(n+1)",
"redl",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"ans = 0",
"0",
"ans",
"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())
boxl = [1]*(n+1)
redl = [False]*(n+1)
redl[1] = True
for _ in range(m):
x,y = map(int, input().split())
if redl[x]:
redl[y] = True
if boxl[x] == 1:
redl[x] = False
boxl[x] -= 1
boxl[y] += 1
ans = 0
for r in redl:
if r: ans += 1
print(ans) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
23,
13,
13,
23,
13,
13,
12,
13,
29,
4,
13,
4,
13,
4,
18,
4,
13,
13,
23,
13,
17,
23,
13,
13,
23,
13,
13,
12,
13,
42,
13,
29,
13,
23,
13,
23,
13,
12,
13,
23,
13,
23,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
17,
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,
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,
4,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
154,
4
],
[
27,
14
],
[
24,
17
],
[
155,
21
],
[
25,
24
],
[
28,
27
],
[
48,
33
],
[
45,
35
],
[
155,
39
],
[
43,
42
],
[
46,
45
],
[
49,
48
],
[
57,
55
],
[
57,
57
],
[
59,
59
],
[
63,
63
],
[
65,
65
],
[
70,
69
],
[
152,
71
],
[
70,
72
],
[
75,
74
],
[
69,
83
],
[
87,
86
],
[
69,
95
],
[
99,
98
],
[
102,
101
],
[
72,
104
],
[
107,
106
],
[
152,
108
],
[
107,
109
],
[
74,
112
],
[
106,
113
],
[
118,
115
],
[
74,
116
],
[
109,
117
],
[
131,
121
],
[
86,
122
],
[
106,
123
],
[
129,
126
],
[
74,
127
],
[
106,
128
],
[
134,
131
],
[
86,
132
],
[
106,
133
],
[
139,
136
],
[
86,
137
],
[
109,
138
],
[
142,
141
],
[
74,
144
],
[
141,
147
],
[
98,
147
],
[
158,
149
],
[
154,
155
]
] | [
"import sys\ninput = sys.stdin.readline\n\n# from collections import deque\n\ndef linput(ty=int, cnv=list):\n return cnv(map(ty, input().split()))\n\ndef vinput(rep=1, ty=int, cnv=list):\n return cnv(ty(input().rstrip()) for _ in \"*\"*rep)\n\ndef gcd(n,m):\n while m: n,m = m, n%m\n return n\n\ndef lcm(n,m): return n*m//gcd(n,m)\n\ndef main():\n N,M = linput()\n\n vR = [0, 1,] + [0,]*(N-1)\n vN = [0, 1,] + [1,]*(N-1)\n\n res = 0\n\n for _ in range(M):\n a,b = linput()\n if vR[a]:\n vR[b] = 1\n if vN[a]==1:\n vR[a] = 0\n\n vN[a] -= 1\n vN[b] += 1\n\n res = sum(vR)\n print(res)\n # sT = \"No Yes\".split()\n # print(sT[res])\n # for vR in mR:\n # print(*vR, sep=\"\")\n\nmain()",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def linput(ty=int, cnv=list):\n return cnv(map(ty, input().split()))",
"linput",
"return cnv(map(ty, input().split()))",
"cnv(map(ty, input().split()))",
"cnv",
"map(ty, input().split())",
"map",
"ty",
"input().split()",
"().split",
"()",
"input",
"split",
"ty=int",
"ty",
"int",
"cnv=list",
"cnv",
"list",
"def vinput(rep=1, ty=int, cnv=list):\n return cnv(ty(input().rstrip()) for _ in \"*\"*rep)",
"vinput",
"return cnv(ty(input().rstrip()) for _ in \"*\"*rep)",
"cnv(ty(input().rstrip()) for _ in \"*\"*rep)",
"cnv",
"ty(input().rstrip())",
"ty",
"input().rstrip()",
"().rstrip",
"()",
"input",
"rstrip",
"rep=1",
"rep",
"1",
"ty=int",
"ty",
"int",
"cnv=list",
"cnv",
"list",
"def gcd(n,m):\n while m: n,m = m, n%m\n return n",
"gcd",
"while m: n,m = m, n%m\n ",
"m",
"return n",
"n",
"n",
"n",
"m",
"m",
"def lcm(n,m): return n*m//gcd(n,m)",
"lcm",
"n",
"n",
"m",
"m",
"def main():\n N,M = linput()\n\n vR = [0, 1,] + [0,]*(N-1)\n vN = [0, 1,] + [1,]*(N-1)\n\n res = 0\n\n for _ in range(M):\n a,b = linput()\n if vR[a]:\n vR[b] = 1\n if vN[a]==1:\n vR[a] = 0\n\n vN[a] -= 1\n vN[b] += 1\n\n res = sum(vR)\n print(res)\n # sT = \"No Yes\".split()\n # print(sT[res])\n # for vR in mR:\n # print(*vR, sep=\"\")",
"main",
"N,M = linput()",
"N",
"linput()",
"linput",
"M",
"vR = [0, 1,] + [0,]*(N-1)",
"vR",
"[0, 1,] + [0,]*(N-1)",
"[0, 1,]",
"0",
"1",
"[0,]*(N-1)",
"[0,]",
"0",
"N-1",
"N",
"1",
"vN = [0, 1,] + [1,]*(N-1)",
"vN",
"[0, 1,] + [1,]*(N-1)",
"[0, 1,]",
"0",
"1",
"[1,]*(N-1)",
"[1,]",
"1",
"N-1",
"N",
"1",
"res = 0",
"res",
"0",
"for _ in range(M):\n a,b = linput()\n if vR[a]:\n vR[b] = 1\n if vN[a]==1:\n vR[a] = 0\n\n vN[a] -= 1\n vN[b] += 1\n\n ",
"_",
"range(M)",
"range",
"M",
"a,b = linput()",
"a",
"linput()",
"linput",
"b",
"if vR[a]:\n vR[b] = 1\n ",
"vR[a]",
"vR",
"a",
"vR[b] = 1",
"vR[b]",
"vR",
"b",
"1",
"if vN[a]==1:\n vR[a] = 0\n\n ",
"vN[a]==1",
"vN[a]",
"vN",
"a",
"1",
"vR[a] = 0",
"vR[a]",
"vR",
"a",
"0",
"vN[a] -= 1",
"vN[a]",
"vN",
"a",
"1",
"vN[b] += 1",
"vN[b]",
"vN",
"b",
"1",
"res = sum(vR)",
"res",
"sum(vR)",
"sum",
"vR",
"print(res)",
"print",
"res",
"main()",
"main",
"def linput(ty=int, cnv=list):\n return cnv(map(ty, input().split()))",
"def linput(ty=int, cnv=list):\n return cnv(map(ty, input().split()))",
"linput",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def main():\n N,M = linput()\n\n vR = [0, 1,] + [0,]*(N-1)\n vN = [0, 1,] + [1,]*(N-1)\n\n res = 0\n\n for _ in range(M):\n a,b = linput()\n if vR[a]:\n vR[b] = 1\n if vN[a]==1:\n vR[a] = 0\n\n vN[a] -= 1\n vN[b] += 1\n\n res = sum(vR)\n print(res)\n # sT = \"No Yes\".split()\n # print(sT[res])\n # for vR in mR:\n # print(*vR, sep=\"\")",
"def main():\n N,M = linput()\n\n vR = [0, 1,] + [0,]*(N-1)\n vN = [0, 1,] + [1,]*(N-1)\n\n res = 0\n\n for _ in range(M):\n a,b = linput()\n if vR[a]:\n vR[b] = 1\n if vN[a]==1:\n vR[a] = 0\n\n vN[a] -= 1\n vN[b] += 1\n\n res = sum(vR)\n print(res)\n # sT = \"No Yes\".split()\n # print(sT[res])\n # for vR in mR:\n # print(*vR, sep=\"\")",
"main",
"def lcm(n,m): return n*m//gcd(n,m)",
"def lcm(n,m): return n*m//gcd(n,m)",
"lcm",
"def gcd(n,m):\n while m: n,m = m, n%m\n return n",
"def gcd(n,m):\n while m: n,m = m, n%m\n return n",
"gcd",
"def vinput(rep=1, ty=int, cnv=list):\n return cnv(ty(input().rstrip()) for _ in \"*\"*rep)",
"def vinput(rep=1, ty=int, cnv=list):\n return cnv(ty(input().rstrip()) for _ in \"*\"*rep)",
"vinput"
] | import sys
input = sys.stdin.readline
# from collections import deque
def linput(ty=int, cnv=list):
return cnv(map(ty, input().split()))
def vinput(rep=1, ty=int, cnv=list):
return cnv(ty(input().rstrip()) for _ in "*"*rep)
def gcd(n,m):
while m: n,m = m, n%m
return n
def lcm(n,m): return n*m//gcd(n,m)
def main():
N,M = linput()
vR = [0, 1,] + [0,]*(N-1)
vN = [0, 1,] + [1,]*(N-1)
res = 0
for _ in range(M):
a,b = linput()
if vR[a]:
vR[b] = 1
if vN[a]==1:
vR[a] = 0
vN[a] -= 1
vN[b] += 1
res = sum(vR)
print(res)
# sT = "No Yes".split()
# print(sT[res])
# for vR in mR:
# print(*vR, sep="")
main()
|
[
7,
15,
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,
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,
0,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
13,
17,
4,
13,
4,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
127,
3
],
[
127,
12
],
[
112,
14
],
[
128,
18
],
[
23,
20
],
[
113,
21
],
[
106,
25
],
[
128,
29
],
[
115,
31
],
[
35,
34
],
[
119,
37
],
[
121,
39
],
[
121,
48
],
[
55,
50
],
[
107,
51
],
[
122,
53
],
[
62,
57
],
[
107,
58
],
[
110,
60
],
[
113,
65
],
[
122,
67
],
[
75,
70
],
[
113,
71
],
[
110,
73
],
[
103,
77
],
[
107,
82
],
[
122,
84
],
[
93,
88
],
[
113,
89
],
[
122,
91
],
[
124,
95
],
[
113,
101
],
[
103,
104
],
[
106,
107
],
[
121,
110
],
[
112,
113
],
[
115,
116
],
[
127,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"from collections import defaultdict\nn,m=map(int, input().split())\nv = [0]*n\nv[0]=1\nans = [1]*n\nfi = 1\nfor i in range(m):\n a,b=map(int, input().split())\n ans[a-1]-=1\n ans[b-1]+=1\n if v[a-1]:\n v[b-1]=1\n fi+=1\n if ans[a-1]==0:\n v[a-1]=0\n fi-=1\n\nprint(sum(v))",
"from collections import defaultdict",
"n,m=map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"v = [0]*n",
"v",
"[0]*n",
"[0]",
"0",
"n",
"v[0]=1",
"v[0]",
"v",
"0",
"1",
"ans = [1]*n",
"ans",
"[1]*n",
"[1]",
"1",
"n",
"fi = 1",
"fi",
"1",
"for i in range(m):\n a,b=map(int, input().split())\n ans[a-1]-=1\n ans[b-1]+=1\n if v[a-1]:\n v[b-1]=1\n fi+=1\n if ans[a-1]==0:\n v[a-1]=0\n fi-=1",
"i",
"range(m)",
"range",
"m",
"a,b=map(int, input().split())",
"a",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"b",
"ans[a-1]-=1",
"ans[a-1]",
"ans",
"a-1",
"a",
"1",
"1",
"ans[b-1]+=1",
"ans[b-1]",
"ans",
"b-1",
"b",
"1",
"1",
"if v[a-1]:\n v[b-1]=1\n fi+=1\n ",
"v[a-1]",
"v",
"a-1",
"a",
"1",
"v[b-1]=1",
"v[b-1]",
"v",
"b-1",
"b",
"1",
"1",
"fi+=1",
"fi",
"1",
"if ans[a-1]==0:\n v[a-1]=0\n fi-=1",
"ans[a-1]==0",
"ans[a-1]",
"ans",
"a-1",
"a",
"1",
"0",
"v[a-1]=0",
"v[a-1]",
"v",
"a-1",
"a",
"1",
"0",
"fi-=1",
"fi",
"1",
"print(sum(v))",
"print",
"sum(v)",
"sum",
"v",
"fi+=1",
"1",
"fi",
"ans = [1]*n",
"[1]*n",
"ans",
"b=map(int, input().split())",
"map(int, input().split())",
"b",
"v = [0]*n",
"[0]*n",
"v",
"fi = 1",
"1",
"fi",
"m=map(int, input().split())",
"map(int, input().split())",
"m",
"a,b=map(int, input().split())",
"map(int, input().split())",
"a",
"fi-=1",
"1",
"fi",
"n,m=map(int, input().split())",
"map(int, input().split())",
"n"
] | from collections import defaultdict
n,m=map(int, input().split())
v = [0]*n
v[0]=1
ans = [1]*n
fi = 1
for i in range(m):
a,b=map(int, input().split())
ans[a-1]-=1
ans[b-1]+=1
if v[a-1]:
v[b-1]=1
fi+=1
if ans[a-1]==0:
v[a-1]=0
fi-=1
print(sum(v))
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
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,
4,
13,
4,
18,
13,
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,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
14,
2,
2,
4,
13,
13,
17,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] | [
[
121,
4
],
[
127,
11
],
[
122,
18
],
[
127,
20
],
[
109,
22
],
[
128,
27
],
[
33,
30
],
[
110,
31
],
[
124,
35
],
[
125,
40
],
[
45,
44
],
[
116,
47
],
[
118,
49
],
[
122,
56
],
[
118,
58
],
[
63,
60
],
[
110,
61
],
[
113,
62
],
[
68,
65
],
[
110,
66
],
[
119,
67
],
[
113,
71
],
[
125,
72
],
[
60,
75
],
[
110,
76
],
[
113,
77
],
[
125,
81
],
[
113,
83
],
[
125,
89
],
[
119,
92
],
[
125,
93
],
[
125,
96
],
[
125,
100
],
[
119,
102
],
[
125,
107
],
[
109,
110
],
[
118,
113
],
[
127,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"import sys\ninput = sys.stdin.readline\n\n# B - Box and Ball\nN, M = map(int, input().split())\n\nboxes = [1] * (N + 1)\nboxes[0] = 0\n\nball_exists = set()\nball_exists.add(1)\n\nfor i in range(M):\n x, y = map(int, input().split())\n\n boxes[x] -= 1\n boxes[y] += 1\n \n if x in ball_exists:\n if boxes[x] == 0:\n ball_exists.remove(x)\n\n if len(ball_exists) == 1 and y in ball_exists:\n ball_exists.clear()\n\n ball_exists.add(y)\n\n #print(boxes)\n #print(ball_exists)\n\nprint(len(ball_exists))",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"boxes = [1] * (N + 1)",
"boxes",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"boxes[0] = 0",
"boxes[0]",
"boxes",
"0",
"0",
"ball_exists = set()",
"ball_exists",
"set()",
"set",
"ball_exists.add(1)",
"ball_exists.add",
"ball_exists",
"add",
"1",
"for i in range(M):\n x, y = map(int, input().split())\n\n boxes[x] -= 1\n boxes[y] += 1\n \n if x in ball_exists:\n if boxes[x] == 0:\n ball_exists.remove(x)\n\n if len(ball_exists) == 1 and y in ball_exists:\n ball_exists.clear()\n\n ball_exists.add(y)\n\n #print(boxes)\n #print(ball_exists)",
"i",
"range(M)",
"range",
"M",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"boxes[x] -= 1",
"boxes[x]",
"boxes",
"x",
"1",
"boxes[y] += 1",
"boxes[y]",
"boxes",
"y",
"1",
"if x in ball_exists:\n if boxes[x] == 0:\n ball_exists.remove(x)\n\n if len(ball_exists) == 1 and y in ball_exists:\n ball_exists.clear()\n\n ball_exists.add(y)\n\n #print(boxes)\n #print(ball_exists)",
"x in ball_exists",
"x",
"ball_exists",
"if boxes[x] == 0:\n ball_exists.remove(x)\n\n if len(ball_exists) == 1 and y in ball_exists:\n ball_exists.clear()\n\n ",
"boxes[x] == 0",
"boxes[x]",
"boxes",
"x",
"0",
"ball_exists.remove(x)",
"ball_exists.remove",
"ball_exists",
"remove",
"x",
"if len(ball_exists) == 1 and y in ball_exists:\n ball_exists.clear()\n\n ",
"len(ball_exists) == 1 and y in ball_exists",
"len(ball_exists) == 1",
"len(ball_exists)",
"len",
"ball_exists",
"1",
"y in ball_exists",
"y",
"ball_exists",
"ball_exists.clear()",
"ball_exists.clear",
"ball_exists",
"clear",
"ball_exists.add(y)",
"ball_exists.add",
"ball_exists",
"add",
"y",
"print(len(ball_exists))",
"print",
"len(ball_exists)",
"len",
"ball_exists",
"boxes = [1] * (N + 1)",
"[1] * (N + 1)",
"boxes",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"ball_exists = set()",
"set()",
"ball_exists",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N"
] | import sys
input = sys.stdin.readline
# B - Box and Ball
N, M = map(int, input().split())
boxes = [1] * (N + 1)
boxes[0] = 0
ball_exists = set()
ball_exists.add(1)
for i in range(M):
x, y = map(int, input().split())
boxes[x] -= 1
boxes[y] += 1
if x in ball_exists:
if boxes[x] == 0:
ball_exists.remove(x)
if len(ball_exists) == 1 and y in ball_exists:
ball_exists.clear()
ball_exists.add(y)
#print(boxes)
#print(ball_exists)
print(len(ball_exists)) |
[
7,
12,
13,
17,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
0,
13,
13,
0,
18,
13,
17,
39,
17,
0,
13,
17,
28,
13,
13,
13,
14,
2,
17,
18,
13,
13,
0,
18,
13,
13,
39,
17,
14,
2,
17,
18,
13,
13,
4,
18,
18,
13,
13,
13,
17,
4,
18,
18,
13,
13,
13,
17,
0,
18,
13,
13,
39,
17,
4,
18,
18,
13,
13,
13,
17,
0,
13,
17,
28,
13,
13,
28,
13,
4,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
7,
6
],
[
6,
15
],
[
18,
17
],
[
18,
19
],
[
23,
22
],
[
19,
25
],
[
30,
29
],
[
34,
33
],
[
17,
36
],
[
42,
41
],
[
47,
44
],
[
41,
45
],
[
51,
50
],
[
41,
60
],
[
66,
63
],
[
41,
64
],
[
41,
72
],
[
41,
77
],
[
41,
84
],
[
92,
89
],
[
41,
90
],
[
41,
97
],
[
103,
102
],
[
106,
105
],
[
41,
105
],
[
109,
108
],
[
105,
111
],
[
108,
114
],
[
118,
117
],
[
117,
121
],
[
102,
121
],
[
130,
127
]
] | [
"def resolve():\n '''\n code here\n '''\n N, M = [int(item) for item in input().split()]\n queries = [[int(item)-1 for item in input().split()] for _ in range(M)]\n\n memo = [['w'] for _ in range(N)]\n memo[0] = ['r']\n is_first_0 = True\n for x, y in queries:\n if 'r' in memo[x]:\n memo[y] += ['r']\n if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n else:\n memo[y] += ['w']\n memo[x].remove('w')\n res = 0\n for line in memo:\n for item in set(line):\n if item == 'r':\n res += 1\n print(res)\n\n\n\nif __name__ == \"__main__\":\n resolve()",
"def resolve():\n '''\n code here\n '''\n N, M = [int(item) for item in input().split()]\n queries = [[int(item)-1 for item in input().split()] for _ in range(M)]\n\n memo = [['w'] for _ in range(N)]\n memo[0] = ['r']\n is_first_0 = True\n for x, y in queries:\n if 'r' in memo[x]:\n memo[y] += ['r']\n if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n else:\n memo[y] += ['w']\n memo[x].remove('w')\n res = 0\n for line in memo:\n for item in set(line):\n if item == 'r':\n res += 1\n print(res)",
"resolve",
"'''\n code here\n '''",
"int(item) for item in input().split()",
"for item in input().split()",
"item",
"input().split()",
"().split",
"()",
"input",
"split",
"for item in input().split()",
"int(item)",
"int",
"item",
"N, M = [int(item) for item in input().split()]",
"N",
"[int(item) for item in input().split()]",
"M",
"[int(item)-1 for item in input().split()] for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"[int(item)-1 for item in input().split()]",
"queries = [[int(item)-1 for item in input().split()] for _ in range(M)]",
"queries",
"[[int(item)-1 for item in input().split()] for _ in range(M)]",
"['w'] for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"['w']",
"'w'",
"memo = [['w'] for _ in range(N)]",
"memo",
"[['w'] for _ in range(N)]",
"memo[0] = ['r']",
"memo[0]",
"memo",
"0",
"['r']",
"'r'",
"is_first_0 = True",
"is_first_0",
"True",
"for x, y in queries:\n if 'r' in memo[x]:\n memo[y] += ['r']\n if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n else:\n memo[y] += ['w']\n memo[x].remove('w')\n ",
"x",
"y",
"queries",
"if 'r' in memo[x]:\n memo[y] += ['r']\n if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n else:\n memo[y] += ['w']\n memo[x].remove('w')\n ",
"'r' in memo[x]",
"'r'",
"memo[x]",
"memo",
"x",
"memo[y] += ['r']",
"memo[y]",
"memo",
"y",
"['r']",
"'r'",
"if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n ",
"'w' in memo[x]",
"'w'",
"memo[x]",
"memo",
"x",
"memo[x].remove('w')",
"[x].remove",
"[x]",
"memo",
"x",
"remove",
"'w'",
"memo[x].remove('r')",
"[x].remove",
"[x]",
"memo",
"x",
"remove",
"'r'",
"memo[y] += ['w']",
"memo[y]",
"memo",
"y",
"['w']",
"'w'",
"memo[x].remove('w')",
"[x].remove",
"[x]",
"memo",
"x",
"remove",
"'w'",
"res = 0",
"res",
"0",
"for line in memo:\n for item in set(line):\n if item == 'r':\n res += 1\n ",
"line",
"memo",
"for item in set(line):\n if item == 'r':\n res += 1\n ",
"item",
"set(line)",
"set",
"line",
"if item == 'r':\n res += 1\n ",
"item == 'r'",
"item",
"'r'",
"res += 1",
"res",
"1",
"print(res)",
"print",
"res",
"if __name__ == \"__main__\":\n resolve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"resolve()",
"resolve",
"def resolve():\n '''\n code here\n '''\n N, M = [int(item) for item in input().split()]\n queries = [[int(item)-1 for item in input().split()] for _ in range(M)]\n\n memo = [['w'] for _ in range(N)]\n memo[0] = ['r']\n is_first_0 = True\n for x, y in queries:\n if 'r' in memo[x]:\n memo[y] += ['r']\n if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n else:\n memo[y] += ['w']\n memo[x].remove('w')\n res = 0\n for line in memo:\n for item in set(line):\n if item == 'r':\n res += 1\n print(res)",
"def resolve():\n '''\n code here\n '''\n N, M = [int(item) for item in input().split()]\n queries = [[int(item)-1 for item in input().split()] for _ in range(M)]\n\n memo = [['w'] for _ in range(N)]\n memo[0] = ['r']\n is_first_0 = True\n for x, y in queries:\n if 'r' in memo[x]:\n memo[y] += ['r']\n if 'w' in memo[x]:\n memo[x].remove('w')\n else:\n memo[x].remove('r')\n else:\n memo[y] += ['w']\n memo[x].remove('w')\n res = 0\n for line in memo:\n for item in set(line):\n if item == 'r':\n res += 1\n print(res)",
"resolve"
] | def resolve():
'''
code here
'''
N, M = [int(item) for item in input().split()]
queries = [[int(item)-1 for item in input().split()] for _ in range(M)]
memo = [['w'] for _ in range(N)]
memo[0] = ['r']
is_first_0 = True
for x, y in queries:
if 'r' in memo[x]:
memo[y] += ['r']
if 'w' in memo[x]:
memo[x].remove('w')
else:
memo[x].remove('r')
else:
memo[y] += ['w']
memo[x].remove('w')
res = 0
for line in memo:
for item in set(line):
if item == 'r':
res += 1
print(res)
if __name__ == "__main__":
resolve()
|
[
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,
4,
18,
13,
13,
17,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] | [
[
116,
2
],
[
116,
11
],
[
104,
13
],
[
111,
17
],
[
22,
19
],
[
105,
20
],
[
92,
24
],
[
111,
28
],
[
31,
30
],
[
117,
33
],
[
107,
35
],
[
107,
44
],
[
113,
46
],
[
101,
49
],
[
105,
53
],
[
114,
54
],
[
96,
54
],
[
59,
56
],
[
105,
57
],
[
102,
58
],
[
108,
58
],
[
64,
61
],
[
93,
62
],
[
114,
63
],
[
96,
63
],
[
69,
66
],
[
93,
67
],
[
102,
68
],
[
108,
68
],
[
61,
72
],
[
93,
73
],
[
114,
74
],
[
96,
74
],
[
80,
77
],
[
105,
78
],
[
114,
79
],
[
96,
79
],
[
98,
82
],
[
105,
85
],
[
99,
90
],
[
92,
93
],
[
107,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
116,
111
],
[
113,
114
],
[
116,
117
]
] | [
"N, M = map(int, input().split())\npossibility = [False] * N # True: 赤いボールが入っている可能性がある\npossibility[0] = True\nballs = [1] * N # 箱に入っているボールの数\nfor i in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n if possibility[x]:\n possibility[y] = True\n balls[x] -= 1\n balls[y] += 1\n if balls[x] == 0:\n possibility[x] = False\n\nans = possibility.count(True)\nprint(ans)",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"possibility = [False] * N",
"possibility",
"[False] * N",
"[False]",
"False",
"N",
"possibility[0] = True",
"possibility[0]",
"possibility",
"0",
"True",
"balls = [1] * N",
"balls",
"[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 possibility[x]:\n possibility[y] = True\n balls[x] -= 1\n balls[y] += 1\n if balls[x] == 0:\n possibility[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 possibility[x]:\n possibility[y] = True\n ",
"possibility[x]",
"possibility",
"x",
"possibility[y] = True",
"possibility[y]",
"possibility",
"y",
"True",
"balls[x] -= 1",
"balls[x]",
"balls",
"x",
"1",
"balls[y] += 1",
"balls[y]",
"balls",
"y",
"1",
"if balls[x] == 0:\n possibility[x] = False",
"balls[x] == 0",
"balls[x]",
"balls",
"x",
"0",
"possibility[x] = False",
"possibility[x]",
"possibility",
"x",
"False",
"ans = possibility.count(True)",
"ans",
"possibility.count(True)",
"possibility.count",
"possibility",
"count",
"True",
"print(ans)",
"print",
"ans",
"balls = [1] * N",
"[1] * N",
"balls",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"ans = possibility.count(True)",
"possibility.count(True)",
"ans",
"y -= 1",
"1",
"y",
"possibility = [False] * N",
"[False] * N",
"possibility",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"x -= 1",
"1",
"x",
"M = map(int, input().split())",
"map(int, input().split())",
"M"
] | N, M = map(int, input().split())
possibility = [False] * N # True: 赤いボールが入っている可能性がある
possibility[0] = True
balls = [1] * N # 箱に入っているボールの数
for i in range(M):
x, y = map(int, input().split())
x -= 1
y -= 1
if possibility[x]:
possibility[y] = True
balls[x] -= 1
balls[y] += 1
if balls[x] == 0:
possibility[x] = False
ans = possibility.count(True)
print(ans)
|
[
7,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
29,
13,
23,
13,
12,
13,
29,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
29,
4,
18,
13,
13,
13,
13,
23,
13,
23,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
18,
13,
13,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
42,
2,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
13,
14,
40,
2,
13,
13,
4,
18,
13,
13,
13,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
42,
2,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
17,
14,
40,
2,
13,
13,
4,
18,
13,
13,
13,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
15,
15,
15,
15,
13,
15,
15,
15,
13,
15,
13,
15,
13,
15,
15,
15,
15,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
13,
0,
18,
13,
13,
17,
14,
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,
4,
13,
4,
13,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
39,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
37,
36
],
[
48,
39
],
[
48,
48
],
[
71,
68
],
[
73,
69
],
[
71,
71
],
[
73,
73
],
[
79,
78
],
[
96,
81
],
[
92,
87
],
[
94,
88
],
[
92,
92
],
[
94,
94
],
[
96,
96
],
[
101,
100
],
[
100,
106
],
[
135,
107
],
[
110,
109
],
[
131,
114
],
[
133,
115
],
[
109,
119
],
[
100,
120
],
[
100,
123
],
[
109,
125
],
[
100,
129
],
[
131,
131
],
[
133,
133
],
[
135,
135
],
[
140,
139
],
[
139,
145
],
[
173,
146
],
[
149,
148
],
[
342,
150
],
[
169,
151
],
[
171,
152
],
[
148,
157
],
[
139,
158
],
[
139,
161
],
[
148,
163
],
[
139,
167
],
[
169,
169
],
[
171,
171
],
[
173,
173
],
[
308,
199
],
[
329,
206
],
[
303,
208
],
[
329,
209
],
[
311,
211
],
[
215,
214
],
[
300,
217
],
[
332,
219
],
[
303,
221
],
[
332,
222
],
[
312,
225
],
[
333,
229
],
[
318,
232
],
[
314,
235
],
[
330,
239
],
[
320,
241
],
[
330,
245
],
[
250,
247
],
[
321,
248
],
[
259,
256
],
[
315,
257
],
[
318,
258
],
[
283,
262
],
[
321,
263
],
[
333,
264
],
[
270,
267
],
[
321,
268
],
[
318,
269
],
[
275,
272
],
[
315,
273
],
[
333,
274
],
[
272,
278
],
[
315,
279
],
[
333,
280
],
[
286,
283
],
[
321,
284
],
[
333,
285
],
[
321,
291
],
[
329,
300
],
[
308,
309
],
[
311,
312
],
[
314,
315
],
[
332,
318
],
[
320,
321
],
[
329,
330
],
[
332,
333
]
] | [
"def getN():\n return int(input())\ndef getNM():\n return map(int, input().split())\ndef getList():\n return list(map(int, input().split()))\ndef getArray(intn):\n return [int(input()) for i in range(intn)]\ndef input():\n return sys.stdin.readline().rstrip()\ndef rand_N(ran1, ran2):\n return random.randint(ran1, ran2)\ndef rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]\ndef rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)\n\ndef rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)\n\nfrom collections import defaultdict, deque, Counter\nfrom sys import exit\nfrom decimal import *\nimport heapq\nfrom math import sqrt, pi\nfrom fractions import gcd\nimport random\nimport string\nimport copy\nfrom itertools import combinations, permutations, product\nfrom operator import mul, itemgetter\nfrom functools import reduce\nfrom bisect import bisect_left, bisect_right\n\nimport sys\nsys.setrecursionlimit(1000000000)\nmod = 10 ** 9 + 7\n\n#############\n# Main Code #\n#############\n\nN, M = getNM()\nque = []\nfor i in range(M):\n a, b = getNM()\n que.append([a - 1, b - 1])\nball = [1] * N\nred = [0] * N\nred[0] = 1\n\nfor a, b in que:\n ball[b] += 1\n if red[a] == 1:\n red[b] = 1\n ball[a] -= 1\n if ball[a] == 0:\n red[a] = 0\nprint(sum(red))",
"def getN():\n return int(input())",
"getN",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"def getNM():\n return map(int, input().split())",
"getNM",
"return map(int, input().split())",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def getList():\n return list(map(int, input().split()))",
"getList",
"return list(map(int, input().split()))",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"getArray",
"int(input()) for i in range(intn)",
"for i in range(intn)",
"i",
"range(intn)",
"range",
"intn",
"for i in range(intn)",
"int(input())",
"int",
"input()",
"input",
"return [int(input()) for i in range(intn)]",
"[int(input()) for i in range(intn)]",
"intn",
"intn",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"return sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"rand_N",
"return random.randint(ran1, ran2)",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"ran1",
"ran1",
"ran2",
"ran2",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"rand_List",
"random.randint(ran1, ran2) for i in range(rantime)",
"for i in range(rantime)",
"i",
"range(rantime)",
"range",
"rantime",
"for i in range(rantime)",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"return [random.randint(ran1, ran2) for i in range(rantime)]",
"[random.randint(ran1, ran2) for i in range(rantime)]",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"rand_ints_nodup",
"ns = []",
"ns",
"[]",
"while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n ",
"len(ns) < rantime",
"len(ns)",
"len",
"ns",
"rantime",
"n = random.randint(ran1, ran2)",
"n",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"if not n in ns:\n ns.append(n)\n ",
"not n in ns",
"n in ns",
"n",
"ns",
"ns.append(n)",
"ns.append",
"ns",
"append",
"n",
"return sorted(ns)",
"sorted(ns)",
"sorted",
"ns",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"rand_query",
"r_query = []",
"r_query",
"[]",
"while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n ",
"len(r_query) < rantime",
"len(r_query)",
"len",
"r_query",
"rantime",
"n_q = rand_ints_nodup(ran1, ran2, 2)",
"n_q",
"rand_ints_nodup(ran1, ran2, 2)",
"rand_ints_nodup",
"ran1",
"ran2",
"2",
"if not n_q in r_query:\n r_query.append(n_q)\n ",
"not n_q in r_query",
"n_q in r_query",
"n_q",
"r_query",
"r_query.append(n_q)",
"r_query.append",
"r_query",
"append",
"n_q",
"return sorted(r_query)",
"sorted(r_query)",
"sorted",
"r_query",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"from collections import defaultdict, deque, Counter",
"from sys import exit",
"from decimal import *",
"import heapq",
"heapq",
"from math import sqrt, pi",
"from fractions import gcd",
"import random",
"random",
"import string",
"string",
"import copy",
"copy",
"from itertools import combinations, permutations, product",
"from operator import mul, itemgetter",
"from functools import reduce",
"from bisect import bisect_left, bisect_right",
"import sys",
"sys",
"sys.setrecursionlimit(1000000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1000000000",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"N, M = getNM()",
"N",
"getNM()",
"getNM",
"M",
"que = []",
"que",
"[]",
"for i in range(M):\n a, b = getNM()\n que.append([a - 1, b - 1])",
"i",
"range(M)",
"range",
"M",
"a, b = getNM()",
"a",
"getNM()",
"getNM",
"b",
"que.append([a - 1, b - 1])",
"que.append",
"que",
"append",
"[a - 1, b - 1]",
"a - 1",
"a",
"1",
"b - 1",
"b",
"1",
"ball = [1] * N",
"ball",
"[1] * N",
"[1]",
"1",
"N",
"red = [0] * N",
"red",
"[0] * N",
"[0]",
"0",
"N",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"for a, b in que:\n ball[b] += 1\n if red[a] == 1:\n red[b] = 1\n ball[a] -= 1\n if ball[a] == 0:\n red[a] = 0",
"a",
"b",
"que",
"ball[b] += 1",
"ball[b]",
"ball",
"b",
"1",
"if red[a] == 1:\n red[b] = 1\n ",
"red[a] == 1",
"red[a]",
"red",
"a",
"1",
"red[b] = 1",
"red[b]",
"red",
"b",
"1",
"ball[a] -= 1",
"ball[a]",
"ball",
"a",
"1",
"if ball[a] == 0:\n red[a] = 0",
"ball[a] == 0",
"ball[a]",
"ball",
"a",
"0",
"red[a] = 0",
"red[a]",
"red",
"a",
"0",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"rand_List",
"def getN():\n return int(input())",
"def getN():\n return int(input())",
"getN",
"M = getNM()",
"getNM()",
"M",
"def getNM():\n return map(int, input().split())",
"def getNM():\n return map(int, input().split())",
"getNM",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"rand_N",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"que = []",
"[]",
"que",
"ball = [1] * N",
"[1] * N",
"ball",
"b = getNM()",
"getNM()",
"b",
"red = [0] * N",
"[0] * N",
"red",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"getArray",
"def getList():\n return list(map(int, input().split()))",
"def getList():\n return list(map(int, input().split()))",
"getList",
"N, M = getNM()",
"getNM()",
"N",
"a, b = getNM()",
"getNM()",
"a",
"def input():\n return sys.stdin.readline().rstrip()",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"rand_query",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"rand_ints_nodup"
] | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, M = getNM()
que = []
for i in range(M):
a, b = getNM()
que.append([a - 1, b - 1])
ball = [1] * N
red = [0] * N
red[0] = 1
for a, b in que:
ball[b] += 1
if red[a] == 1:
red[b] = 1
ball[a] -= 1
if ball[a] == 0:
red[a] = 0
print(sum(red)) |
[
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,
2,
13,
17,
4,
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,
0,
18,
13,
2,
13,
17,
17,
14,
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,
13,
17,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] | [
[
129,
2
],
[
129,
11
],
[
15,
14
],
[
127,
17
],
[
117,
21
],
[
26,
25
],
[
127,
29
],
[
132,
34
],
[
120,
40
],
[
44,
43
],
[
130,
46
],
[
138,
48
],
[
138,
57
],
[
133,
60
],
[
136,
62
],
[
70,
65
],
[
133,
66
],
[
139,
68
],
[
118,
74
],
[
136,
76
],
[
85,
80
],
[
133,
81
],
[
136,
83
],
[
92,
87
],
[
118,
88
],
[
136,
90
],
[
99,
94
],
[
118,
95
],
[
139,
97
],
[
141,
101
],
[
105,
104
],
[
133,
104
],
[
104,
108
],
[
123,
111
],
[
124,
115
],
[
142,
115
],
[
121,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
129,
127
],
[
129,
130
],
[
132,
133
],
[
138,
136
],
[
138,
139
],
[
141,
142
]
] | [
"N, M = map(int, input().split())\nball_count = [1 for _ in range(N)]\nif_red_exists = [1] + [0 for _ in range(N-1)]\ncount = 1\nfor _ in range(M):\n x, y = map(int, input().split())\n if if_red_exists[x-1]:\n # 赤が存在する場合\n if_red_exists[y-1] = 1\n if ball_count[x-1] <= 1:\n if_red_exists[x-1] = 0\n ball_count[x-1] -= 1\n ball_count[y-1] += 1\n\ncount = 0\nfor e in if_red_exists:\n if e == 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",
"1 for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"1",
"ball_count = [1 for _ in range(N)]",
"ball_count",
"[1 for _ in range(N)]",
"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",
"if_red_exists = [1] + [0 for _ in range(N-1)]",
"if_red_exists",
"[1] + [0 for _ in range(N-1)]",
"[1]",
"1",
"[0 for _ in range(N-1)]",
"count = 1",
"count",
"1",
"for _ in range(M):\n x, y = map(int, input().split())\n if if_red_exists[x-1]:\n # 赤が存在する場合\n if_red_exists[y-1] = 1\n if ball_count[x-1] <= 1:\n if_red_exists[x-1] = 0\n ball_count[x-1] -= 1\n ball_count[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",
"if if_red_exists[x-1]:\n # 赤が存在する場合\n if_red_exists[y-1] = 1\n if ball_count[x-1] <= 1:\n if_red_exists[x-1] = 0\n ",
"if_red_exists[x-1]",
"if_red_exists",
"x-1",
"x",
"1",
"if_red_exists[y-1] = 1",
"if_red_exists[y-1]",
"if_red_exists",
"y-1",
"y",
"1",
"1",
"if ball_count[x-1] <= 1:\n if_red_exists[x-1] = 0\n ",
"ball_count[x-1] <= 1",
"ball_count[x-1]",
"ball_count",
"x-1",
"x",
"1",
"1",
"if_red_exists[x-1] = 0",
"if_red_exists[x-1]",
"if_red_exists",
"x-1",
"x",
"1",
"0",
"ball_count[x-1] -= 1",
"ball_count[x-1]",
"ball_count",
"x-1",
"x",
"1",
"1",
"ball_count[y-1] += 1",
"ball_count[y-1]",
"ball_count",
"y-1",
"y",
"1",
"1",
"count = 0",
"count",
"0",
"for e in if_red_exists:\n if e == 1:\n count += 1",
"e",
"if_red_exists",
"if e == 1:\n count += 1",
"e == 1",
"e",
"1",
"count += 1",
"count",
"1",
"print(count)",
"print",
"count",
"ball_count = [1 for _ in range(N)]",
"[1 for _ in range(N)]",
"ball_count",
"count = 1",
"1",
"count",
"count += 1",
"1",
"count",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"if_red_exists = [1] + [0 for _ in range(N-1)]",
"[1] + [0 for _ in range(N-1)]",
"if_red_exists",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"count = 0",
"0",
"count"
] | N, M = map(int, input().split())
ball_count = [1 for _ in range(N)]
if_red_exists = [1] + [0 for _ in range(N-1)]
count = 1
for _ in range(M):
x, y = map(int, input().split())
if if_red_exists[x-1]:
# 赤が存在する場合
if_red_exists[y-1] = 1
if ball_count[x-1] <= 1:
if_red_exists[x-1] = 0
ball_count[x-1] -= 1
ball_count[y-1] += 1
count = 0
for e in if_red_exists:
if e == 1:
count += 1
print(count)
|
[
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,
28,
13,
4,
13,
13,
0,
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,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
9,
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,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
156,
2
],
[
156,
11
],
[
15,
14
],
[
145,
17
],
[
147,
23
],
[
31,
26
],
[
148,
28
],
[
34,
33
],
[
157,
36
],
[
138,
38
],
[
138,
47
],
[
153,
49
],
[
141,
52
],
[
60,
55
],
[
148,
57
],
[
154,
58
],
[
139,
58
],
[
67,
62
],
[
148,
64
],
[
142,
65
],
[
133,
65
],
[
148,
72
],
[
154,
73
],
[
139,
73
],
[
82,
77
],
[
148,
79
],
[
142,
80
],
[
133,
80
],
[
148,
87
],
[
142,
88
],
[
133,
88
],
[
98,
93
],
[
148,
95
],
[
142,
96
],
[
133,
96
],
[
148,
103
],
[
154,
104
],
[
139,
104
],
[
113,
108
],
[
148,
110
],
[
154,
111
],
[
139,
111
],
[
135,
115
],
[
150,
126
],
[
151,
130
],
[
136,
130
],
[
138,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
156,
145
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
]
] | [
"n, m = map(int, input().split())\nboxes = [[0, 1] for _ in range(n)]\nboxes[0][0] = 1\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n boxes[x][1] -= 1\n boxes[y][1] += 1\n if boxes[x][0] == 1:\n boxes[y][0] = 1\n else:\n if boxes[y][0] == 1:\n continue\n else:\n boxes[y][0] = 0 \n if boxes[x][1] == 0:\n boxes[x][0] = -1\nans = 0\nfor a, b in boxes:\n # print(a, b)\n if a > 0:\n ans += 1\n# print(boxes)\nprint(ans)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"[0, 1] for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"[0, 1]",
"0",
"1",
"boxes = [[0, 1] for _ in range(n)]",
"boxes",
"[[0, 1] for _ in range(n)]",
"boxes[0][0] = 1",
"boxes[0][0]",
"[0]",
"boxes",
"0",
"0",
"1",
"for _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n boxes[x][1] -= 1\n boxes[y][1] += 1\n if boxes[x][0] == 1:\n boxes[y][0] = 1\n else:\n if boxes[y][0] == 1:\n continue\n else:\n boxes[y][0] = 0 \n if boxes[x][1] == 0:\n boxes[x][0] = -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",
"boxes[x][1] -= 1",
"boxes[x][1]",
"[x]",
"boxes",
"x",
"1",
"1",
"boxes[y][1] += 1",
"boxes[y][1]",
"[y]",
"boxes",
"y",
"1",
"1",
"if boxes[x][0] == 1:\n boxes[y][0] = 1\n else:\n if boxes[y][0] == 1:\n continue\n else:\n boxes[y][0] = 0 \n ",
"boxes[x][0] == 1",
"boxes[x][0]",
"[x]",
"boxes",
"x",
"0",
"1",
"boxes[y][0] = 1",
"boxes[y][0]",
"[y]",
"boxes",
"y",
"0",
"1",
"if boxes[y][0] == 1:\n continue\n else:\n boxes[y][0] = 0 \n ",
"boxes[y][0] == 1",
"boxes[y][0]",
"[y]",
"boxes",
"y",
"0",
"1",
"continue",
"boxes[y][0] = 0",
"boxes[y][0]",
"[y]",
"boxes",
"y",
"0",
"0",
"if boxes[x][1] == 0:\n boxes[x][0] = -1",
"boxes[x][1] == 0",
"boxes[x][1]",
"[x]",
"boxes",
"x",
"1",
"0",
"boxes[x][0] = -1",
"boxes[x][0]",
"[x]",
"boxes",
"x",
"0",
"-1",
"ans = 0",
"ans",
"0",
"for a, b in boxes:\n # print(a, b)\n if a > 0:\n ans += 1\n# print(boxes)",
"a",
"b",
"boxes",
"if a > 0:\n ans += 1\n# print(boxes)",
"a > 0",
"a",
"0",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"ans = 0",
"0",
"ans",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y -= 1",
"1",
"y",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"boxes = [[0, 1] for _ in range(n)]",
"[[0, 1] for _ in range(n)]",
"boxes",
"ans += 1",
"1",
"ans",
"x -= 1",
"1",
"x",
"m = map(int, input().split())",
"map(int, input().split())",
"m"
] | n, m = map(int, input().split())
boxes = [[0, 1] for _ in range(n)]
boxes[0][0] = 1
for _ in range(m):
x, y = map(int, input().split())
x -= 1
y -= 1
boxes[x][1] -= 1
boxes[y][1] += 1
if boxes[x][0] == 1:
boxes[y][0] = 1
else:
if boxes[y][0] == 1:
continue
else:
boxes[y][0] = 0
if boxes[x][1] == 0:
boxes[x][0] = -1
ans = 0
for a, b in boxes:
# print(a, b)
if a > 0:
ans += 1
# print(boxes)
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,
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,
4,
13,
13,
0,
13,
18,
13,
13,
13,
18,
13,
13,
0,
13,
2,
13,
17,
13,
2,
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,
4,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
18,
13,
10,
2,
13
] | [
[
126,
2
],
[
126,
11
],
[
138,
13
],
[
127,
17
],
[
129,
19
],
[
127,
23
],
[
26,
25
],
[
127,
28
],
[
33,
30
],
[
139,
31
],
[
25,
32
],
[
33,
41
],
[
130,
42
],
[
25,
43
],
[
141,
45
],
[
124,
49
],
[
135,
51
],
[
124,
55
],
[
60,
57
],
[
136,
58
],
[
63,
62
],
[
127,
65
],
[
144,
67
],
[
30,
68
],
[
139,
69
],
[
62,
70
],
[
132,
71
],
[
41,
72
],
[
130,
73
],
[
62,
74
],
[
147,
76
],
[
145,
78
],
[
148,
78
],
[
120,
80
],
[
133,
82
],
[
121,
82
],
[
136,
86
],
[
148,
87
],
[
145,
87
],
[
92,
89
],
[
136,
90
],
[
121,
91
],
[
133,
91
],
[
97,
94
],
[
142,
95
],
[
148,
96
],
[
145,
96
],
[
102,
99
],
[
142,
100
],
[
121,
101
],
[
133,
101
],
[
94,
105
],
[
142,
106
],
[
148,
107
],
[
145,
107
],
[
113,
110
],
[
136,
111
],
[
148,
112
],
[
145,
112
],
[
136,
118
],
[
120,
121
],
[
126,
124
],
[
126,
127
],
[
129,
130
],
[
41,
132
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
30,
144
],
[
144,
145
],
[
147,
148
]
] | [
"n,m = map(int,input().split())\nx_li = [0]*m\ny_li = [0]*m\nfor i in range(m):\n x_li[i],y_li[i]=map(int,input().split())\n\nmap_li = [1]*n\nred = [False]*n\nred[0]=True\n\nfor i in range(m):\n x,y = x_li[i],y_li[i]\n x,y = x-1,y-1\n if red[x]:\n red[y]=True\n map_li[x]-=1\n map_li[y]+=1\n if map_li[x]==0:\n red[x]=False\n#print(map_li)\nprint(sum(red))",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"x_li = [0]*m",
"x_li",
"[0]*m",
"[0]",
"0",
"m",
"y_li = [0]*m",
"y_li",
"[0]*m",
"[0]",
"0",
"m",
"for i in range(m):\n x_li[i],y_li[i]=map(int,input().split())",
"i",
"range(m)",
"range",
"m",
"x_li[i],y_li[i]=map(int,input().split())",
"x_li[i]",
"x_li",
"i",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y_li[i]",
"y_li",
"i",
"map_li = [1]*n",
"map_li",
"[1]*n",
"[1]",
"1",
"n",
"red = [False]*n",
"red",
"[False]*n",
"[False]",
"False",
"n",
"red[0]=True",
"red[0]",
"red",
"0",
"True",
"for i in range(m):\n x,y = x_li[i],y_li[i]\n x,y = x-1,y-1\n if red[x]:\n red[y]=True\n map_li[x]-=1\n map_li[y]+=1\n if map_li[x]==0:\n red[x]=False\n#print(map_li)",
"i",
"range(m)",
"range",
"m",
"x,y = x_li[i],y_li[i]",
"x",
"x_li[i]",
"x_li",
"i",
"y",
"y_li[i]",
"y_li",
"i",
"x,y = x-1,y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"if red[x]:\n red[y]=True\n ",
"red[x]",
"red",
"x",
"red[y]=True",
"red[y]",
"red",
"y",
"True",
"map_li[x]-=1",
"map_li[x]",
"map_li",
"x",
"1",
"map_li[y]+=1",
"map_li[y]",
"map_li",
"y",
"1",
"if map_li[x]==0:\n red[x]=False\n#print(map_li)",
"map_li[x]==0",
"map_li[x]",
"map_li",
"x",
"0",
"red[x]=False",
"red[x]",
"red",
"x",
"False",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"y = x-1,y-1",
"y-1",
"y",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"y_li = [0]*m",
"[0]*m",
"y_li",
"y = x_li[i],y_li[i]",
"y_li[i]",
"y",
"red = [False]*n",
"[False]*n",
"red",
"x_li = [0]*m",
"[0]*m",
"x_li",
"map_li = [1]*n",
"[1]*n",
"map_li",
"x,y = x_li[i],y_li[i]",
"x_li[i]",
"x",
"x,y = x-1,y-1",
"x-1",
"x"
] | n,m = map(int,input().split())
x_li = [0]*m
y_li = [0]*m
for i in range(m):
x_li[i],y_li[i]=map(int,input().split())
map_li = [1]*n
red = [False]*n
red[0]=True
for i in range(m):
x,y = x_li[i],y_li[i]
x,y = x-1,y-1
if red[x]:
red[y]=True
map_li[x]-=1
map_li[y]+=1
if map_li[x]==0:
red[x]=False
#print(map_li)
print(sum(red)) |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
2,
13,
17,
0,
13,
4,
18,
13,
13,
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,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
2,
18,
13,
13,
17,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
18,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
112,
4
],
[
112,
13
],
[
109,
15
],
[
107,
21
],
[
103,
24
],
[
107,
30
],
[
36,
33
],
[
104,
34
],
[
39,
38
],
[
113,
41
],
[
100,
43
],
[
100,
52
],
[
73,
55
],
[
104,
56
],
[
101,
57
],
[
63,
60
],
[
104,
61
],
[
98,
62
],
[
78,
67
],
[
110,
68
],
[
101,
69
],
[
76,
73
],
[
104,
74
],
[
101,
75
],
[
81,
78
],
[
110,
79
],
[
101,
80
],
[
86,
83
],
[
110,
84
],
[
98,
85
],
[
104,
92
],
[
104,
94
],
[
100,
98
],
[
100,
101
],
[
103,
104
],
[
112,
107
],
[
109,
110
],
[
112,
113
]
] | [
"import numpy as np\n\nN,M=map(int,input().split())\nlength=np.ones(N+1)\naka=np.ones(N+1)\naka[1]=-1\n\nfor _ in range(M):\n x,y=map(int,input().split())\n if aka[x]==-1:\n aka[y]=-1\n if length[x]-1==0:\n aka[x]=1\n length[x]-=1\n length[y]+=1\n\nprint(len(aka[aka<0]))",
"import numpy as np",
"numpy",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"length=np.ones(N+1)",
"length",
"np.ones(N+1)",
"np.ones",
"np",
"ones",
"N+1",
"N",
"1",
"aka=np.ones(N+1)",
"aka",
"np.ones(N+1)",
"np.ones",
"np",
"ones",
"N+1",
"N",
"1",
"aka[1]=-1",
"aka[1]",
"aka",
"1",
"-1",
"for _ in range(M):\n x,y=map(int,input().split())\n if aka[x]==-1:\n aka[y]=-1\n if length[x]-1==0:\n aka[x]=1\n length[x]-=1\n length[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 aka[x]==-1:\n aka[y]=-1\n ",
"aka[x]==-1",
"aka[x]",
"aka",
"x",
"-1",
"aka[y]=-1",
"aka[y]",
"aka",
"y",
"-1",
"if length[x]-1==0:\n aka[x]=1\n ",
"length[x]-1==0",
"length[x]-1",
"length[x]",
"length",
"x",
"1",
"0",
"aka[x]=1",
"aka[x]",
"aka",
"x",
"1",
"length[x]-=1",
"length[x]",
"length",
"x",
"1",
"length[y]+=1",
"length[y]",
"length",
"y",
"1",
"print(len(aka[aka<0]))",
"print",
"len(aka[aka<0])",
"len",
"aka[aka<0]",
"aka",
"aka<0",
"aka",
"0",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"aka=np.ones(N+1)",
"np.ones(N+1)",
"aka",
"N,M=map(int,input().split())",
"map(int,input().split())",
"N",
"length=np.ones(N+1)",
"np.ones(N+1)",
"length",
"M=map(int,input().split())",
"map(int,input().split())",
"M"
] | import numpy as np
N,M=map(int,input().split())
length=np.ones(N+1)
aka=np.ones(N+1)
aka[1]=-1
for _ in range(M):
x,y=map(int,input().split())
if aka[x]==-1:
aka[y]=-1
if length[x]-1==0:
aka[x]=1
length[x]-=1
length[y]+=1
print(len(aka[aka<0])) |
[
7,
15,
13,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
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,
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,
13,
17,
28,
13,
13,
4,
13,
13,
13,
0,
13,
2,
40,
13,
17,
40,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13
] | [
[
142,
7
],
[
130,
14
],
[
143,
23
],
[
130,
25
],
[
124,
27
],
[
131,
32
],
[
38,
35
],
[
125,
36
],
[
121,
40
],
[
131,
45
],
[
49,
48
],
[
119,
51
],
[
136,
53
],
[
143,
60
],
[
136,
62
],
[
91,
65
],
[
125,
66
],
[
137,
67
],
[
73,
70
],
[
125,
71
],
[
128,
72
],
[
78,
75
],
[
122,
76
],
[
137,
77
],
[
83,
80
],
[
122,
81
],
[
128,
82
],
[
75,
86
],
[
122,
87
],
[
137,
88
],
[
94,
91
],
[
125,
92
],
[
137,
93
],
[
139,
96
],
[
122,
103
],
[
125,
104
],
[
133,
106
],
[
134,
116
],
[
140,
116
],
[
130,
119
],
[
121,
122
],
[
124,
125
],
[
136,
128
],
[
130,
131
],
[
133,
134
],
[
136,
137
],
[
139,
140
],
[
142,
143
]
] | [
"import sys,math,collections,itertools\ninput = sys.stdin.readline\n\nN,M=list(map(int,input().split()))\nball = [0]*(N+1)\nball[1]=1\nball_num = [1]*(N+1)\nfor i in range(M):\n x,y=map(int,input().split())\n if ball[x]==1:\n ball[y]=1\n ball_num[x]-=1\n ball_num[y]+=1\n if ball_num[x]==0:\n ball[x]=0\n \ncnt = 0\nfor a,b in zip(ball_num,ball):\n cnt += (a!=0 and b != 0)\nprint(cnt)",
"import sys,math,collections,itertools",
"sys",
"math",
"collections",
"itertools",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"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",
"ball = [0]*(N+1)",
"ball",
"[0]*(N+1)",
"[0]",
"0",
"N+1",
"N",
"1",
"ball[1]=1",
"ball[1]",
"ball",
"1",
"1",
"ball_num = [1]*(N+1)",
"ball_num",
"[1]*(N+1)",
"[1]",
"1",
"N+1",
"N",
"1",
"for i in range(M):\n x,y=map(int,input().split())\n if ball[x]==1:\n ball[y]=1\n ball_num[x]-=1\n ball_num[y]+=1\n if ball_num[x]==0:\n ball[x]=0\n ",
"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 ball[x]==1:\n ball[y]=1\n ",
"ball[x]==1",
"ball[x]",
"ball",
"x",
"1",
"ball[y]=1",
"ball[y]",
"ball",
"y",
"1",
"ball_num[x]-=1",
"ball_num[x]",
"ball_num",
"x",
"1",
"ball_num[y]+=1",
"ball_num[y]",
"ball_num",
"y",
"1",
"if ball_num[x]==0:\n ball[x]=0\n ",
"ball_num[x]==0",
"ball_num[x]",
"ball_num",
"x",
"0",
"ball[x]=0",
"ball[x]",
"ball",
"x",
"0",
"cnt = 0",
"cnt",
"0",
"for a,b in zip(ball_num,ball):\n cnt += (a!=0 and b != 0)",
"a",
"b",
"zip(ball_num,ball)",
"zip",
"ball_num",
"ball",
"cnt += (a!=0 and b != 0)",
"cnt",
"a!=0 and b != 0",
"a!=0",
"a",
"0",
"b != 0",
"b",
"0",
"print(cnt)",
"print",
"cnt",
"M=list(map(int,input().split()))",
"list(map(int,input().split()))",
"M",
"ball_num = [1]*(N+1)",
"[1]*(N+1)",
"ball_num",
"ball = [0]*(N+1)",
"[0]*(N+1)",
"ball",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"N,M=list(map(int,input().split()))",
"list(map(int,input().split()))",
"N",
"cnt += (a!=0 and b != 0)",
"a!=0 and b != 0",
"cnt",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"cnt = 0",
"0",
"cnt",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input"
] | import sys,math,collections,itertools
input = sys.stdin.readline
N,M=list(map(int,input().split()))
ball = [0]*(N+1)
ball[1]=1
ball_num = [1]*(N+1)
for i in range(M):
x,y=map(int,input().split())
if ball[x]==1:
ball[y]=1
ball_num[x]-=1
ball_num[y]+=1
if ball_num[x]==0:
ball[x]=0
cnt = 0
for a,b in zip(ball_num,ball):
cnt += (a!=0 and b != 0)
print(cnt) |
[
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,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
14,
2,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
14,
2,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13
] | [
[
128,
2
],
[
128,
13
],
[
17,
16
],
[
117,
19
],
[
122,
32
],
[
119,
35
],
[
129,
39
],
[
125,
41
],
[
129,
45
],
[
50,
47
],
[
126,
48
],
[
53,
52
],
[
123,
52
],
[
126,
57
],
[
52,
60
],
[
72,
65
],
[
126,
66
],
[
52,
69
],
[
81,
74
],
[
120,
75
],
[
52,
78
],
[
90,
83
],
[
120,
84
],
[
52,
87
],
[
120,
94
],
[
52,
97
],
[
109,
102
],
[
126,
103
],
[
52,
106
],
[
126,
114
],
[
128,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
]
] | [
"N,M = list(map(int,input().split()))\nXY = [list(map(int,input().split())) for _ in range(M)]\nL1 = [1]*N\nL2 = [0]*N\nL2[0] = 1\nfor xy in XY:\n if L2[xy[0]-1] == 1:\n L2[xy[1]-1] = 1\n L1[xy[0]-1] -= 1\n L1[xy[1]-1] += 1\n if L1[xy[0]-1] == 0:\n L2[xy[0]-1] = 0\nprint(sum(L2))",
"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 _ 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)]",
"L1 = [1]*N",
"L1",
"[1]*N",
"[1]",
"1",
"N",
"L2 = [0]*N",
"L2",
"[0]*N",
"[0]",
"0",
"N",
"L2[0] = 1",
"L2[0]",
"L2",
"0",
"1",
"for xy in XY:\n if L2[xy[0]-1] == 1:\n L2[xy[1]-1] = 1\n L1[xy[0]-1] -= 1\n L1[xy[1]-1] += 1\n if L1[xy[0]-1] == 0:\n L2[xy[0]-1] = 0",
"xy",
"XY",
"if L2[xy[0]-1] == 1:\n L2[xy[1]-1] = 1\n ",
"L2[xy[0]-1] == 1",
"L2[xy[0]-1]",
"L2",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"1",
"L2[xy[1]-1] = 1",
"L2[xy[1]-1]",
"L2",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"1",
"L1[xy[0]-1] -= 1",
"L1[xy[0]-1]",
"L1",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"1",
"L1[xy[1]-1] += 1",
"L1[xy[1]-1]",
"L1",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"1",
"if L1[xy[0]-1] == 0:\n L2[xy[0]-1] = 0",
"L1[xy[0]-1] == 0",
"L1[xy[0]-1]",
"L1",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"0",
"L2[xy[0]-1] = 0",
"L2[xy[0]-1]",
"L2",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"0",
"print(sum(L2))",
"print",
"sum(L2)",
"sum",
"L2",
"M = list(map(int,input().split()))",
"list(map(int,input().split()))",
"M",
"L1 = [1]*N",
"[1]*N",
"L1",
"XY = [list(map(int,input().split())) for _ in range(M)]",
"[list(map(int,input().split())) for _ in range(M)]",
"XY",
"L2 = [0]*N",
"[0]*N",
"L2",
"N,M = list(map(int,input().split()))",
"list(map(int,input().split()))",
"N"
] | N,M = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in range(M)]
L1 = [1]*N
L2 = [0]*N
L2[0] = 1
for xy in XY:
if L2[xy[0]-1] == 1:
L2[xy[1]-1] = 1
L1[xy[0]-1] -= 1
L1[xy[1]-1] += 1
if L1[xy[0]-1] == 0:
L2[xy[0]-1] = 0
print(sum(L2)) |
[
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,
0,
13,
2,
18,
13,
17,
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,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
2,
13
] | [
[
107,
2
],
[
107,
11
],
[
15,
14
],
[
108,
17
],
[
116,
30
],
[
122,
33
],
[
105,
37
],
[
110,
39
],
[
105,
43
],
[
48,
45
],
[
123,
46
],
[
51,
50
],
[
117,
50
],
[
119,
53
],
[
50,
56
],
[
113,
60
],
[
50,
63
],
[
84,
68
],
[
123,
69
],
[
120,
70
],
[
76,
73
],
[
123,
74
],
[
114,
75
],
[
89,
79
],
[
111,
80
],
[
120,
81
],
[
87,
84
],
[
123,
85
],
[
120,
86
],
[
92,
89
],
[
111,
90
],
[
120,
91
],
[
97,
94
],
[
111,
95
],
[
114,
96
],
[
123,
102
],
[
107,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
]
] | [
"n,m = map(int,input().split())\nxyl = [list(map(int,input().split())) for nesya in range(m)]\nred = [0]*n\nball = [1]*n\nred[0] = 1\nfor xy in xyl:\n x = xy[0]-1\n y = xy[1]-1\n if red[x] > 0:\n red[y] = 1\n if ball[x] == 1:\n red[x] = 0\n ball[x] -= 1\n ball[y] += 1\nprint(sum(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 nesya in range(m)",
"for nesya in range(m)",
"nesya",
"range(m)",
"range",
"m",
"for nesya in range(m)",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"xyl = [list(map(int,input().split())) for nesya in range(m)]",
"xyl",
"[list(map(int,input().split())) for nesya in range(m)]",
"red = [0]*n",
"red",
"[0]*n",
"[0]",
"0",
"n",
"ball = [1]*n",
"ball",
"[1]*n",
"[1]",
"1",
"n",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"for xy in xyl:\n x = xy[0]-1\n y = xy[1]-1\n if red[x] > 0:\n red[y] = 1\n if ball[x] == 1:\n red[x] = 0\n ball[x] -= 1\n ball[y] += 1",
"xy",
"xyl",
"x = xy[0]-1",
"x",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"y = xy[1]-1",
"y",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"if red[x] > 0:\n red[y] = 1\n if ball[x] == 1:\n red[x] = 0\n ",
"red[x] > 0",
"red[x]",
"red",
"x",
"0",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"if ball[x] == 1:\n red[x] = 0\n ",
"ball[x] == 1",
"ball[x]",
"ball",
"x",
"1",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"ball[x] -= 1",
"ball[x]",
"ball",
"x",
"1",
"ball[y] += 1",
"ball[y]",
"ball",
"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",
"ball = [1]*n",
"[1]*n",
"ball",
"y = xy[1]-1",
"xy[1]-1",
"y",
"xyl = [list(map(int,input().split())) for nesya in range(m)]",
"[list(map(int,input().split())) for nesya in range(m)]",
"xyl",
"x = xy[0]-1",
"xy[0]-1",
"x",
"red = [0]*n",
"[0]*n",
"red"
] | n,m = map(int,input().split())
xyl = [list(map(int,input().split())) for nesya in range(m)]
red = [0]*n
ball = [1]*n
red[0] = 1
for xy in xyl:
x = xy[0]-1
y = xy[1]-1
if red[x] > 0:
red[y] = 1
if ball[x] == 1:
red[x] = 0
ball[x] -= 1
ball[y] += 1
print(sum(red)) |
[
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,
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,
2,
18,
13,
13,
17,
40,
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,
14,
2,
2,
18,
13,
13,
17,
40,
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,
41,
28,
13,
13,
40,
13,
17,
4,
17,
0,
13,
4,
13,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
175,
2
],
[
175,
11
],
[
193,
13
],
[
176,
18
],
[
24,
21
],
[
194,
22
],
[
178,
26
],
[
176,
31
],
[
37,
34
],
[
179,
35
],
[
181,
39
],
[
176,
44
],
[
48,
47
],
[
173,
50
],
[
190,
52
],
[
190,
61
],
[
66,
63
],
[
182,
64
],
[
191,
65
],
[
71,
68
],
[
182,
69
],
[
188,
70
],
[
150,
75
],
[
107,
75
],
[
179,
76
],
[
191,
77
],
[
145,
80
],
[
129,
80
],
[
194,
81
],
[
191,
82
],
[
88,
85
],
[
179,
86
],
[
188,
87
],
[
93,
90
],
[
194,
91
],
[
188,
92
],
[
150,
97
],
[
107,
97
],
[
179,
98
],
[
191,
99
],
[
145,
102
],
[
129,
102
],
[
194,
103
],
[
191,
104
],
[
110,
107
],
[
179,
108
],
[
191,
109
],
[
115,
112
],
[
179,
113
],
[
188,
114
],
[
107,
119
],
[
150,
119
],
[
179,
120
],
[
191,
121
],
[
145,
124
],
[
129,
124
],
[
194,
125
],
[
191,
126
],
[
132,
129
],
[
194,
130
],
[
191,
131
],
[
137,
134
],
[
194,
135
],
[
188,
136
],
[
63,
140
],
[
182,
141
],
[
191,
142
],
[
148,
145
],
[
194,
146
],
[
191,
147
],
[
153,
150
],
[
179,
151
],
[
191,
152
],
[
157,
156
],
[
179,
156
],
[
156,
159
],
[
184,
164
],
[
185,
170
],
[
175,
173
],
[
175,
176
],
[
178,
179
],
[
181,
182
],
[
184,
185
],
[
190,
188
],
[
190,
191
],
[
193,
194
]
] | [
"N, M = map(int, input().split())\n\nW = [1] * (N + 1)\nW[1] = 0\nR = [0] * (N + 1)\nR[1] = 1\ncnt = [1] * (N + 1)\n\nfor _ in range(M):\n fr, to = map(int, input().split())\n cnt[fr] -= 1\n cnt[to] += 1\n\n if R[fr] == 1 and W[fr] >= 1:\n R[to] = 1\n W[to] += 1\n\n if R[fr] == 1 and W[fr] == 0:\n R[fr] = 0\n R[to] = 1\n\n if R[fr] == 0 and W[fr] >= 1:\n W[fr] -= 1\n W[to] += 1\n\n if cnt[fr] == 0:\n W[fr] = 0\n R[fr] = 0\n\nans = len([0 for r in R if r >= 1])\nprint(ans)",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"W = [1] * (N + 1)",
"W",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"W[1] = 0",
"W[1]",
"W",
"1",
"0",
"R = [0] * (N + 1)",
"R",
"[0] * (N + 1)",
"[0]",
"0",
"N + 1",
"N",
"1",
"R[1] = 1",
"R[1]",
"R",
"1",
"1",
"cnt = [1] * (N + 1)",
"cnt",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"for _ in range(M):\n fr, to = map(int, input().split())\n cnt[fr] -= 1\n cnt[to] += 1\n\n if R[fr] == 1 and W[fr] >= 1:\n R[to] = 1\n W[to] += 1\n\n if R[fr] == 1 and W[fr] == 0:\n R[fr] = 0\n R[to] = 1\n\n if R[fr] == 0 and W[fr] >= 1:\n W[fr] -= 1\n W[to] += 1\n\n if cnt[fr] == 0:\n W[fr] = 0\n R[fr] = 0",
"_",
"range(M)",
"range",
"M",
"fr, to = map(int, input().split())",
"fr",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"to",
"cnt[fr] -= 1",
"cnt[fr]",
"cnt",
"fr",
"1",
"cnt[to] += 1",
"cnt[to]",
"cnt",
"to",
"1",
"if R[fr] == 1 and W[fr] >= 1:\n R[to] = 1\n W[to] += 1\n\n ",
"R[fr] == 1 and W[fr] >= 1",
"R[fr] == 1",
"R[fr]",
"R",
"fr",
"1",
"W[fr] >= 1",
"W[fr]",
"W",
"fr",
"1",
"R[to] = 1",
"R[to]",
"R",
"to",
"1",
"W[to] += 1",
"W[to]",
"W",
"to",
"1",
"if R[fr] == 1 and W[fr] == 0:\n R[fr] = 0\n R[to] = 1\n\n ",
"R[fr] == 1 and W[fr] == 0",
"R[fr] == 1",
"R[fr]",
"R",
"fr",
"1",
"W[fr] == 0",
"W[fr]",
"W",
"fr",
"0",
"R[fr] = 0",
"R[fr]",
"R",
"fr",
"0",
"R[to] = 1",
"R[to]",
"R",
"to",
"1",
"if R[fr] == 0 and W[fr] >= 1:\n W[fr] -= 1\n W[to] += 1\n\n ",
"R[fr] == 0 and W[fr] >= 1",
"R[fr] == 0",
"R[fr]",
"R",
"fr",
"0",
"W[fr] >= 1",
"W[fr]",
"W",
"fr",
"1",
"W[fr] -= 1",
"W[fr]",
"W",
"fr",
"1",
"W[to] += 1",
"W[to]",
"W",
"to",
"1",
"if cnt[fr] == 0:\n W[fr] = 0\n R[fr] = 0",
"cnt[fr] == 0",
"cnt[fr]",
"cnt",
"fr",
"0",
"W[fr] = 0",
"W[fr]",
"W",
"fr",
"0",
"R[fr] = 0",
"R[fr]",
"R",
"fr",
"0",
"0 for r in R if r >= 1",
"for r in R if r >= 1",
"r",
"R",
"r >= 1",
"r",
"1",
"if r >= 1",
"0",
"ans = len([0 for r in R if r >= 1])",
"ans",
"len([0 for r in R if r >= 1])",
"len",
"[0 for r in R if r >= 1]",
"print(ans)",
"print",
"ans",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"R = [0] * (N + 1)",
"[0] * (N + 1)",
"R",
"cnt = [1] * (N + 1)",
"[1] * (N + 1)",
"cnt",
"ans = len([0 for r in R if r >= 1])",
"len([0 for r in R if r >= 1])",
"ans",
"to = map(int, input().split())",
"map(int, input().split())",
"to",
"fr, to = map(int, input().split())",
"map(int, input().split())",
"fr",
"W = [1] * (N + 1)",
"[1] * (N + 1)",
"W"
] | N, M = map(int, input().split())
W = [1] * (N + 1)
W[1] = 0
R = [0] * (N + 1)
R[1] = 1
cnt = [1] * (N + 1)
for _ in range(M):
fr, to = map(int, input().split())
cnt[fr] -= 1
cnt[to] += 1
if R[fr] == 1 and W[fr] >= 1:
R[to] = 1
W[to] += 1
if R[fr] == 1 and W[fr] == 0:
R[fr] = 0
R[to] = 1
if R[fr] == 0 and W[fr] >= 1:
W[fr] -= 1
W[to] += 1
if cnt[fr] == 0:
W[fr] = 0
R[fr] = 0
ans = len([0 for r in R if r >= 1])
print(ans)
|
[
7,
12,
13,
15,
13,
0,
13,
18,
18,
13,
13,
13,
41,
28,
13,
4,
18,
4,
18,
4,
13,
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,
18,
4,
13,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
18,
13,
2,
13,
17,
2,
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,
0,
18,
13,
2,
13,
17,
17,
41,
28,
13,
13,
13,
4,
17,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
7,
6
],
[
15,
14
],
[
6,
20
],
[
14,
26
],
[
29,
28
],
[
29,
30
],
[
33,
32
],
[
28,
36
],
[
39,
38
],
[
28,
42
],
[
47,
44
],
[
32,
45
],
[
50,
49
],
[
30,
52
],
[
56,
55
],
[
6,
61
],
[
55,
67
],
[
70,
69
],
[
70,
71
],
[
78,
73
],
[
32,
74
],
[
71,
76
],
[
32,
80
],
[
71,
82
],
[
32,
85
],
[
69,
87
],
[
95,
90
],
[
38,
91
],
[
71,
93
],
[
102,
97
],
[
38,
98
],
[
69,
100
],
[
38,
106
],
[
69,
108
],
[
117,
112
],
[
32,
113
],
[
69,
115
],
[
121,
120
],
[
32,
120
],
[
138,
135
]
] | [
"def main():\n import sys\n input = sys.stdin.readline\n N, M = [int(x) for x in input().strip().split()]\n f = [False] * N\n c = [1] * N\n f[0] = True\n \n for m in range(M):\n x, y = [int(x) for x in input().strip().split()]\n f[y-1] = f[y-1] or f[x-1]\n c[y-1] += 1\n c[x-1] -= 1\n if c[x-1] == 0:\n f[x-1] = False\n \n print(len([1 for b in f if b]))\n\nif __name__ == '__main__':\n main()",
"def main():\n import sys\n input = sys.stdin.readline\n N, M = [int(x) for x in input().strip().split()]\n f = [False] * N\n c = [1] * N\n f[0] = True\n \n for m in range(M):\n x, y = [int(x) for x in input().strip().split()]\n f[y-1] = f[y-1] or f[x-1]\n c[y-1] += 1\n c[x-1] -= 1\n if c[x-1] == 0:\n f[x-1] = False\n \n print(len([1 for b in f if b]))",
"main",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"int(x) for x in input().strip().split()",
"for x in input().strip().split()",
"x",
"input().strip().split()",
"().strip().split",
"().strip()",
"().strip",
"()",
"input",
"strip",
"split",
"for x in input().strip().split()",
"int(x)",
"int",
"x",
"N, M = [int(x) for x in input().strip().split()]",
"N",
"[int(x) for x in input().strip().split()]",
"M",
"f = [False] * N",
"f",
"[False] * N",
"[False]",
"False",
"N",
"c = [1] * N",
"c",
"[1] * N",
"[1]",
"1",
"N",
"f[0] = True",
"f[0]",
"f",
"0",
"True",
"for m in range(M):\n x, y = [int(x) for x in input().strip().split()]\n f[y-1] = f[y-1] or f[x-1]\n c[y-1] += 1\n c[x-1] -= 1\n if c[x-1] == 0:\n f[x-1] = False\n \n ",
"m",
"range(M)",
"range",
"M",
"int(x) for x in input().strip().split()",
"for x in input().strip().split()",
"x",
"input().strip().split()",
"().strip().split",
"().strip()",
"().strip",
"()",
"input",
"strip",
"split",
"for x in input().strip().split()",
"int(x)",
"int",
"x",
"x, y = [int(x) for x in input().strip().split()]",
"x",
"[int(x) for x in input().strip().split()]",
"y",
"f[y-1] = f[y-1] or f[x-1]",
"f[y-1]",
"f",
"y-1",
"y",
"1",
"f[y-1] or f[x-1]",
"f[y-1]",
"f",
"y-1",
"y",
"1",
"f[x-1]",
"f",
"x-1",
"x",
"1",
"c[y-1] += 1",
"c[y-1]",
"c",
"y-1",
"y",
"1",
"1",
"c[x-1] -= 1",
"c[x-1]",
"c",
"x-1",
"x",
"1",
"1",
"if c[x-1] == 0:\n f[x-1] = False\n \n ",
"c[x-1] == 0",
"c[x-1]",
"c",
"x-1",
"x",
"1",
"0",
"f[x-1] = False",
"f[x-1]",
"f",
"x-1",
"x",
"1",
"False",
"1 for b in f if b",
"for b in f if b",
"b",
"f",
"b",
"if b",
"1",
"print(len([1 for b in f if b]))",
"print",
"len([1 for b in f if b])",
"len",
"[1 for b in f if b]",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n import sys\n input = sys.stdin.readline\n N, M = [int(x) for x in input().strip().split()]\n f = [False] * N\n c = [1] * N\n f[0] = True\n \n for m in range(M):\n x, y = [int(x) for x in input().strip().split()]\n f[y-1] = f[y-1] or f[x-1]\n c[y-1] += 1\n c[x-1] -= 1\n if c[x-1] == 0:\n f[x-1] = False\n \n print(len([1 for b in f if b]))",
"def main():\n import sys\n input = sys.stdin.readline\n N, M = [int(x) for x in input().strip().split()]\n f = [False] * N\n c = [1] * N\n f[0] = True\n \n for m in range(M):\n x, y = [int(x) for x in input().strip().split()]\n f[y-1] = f[y-1] or f[x-1]\n c[y-1] += 1\n c[x-1] -= 1\n if c[x-1] == 0:\n f[x-1] = False\n \n print(len([1 for b in f if b]))",
"main"
] | def main():
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
f = [False] * N
c = [1] * N
f[0] = True
for m in range(M):
x, y = [int(x) for x in input().strip().split()]
f[y-1] = f[y-1] or f[x-1]
c[y-1] += 1
c[x-1] -= 1
if c[x-1] == 0:
f[x-1] = False
print(len([1 for b in f if b]))
if __name__ == '__main__':
main() |
[
7,
12,
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,
23,
13,
23,
13,
14,
2,
13,
17,
41,
28,
13,
4,
18,
4,
13,
13,
17,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
17,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
4,
13,
13,
13,
4,
13,
4,
13,
13,
10,
12,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13
] | [
[
34,
6
],
[
11,
8
],
[
36,
10
],
[
34,
16
],
[
22,
19
],
[
34,
21
],
[
27,
24
],
[
34,
26
],
[
32,
29
],
[
36,
31
],
[
34,
34
],
[
36,
36
],
[
44,
43
],
[
43,
53
],
[
141,
55
],
[
141,
57
],
[
61,
60
],
[
142,
63
],
[
144,
67
],
[
72,
71
],
[
142,
75
],
[
147,
80
],
[
87,
86
],
[
136,
89
],
[
93,
92
],
[
92,
102
],
[
150,
104
],
[
150,
106
],
[
132,
108
],
[
130,
110
],
[
133,
110
],
[
138,
112
],
[
151,
114
],
[
139,
114
],
[
127,
117
],
[
133,
118
],
[
130,
118
],
[
139,
119
],
[
151,
119
],
[
148,
124
],
[
150,
130
],
[
132,
133
],
[
141,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
]
] | [
"def operate(x, y):\n if is_red[x]:\n is_red[y] = True\n if num_ball[x] == 1:\n is_red[x] = False\n num_ball[x] -= 1\n num_ball[y] += 1\n\n\nif __name__ == \"__main__\":\n\n N, M = [int(x) for x in input().split(\" \")]\n num_ball = [1 for _ in range(N)]\n is_red = [True] + [False for _ in range(N - 1)]\n\n for _ in range(M):\n x, y = [int(x) for x in input().split(\" \")]\n x, y = x - 1, y - 1\n operate(x, y)\n print(sum(is_red))",
"def operate(x, y):\n if is_red[x]:\n is_red[y] = True\n if num_ball[x] == 1:\n is_red[x] = False\n num_ball[x] -= 1\n num_ball[y] += 1",
"operate",
"if is_red[x]:\n is_red[y] = True\n if num_ball[x] == 1:\n is_red[x] = False\n ",
"is_red[x]",
"is_red",
"x",
"is_red[y] = True",
"is_red[y]",
"is_red",
"y",
"True",
"if num_ball[x] == 1:\n is_red[x] = False\n ",
"num_ball[x] == 1",
"num_ball[x]",
"num_ball",
"x",
"1",
"is_red[x] = False",
"is_red[x]",
"is_red",
"x",
"False",
"num_ball[x] -= 1",
"num_ball[x]",
"num_ball",
"x",
"1",
"num_ball[y] += 1",
"num_ball[y]",
"num_ball",
"y",
"1",
"x",
"x",
"y",
"y",
"if __name__ == \"__main__\":\n\n N, M = [int(x) for x in input().split(\" \")]\n num_ball = [1 for _ in range(N)]\n is_red = [True] + [False for _ in range(N - 1)]\n\n for _ in range(M):\n x, y = [int(x) for x in input().split(\" \")]\n x, y = x - 1, y - 1\n operate(x, y)\n print(sum(is_red))",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"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",
"1 for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"1",
"num_ball = [1 for _ in range(N)]",
"num_ball",
"[1 for _ in range(N)]",
"False for _ in range(N - 1)",
"for _ in range(N - 1)",
"_",
"range(N - 1)",
"range",
"N - 1",
"N",
"1",
"for _ in range(N - 1)",
"False",
"is_red = [True] + [False for _ in range(N - 1)]",
"is_red",
"[True] + [False for _ in range(N - 1)]",
"[True]",
"True",
"[False for _ in range(N - 1)]",
"for _ in range(M):\n x, y = [int(x) for x in input().split(\" \")]\n x, y = x - 1, y - 1\n operate(x, y)\n ",
"_",
"range(M)",
"range",
"M",
"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",
"x, y = [int(x) for x in input().split(\" \")]",
"x",
"[int(x) for x in input().split(\" \")]",
"y",
"x, y = x - 1, y - 1",
"x",
"x - 1",
"x",
"1",
"y",
"y - 1",
"y",
"1",
"operate(x, y)",
"operate",
"x",
"y",
"print(sum(is_red))",
"print",
"sum(is_red)",
"sum",
"is_red",
"def operate(x, y):\n if is_red[x]:\n is_red[y] = True\n if num_ball[x] == 1:\n is_red[x] = False\n num_ball[x] -= 1\n num_ball[y] += 1",
"def operate(x, y):\n if is_red[x]:\n is_red[y] = True\n if num_ball[x] == 1:\n is_red[x] = False\n num_ball[x] -= 1\n num_ball[y] += 1",
"operate",
"x, y = [int(x) for x in input().split(\" \")]",
"[int(x) for x in input().split(\" \")]",
"x",
"x, y = x - 1, y - 1",
"x - 1",
"x",
"M = [int(x) for x in input().split(\" \")]",
"[int(x) for x in input().split(\" \")]",
"M",
"y = x - 1, y - 1",
"y - 1",
"y",
"N, M = [int(x) for x in input().split(\" \")]",
"[int(x) for x in input().split(\" \")]",
"N",
"num_ball = [1 for _ in range(N)]",
"[1 for _ in range(N)]",
"num_ball",
"is_red = [True] + [False for _ in range(N - 1)]",
"[True] + [False for _ in range(N - 1)]",
"is_red",
"y = [int(x) for x in input().split(\" \")]",
"[int(x) for x in input().split(\" \")]",
"y"
] | def operate(x, y):
if is_red[x]:
is_red[y] = True
if num_ball[x] == 1:
is_red[x] = False
num_ball[x] -= 1
num_ball[y] += 1
if __name__ == "__main__":
N, M = [int(x) for x in input().split(" ")]
num_ball = [1 for _ in range(N)]
is_red = [True] + [False for _ in range(N - 1)]
for _ in range(M):
x, y = [int(x) for x in input().split(" ")]
x, y = x - 1, y - 1
operate(x, y)
print(sum(is_red)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
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,
18,
13,
39,
17,
18,
13,
39,
17,
17,
0,
13,
2,
13,
17,
13,
2,
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,
2,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] | [
[
109,
2
],
[
109,
15
],
[
109,
16
],
[
100,
19
],
[
107,
23
],
[
94,
25
],
[
107,
29
],
[
34,
31
],
[
95,
32
],
[
103,
50
],
[
104,
52
],
[
97,
54
],
[
98,
56
],
[
62,
59
],
[
101,
60
],
[
104,
61
],
[
67,
64
],
[
101,
65
],
[
98,
66
],
[
95,
70
],
[
104,
71
],
[
76,
73
],
[
95,
74
],
[
98,
75
],
[
59,
79
],
[
101,
80
],
[
104,
81
],
[
87,
84
],
[
95,
85
],
[
104,
86
],
[
95,
92
],
[
94,
95
],
[
97,
98
],
[
100,
101
],
[
103,
104
],
[
109,
107
],
[
109,
110
]
] | [
"n, m, *XY = map(int, open(0).read().split())\nA = [1] * n\nB = [0] * n\nB[0] = 1\nfor x, y in zip(XY[::2], XY[1::2]):\n x, y = x-1, y-1\n A[x] -= 1\n A[y] += 1\n if B[x]:\n B[y] = 1\n if A[x] == 0:\n B[x] = 0\nprint(sum(B))",
"n, m, *XY = 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",
"m",
"*XY",
"XY",
"A = [1] * n",
"A",
"[1] * n",
"[1]",
"1",
"n",
"B = [0] * n",
"B",
"[0] * n",
"[0]",
"0",
"n",
"B[0] = 1",
"B[0]",
"B",
"0",
"1",
"for x, y in zip(XY[::2], XY[1::2]):\n x, y = x-1, y-1\n A[x] -= 1\n A[y] += 1\n if B[x]:\n B[y] = 1\n if A[x] == 0:\n B[x] = 0",
"x",
"y",
"zip(XY[::2], XY[1::2])",
"zip",
"XY[::2]",
"XY",
"::2",
"2",
"XY[1::2]",
"XY",
"1::2",
"1",
"2",
"x, y = x-1, y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"A[x] -= 1",
"A[x]",
"A",
"x",
"1",
"A[y] += 1",
"A[y]",
"A",
"y",
"1",
"if B[x]:\n B[y] = 1\n ",
"B[x]",
"B",
"x",
"B[y] = 1",
"B[y]",
"B",
"y",
"1",
"if A[x] == 0:\n B[x] = 0",
"A[x] == 0",
"A[x]",
"A",
"x",
"0",
"B[x] = 0",
"B[x]",
"B",
"x",
"0",
"print(sum(B))",
"print",
"sum(B)",
"sum",
"B",
"B = [0] * n",
"[0] * n",
"B",
"y = x-1, y-1",
"y-1",
"y",
"A = [1] * n",
"[1] * n",
"A",
"x, y = x-1, y-1",
"x-1",
"x",
"n, m, *XY = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"n",
"m, *XY = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"m"
] | n, m, *XY = map(int, open(0).read().split())
A = [1] * n
B = [0] * n
B[0] = 1
for x, y in zip(XY[::2], XY[1::2]):
x, y = x-1, y-1
A[x] -= 1
A[y] += 1
if B[x]:
B[y] = 1
if A[x] == 0:
B[x] = 0
print(sum(B)) |
[
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,
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,
13,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13
] | [
[
115,
2
],
[
115,
11
],
[
15,
14
],
[
116,
17
],
[
112,
30
],
[
106,
33
],
[
104,
37
],
[
109,
39
],
[
104,
43
],
[
48,
45
],
[
110,
46
],
[
59,
54
],
[
107,
55
],
[
66,
61
],
[
107,
62
],
[
110,
70
],
[
81,
76
],
[
110,
77
],
[
107,
85
],
[
96,
91
],
[
110,
92
],
[
110,
101
],
[
115,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
115,
116
]
] | [
"N,M = map(int,input().split())\nxy = [list(map(int,input().split())) for _ in range(M)]\n\nball_count = [1]*N\nvisited = [0]*N\nvisited[0] = 1\n\nfor x,y in xy:\n ball_count[x-1] -= 1\n ball_count[y-1] += 1\n if visited[x-1] == 1:\n visited[y-1] = 1\n if ball_count[x-1] == 0:\n visited[x-1] = 0\n\nprint(sum(visited))",
"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)]",
"ball_count = [1]*N",
"ball_count",
"[1]*N",
"[1]",
"1",
"N",
"visited = [0]*N",
"visited",
"[0]*N",
"[0]",
"0",
"N",
"visited[0] = 1",
"visited[0]",
"visited",
"0",
"1",
"for x,y in xy:\n ball_count[x-1] -= 1\n ball_count[y-1] += 1\n if visited[x-1] == 1:\n visited[y-1] = 1\n if ball_count[x-1] == 0:\n visited[x-1] = 0",
"x",
"y",
"xy",
"ball_count[x-1] -= 1",
"ball_count[x-1]",
"ball_count",
"x-1",
"x",
"1",
"1",
"ball_count[y-1] += 1",
"ball_count[y-1]",
"ball_count",
"y-1",
"y",
"1",
"1",
"if visited[x-1] == 1:\n visited[y-1] = 1\n ",
"visited[x-1] == 1",
"visited[x-1]",
"visited",
"x-1",
"x",
"1",
"1",
"visited[y-1] = 1",
"visited[y-1]",
"visited",
"y-1",
"y",
"1",
"1",
"if ball_count[x-1] == 0:\n visited[x-1] = 0",
"ball_count[x-1] == 0",
"ball_count[x-1]",
"ball_count",
"x-1",
"x",
"1",
"0",
"visited[x-1] = 0",
"visited[x-1]",
"visited",
"x-1",
"x",
"1",
"0",
"print(sum(visited))",
"print",
"sum(visited)",
"sum",
"visited",
"N,M = map(int,input().split())",
"map(int,input().split())",
"N",
"ball_count = [1]*N",
"[1]*N",
"ball_count",
"visited = [0]*N",
"[0]*N",
"visited",
"xy = [list(map(int,input().split())) for _ in range(M)]",
"[list(map(int,input().split())) for _ in range(M)]",
"xy",
"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)]
ball_count = [1]*N
visited = [0]*N
visited[0] = 1
for x,y in xy:
ball_count[x-1] -= 1
ball_count[y-1] += 1
if visited[x-1] == 1:
visited[y-1] = 1
if ball_count[x-1] == 0:
visited[x-1] = 0
print(sum(visited)) |
[
7,
15,
13,
13,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
15,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
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,
13,
13,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
26,
25
],
[
167,
31
],
[
35,
35
],
[
142,
44
],
[
148,
49
],
[
160,
57
],
[
167,
59
],
[
160,
60
],
[
64,
63
],
[
161,
66
],
[
176,
69
],
[
151,
71
],
[
154,
74
],
[
158,
78
],
[
83,
80
],
[
155,
81
],
[
163,
85
],
[
158,
89
],
[
155,
96
],
[
106,
101
],
[
155,
102
],
[
113,
108
],
[
164,
109
],
[
120,
115
],
[
164,
116
],
[
164,
124
],
[
135,
130
],
[
155,
131
],
[
155,
140
],
[
142,
143
],
[
148,
149
],
[
151,
152
],
[
154,
155
],
[
160,
158
],
[
160,
161
],
[
163,
164
]
] | [
"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom decimal import Decimal\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10**9 + 7\nfrom decimal import *\n\nN, M = MAP()\nxy = [LIST() for _ in range(M)]\n\ncheck = [0]*N\ncheck[0] = 1\ncnt = [1]*N\n\nfor x, y in xy:\n\tif check[x-1]:\n\t\tcheck[y-1] = 1\n\tcnt[x-1] -= 1\n\tcnt[y-1] += 1\n\tif cnt[x-1] == 0:\n\t\tcheck[x-1] = 0\n\nprint(sum(check))",
"import sys, re",
"sys",
"re",
"from collections import deque, defaultdict, Counter",
"from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees",
"from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby",
"from operator import itemgetter, mul",
"from copy import deepcopy",
"from string import ascii_lowercase, ascii_uppercase, digits",
"from bisect import bisect, bisect_left, insort, insort_left",
"from fractions import gcd",
"from heapq import heappush, heappop",
"from functools import reduce",
"from decimal import Decimal",
"def input(): return sys.stdin.readline().strip()",
"input",
"def INT(): return int(input())",
"INT",
"def MAP(): return map(int, input().split())",
"MAP",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"MAP() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"MAP()",
"MAP",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"n",
"n",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"mod = 10**9 + 7",
"mod",
"10**9 + 7",
"10**9",
"10",
"9",
"7",
"from decimal import *",
"N, M = MAP()",
"N",
"MAP()",
"MAP",
"M",
"LIST() for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"LIST()",
"LIST",
"xy = [LIST() for _ in range(M)]",
"xy",
"[LIST() for _ in range(M)]",
"check = [0]*N",
"check",
"[0]*N",
"[0]",
"0",
"N",
"check[0] = 1",
"check[0]",
"check",
"0",
"1",
"cnt = [1]*N",
"cnt",
"[1]*N",
"[1]",
"1",
"N",
"for x, y in xy:\n\tif check[x-1]:\n\t\tcheck[y-1] = 1\n\tcnt[x-1] -= 1\n\tcnt[y-1] += 1\n\tif cnt[x-1] == 0:\n\t\tcheck[x-1] = 0",
"x",
"y",
"xy",
"if check[x-1]:\n\t\tcheck[y-1] = 1\n\t",
"check[x-1]",
"check",
"x-1",
"x",
"1",
"check[y-1] = 1",
"check[y-1]",
"check",
"y-1",
"y",
"1",
"1",
"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\t\tcheck[x-1] = 0",
"cnt[x-1] == 0",
"cnt[x-1]",
"cnt",
"x-1",
"x",
"1",
"0",
"check[x-1] = 0",
"check[x-1]",
"check",
"x-1",
"x",
"1",
"0",
"print(sum(check))",
"print",
"sum(check)",
"sum",
"check",
"INF = float('inf')",
"float('inf')",
"INF",
"def INT(): return int(input())",
"def INT(): return int(input())",
"INT",
"mod = 10**9 + 7",
"10**9 + 7",
"mod",
"xy = [LIST() for _ in range(M)]",
"[LIST() for _ in range(M)]",
"xy",
"check = [0]*N",
"[0]*N",
"check",
"N, M = MAP()",
"MAP()",
"N",
"M = MAP()",
"MAP()",
"M",
"cnt = [1]*N",
"[1]*N",
"cnt",
"def MAP(): return map(int, input().split())",
"def MAP(): return map(int, input().split())",
"MAP",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"def LIST(): return list(map(int, input().split()))",
"def LIST(): return list(map(int, input().split()))",
"LIST"
] | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
N, M = MAP()
xy = [LIST() for _ in range(M)]
check = [0]*N
check[0] = 1
cnt = [1]*N
for x, y in xy:
if check[x-1]:
check[y-1] = 1
cnt[x-1] -= 1
cnt[y-1] += 1
if cnt[x-1] == 0:
check[x-1] = 0
print(sum(check))
|
[
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,
0,
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,
18,
13,
13,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13
] | [
[
104,
2
],
[
104,
11
],
[
15,
14
],
[
105,
18
],
[
107,
23
],
[
28,
27
],
[
105,
31
],
[
95,
36
],
[
42,
39
],
[
96,
40
],
[
45,
44
],
[
102,
47
],
[
110,
49
],
[
110,
58
],
[
63,
60
],
[
96,
61
],
[
99,
62
],
[
83,
63
],
[
96,
64
],
[
111,
65
],
[
70,
67
],
[
108,
68
],
[
111,
69
],
[
75,
72
],
[
108,
73
],
[
99,
74
],
[
67,
78
],
[
108,
79
],
[
111,
80
],
[
86,
83
],
[
96,
84
],
[
111,
85
],
[
96,
91
],
[
95,
96
],
[
110,
99
],
[
104,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"n, m = map(int,input().split())\nnum = [1 for i in range(n+1)]\nred = [False for i in range(n+1)]\nred[1] = True\nfor i in range(m):\n x, y = map(int,input().split())\n red[y] |= red[x]\n num[x] -= 1\n num[y] += 1\n if num[x] == 0:\n red[x] = False\nprint(red.count(True))",
"n, m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"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)",
"1",
"num = [1 for i in range(n+1)]",
"num",
"[1 for i in range(n+1)]",
"False 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)",
"False",
"red = [False for i in range(n+1)]",
"red",
"[False for i in range(n+1)]",
"red[1] = True",
"red[1]",
"red",
"1",
"True",
"for i in range(m):\n x, y = map(int,input().split())\n red[y] |= red[x]\n num[x] -= 1\n num[y] += 1\n if num[x] == 0:\n red[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",
"red[y] |= red[x]",
"red[y]",
"red",
"y",
"red[x]",
"red",
"x",
"num[x] -= 1",
"num[x]",
"num",
"x",
"1",
"num[y] += 1",
"num[y]",
"num",
"y",
"1",
"if num[x] == 0:\n red[x] = False",
"num[x] == 0",
"num[x]",
"num",
"x",
"0",
"red[x] = False",
"red[x]",
"red",
"x",
"False",
"print(red.count(True))",
"print",
"red.count(True)",
"red.count",
"red",
"count",
"True",
"red = [False for i in range(n+1)]",
"[False for i in range(n+1)]",
"red",
"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())",
"map(int,input().split())",
"n",
"num = [1 for i in range(n+1)]",
"[1 for i in range(n+1)]",
"num",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x"
] | n, m = map(int,input().split())
num = [1 for i in range(n+1)]
red = [False for i in range(n+1)]
red[1] = True
for i in range(m):
x, y = map(int,input().split())
red[y] |= red[x]
num[x] -= 1
num[y] += 1
if num[x] == 0:
red[x] = False
print(red.count(True)) |
[
7,
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,
2,
13,
17,
13,
2,
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,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
4,
19
],
[
24,
21
],
[
15,
22
],
[
27,
26
],
[
4,
30
],
[
33,
32
],
[
13,
35
],
[
38,
37
],
[
38,
46
],
[
49,
48
],
[
37,
50
],
[
48,
50
],
[
53,
52
],
[
46,
54
],
[
52,
54
],
[
60,
57
],
[
26,
58
],
[
48,
59
],
[
37,
59
],
[
65,
62
],
[
26,
63
],
[
52,
64
],
[
46,
64
],
[
15,
68
],
[
48,
69
],
[
37,
69
],
[
74,
71
],
[
15,
72
],
[
52,
73
],
[
46,
73
],
[
57,
77
],
[
26,
78
],
[
48,
79
],
[
37,
79
],
[
85,
82
],
[
15,
83
],
[
48,
84
],
[
37,
84
],
[
15,
90
],
[
99,
96
]
] | [
"def solve():\n N, M = map(int, input().split())\n contains_redball = [False] * N\n contains_redball[0] = True\n balls_cnt = [1] * N\n for _ in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n balls_cnt[x] -= 1\n balls_cnt[y] += 1\n if contains_redball[x]:\n contains_redball[y] = True\n if balls_cnt[x] == 0:\n contains_redball[x] = False\n print(sum(contains_redball))\n\nif __name__ == '__main__':\n solve()",
"def solve():\n N, M = map(int, input().split())\n contains_redball = [False] * N\n contains_redball[0] = True\n balls_cnt = [1] * N\n for _ in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n balls_cnt[x] -= 1\n balls_cnt[y] += 1\n if contains_redball[x]:\n contains_redball[y] = True\n if balls_cnt[x] == 0:\n contains_redball[x] = False\n print(sum(contains_redball))",
"solve",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"contains_redball = [False] * N",
"contains_redball",
"[False] * N",
"[False]",
"False",
"N",
"contains_redball[0] = True",
"contains_redball[0]",
"contains_redball",
"0",
"True",
"balls_cnt = [1] * N",
"balls_cnt",
"[1] * N",
"[1]",
"1",
"N",
"for _ in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n balls_cnt[x] -= 1\n balls_cnt[y] += 1\n if contains_redball[x]:\n contains_redball[y] = True\n if balls_cnt[x] == 0:\n contains_redball[x] = False\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, y = x - 1, y - 1",
"x",
"x - 1",
"x",
"1",
"y",
"y - 1",
"y",
"1",
"balls_cnt[x] -= 1",
"balls_cnt[x]",
"balls_cnt",
"x",
"1",
"balls_cnt[y] += 1",
"balls_cnt[y]",
"balls_cnt",
"y",
"1",
"if contains_redball[x]:\n contains_redball[y] = True\n ",
"contains_redball[x]",
"contains_redball",
"x",
"contains_redball[y] = True",
"contains_redball[y]",
"contains_redball",
"y",
"True",
"if balls_cnt[x] == 0:\n contains_redball[x] = False\n ",
"balls_cnt[x] == 0",
"balls_cnt[x]",
"balls_cnt",
"x",
"0",
"contains_redball[x] = False",
"contains_redball[x]",
"contains_redball",
"x",
"False",
"print(sum(contains_redball))",
"print",
"sum(contains_redball)",
"sum",
"contains_redball",
"if __name__ == '__main__':\n solve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"solve()",
"solve",
"def solve():\n N, M = map(int, input().split())\n contains_redball = [False] * N\n contains_redball[0] = True\n balls_cnt = [1] * N\n for _ in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n balls_cnt[x] -= 1\n balls_cnt[y] += 1\n if contains_redball[x]:\n contains_redball[y] = True\n if balls_cnt[x] == 0:\n contains_redball[x] = False\n print(sum(contains_redball))",
"def solve():\n N, M = map(int, input().split())\n contains_redball = [False] * N\n contains_redball[0] = True\n balls_cnt = [1] * N\n for _ in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n balls_cnt[x] -= 1\n balls_cnt[y] += 1\n if contains_redball[x]:\n contains_redball[y] = True\n if balls_cnt[x] == 0:\n contains_redball[x] = False\n print(sum(contains_redball))",
"solve"
] | def solve():
N, M = map(int, input().split())
contains_redball = [False] * N
contains_redball[0] = True
balls_cnt = [1] * N
for _ in range(M):
x, y = map(int, input().split())
x, y = x - 1, y - 1
balls_cnt[x] -= 1
balls_cnt[y] += 1
if contains_redball[x]:
contains_redball[y] = True
if balls_cnt[x] == 0:
contains_redball[x] = False
print(sum(contains_redball))
if __name__ == '__main__':
solve() |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
8,
2,
13,
17,
17,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
14,
18,
13,
2,
18,
13,
17,
17,
14,
2,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
139,
2
],
[
139,
11
],
[
15,
14
],
[
131,
17
],
[
14,
21
],
[
127,
26
],
[
31,
30
],
[
131,
33
],
[
133,
37
],
[
41,
40
],
[
140,
43
],
[
136,
45
],
[
128,
58
],
[
137,
61
],
[
134,
67
],
[
137,
70
],
[
82,
75
],
[
128,
76
],
[
137,
79
],
[
91,
84
],
[
128,
85
],
[
137,
88
],
[
100,
93
],
[
128,
94
],
[
137,
97
],
[
109,
102
],
[
134,
103
],
[
137,
106
],
[
118,
111
],
[
134,
112
],
[
137,
115
],
[
128,
123
],
[
127,
128
],
[
139,
131
],
[
133,
134
],
[
136,
137
],
[
139,
140
]
] | [
"n, m = map(int, input().split())\nl = [True if i == 0 else False for i in range(n)]\nk = [1 for i in range(n)]\nfor i in range(m):\n xy = list(map(int, input().split()))\n if l[xy[0]-1]:\n if k[xy[0]-1] > 1:\n l[xy[1]-1] = True\n else:\n l[xy[1]-1] = True\n l[xy[0]-1] = False\n k[xy[0]-1] -= 1\n k[xy[1]-1] += 1\nprint(l.count(True))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"True if i == 0 else False for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"True if i == 0 else False",
"i == 0",
"i",
"0",
"True",
"False",
"l = [True if i == 0 else False for i in range(n)]",
"l",
"[True if i == 0 else False 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",
"k = [1 for i in range(n)]",
"k",
"[1 for i in range(n)]",
"for i in range(m):\n xy = list(map(int, input().split()))\n if l[xy[0]-1]:\n if k[xy[0]-1] > 1:\n l[xy[1]-1] = True\n else:\n l[xy[1]-1] = True\n l[xy[0]-1] = False\n k[xy[0]-1] -= 1\n k[xy[1]-1] += 1",
"i",
"range(m)",
"range",
"m",
"xy = list(map(int, input().split()))",
"xy",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"if l[xy[0]-1]:\n if k[xy[0]-1] > 1:\n l[xy[1]-1] = True\n else:\n l[xy[1]-1] = True\n l[xy[0]-1] = False\n ",
"l[xy[0]-1]",
"l",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"if k[xy[0]-1] > 1:\n l[xy[1]-1] = True\n else:\n l[xy[1]-1] = True\n l[xy[0]-1] = False\n ",
"k[xy[0]-1] > 1",
"k[xy[0]-1]",
"k",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"1",
"l[xy[1]-1] = True",
"l[xy[1]-1]",
"l",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"True",
"l[xy[1]-1] = True",
"l[xy[1]-1]",
"l",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"True",
"l[xy[0]-1] = False",
"l[xy[0]-1]",
"l",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"False",
"k[xy[0]-1] -= 1",
"k[xy[0]-1]",
"k",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"1",
"k[xy[1]-1] += 1",
"k[xy[1]-1]",
"k",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"1",
"print(l.count(True))",
"print",
"l.count(True)",
"l.count",
"l",
"count",
"True",
"l = [True if i == 0 else False for i in range(n)]",
"[True if i == 0 else False for i in range(n)]",
"l",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"k = [1 for i in range(n)]",
"[1 for i in range(n)]",
"k",
"xy = list(map(int, input().split()))",
"list(map(int, input().split()))",
"xy",
"m = map(int, input().split())",
"map(int, input().split())",
"m"
] | n, m = map(int, input().split())
l = [True if i == 0 else False for i in range(n)]
k = [1 for i in range(n)]
for i in range(m):
xy = list(map(int, input().split()))
if l[xy[0]-1]:
if k[xy[0]-1] > 1:
l[xy[1]-1] = True
else:
l[xy[1]-1] = True
l[xy[0]-1] = False
k[xy[0]-1] -= 1
k[xy[1]-1] += 1
print(l.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,
14,
18,
13,
2,
13,
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,
18,
13,
2,
13,
17,
17,
9,
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,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
145,
2
],
[
145,
11
],
[
133,
13
],
[
146,
17
],
[
22,
19
],
[
134,
20
],
[
139,
24
],
[
146,
28
],
[
31,
30
],
[
143,
33
],
[
148,
35
],
[
148,
44
],
[
134,
47
],
[
137,
49
],
[
140,
54
],
[
137,
56
],
[
65,
60
],
[
134,
61
],
[
149,
63
],
[
140,
69
],
[
137,
71
],
[
80,
75
],
[
134,
76
],
[
149,
78
],
[
87,
82
],
[
134,
83
],
[
137,
85
],
[
95,
90
],
[
140,
91
],
[
137,
93
],
[
102,
97
],
[
140,
98
],
[
149,
100
],
[
140,
106
],
[
137,
108
],
[
117,
112
],
[
140,
113
],
[
137,
115
],
[
124,
119
],
[
140,
120
],
[
149,
122
],
[
134,
129
],
[
133,
134
],
[
148,
137
],
[
139,
140
],
[
145,
143
],
[
145,
146
],
[
148,
149
]
] | [
"# agc002_b.py\nN, M = map(int,input().split())\nflg = [False]*N\nflg[0] = True\ncnt = [1]*N\nfor i in range(M):\n x, y = map(int,input().split())\n if flg[x-1]:\n if cnt[x-1]>1:\n flg[y-1] = True\n elif cnt[x-1]==1:\n flg[y-1] = True\n flg[x-1] = False\n else:\n continue\n cnt[x-1]-=1\n cnt[y-1]+=1\n else:\n if cnt[x-1]>0:\n cnt[x-1]-=1\n cnt[y-1]+=1\n\n\nprint(flg.count(True))",
"N, M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"flg = [False]*N",
"flg",
"[False]*N",
"[False]",
"False",
"N",
"flg[0] = True",
"flg[0]",
"flg",
"0",
"True",
"cnt = [1]*N",
"cnt",
"[1]*N",
"[1]",
"1",
"N",
"for i in range(M):\n x, y = map(int,input().split())\n if flg[x-1]:\n if cnt[x-1]>1:\n flg[y-1] = True\n elif cnt[x-1]==1:\n flg[y-1] = True\n flg[x-1] = False\n else:\n continue\n cnt[x-1]-=1\n cnt[y-1]+=1\n else:\n if cnt[x-1]>0:\n cnt[x-1]-=1\n cnt[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",
"if flg[x-1]:\n if cnt[x-1]>1:\n flg[y-1] = True\n elif cnt[x-1]==1:\n flg[y-1] = True\n flg[x-1] = False\n else:\n continue\n cnt[x-1]-=1\n cnt[y-1]+=1\n else:\n if cnt[x-1]>0:\n cnt[x-1]-=1\n cnt[y-1]+=1",
"flg[x-1]",
"flg",
"x-1",
"x",
"1",
"if cnt[x-1]>1:\n flg[y-1] = True\n elif cnt[x-1]==1:\n flg[y-1] = True\n flg[x-1] = False\n else:\n continue\n ",
"cnt[x-1]>1",
"cnt[x-1]",
"cnt",
"x-1",
"x",
"1",
"1",
"flg[y-1] = True",
"flg[y-1]",
"flg",
"y-1",
"y",
"1",
"True",
"elif cnt[x-1]==1:\n flg[y-1] = True\n flg[x-1] = False\n ",
"cnt[x-1]==1",
"cnt[x-1]",
"cnt",
"x-1",
"x",
"1",
"1",
"flg[y-1] = True",
"flg[y-1]",
"flg",
"y-1",
"y",
"1",
"True",
"flg[x-1] = False",
"flg[x-1]",
"flg",
"x-1",
"x",
"1",
"False",
"continue",
"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 cnt[x-1]-=1\n cnt[y-1]+=1",
"cnt[x-1]>0",
"cnt[x-1]",
"cnt",
"x-1",
"x",
"1",
"0",
"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",
"print(flg.count(True))",
"print",
"flg.count(True)",
"flg.count",
"flg",
"count",
"True",
"flg = [False]*N",
"[False]*N",
"flg",
"x, y = map(int,input().split())",
"map(int,input().split())",
"x",
"cnt = [1]*N",
"[1]*N",
"cnt",
"M = map(int,input().split())",
"map(int,input().split())",
"M",
"N, M = map(int,input().split())",
"map(int,input().split())",
"N",
"y = map(int,input().split())",
"map(int,input().split())",
"y"
] | # agc002_b.py
N, M = map(int,input().split())
flg = [False]*N
flg[0] = True
cnt = [1]*N
for i in range(M):
x, y = map(int,input().split())
if flg[x-1]:
if cnt[x-1]>1:
flg[y-1] = True
elif cnt[x-1]==1:
flg[y-1] = True
flg[x-1] = False
else:
continue
cnt[x-1]-=1
cnt[y-1]+=1
else:
if cnt[x-1]>0:
cnt[x-1]-=1
cnt[y-1]+=1
print(flg.count(True)) |
[
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,
2,
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,
2,
13,
17,
14,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
119,
2
],
[
119,
11
],
[
116,
13
],
[
120,
18
],
[
104,
21
],
[
120,
26
],
[
32,
29
],
[
105,
30
],
[
35,
34
],
[
114,
37
],
[
125,
39
],
[
125,
48
],
[
53,
50
],
[
117,
51
],
[
126,
52
],
[
58,
55
],
[
117,
56
],
[
123,
57
],
[
77,
61
],
[
105,
62
],
[
126,
63
],
[
69,
66
],
[
105,
67
],
[
123,
68
],
[
50,
72
],
[
117,
73
],
[
126,
74
],
[
80,
77
],
[
105,
78
],
[
126,
79
],
[
110,
82
],
[
86,
85
],
[
120,
89
],
[
105,
94
],
[
85,
95
],
[
107,
98
],
[
108,
102
],
[
111,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
119,
114
],
[
116,
117
],
[
119,
120
],
[
125,
123
],
[
125,
126
]
] | [
"n,m=map(int,input().split())\nquant=[1]*(n+1)\nprob=[0]*(n+1)\nprob[1]=1\nfor i in range(m):\n x,y=map(int,input().split())\n quant[x]-=1\n quant[y]+=1\n if prob[x]>0:\n prob[y]+=1\n if quant[x]==0:\n prob[x]=0\n\ncnt=0\nfor i in range(n+1):\n if prob[i]>0:\n cnt+=1\nprint(cnt)\n ",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"quant=[1]*(n+1)",
"quant",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"prob=[0]*(n+1)",
"prob",
"[0]*(n+1)",
"[0]",
"0",
"n+1",
"n",
"1",
"prob[1]=1",
"prob[1]",
"prob",
"1",
"1",
"for i in range(m):\n x,y=map(int,input().split())\n quant[x]-=1\n quant[y]+=1\n if prob[x]>0:\n prob[y]+=1\n if quant[x]==0:\n prob[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",
"quant[x]-=1",
"quant[x]",
"quant",
"x",
"1",
"quant[y]+=1",
"quant[y]",
"quant",
"y",
"1",
"if prob[x]>0:\n prob[y]+=1\n ",
"prob[x]>0",
"prob[x]",
"prob",
"x",
"0",
"prob[y]+=1",
"prob[y]",
"prob",
"y",
"1",
"if quant[x]==0:\n prob[x]=0",
"quant[x]==0",
"quant[x]",
"quant",
"x",
"0",
"prob[x]=0",
"prob[x]",
"prob",
"x",
"0",
"cnt=0",
"cnt",
"0",
"for i in range(n+1):\n if prob[i]>0:\n cnt+=1",
"i",
"range(n+1)",
"range",
"n+1",
"n",
"1",
"if prob[i]>0:\n cnt+=1",
"prob[i]>0",
"prob[i]",
"prob",
"i",
"0",
"cnt+=1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"prob=[0]*(n+1)",
"[0]*(n+1)",
"prob",
"cnt+=1",
"1",
"cnt",
"cnt=0",
"0",
"cnt",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"quant=[1]*(n+1)",
"[1]*(n+1)",
"quant",
"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"
] | n,m=map(int,input().split())
quant=[1]*(n+1)
prob=[0]*(n+1)
prob[1]=1
for i in range(m):
x,y=map(int,input().split())
quant[x]-=1
quant[y]+=1
if prob[x]>0:
prob[y]+=1
if quant[x]==0:
prob[x]=0
cnt=0
for i in range(n+1):
if prob[i]>0:
cnt+=1
print(cnt)
|
[
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,
0,
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,
18,
13,
13,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
17,
14,
40,
18,
13,
13,
0,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] | [
[
128,
2
],
[
128,
11
],
[
15,
14
],
[
129,
18
],
[
119,
23
],
[
28,
27
],
[
129,
31
],
[
110,
36
],
[
42,
39
],
[
120,
40
],
[
113,
44
],
[
48,
47
],
[
117,
50
],
[
122,
52
],
[
122,
61
],
[
66,
63
],
[
111,
64
],
[
108,
65
],
[
71,
68
],
[
111,
69
],
[
123,
70
],
[
120,
74
],
[
108,
75
],
[
63,
78
],
[
111,
79
],
[
108,
80
],
[
86,
83
],
[
120,
84
],
[
108,
85
],
[
131,
88
],
[
96,
92
],
[
120,
93
],
[
123,
94
],
[
99,
96
],
[
120,
97
],
[
123,
98
],
[
125,
101
],
[
126,
105
],
[
132,
105
],
[
114,
105
],
[
122,
108
],
[
110,
111
],
[
113,
114
],
[
128,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
]
] | [
"N, K = map(int, input().split())\nr = [False for _ in range(N+1)]\nb = [1 for _ in range(N+1)]\nr[1] = True\nr_cnt = 1\nfor _ in range(K):\n x, y = map(int, input().split())\n b[x] -= 1\n b[y] += 1\n if r[x]:\n if b[x] == 0:\n r[x] = False\n r_cnt -= 1\n if not r[y]:\n r[y] = True\n r_cnt += 1\nprint(r_cnt)",
"N, K = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"K",
"False for _ in range(N+1)",
"for _ in range(N+1)",
"_",
"range(N+1)",
"range",
"N+1",
"N",
"1",
"for _ in range(N+1)",
"False",
"r = [False for _ in range(N+1)]",
"r",
"[False 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",
"b = [1 for _ in range(N+1)]",
"b",
"[1 for _ in range(N+1)]",
"r[1] = True",
"r[1]",
"r",
"1",
"True",
"r_cnt = 1",
"r_cnt",
"1",
"for _ in range(K):\n x, y = map(int, input().split())\n b[x] -= 1\n b[y] += 1\n if r[x]:\n if b[x] == 0:\n r[x] = False\n r_cnt -= 1\n if not r[y]:\n r[y] = True\n r_cnt += 1",
"_",
"range(K)",
"range",
"K",
"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 r[x]:\n if b[x] == 0:\n r[x] = False\n r_cnt -= 1\n if not r[y]:\n r[y] = True\n r_cnt += 1",
"r[x]",
"r",
"x",
"if b[x] == 0:\n r[x] = False\n r_cnt -= 1\n ",
"b[x] == 0",
"b[x]",
"b",
"x",
"0",
"r[x] = False",
"r[x]",
"r",
"x",
"False",
"r_cnt -= 1",
"r_cnt",
"1",
"if not r[y]:\n r[y] = True\n r_cnt += 1",
"not r[y]",
"r[y]",
"r",
"y",
"r[y] = True",
"r[y]",
"r",
"y",
"True",
"r_cnt += 1",
"r_cnt",
"1",
"print(r_cnt)",
"print",
"r_cnt",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"b = [1 for _ in range(N+1)]",
"[1 for _ in range(N+1)]",
"b",
"r_cnt = 1",
"1",
"r_cnt",
"K = map(int, input().split())",
"map(int, input().split())",
"K",
"r = [False for _ in range(N+1)]",
"[False for _ in range(N+1)]",
"r",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"r_cnt += 1",
"1",
"r_cnt",
"N, K = map(int, input().split())",
"map(int, input().split())",
"N",
"r_cnt -= 1",
"1",
"r_cnt"
] | N, K = map(int, input().split())
r = [False for _ in range(N+1)]
b = [1 for _ in range(N+1)]
r[1] = True
r_cnt = 1
for _ in range(K):
x, y = map(int, input().split())
b[x] -= 1
b[y] += 1
if r[x]:
if b[x] == 0:
r[x] = False
r_cnt -= 1
if not r[y]:
r[y] = True
r_cnt += 1
print(r_cnt) |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
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,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
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,
13,
4,
13,
13,
4,
13,
13,
10,
2,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
18,
13,
10,
2,
13,
10,
4,
13
] | [
[
124,
4
],
[
15,
14
],
[
125,
18
],
[
14,
23
],
[
121,
25
],
[
121,
27
],
[
127,
29
],
[
119,
34
],
[
109,
37
],
[
119,
42
],
[
48,
45
],
[
110,
46
],
[
51,
50
],
[
122,
53
],
[
57,
56
],
[
125,
60
],
[
56,
65
],
[
115,
67
],
[
115,
69
],
[
110,
72
],
[
113,
73
],
[
78,
75
],
[
110,
76
],
[
116,
77
],
[
83,
80
],
[
128,
81
],
[
113,
82
],
[
88,
85
],
[
128,
86
],
[
116,
87
],
[
80,
91
],
[
128,
92
],
[
113,
93
],
[
99,
96
],
[
110,
97
],
[
113,
98
],
[
130,
101
],
[
110,
104
],
[
131,
107
],
[
109,
110
],
[
115,
113
],
[
115,
116
],
[
121,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
],
[
130,
131
]
] | [
"# https://atcoder.jp/contests/agc002/tasks/agc002_b\nimport sys\ninput = sys.stdin.buffer.readline\n\nn, m = [int(i) for i in input().split()]\n\ncount = [1] * (n + 1) # 1-indexed\nhave_red = [0] * (n + 1) # 1-indexed\nhave_red[1] = 1\nfor _ in range(m):\n x, y = [int(i) for i in input().split()]\n if have_red[x]:\n have_red[y] = 1\n count[x] -= 1\n count[y] += 1\n if count[x] == 0:\n have_red[x] = 0\n\nans = sum(have_red)\n\nprint(ans)",
"import sys",
"sys",
"input = sys.stdin.buffer.readline",
"input",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"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, m = [int(i) for i in input().split()]",
"n",
"[int(i) for i in input().split()]",
"m",
"count = [1] * (n + 1)",
"count",
"[1] * (n + 1)",
"[1]",
"1",
"n + 1",
"n",
"1",
"have_red = [0] * (n + 1)",
"have_red",
"[0] * (n + 1)",
"[0]",
"0",
"n + 1",
"n",
"1",
"have_red[1] = 1",
"have_red[1]",
"have_red",
"1",
"1",
"for _ in range(m):\n x, y = [int(i) for i in input().split()]\n if have_red[x]:\n have_red[y] = 1\n count[x] -= 1\n count[y] += 1\n if count[x] == 0:\n have_red[x] = 0",
"_",
"range(m)",
"range",
"m",
"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",
"x, y = [int(i) for i in input().split()]",
"x",
"[int(i) for i in input().split()]",
"y",
"if have_red[x]:\n have_red[y] = 1\n ",
"have_red[x]",
"have_red",
"x",
"have_red[y] = 1",
"have_red[y]",
"have_red",
"y",
"1",
"count[x] -= 1",
"count[x]",
"count",
"x",
"1",
"count[y] += 1",
"count[y]",
"count",
"y",
"1",
"if count[x] == 0:\n have_red[x] = 0",
"count[x] == 0",
"count[x]",
"count",
"x",
"0",
"have_red[x] = 0",
"have_red[x]",
"have_red",
"x",
"0",
"ans = sum(have_red)",
"ans",
"sum(have_red)",
"sum",
"have_red",
"print(ans)",
"print",
"ans",
"have_red = [0] * (n + 1)",
"[0] * (n + 1)",
"have_red",
"x, y = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"x",
"y = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"y",
"n, m = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"n",
"m = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"m",
"input = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"input",
"count = [1] * (n + 1)",
"[1] * (n + 1)",
"count",
"ans = sum(have_red)",
"sum(have_red)",
"ans"
] | # https://atcoder.jp/contests/agc002/tasks/agc002_b
import sys
input = sys.stdin.buffer.readline
n, m = [int(i) for i in input().split()]
count = [1] * (n + 1) # 1-indexed
have_red = [0] * (n + 1) # 1-indexed
have_red[1] = 1
for _ in range(m):
x, y = [int(i) for i in input().split()]
if have_red[x]:
have_red[y] = 1
count[x] -= 1
count[y] += 1
if count[x] == 0:
have_red[x] = 0
ans = sum(have_red)
print(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,
14,
2,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
87,
2
],
[
87,
11
],
[
78,
13
],
[
76,
18
],
[
81,
21
],
[
76,
26
],
[
32,
29
],
[
82,
30
],
[
35,
34
],
[
88,
37
],
[
90,
39
],
[
90,
48
],
[
53,
50
],
[
79,
51
],
[
91,
52
],
[
58,
55
],
[
79,
56
],
[
85,
57
],
[
82,
61
],
[
91,
62
],
[
50,
65
],
[
79,
66
],
[
91,
67
],
[
82,
73
],
[
87,
76
],
[
78,
79
],
[
81,
82
],
[
90,
85
],
[
87,
88
],
[
90,
91
]
] | [
"n,m=map(int,input().split())\na=[1]*(n+1)\nb=[0]*(n+1)\nb[1]=1\nfor _ in range(m):\n x,y=map(int,input().split())\n a[x]-=1\n a[y]+=1\n if b[x]:b[y]=1\n if a[x]==0:b[x]=0\nprint(sum(b))",
"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",
"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 x,y=map(int,input().split())\n a[x]-=1\n a[y]+=1\n if b[x]:b[y]=1\n if a[x]==0:b[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",
"a[x]-=1",
"a[x]",
"a",
"x",
"1",
"a[y]+=1",
"a[y]",
"a",
"y",
"1",
"if b[x]:b[y]=1\n ",
"b[x]",
"b",
"x",
"if a[x]==0:b[x]",
"a[x]==0",
"a[x]",
"a",
"x",
"0",
"print(sum(b))",
"print",
"sum(b)",
"sum",
"b",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"a=[1]*(n+1)",
"[1]*(n+1)",
"a",
"b=[0]*(n+1)",
"[0]*(n+1)",
"b",
"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"
] | n,m=map(int,input().split())
a=[1]*(n+1)
b=[0]*(n+1)
b[1]=1
for _ in range(m):
x,y=map(int,input().split())
a[x]-=1
a[y]+=1
if b[x]:b[y]=1
if a[x]==0:b[x]=0
print(sum(b)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
39,
17,
4,
18,
13,
13,
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,
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,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
113,
2
],
[
113,
11
],
[
116,
13
],
[
102,
17
],
[
107,
19
],
[
108,
24
],
[
102,
30
],
[
34,
33
],
[
114,
36
],
[
110,
38
],
[
110,
47
],
[
98,
49
],
[
96,
51
],
[
99,
51
],
[
104,
53
],
[
111,
55
],
[
105,
55
],
[
70,
59
],
[
108,
60
],
[
99,
61
],
[
96,
61
],
[
80,
65
],
[
117,
66
],
[
99,
67
],
[
96,
67
],
[
73,
70
],
[
108,
71
],
[
99,
72
],
[
96,
72
],
[
78,
75
],
[
108,
76
],
[
105,
77
],
[
111,
77
],
[
83,
80
],
[
117,
81
],
[
99,
82
],
[
96,
82
],
[
88,
85
],
[
117,
86
],
[
105,
87
],
[
111,
87
],
[
108,
93
],
[
110,
96
],
[
98,
99
],
[
113,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
]
] | [
"N, M = map(int, input().split())\nbox = [1] * N\nred = [1]\nred.extend([0] * (N - 1))\n\nfor i in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n \n if red[x] == 1:\n if box[x] == 1:\n red[x] = 0\n red[y] = 1\n \n box[x] -= 1\n box[y] += 1\n\n\nprint(sum(red))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"box = [1] * N",
"box",
"[1] * N",
"[1]",
"1",
"N",
"red = [1]",
"red",
"[1]",
"1",
"red.extend([0] * (N - 1))",
"red.extend",
"red",
"extend",
"[0] * (N - 1)",
"[0]",
"0",
"N - 1",
"N",
"1",
"for i in range(M):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n \n if red[x] == 1:\n if box[x] == 1:\n red[x] = 0\n red[y] = 1\n \n box[x] -= 1\n box[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 red[x] == 1:\n if box[x] == 1:\n red[x] = 0\n red[y] = 1\n \n ",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"if box[x] == 1:\n red[x] = 0\n ",
"box[x] == 1",
"box[x]",
"box",
"x",
"1",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"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(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"x, y = x - 1, y - 1",
"x - 1",
"x",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"y = x - 1, y - 1",
"y - 1",
"y",
"red = [1]",
"[1]",
"red",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"box = [1] * N",
"[1] * N",
"box"
] | N, M = map(int, input().split())
box = [1] * N
red = [1]
red.extend([0] * (N - 1))
for i in range(M):
x, y = map(int, input().split())
x, y = x - 1, y - 1
if red[x] == 1:
if box[x] == 1:
red[x] = 0
red[y] = 1
box[x] -= 1
box[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,
39,
39,
17,
17,
28,
13,
4,
13,
2,
13,
17,
4,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
13,
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,
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,
14,
40,
18,
18,
13,
13,
17,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
13,
13,
10,
39,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] | [
[
175,
2
],
[
175,
11
],
[
15,
14
],
[
176,
17
],
[
163,
30
],
[
166,
33
],
[
40,
39
],
[
161,
43
],
[
167,
47
],
[
54,
53
],
[
176,
56
],
[
69,
58
],
[
167,
60
],
[
164,
64
],
[
53,
65
],
[
82,
71
],
[
167,
73
],
[
164,
77
],
[
53,
78
],
[
167,
87
],
[
164,
91
],
[
53,
92
],
[
109,
98
],
[
167,
100
],
[
164,
104
],
[
53,
105
],
[
167,
114
],
[
164,
118
],
[
53,
119
],
[
136,
125
],
[
167,
127
],
[
164,
131
],
[
53,
132
],
[
169,
138
],
[
142,
141
],
[
161,
144
],
[
167,
149
],
[
141,
150
],
[
172,
154
],
[
173,
158
],
[
170,
158
],
[
175,
161
],
[
163,
164
],
[
166,
167
],
[
169,
170
],
[
172,
173
],
[
175,
176
]
] | [
"N, M = map(int,input().split())\nz = [list(map(int,input().split())) for i in range(M)]\nbox = [[1,1]]\nfor i in range(N-1):\n box.append([0,1])\nfor i in range(M):\n box[z[i][0]-1][1] -= 1\n box[z[i][1]-1][1] += 1\n if (box[z[i][0]-1][0] == 1):\n box[z[i][1]-1][0] = 1\n if (box[z[i][0]-1][1] == 0):\n box[z[i][0]-1][0] = 0\nans = 0\nfor i in range(N):\n if (box[i][0] != 0):\n ans += 1\nprint(ans)",
"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",
"z = [list(map(int,input().split())) for i in range(M)]",
"z",
"[list(map(int,input().split())) for i in range(M)]",
"box = [[1,1]]",
"box",
"[[1,1]]",
"[1,1]",
"1",
"1",
"for i in range(N-1):\n box.append([0,1])",
"i",
"range(N-1)",
"range",
"N-1",
"N",
"1",
"box.append([0,1])",
"box.append",
"box",
"append",
"[0,1]",
"0",
"1",
"for i in range(M):\n box[z[i][0]-1][1] -= 1\n box[z[i][1]-1][1] += 1\n if (box[z[i][0]-1][0] == 1):\n box[z[i][1]-1][0] = 1\n if (box[z[i][0]-1][1] == 0):\n box[z[i][0]-1][0] = 0",
"i",
"range(M)",
"range",
"M",
"box[z[i][0]-1][1] -= 1",
"box[z[i][0]-1][1]",
"[z[i][0]-1]",
"box",
"z[i][0]-1",
"z[i][0]",
"[i]",
"z",
"i",
"0",
"1",
"1",
"1",
"box[z[i][1]-1][1] += 1",
"box[z[i][1]-1][1]",
"[z[i][1]-1]",
"box",
"z[i][1]-1",
"z[i][1]",
"[i]",
"z",
"i",
"1",
"1",
"1",
"1",
"if (box[z[i][0]-1][0] == 1):\n box[z[i][1]-1][0] = 1\n ",
"box[z[i][0]-1][0] == 1",
"box[z[i][0]-1][0]",
"[z[i][0]-1]",
"box",
"z[i][0]-1",
"z[i][0]",
"[i]",
"z",
"i",
"0",
"1",
"0",
"1",
"box[z[i][1]-1][0] = 1",
"box[z[i][1]-1][0]",
"[z[i][1]-1]",
"box",
"z[i][1]-1",
"z[i][1]",
"[i]",
"z",
"i",
"1",
"1",
"0",
"1",
"if (box[z[i][0]-1][1] == 0):\n box[z[i][0]-1][0] = 0",
"box[z[i][0]-1][1] == 0",
"box[z[i][0]-1][1]",
"[z[i][0]-1]",
"box",
"z[i][0]-1",
"z[i][0]",
"[i]",
"z",
"i",
"0",
"1",
"1",
"0",
"box[z[i][0]-1][0] = 0",
"box[z[i][0]-1][0]",
"[z[i][0]-1]",
"box",
"z[i][0]-1",
"z[i][0]",
"[i]",
"z",
"i",
"0",
"1",
"0",
"0",
"ans = 0",
"ans",
"0",
"for i in range(N):\n if (box[i][0] != 0):\n ans += 1",
"i",
"range(N)",
"range",
"N",
"if (box[i][0] != 0):\n ans += 1",
"box[i][0] != 0",
"box[i][0]",
"[i]",
"box",
"i",
"0",
"0",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"N, M = map(int,input().split())",
"map(int,input().split())",
"N",
"z = [list(map(int,input().split())) for i in range(M)]",
"[list(map(int,input().split())) for i in range(M)]",
"z",
"box = [[1,1]]",
"[[1,1]]",
"box",
"ans = 0",
"0",
"ans",
"ans += 1",
"1",
"ans",
"M = map(int,input().split())",
"map(int,input().split())",
"M"
] | N, M = map(int,input().split())
z = [list(map(int,input().split())) for i in range(M)]
box = [[1,1]]
for i in range(N-1):
box.append([0,1])
for i in range(M):
box[z[i][0]-1][1] -= 1
box[z[i][1]-1][1] += 1
if (box[z[i][0]-1][0] == 1):
box[z[i][1]-1][0] = 1
if (box[z[i][0]-1][1] == 0):
box[z[i][0]-1][0] = 0
ans = 0
for i in range(N):
if (box[i][0] != 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,
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,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13
] | [
[
131,
2
],
[
131,
11
],
[
110,
13
],
[
132,
17
],
[
128,
19
],
[
132,
23
],
[
28,
25
],
[
111,
26
],
[
31,
30
],
[
105,
33
],
[
113,
35
],
[
113,
44
],
[
122,
46
],
[
116,
49
],
[
55,
52
],
[
129,
53
],
[
117,
54
],
[
114,
54
],
[
79,
58
],
[
111,
59
],
[
123,
60
],
[
108,
60
],
[
66,
63
],
[
111,
64
],
[
117,
65
],
[
114,
65
],
[
71,
68
],
[
129,
69
],
[
123,
70
],
[
108,
70
],
[
68,
74
],
[
129,
75
],
[
123,
76
],
[
108,
76
],
[
82,
79
],
[
111,
80
],
[
123,
81
],
[
108,
81
],
[
119,
84
],
[
88,
87
],
[
132,
90
],
[
111,
94
],
[
87,
95
],
[
125,
98
],
[
126,
102
],
[
120,
102
],
[
131,
105
],
[
113,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
]
] | [
"n,m=map(int,input().split())\ndp=[False]*n\ndp2=[1]*n\n\ndp[0]=True\n\nfor i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n dp2[y]+=1\n if dp[x]==True:\n dp[y]=True\n \n dp2[x]-=1\n if dp2[x]==0:\n dp[x]=False\n \nans=0\n\nfor i in range(n):\n if dp[i]==True:\n ans+=1\n \n \nprint(ans)",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"dp=[False]*n",
"dp",
"[False]*n",
"[False]",
"False",
"n",
"dp2=[1]*n",
"dp2",
"[1]*n",
"[1]",
"1",
"n",
"dp[0]=True",
"dp[0]",
"dp",
"0",
"True",
"for i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n dp2[y]+=1\n if dp[x]==True:\n dp[y]=True\n \n dp2[x]-=1\n if dp2[x]==0:\n dp[x]=False\n ",
"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",
"dp2[y]+=1",
"dp2[y]",
"dp2",
"y",
"1",
"if dp[x]==True:\n dp[y]=True\n \n ",
"dp[x]==True",
"dp[x]",
"dp",
"x",
"True",
"dp[y]=True",
"dp[y]",
"dp",
"y",
"True",
"dp2[x]-=1",
"dp2[x]",
"dp2",
"x",
"1",
"if dp2[x]==0:\n dp[x]=False\n ",
"dp2[x]==0",
"dp2[x]",
"dp2",
"x",
"0",
"dp[x]=False",
"dp[x]",
"dp",
"x",
"False",
"ans=0",
"ans",
"0",
"for i in range(n):\n if dp[i]==True:\n ans+=1\n \n ",
"i",
"range(n)",
"range",
"n",
"if dp[i]==True:\n ans+=1\n \n ",
"dp[i]==True",
"dp[i]",
"dp",
"i",
"True",
"ans+=1",
"ans",
"1",
"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",
"dp=[False]*n",
"[False]*n",
"dp",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"y-=1",
"1",
"y",
"ans=0",
"0",
"ans",
"x-=1",
"1",
"x",
"ans+=1",
"1",
"ans",
"dp2=[1]*n",
"[1]*n",
"dp2",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n"
] | n,m=map(int,input().split())
dp=[False]*n
dp2=[1]*n
dp[0]=True
for i in range(m):
x,y=map(int,input().split())
x-=1
y-=1
dp2[y]+=1
if dp[x]==True:
dp[y]=True
dp2[x]-=1
if dp2[x]==0:
dp[x]=False
ans=0
for i in range(n):
if dp[i]==True:
ans+=1
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
39,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
2,
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,
0,
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,
39,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] | [
[
126,
2
],
[
126,
11
],
[
129,
13
],
[
17,
16
],
[
121,
19
],
[
132,
21
],
[
132,
30
],
[
130,
33
],
[
138,
39
],
[
127,
43
],
[
48,
45
],
[
139,
46
],
[
135,
50
],
[
127,
54
],
[
139,
62
],
[
133,
64
],
[
136,
68
],
[
133,
70
],
[
79,
74
],
[
139,
75
],
[
124,
77
],
[
139,
82
],
[
133,
84
],
[
92,
87
],
[
139,
88
],
[
124,
90
],
[
99,
94
],
[
139,
95
],
[
133,
97
],
[
106,
101
],
[
136,
102
],
[
133,
104
],
[
113,
108
],
[
136,
109
],
[
124,
111
],
[
139,
118
],
[
126,
121
],
[
132,
124
],
[
126,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
]
] | [
"n, m = map(int, input().split())\nxy = []\nfor _ in range(m):\n x, y = map(int, input().split())\n xy.append((x, y))\nreds = [False]*n\nreds[0] = True\nballs = [1]*n\nfor x, y in xy:\n if reds[x-1] and balls[x-1]>1:\n reds[y-1] = True\n elif reds[x-1]:\n reds[y-1] = True\n reds[x-1] = False\n balls[x-1] -= 1\n balls[y-1] += 1\nprint(sum(reds))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"xy = []",
"xy",
"[]",
"for _ in range(m):\n x, y = map(int, input().split())\n xy.append((x, y))",
"_",
"range(m)",
"range",
"m",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"xy.append((x, y))",
"xy.append",
"xy",
"append",
"(x, y)",
"x",
"y",
"reds = [False]*n",
"reds",
"[False]*n",
"[False]",
"False",
"n",
"reds[0] = True",
"reds[0]",
"reds",
"0",
"True",
"balls = [1]*n",
"balls",
"[1]*n",
"[1]",
"1",
"n",
"for x, y in xy:\n if reds[x-1] and balls[x-1]>1:\n reds[y-1] = True\n elif reds[x-1]:\n reds[y-1] = True\n reds[x-1] = False\n balls[x-1] -= 1\n balls[y-1] += 1",
"x",
"y",
"xy",
"if reds[x-1] and balls[x-1]>1:\n reds[y-1] = True\n elif reds[x-1]:\n reds[y-1] = True\n reds[x-1] = False\n ",
"reds[x-1] and balls[x-1]>1",
"reds[x-1]",
"reds",
"x-1",
"x",
"1",
"balls[x-1]>1",
"balls[x-1]",
"balls",
"x-1",
"x",
"1",
"1",
"reds[y-1] = True",
"reds[y-1]",
"reds",
"y-1",
"y",
"1",
"True",
"elif reds[x-1]:\n reds[y-1] = True\n reds[x-1] = False\n ",
"reds[x-1]",
"reds",
"x-1",
"x",
"1",
"reds[y-1] = True",
"reds[y-1]",
"reds",
"y-1",
"y",
"1",
"True",
"reds[x-1] = False",
"reds[x-1]",
"reds",
"x-1",
"x",
"1",
"False",
"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(sum(reds))",
"print",
"sum(reds)",
"sum",
"reds",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"xy = []",
"[]",
"xy",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"balls = [1]*n",
"[1]*n",
"balls",
"reds = [False]*n",
"[False]*n",
"reds"
] | n, m = map(int, input().split())
xy = []
for _ in range(m):
x, y = map(int, input().split())
xy.append((x, y))
reds = [False]*n
reds[0] = True
balls = [1]*n
for x, y in xy:
if reds[x-1] and balls[x-1]>1:
reds[y-1] = True
elif reds[x-1]:
reds[y-1] = True
reds[x-1] = False
balls[x-1] -= 1
balls[y-1] += 1
print(sum(reds)) |
[
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,
4,
18,
13,
13,
17,
39,
17,
17,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
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,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
18,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13,
10,
13,
13
] | [
[
128,
2
],
[
128,
11
],
[
15,
14
],
[
126,
17
],
[
140,
23
],
[
141,
27
],
[
39,
34
],
[
141,
36
],
[
42,
41
],
[
129,
44
],
[
131,
46
],
[
131,
55
],
[
62,
57
],
[
141,
59
],
[
123,
60
],
[
141,
67
],
[
132,
68
],
[
77,
72
],
[
141,
74
],
[
123,
75
],
[
84,
79
],
[
141,
81
],
[
132,
82
],
[
141,
89
],
[
132,
90
],
[
99,
94
],
[
141,
96
],
[
132,
97
],
[
134,
101
],
[
105,
104
],
[
126,
109
],
[
137,
112
],
[
141,
115
],
[
104,
116
],
[
138,
120
],
[
135,
120
],
[
131,
123
],
[
128,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
]
] | [
"N,M = map(int,input().split())\nA = [[0,1] for _ in range(N)]\nA.insert(0,[0,0])\nA[1][0] = 1\nfor _ in range(M):\n x,y = map(int,input().split())\n A[y][1] += 1\n if A[x][0]==1:\n A[y][0]=1\n A[x][1] -= 1\n if A[x][1]==0:\n A[x][0]=0\ncnt = 0\nfor i in range(1,N+1):\n cnt += A[i][0]\nprint(cnt)",
"N,M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"[0,1] for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"[0,1]",
"0",
"1",
"A = [[0,1] for _ in range(N)]",
"A",
"[[0,1] for _ in range(N)]",
"A.insert(0,[0,0])",
"A.insert",
"A",
"insert",
"0",
"[0,0]",
"0",
"0",
"A[1][0] = 1",
"A[1][0]",
"[1]",
"A",
"1",
"0",
"1",
"for _ in range(M):\n x,y = map(int,input().split())\n A[y][1] += 1\n if A[x][0]==1:\n A[y][0]=1\n A[x][1] -= 1\n if A[x][1]==0:\n A[x][0]=0",
"_",
"range(M)",
"range",
"M",
"x,y = map(int,input().split())",
"x",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"A[y][1] += 1",
"A[y][1]",
"[y]",
"A",
"y",
"1",
"1",
"if A[x][0]==1:\n A[y][0]=1\n ",
"A[x][0]==1",
"A[x][0]",
"[x]",
"A",
"x",
"0",
"1",
"A[y][0]=1",
"A[y][0]",
"[y]",
"A",
"y",
"0",
"1",
"A[x][1] -= 1",
"A[x][1]",
"[x]",
"A",
"x",
"1",
"1",
"if A[x][1]==0:\n A[x][0]=0",
"A[x][1]==0",
"A[x][1]",
"[x]",
"A",
"x",
"1",
"0",
"A[x][0]=0",
"A[x][0]",
"[x]",
"A",
"x",
"0",
"0",
"cnt = 0",
"cnt",
"0",
"for i in range(1,N+1):\n cnt += A[i][0]",
"i",
"range(1,N+1)",
"range",
"1",
"N+1",
"N",
"1",
"cnt += A[i][0]",
"cnt",
"A[i][0]",
"[i]",
"A",
"i",
"0",
"print(cnt)",
"print",
"cnt",
"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 += A[i][0]",
"A[i][0]",
"cnt",
"A = [[0,1] for _ in range(N)]",
"[[0,1] for _ in range(N)]",
"A"
] | N,M = map(int,input().split())
A = [[0,1] for _ in range(N)]
A.insert(0,[0,0])
A[1][0] = 1
for _ in range(M):
x,y = map(int,input().split())
A[y][1] += 1
if A[x][0]==1:
A[y][0]=1
A[x][1] -= 1
if A[x][1]==0:
A[x][0]=0
cnt = 0
for i in range(1,N+1):
cnt += A[i][0]
print(cnt) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
40,
18,
13,
13,
0,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
18,
13,
13,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13
] | [
[
136,
2
],
[
136,
11
],
[
124,
13
],
[
17,
16
],
[
122,
19
],
[
130,
21
],
[
130,
30
],
[
125,
33
],
[
116,
37
],
[
131,
40
],
[
118,
43
],
[
137,
47
],
[
52,
49
],
[
119,
50
],
[
139,
54
],
[
137,
58
],
[
119,
65
],
[
116,
66
],
[
71,
68
],
[
119,
69
],
[
131,
70
],
[
76,
73
],
[
140,
74
],
[
116,
75
],
[
81,
78
],
[
140,
79
],
[
131,
80
],
[
73,
84
],
[
140,
85
],
[
116,
86
],
[
91,
88
],
[
119,
89
],
[
116,
90
],
[
133,
93
],
[
97,
96
],
[
137,
99
],
[
119,
103
],
[
96,
104
],
[
140,
106
],
[
96,
107
],
[
127,
109
],
[
128,
113
],
[
134,
113
],
[
130,
116
],
[
118,
119
],
[
136,
122
],
[
124,
125
],
[
127,
128
],
[
130,
131
],
[
133,
134
],
[
136,
137
],
[
139,
140
]
] | [
"# https://atcoder.jp/contests/agc002/tasks/agc002_b\n\nn, m = map(int, input().split())\n\nxy = []\nfor _ in range(m):\n x, y = map(int, input().split())\n xy.append((x - 1, y - 1))\n\nbox = [0] * n\nbox[0] = 1\nnum = [1] * n\nfor x, y in xy:\n if box[x]:\n box[y] |= 1\n num[x] -= 1\n num[y] += 1\n if not num[x]:\n box[x] = 0\nans = 0\nfor i in range(n):\n if box[i] and num[i]:\n ans += 1\nprint(ans)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"xy = []",
"xy",
"[]",
"for _ in range(m):\n x, y = map(int, input().split())\n xy.append((x - 1, 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",
"xy.append((x - 1, y - 1))",
"xy.append",
"xy",
"append",
"(x - 1, y - 1)",
"x - 1",
"x",
"1",
"y - 1",
"y",
"1",
"box = [0] * n",
"box",
"[0] * n",
"[0]",
"0",
"n",
"box[0] = 1",
"box[0]",
"box",
"0",
"1",
"num = [1] * n",
"num",
"[1] * n",
"[1]",
"1",
"n",
"for x, y in xy:\n if box[x]:\n box[y] |= 1\n num[x] -= 1\n num[y] += 1\n if not num[x]:\n box[x] = 0",
"x",
"y",
"xy",
"if box[x]:\n box[y] |= 1\n ",
"box[x]",
"box",
"x",
"box[y] |= 1",
"box[y]",
"box",
"y",
"1",
"num[x] -= 1",
"num[x]",
"num",
"x",
"1",
"num[y] += 1",
"num[y]",
"num",
"y",
"1",
"if not num[x]:\n box[x] = 0",
"not num[x]",
"num[x]",
"num",
"x",
"box[x] = 0",
"box[x]",
"box",
"x",
"0",
"ans = 0",
"ans",
"0",
"for i in range(n):\n if box[i] and num[i]:\n ans += 1",
"i",
"range(n)",
"range",
"n",
"if box[i] and num[i]:\n ans += 1",
"box[i] and num[i]",
"box[i]",
"box",
"i",
"num[i]",
"num",
"i",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"box = [0] * n",
"[0] * n",
"box",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"xy = []",
"[]",
"xy",
"ans += 1",
"1",
"ans",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"ans = 0",
"0",
"ans",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"num = [1] * n",
"[1] * n",
"num"
] | # https://atcoder.jp/contests/agc002/tasks/agc002_b
n, m = map(int, input().split())
xy = []
for _ in range(m):
x, y = map(int, input().split())
xy.append((x - 1, y - 1))
box = [0] * n
box[0] = 1
num = [1] * n
for x, y in xy:
if box[x]:
box[y] |= 1
num[x] -= 1
num[y] += 1
if not num[x]:
box[x] = 0
ans = 0
for i in range(n):
if box[i] and num[i]:
ans += 1
print(ans) |
[
7,
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,
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,
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,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
104,
2
],
[
104,
11
],
[
98,
13
],
[
96,
21
],
[
110,
24
],
[
96,
28
],
[
31,
30
],
[
105,
33
],
[
107,
35
],
[
107,
44
],
[
99,
48
],
[
108,
50
],
[
59,
54
],
[
99,
55
],
[
102,
57
],
[
111,
63
],
[
108,
65
],
[
74,
69
],
[
99,
70
],
[
108,
72
],
[
81,
76
],
[
111,
77
],
[
108,
79
],
[
88,
83
],
[
111,
84
],
[
102,
86
],
[
99,
93
],
[
104,
96
],
[
98,
99
],
[
107,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"n, m = map(int, input().split())\nred = [1] + [0] * (n - 1)\nnum = [1] * n\nfor i in range(m):\n x, y = map(int, input().split())\n if red[x - 1] == 1:\n red[y - 1] = 1\n if num[x - 1] == 1:\n red[x - 1] = 0\n num[x - 1] -= 1\n num[y - 1] += 1\n \nprint(sum(red))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"red = [1] + [0] * (n - 1)",
"red",
"[1] + [0] * (n - 1)",
"[1]",
"1",
"[0] * (n - 1)",
"[0]",
"0",
"n - 1",
"n",
"1",
"num = [1] * n",
"num",
"[1] * n",
"[1]",
"1",
"n",
"for i in range(m):\n x, y = map(int, input().split())\n if red[x - 1] == 1:\n red[y - 1] = 1\n if num[x - 1] == 1:\n red[x - 1] = 0\n num[x - 1] -= 1\n num[y - 1] += 1\n ",
"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 red[x - 1] == 1:\n red[y - 1] = 1\n if num[x - 1] == 1:\n red[x - 1] = 0\n ",
"red[x - 1] == 1",
"red[x - 1]",
"red",
"x - 1",
"x",
"1",
"1",
"red[y - 1] = 1",
"red[y - 1]",
"red",
"y - 1",
"y",
"1",
"1",
"if num[x - 1] == 1:\n red[x - 1] = 0\n ",
"num[x - 1] == 1",
"num[x - 1]",
"num",
"x - 1",
"x",
"1",
"1",
"red[x - 1] = 0",
"red[x - 1]",
"red",
"x - 1",
"x",
"1",
"0",
"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",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"red = [1] + [0] * (n - 1)",
"[1] + [0] * (n - 1)",
"red",
"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",
"num = [1] * n",
"[1] * n",
"num"
] | n, m = map(int, input().split())
red = [1] + [0] * (n - 1)
num = [1] * n
for i in range(m):
x, y = map(int, input().split())
if red[x - 1] == 1:
red[y - 1] = 1
if num[x - 1] == 1:
red[x - 1] = 0
num[x - 1] -= 1
num[y - 1] += 1
print(sum(red)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
41,
28,
13,
4,
13,
13,
4,
21,
22,
17,
17,
22,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
13,
4,
13,
31,
2,
39,
4,
13,
13,
17,
0,
13,
17,
0,
13,
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,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
4,
13,
4,
13,
18,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13
] | [
[
116,
2
],
[
116,
15
],
[
116,
16
],
[
21,
20
],
[
114,
23
],
[
122,
33
],
[
41,
36
],
[
123,
38
],
[
110,
55
],
[
119,
58
],
[
123,
63
],
[
111,
64
],
[
72,
67
],
[
123,
69
],
[
120,
70
],
[
123,
77
],
[
111,
78
],
[
87,
82
],
[
123,
84
],
[
111,
85
],
[
94,
89
],
[
123,
91
],
[
111,
92
],
[
101,
96
],
[
123,
98
],
[
120,
99
],
[
110,
111
],
[
116,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
]
] | [
"N, M, *xy = map(int, open(0).read().split())\nboxes = [{\"count\": 1, \"red\": False} for _ in range(N)]\nboxes[0][\"red\"] = True\n\nfor x, y in zip(*[iter(xy)] * 2):\n x -= 1\n y -= 1\n if boxes[x][\"red\"]:\n boxes[y][\"red\"] = True\n if boxes[x][\"count\"] == 1:\n boxes[x][\"red\"] = False\n boxes[x][\"count\"] -= 1\n boxes[y][\"count\"] += 1\nprint(sum(b[\"red\"] for b in boxes))",
"N, M, *xy = 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",
"M",
"*xy",
"xy",
"{\"count\": 1, \"red\": False} for _ in range(N)",
"for _ in range(N)",
"_",
"range(N)",
"range",
"N",
"for _ in range(N)",
"{\"count\": 1, \"red\": False}",
"\"count\"",
"\"count\"",
"1",
"\"red\"",
"\"red\"",
"False",
"boxes = [{\"count\": 1, \"red\": False} for _ in range(N)]",
"boxes",
"[{\"count\": 1, \"red\": False} for _ in range(N)]",
"boxes[0][\"red\"] = True",
"boxes[0][\"red\"]",
"[0]",
"boxes",
"0",
"\"red\"",
"True",
"for x, y in zip(*[iter(xy)] * 2):\n x -= 1\n y -= 1\n if boxes[x][\"red\"]:\n boxes[y][\"red\"] = True\n if boxes[x][\"count\"] == 1:\n boxes[x][\"red\"] = False\n boxes[x][\"count\"] -= 1\n boxes[y][\"count\"] += 1",
"x",
"y",
"zip(*[iter(xy)] * 2)",
"zip",
"*[iter(xy)] * 2",
"[iter(xy)] * 2",
"[iter(xy)]",
"iter(xy)",
"iter",
"xy",
"2",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if boxes[x][\"red\"]:\n boxes[y][\"red\"] = True\n if boxes[x][\"count\"] == 1:\n boxes[x][\"red\"] = False\n ",
"boxes[x][\"red\"]",
"[x]",
"boxes",
"x",
"\"red\"",
"boxes[y][\"red\"] = True",
"boxes[y][\"red\"]",
"[y]",
"boxes",
"y",
"\"red\"",
"True",
"if boxes[x][\"count\"] == 1:\n boxes[x][\"red\"] = False\n ",
"boxes[x][\"count\"] == 1",
"boxes[x][\"count\"]",
"[x]",
"boxes",
"x",
"\"count\"",
"1",
"boxes[x][\"red\"] = False",
"boxes[x][\"red\"]",
"[x]",
"boxes",
"x",
"\"red\"",
"False",
"boxes[x][\"count\"] -= 1",
"boxes[x][\"count\"]",
"[x]",
"boxes",
"x",
"\"count\"",
"1",
"boxes[y][\"count\"] += 1",
"boxes[y][\"count\"]",
"[y]",
"boxes",
"y",
"\"count\"",
"1",
"print(sum(b[\"red\"] for b in boxes))",
"print",
"sum(b[\"red\"] for b in boxes)",
"sum",
"b[\"red\"]",
"b",
"\"red\"",
"x -= 1",
"1",
"x",
"N, M, *xy = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"N",
"M, *xy = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"M",
"y -= 1",
"1",
"y",
"boxes = [{\"count\": 1, \"red\": False} for _ in range(N)]",
"[{\"count\": 1, \"red\": False} for _ in range(N)]",
"boxes"
] | N, M, *xy = map(int, open(0).read().split())
boxes = [{"count": 1, "red": False} for _ in range(N)]
boxes[0]["red"] = True
for x, y in zip(*[iter(xy)] * 2):
x -= 1
y -= 1
if boxes[x]["red"]:
boxes[y]["red"] = True
if boxes[x]["count"] == 1:
boxes[x]["red"] = False
boxes[x]["count"] -= 1
boxes[y]["count"] += 1
print(sum(b["red"] for b in boxes))
|
[
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,
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,
18,
13,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
107,
2
],
[
107,
11
],
[
101,
13
],
[
105,
17
],
[
110,
19
],
[
105,
23
],
[
28,
25
],
[
111,
26
],
[
31,
30
],
[
108,
33
],
[
98,
35
],
[
98,
44
],
[
92,
46
],
[
89,
49
],
[
55,
52
],
[
102,
53
],
[
93,
54
],
[
96,
54
],
[
60,
57
],
[
102,
58
],
[
90,
59
],
[
99,
59
],
[
111,
63
],
[
93,
64
],
[
96,
64
],
[
69,
66
],
[
111,
67
],
[
90,
68
],
[
99,
68
],
[
52,
72
],
[
102,
73
],
[
93,
74
],
[
96,
74
],
[
80,
77
],
[
111,
78
],
[
93,
79
],
[
96,
79
],
[
111,
85
],
[
89,
90
],
[
92,
93
],
[
98,
96
],
[
98,
99
],
[
101,
102
],
[
107,
105
],
[
107,
108
],
[
110,
111
]
] | [
"n,m=map(int, input().split())\nball=[1]*n\nred=[False]*n\nred[0]=True\nfor i in range(m):\n x, y=map(int, input().split())\n x-=1\n y-=1\n ball[x]-=1\n ball[y]+=1\n if red[x]:\n red[y]=True\n if ball[x]==0:\n red[x]=False\n\nprint(red.count(True))",
"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=[False]*n",
"red",
"[False]*n",
"[False]",
"False",
"n",
"red[0]=True",
"red[0]",
"red",
"0",
"True",
"for i in range(m):\n x, y=map(int, input().split())\n x-=1\n y-=1\n ball[x]-=1\n ball[y]+=1\n if red[x]:\n red[y]=True\n if ball[x]==0:\n red[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",
"ball[x]-=1",
"ball[x]",
"ball",
"x",
"1",
"ball[y]+=1",
"ball[y]",
"ball",
"y",
"1",
"if red[x]:\n red[y]=True\n if ball[x]==0:\n red[x]=False",
"red[x]",
"red",
"x",
"red[y]=True",
"red[y]",
"red",
"y",
"True",
"if ball[x]==0:\n red[x]=False",
"ball[x]==0",
"ball[x]",
"ball",
"x",
"0",
"red[x]=False",
"red[x]",
"red",
"x",
"False",
"print(red.count(True))",
"print",
"red.count(True)",
"red.count",
"red",
"count",
"True",
"y-=1",
"1",
"y",
"x-=1",
"1",
"x",
"x, y=map(int, input().split())",
"map(int, input().split())",
"x",
"y=map(int, input().split())",
"map(int, input().split())",
"y",
"ball=[1]*n",
"[1]*n",
"ball",
"n,m=map(int, input().split())",
"map(int, input().split())",
"n",
"m=map(int, input().split())",
"map(int, input().split())",
"m",
"red=[False]*n",
"[False]*n",
"red"
] | n,m=map(int, input().split())
ball=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
x, y=map(int, input().split())
x-=1
y-=1
ball[x]-=1
ball[y]+=1
if red[x]:
red[y]=True
if ball[x]==0:
red[x]=False
print(red.count(True)) |
[
7,
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,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
28,
13,
13,
0,
13,
2,
18,
13,
17,
17,
13,
2,
18,
13,
17,
17,
14,
2,
18,
13,
13,
17,
9,
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,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
4,
19
],
[
22,
21
],
[
4,
25
],
[
30,
27
],
[
21,
28
],
[
34,
33
],
[
13,
36
],
[
50,
49
],
[
53,
52
],
[
49,
52
],
[
56,
55
],
[
52,
58
],
[
62,
61
],
[
52,
64
],
[
75,
69
],
[
15,
70
],
[
55,
71
],
[
78,
75
],
[
15,
76
],
[
55,
77
],
[
97,
81
],
[
21,
82
],
[
55,
83
],
[
89,
86
],
[
21,
87
],
[
61,
88
],
[
75,
92
],
[
15,
93
],
[
55,
94
],
[
100,
97
],
[
21,
98
],
[
55,
99
],
[
105,
102
],
[
15,
103
],
[
61,
104
],
[
21,
110
],
[
119,
116
]
] | [
"def main():\n n,m = map(int,input().split())\n box = [1] * n\n red = [0] * n\n red[0] += 1\n op = [list(map(int,input().split())) for _ in range(m)]\n for o in op:\n x, y = o[0]-1, o[1]-1\n if box[x] < 1:\n continue\n box[x] -= 1\n if red[x] > 0:\n red[y] = 1\n if box[x] == 0:\n red[x] = 0\n box[y] += 1\n print(sum(red))\n\nif __name__ == \"__main__\":\n main()",
"def main():\n n,m = map(int,input().split())\n box = [1] * n\n red = [0] * n\n red[0] += 1\n op = [list(map(int,input().split())) for _ in range(m)]\n for o in op:\n x, y = o[0]-1, o[1]-1\n if box[x] < 1:\n continue\n box[x] -= 1\n if red[x] > 0:\n red[y] = 1\n if box[x] == 0:\n red[x] = 0\n box[y] += 1\n print(sum(red))",
"main",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"box = [1] * n",
"box",
"[1] * n",
"[1]",
"1",
"n",
"red = [0] * n",
"red",
"[0] * n",
"[0]",
"0",
"n",
"red[0] += 1",
"red[0]",
"red",
"0",
"1",
"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",
"op = [list(map(int,input().split())) for _ in range(m)]",
"op",
"[list(map(int,input().split())) for _ in range(m)]",
"for o in op:\n x, y = o[0]-1, o[1]-1\n if box[x] < 1:\n continue\n box[x] -= 1\n if red[x] > 0:\n red[y] = 1\n if box[x] == 0:\n red[x] = 0\n box[y] += 1\n ",
"o",
"op",
"x, y = o[0]-1, o[1]-1",
"x",
"o[0]-1",
"o[0]",
"o",
"0",
"1",
"y",
"o[1]-1",
"o[1]",
"o",
"1",
"1",
"if box[x] < 1:\n continue\n ",
"box[x] < 1",
"box[x]",
"box",
"x",
"1",
"continue",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"if red[x] > 0:\n red[y] = 1\n ",
"red[x] > 0",
"red[x]",
"red",
"x",
"0",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"if box[x] == 0:\n red[x] = 0\n ",
"box[x] == 0",
"box[x]",
"box",
"x",
"0",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"box[y] += 1",
"box[y]",
"box",
"y",
"1",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n n,m = map(int,input().split())\n box = [1] * n\n red = [0] * n\n red[0] += 1\n op = [list(map(int,input().split())) for _ in range(m)]\n for o in op:\n x, y = o[0]-1, o[1]-1\n if box[x] < 1:\n continue\n box[x] -= 1\n if red[x] > 0:\n red[y] = 1\n if box[x] == 0:\n red[x] = 0\n box[y] += 1\n print(sum(red))",
"def main():\n n,m = map(int,input().split())\n box = [1] * n\n red = [0] * n\n red[0] += 1\n op = [list(map(int,input().split())) for _ in range(m)]\n for o in op:\n x, y = o[0]-1, o[1]-1\n if box[x] < 1:\n continue\n box[x] -= 1\n if red[x] > 0:\n red[y] = 1\n if box[x] == 0:\n red[x] = 0\n box[y] += 1\n print(sum(red))",
"main"
] | def main():
n,m = map(int,input().split())
box = [1] * n
red = [0] * n
red[0] += 1
op = [list(map(int,input().split())) for _ in range(m)]
for o in op:
x, y = o[0]-1, o[1]-1
if box[x] < 1:
continue
box[x] -= 1
if red[x] > 0:
red[y] = 1
if box[x] == 0:
red[x] = 0
box[y] += 1
print(sum(red))
if __name__ == "__main__":
main() |
[
7,
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,
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,
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,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13
] | [
[
129,
9
],
[
32,
31
],
[
133,
33
],
[
32,
34
],
[
37,
36
],
[
31,
40
],
[
43,
42
],
[
31,
46
],
[
51,
48
],
[
42,
49
],
[
54,
53
],
[
34,
56
],
[
59,
58
],
[
59,
73
],
[
78,
75
],
[
36,
76
],
[
58,
77
],
[
83,
80
],
[
36,
81
],
[
73,
82
],
[
42,
86
],
[
58,
87
],
[
92,
89
],
[
42,
90
],
[
73,
91
],
[
75,
95
],
[
36,
96
],
[
58,
97
],
[
103,
100
],
[
42,
101
],
[
58,
102
],
[
106,
105
],
[
109,
108
],
[
31,
111
],
[
42,
114
],
[
108,
115
],
[
118,
117
],
[
117,
121
],
[
105,
121
],
[
136,
127
],
[
129,
130
]
] | [
"#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\n#from itertools import combinations # (string,3) 3回\n#from collections import deque\n#import collections.defaultdict\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\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n n,m = readInts()\n # 数が入っているのと、\n # 箱の中が0かどうかを判別するものを定義する\n # 全部まず1個入ってる\n # 赤は最初だけ!!!!!!!!\n nums = [1] * n\n In = [False] * n\n In[0] = True\n for i in range(m):\n a,b = map(lambda x:int(x) - 1, input().split())\n nums[a] -=1\n nums[b] +=1\n if In[a]:\n In[b] = True\n if nums[a] == 0:\n In[a] = False\n cnt = 0\n #print(In)\n for i in range(n):\n if In[i]:\n cnt += 1\n print(cnt)\nif __name__ == '__main__':\n main()",
"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 main():\n n,m = readInts()\n # 数が入っているのと、\n # 箱の中が0かどうかを判別するものを定義する\n # 全部まず1個入ってる\n # 赤は最初だけ!!!!!!!!\n nums = [1] * n\n In = [False] * n\n In[0] = True\n for i in range(m):\n a,b = map(lambda x:int(x) - 1, input().split())\n nums[a] -=1\n nums[b] +=1\n if In[a]:\n In[b] = True\n if nums[a] == 0:\n In[a] = False\n cnt = 0\n #print(In)\n for i in range(n):\n if In[i]:\n cnt += 1\n print(cnt)",
"main",
"n,m = readInts()",
"n",
"readInts()",
"readInts",
"m",
"nums = [1] * n",
"nums",
"[1] * n",
"[1]",
"1",
"n",
"In = [False] * n",
"In",
"[False] * n",
"[False]",
"False",
"n",
"In[0] = True",
"In[0]",
"In",
"0",
"True",
"for i in range(m):\n a,b = map(lambda x:int(x) - 1, input().split())\n nums[a] -=1\n nums[b] +=1\n if In[a]:\n In[b] = True\n if nums[a] == 0:\n In[a] = False\n ",
"i",
"range(m)",
"range",
"m",
"a,b = map(lambda x:int(x) - 1, input().split())",
"a",
"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",
"b",
"nums[a] -=1",
"nums[a]",
"nums",
"a",
"1",
"nums[b] +=1",
"nums[b]",
"nums",
"b",
"1",
"if In[a]:\n In[b] = True\n ",
"In[a]",
"In",
"a",
"In[b] = True",
"In[b]",
"In",
"b",
"True",
"if nums[a] == 0:\n In[a] = False\n ",
"nums[a] == 0",
"nums[a]",
"nums",
"a",
"0",
"In[a] = False",
"In[a]",
"In",
"a",
"False",
"cnt = 0",
"cnt",
"0",
"for i in range(n):\n if In[i]:\n cnt += 1\n ",
"i",
"range(n)",
"range",
"n",
"if In[i]:\n cnt += 1\n ",
"In[i]",
"In",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"mod = 10**9 + 7",
"10**9 + 7",
"mod",
"def readInts():\n return list(map(int,input().split()))",
"def readInts():\n return list(map(int,input().split()))",
"readInts",
"def main():\n n,m = readInts()\n # 数が入っているのと、\n # 箱の中が0かどうかを判別するものを定義する\n # 全部まず1個入ってる\n # 赤は最初だけ!!!!!!!!\n nums = [1] * n\n In = [False] * n\n In[0] = True\n for i in range(m):\n a,b = map(lambda x:int(x) - 1, input().split())\n nums[a] -=1\n nums[b] +=1\n if In[a]:\n In[b] = True\n if nums[a] == 0:\n In[a] = False\n cnt = 0\n #print(In)\n for i in range(n):\n if In[i]:\n cnt += 1\n print(cnt)",
"def main():\n n,m = readInts()\n # 数が入っているのと、\n # 箱の中が0かどうかを判別するものを定義する\n # 全部まず1個入ってる\n # 赤は最初だけ!!!!!!!!\n nums = [1] * n\n In = [False] * n\n In[0] = True\n for i in range(m):\n a,b = map(lambda x:int(x) - 1, input().split())\n nums[a] -=1\n nums[b] +=1\n if In[a]:\n In[b] = True\n if nums[a] == 0:\n In[a] = False\n cnt = 0\n #print(In)\n for i in range(n):\n if In[i]:\n cnt += 1\n print(cnt)",
"main"
] | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int,input().split()))
def main():
n,m = readInts()
# 数が入っているのと、
# 箱の中が0かどうかを判別するものを定義する
# 全部まず1個入ってる
# 赤は最初だけ!!!!!!!!
nums = [1] * n
In = [False] * n
In[0] = True
for i in range(m):
a,b = map(lambda x:int(x) - 1, input().split())
nums[a] -=1
nums[b] +=1
if In[a]:
In[b] = True
if nums[a] == 0:
In[a] = False
cnt = 0
#print(In)
for i in range(n):
if In[i]:
cnt += 1
print(cnt)
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
39,
17,
17,
0,
13,
13,
0,
18,
13,
17,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
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,
4,
13,
17,
2,
13,
17,
14,
2,
18,
18,
13,
13,
17,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] | [
[
134,
2
],
[
134,
11
],
[
15,
14
],
[
135,
19
],
[
14,
22
],
[
128,
27
],
[
33,
30
],
[
129,
31
],
[
38,
37
],
[
123,
40
],
[
137,
42
],
[
137,
51
],
[
129,
56
],
[
132,
57
],
[
66,
61
],
[
129,
63
],
[
138,
64
],
[
73,
68
],
[
129,
70
],
[
138,
71
],
[
80,
75
],
[
129,
77
],
[
132,
78
],
[
129,
85
],
[
132,
86
],
[
95,
90
],
[
129,
92
],
[
132,
93
],
[
125,
97
],
[
101,
100
],
[
135,
105
],
[
129,
111
],
[
100,
112
],
[
140,
116
],
[
141,
120
],
[
126,
120
],
[
134,
123
],
[
125,
126
],
[
128,
129
],
[
137,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
]
] | [
"N,M = map(int,input().split())\nC = {i:[0,1] for i in range(1,N+1)}\nC[1] = [1,1]\nfor _ in range(M):\n x,y = map(int,input().split())\n if C[x][0]==1:\n C[y][0]=1\n C[y][1] += 1\n C[x][1] -= 1\n if C[x][1]==0:\n C[x][0]=0\ncnt = 0\nfor i in range(1,N+1):\n if C[i][0]==1:\n cnt += 1\nprint(cnt)",
"N,M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"i:[0,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",
"[0,1]",
"0",
"1",
"C = {i:[0,1] for i in range(1,N+1)}",
"C",
"{i:[0,1] for i in range(1,N+1)}",
"C[1] = [1,1]",
"C[1]",
"C",
"1",
"[1,1]",
"1",
"1",
"for _ in range(M):\n x,y = map(int,input().split())\n if C[x][0]==1:\n C[y][0]=1\n C[y][1] += 1\n C[x][1] -= 1\n if C[x][1]==0:\n C[x][0]=0",
"_",
"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][0]==1:\n C[y][0]=1\n ",
"C[x][0]==1",
"C[x][0]",
"[x]",
"C",
"x",
"0",
"1",
"C[y][0]=1",
"C[y][0]",
"[y]",
"C",
"y",
"0",
"1",
"C[y][1] += 1",
"C[y][1]",
"[y]",
"C",
"y",
"1",
"1",
"C[x][1] -= 1",
"C[x][1]",
"[x]",
"C",
"x",
"1",
"1",
"if C[x][1]==0:\n C[x][0]=0",
"C[x][1]==0",
"C[x][1]",
"[x]",
"C",
"x",
"1",
"0",
"C[x][0]=0",
"C[x][0]",
"[x]",
"C",
"x",
"0",
"0",
"cnt = 0",
"cnt",
"0",
"for i in range(1,N+1):\n if C[i][0]==1:\n cnt += 1",
"i",
"range(1,N+1)",
"range",
"1",
"N+1",
"N",
"1",
"if C[i][0]==1:\n cnt += 1",
"C[i][0]==1",
"C[i][0]",
"[i]",
"C",
"i",
"0",
"1",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"M = map(int,input().split())",
"map(int,input().split())",
"M",
"cnt = 0",
"0",
"cnt",
"C = {i:[0,1] for i in range(1,N+1)}",
"{i:[0,1] for i in range(1,N+1)}",
"C",
"x,y = map(int,input().split())",
"map(int,input().split())",
"x",
"N,M = map(int,input().split())",
"map(int,input().split())",
"N",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"cnt += 1",
"1",
"cnt"
] | N,M = map(int,input().split())
C = {i:[0,1] for i in range(1,N+1)}
C[1] = [1,1]
for _ in range(M):
x,y = map(int,input().split())
if C[x][0]==1:
C[y][0]=1
C[y][1] += 1
C[x][1] -= 1
if C[x][1]==0:
C[x][0]=0
cnt = 0
for i in range(1,N+1):
if C[i][0]==1:
cnt += 1
print(cnt) |
[
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,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
2,
18,
18,
13,
13,
17,
17,
0,
13,
2,
18,
18,
13,
13,
17,
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,
0,
13,
4,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13
] | [
[
147,
2
],
[
147,
11
],
[
15,
14
],
[
148,
17
],
[
153,
30
],
[
35,
34
],
[
136,
37
],
[
156,
41
],
[
47,
44
],
[
157,
45
],
[
51,
50
],
[
136,
53
],
[
141,
57
],
[
61,
60
],
[
148,
63
],
[
144,
65
],
[
154,
69
],
[
60,
70
],
[
138,
74
],
[
154,
78
],
[
60,
79
],
[
110,
84
],
[
157,
85
],
[
145,
86
],
[
92,
89
],
[
157,
90
],
[
139,
91
],
[
97,
94
],
[
142,
95
],
[
145,
96
],
[
102,
99
],
[
142,
100
],
[
139,
101
],
[
94,
105
],
[
115,
105
],
[
142,
106
],
[
145,
107
],
[
113,
110
],
[
157,
111
],
[
145,
112
],
[
118,
115
],
[
142,
116
],
[
145,
117
],
[
123,
120
],
[
142,
121
],
[
139,
122
],
[
150,
125
],
[
157,
128
],
[
151,
133
],
[
147,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
]
] | [
"N,M = map(int,input().split())\n\nmoves = [list(map(int,input().split())) for i in range(M)]\nisRed = [False for i in range(N)]\nisRed[0] = True\nBall = [1 for i in range(N)]\n\nfor i in range(M):\n p = moves[i][0] - 1\n q = moves[i][1] - 1\n\n if isRed[p] == True:\n isRed[q] = True\n Ball[p] -= 1\n Ball[q] += 1\n if Ball[p] < 1:\n isRed[p] = False\n \n else:\n Ball[p] -= 1\n Ball[q] += 1\n \nans = isRed.count(True)\n\nprint(ans)",
"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",
"moves = [list(map(int,input().split())) for i in range(M)]",
"moves",
"[list(map(int,input().split())) for i in range(M)]",
"False for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"False",
"isRed = [False for i in range(N)]",
"isRed",
"[False for i in range(N)]",
"isRed[0] = True",
"isRed[0]",
"isRed",
"0",
"True",
"1 for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"1",
"Ball = [1 for i in range(N)]",
"Ball",
"[1 for i in range(N)]",
"for i in range(M):\n p = moves[i][0] - 1\n q = moves[i][1] - 1\n\n if isRed[p] == True:\n isRed[q] = True\n Ball[p] -= 1\n Ball[q] += 1\n if Ball[p] < 1:\n isRed[p] = False\n \n else:\n Ball[p] -= 1\n Ball[q] += 1\n ",
"i",
"range(M)",
"range",
"M",
"p = moves[i][0] - 1",
"p",
"moves[i][0] - 1",
"moves[i][0]",
"[i]",
"moves",
"i",
"0",
"1",
"q = moves[i][1] - 1",
"q",
"moves[i][1] - 1",
"moves[i][1]",
"[i]",
"moves",
"i",
"1",
"1",
"if isRed[p] == True:\n isRed[q] = True\n Ball[p] -= 1\n Ball[q] += 1\n if Ball[p] < 1:\n isRed[p] = False\n \n else:\n Ball[p] -= 1\n Ball[q] += 1\n ",
"isRed[p] == True",
"isRed[p]",
"isRed",
"p",
"True",
"isRed[q] = True",
"isRed[q]",
"isRed",
"q",
"True",
"Ball[p] -= 1",
"Ball[p]",
"Ball",
"p",
"1",
"Ball[q] += 1",
"Ball[q]",
"Ball",
"q",
"1",
"if Ball[p] < 1:\n isRed[p] = False\n \n ",
"Ball[p] < 1",
"Ball[p]",
"Ball",
"p",
"1",
"isRed[p] = False",
"isRed[p]",
"isRed",
"p",
"False",
"Ball[p] -= 1",
"Ball[p]",
"Ball",
"p",
"1",
"Ball[q] += 1",
"Ball[q]",
"Ball",
"q",
"1",
"ans = isRed.count(True)",
"ans",
"isRed.count(True)",
"isRed.count",
"isRed",
"count",
"True",
"print(ans)",
"print",
"ans",
"N,M = map(int,input().split())",
"map(int,input().split())",
"N",
"q = moves[i][1] - 1",
"moves[i][1] - 1",
"q",
"Ball = [1 for i in range(N)]",
"[1 for i in range(N)]",
"Ball",
"p = moves[i][0] - 1",
"moves[i][0] - 1",
"p",
"M = map(int,input().split())",
"map(int,input().split())",
"M",
"ans = isRed.count(True)",
"isRed.count(True)",
"ans",
"moves = [list(map(int,input().split())) for i in range(M)]",
"[list(map(int,input().split())) for i in range(M)]",
"moves",
"isRed = [False for i in range(N)]",
"[False for i in range(N)]",
"isRed"
] | N,M = map(int,input().split())
moves = [list(map(int,input().split())) for i in range(M)]
isRed = [False for i in range(N)]
isRed[0] = True
Ball = [1 for i in range(N)]
for i in range(M):
p = moves[i][0] - 1
q = moves[i][1] - 1
if isRed[p] == True:
isRed[q] = True
Ball[p] -= 1
Ball[q] += 1
if Ball[p] < 1:
isRed[p] = False
else:
Ball[p] -= 1
Ball[q] += 1
ans = isRed.count(True)
print(ans)
|
[
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,
28,
13,
4,
13,
13,
14,
2,
40,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
13,
17,
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
],
[
129,
128
],
[
4,
131
],
[
35,
136
],
[
128,
137
],
[
41,
141
],
[
128,
142
],
[
146,
145
],
[
145,
149
],
[
52,
149
],
[
158,
155
]
] | [
"#!/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 for i in range(N):\n if box[i] != 0 and red_flag[i] == 1:\n ans += 1\n print(ans)\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 for i in range(N):\n if box[i] != 0 and red_flag[i] == 1:\n ans += 1\n print(ans)",
"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",
"for i in range(N):\n if box[i] != 0 and red_flag[i] == 1:\n ans += 1\n ",
"i",
"range(N)",
"range",
"N",
"if box[i] != 0 and red_flag[i] == 1:\n ans += 1\n ",
"box[i] != 0 and red_flag[i] == 1",
"box[i] != 0",
"box[i]",
"box",
"i",
"0",
"red_flag[i] == 1",
"red_flag[i]",
"red_flag",
"i",
"1",
"ans += 1",
"ans",
"1",
"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 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 for i in range(N):\n if box[i] != 0 and red_flag[i] == 1:\n ans += 1\n print(ans)",
"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 for i in range(N):\n if box[i] != 0 and red_flag[i] == 1:\n ans += 1\n print(ans)",
"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
for i in range(N):
if box[i] != 0 and red_flag[i] == 1:
ans += 1
print(ans)
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,
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,
18,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13
] | [
[
104,
2
],
[
104,
11
],
[
107,
13
],
[
105,
17
],
[
101,
19
],
[
105,
23
],
[
28,
25
],
[
102,
26
],
[
31,
30
],
[
99,
33
],
[
92,
35
],
[
92,
44
],
[
95,
46
],
[
110,
49
],
[
55,
52
],
[
108,
53
],
[
96,
54
],
[
90,
54
],
[
60,
57
],
[
108,
58
],
[
111,
59
],
[
93,
59
],
[
102,
63
],
[
96,
64
],
[
90,
64
],
[
69,
66
],
[
102,
67
],
[
111,
68
],
[
93,
68
],
[
52,
72
],
[
108,
73
],
[
96,
74
],
[
90,
74
],
[
80,
77
],
[
102,
78
],
[
96,
79
],
[
90,
79
],
[
102,
85
],
[
92,
90
],
[
92,
93
],
[
95,
96
],
[
104,
99
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"N, M = map(int, input().split())\nball_cnt = [1] * N\nexist_red = [False] * N\nexist_red[0] = True\nfor _ in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n if exist_red[x]:\n exist_red[y] = True\n if ball_cnt[x] == 0:\n exist_red[x] = False\nprint(exist_red.count(True))",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"ball_cnt = [1] * N",
"ball_cnt",
"[1] * N",
"[1]",
"1",
"N",
"exist_red = [False] * N",
"exist_red",
"[False] * N",
"[False]",
"False",
"N",
"exist_red[0] = True",
"exist_red[0]",
"exist_red",
"0",
"True",
"for _ in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n if exist_red[x]:\n exist_red[y] = True\n if ball_cnt[x] == 0:\n exist_red[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",
"ball_cnt[x] -= 1",
"ball_cnt[x]",
"ball_cnt",
"x",
"1",
"ball_cnt[y] += 1",
"ball_cnt[y]",
"ball_cnt",
"y",
"1",
"if exist_red[x]:\n exist_red[y] = True\n ",
"exist_red[x]",
"exist_red",
"x",
"exist_red[y] = True",
"exist_red[y]",
"exist_red",
"y",
"True",
"if ball_cnt[x] == 0:\n exist_red[x] = False",
"ball_cnt[x] == 0",
"ball_cnt[x]",
"ball_cnt",
"x",
"0",
"exist_red[x] = False",
"exist_red[x]",
"exist_red",
"x",
"False",
"print(exist_red.count(True))",
"print",
"exist_red.count(True)",
"exist_red.count",
"exist_red",
"count",
"True",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"x -= 1",
"1",
"x",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"exist_red = [False] * N",
"[False] * N",
"exist_red",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"ball_cnt = [1] * N",
"[1] * N",
"ball_cnt",
"y -= 1",
"1",
"y"
] | N, M = map(int, input().split())
ball_cnt = [1] * N
exist_red = [False] * N
exist_red[0] = True
for _ in range(M):
x, y = map(int, input().split())
x -= 1
y -= 1
ball_cnt[x] -= 1
ball_cnt[y] += 1
if exist_red[x]:
exist_red[y] = True
if ball_cnt[x] == 0:
exist_red[x] = False
print(exist_red.count(True))
|
[
7,
15,
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,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
13,
28,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
40,
18,
13,
13,
0,
18,
13,
13,
17,
0,
13,
4,
13,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
18,
13,
10,
18,
13
] | [
[
118,
4
],
[
121,
11
],
[
21,
20
],
[
21,
29
],
[
32,
31
],
[
20,
36
],
[
40,
39
],
[
20,
44
],
[
50,
47
],
[
39,
48
],
[
53,
52
],
[
119,
59
],
[
63,
62
],
[
52,
65
],
[
29,
65
],
[
52,
66
],
[
29,
66
],
[
39,
73
],
[
79,
76
],
[
39,
77
],
[
84,
81
],
[
31,
82
],
[
89,
86
],
[
31,
87
],
[
86,
92
],
[
31,
93
],
[
99,
96
],
[
39,
97
],
[
102,
101
],
[
39,
104
],
[
101,
107
],
[
116,
113
],
[
118,
119
],
[
121,
122
]
] | [
"import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n n, m = map(int, input().split())\n balls = [1] * (n + 1)\n posib = [0] * (n + 1)\n posib[1] = 1\n m = map(int, read().split())\n ab = zip(m, m)\n for x, y in ab:\n if posib[x]:\n posib[y] = 1\n balls[y] += 1\n balls[x] -= 1\n if not balls[x]:\n posib[x] = 0\n r = sum(posib)\n print(r)\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"read = sys.stdin.read",
"read",
"sys.stdin.read",
"sys.stdin",
"sys",
"stdin",
"read",
"readlines = sys.stdin.readlines",
"readlines",
"sys.stdin.readlines",
"sys.stdin",
"sys",
"stdin",
"readlines",
"def main():\n n, m = map(int, input().split())\n balls = [1] * (n + 1)\n posib = [0] * (n + 1)\n posib[1] = 1\n m = map(int, read().split())\n ab = zip(m, m)\n for x, y in ab:\n if posib[x]:\n posib[y] = 1\n balls[y] += 1\n balls[x] -= 1\n if not balls[x]:\n posib[x] = 0\n r = sum(posib)\n print(r)",
"main",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"balls = [1] * (n + 1)",
"balls",
"[1] * (n + 1)",
"[1]",
"1",
"n + 1",
"n",
"1",
"posib = [0] * (n + 1)",
"posib",
"[0] * (n + 1)",
"[0]",
"0",
"n + 1",
"n",
"1",
"posib[1] = 1",
"posib[1]",
"posib",
"1",
"1",
"m = map(int, read().split())",
"m",
"map(int, read().split())",
"map",
"int",
"read().split()",
"().split",
"()",
"read",
"split",
"ab = zip(m, m)",
"ab",
"zip(m, m)",
"zip",
"m",
"m",
"for x, y in ab:\n if posib[x]:\n posib[y] = 1\n balls[y] += 1\n balls[x] -= 1\n if not balls[x]:\n posib[x] = 0\n ",
"x",
"y",
"ab",
"if posib[x]:\n posib[y] = 1\n ",
"posib[x]",
"posib",
"x",
"posib[y] = 1",
"posib[y]",
"posib",
"y",
"1",
"balls[y] += 1",
"balls[y]",
"balls",
"y",
"1",
"balls[x] -= 1",
"balls[x]",
"balls",
"x",
"1",
"if not balls[x]:\n posib[x] = 0\n ",
"not balls[x]",
"balls[x]",
"balls",
"x",
"posib[x] = 0",
"posib[x]",
"posib",
"x",
"0",
"r = sum(posib)",
"r",
"sum(posib)",
"sum",
"posib",
"print(r)",
"print",
"r",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n n, m = map(int, input().split())\n balls = [1] * (n + 1)\n posib = [0] * (n + 1)\n posib[1] = 1\n m = map(int, read().split())\n ab = zip(m, m)\n for x, y in ab:\n if posib[x]:\n posib[y] = 1\n balls[y] += 1\n balls[x] -= 1\n if not balls[x]:\n posib[x] = 0\n r = sum(posib)\n print(r)",
"def main():\n n, m = map(int, input().split())\n balls = [1] * (n + 1)\n posib = [0] * (n + 1)\n posib[1] = 1\n m = map(int, read().split())\n ab = zip(m, m)\n for x, y in ab:\n if posib[x]:\n posib[y] = 1\n balls[y] += 1\n balls[x] -= 1\n if not balls[x]:\n posib[x] = 0\n r = sum(posib)\n print(r)",
"main",
"read = sys.stdin.read",
"sys.stdin.read",
"read",
"readlines = sys.stdin.readlines",
"sys.stdin.readlines",
"readlines"
] | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
n, m = map(int, input().split())
balls = [1] * (n + 1)
posib = [0] * (n + 1)
posib[1] = 1
m = map(int, read().split())
ab = zip(m, m)
for x, y in ab:
if posib[x]:
posib[y] = 1
balls[y] += 1
balls[x] -= 1
if not balls[x]:
posib[x] = 0
r = sum(posib)
print(r)
if __name__ == '__main__':
main() |
[
7,
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,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
14,
18,
13,
2,
18,
13,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
14,
2,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
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,
39,
13
] | [
[
131,
2
],
[
131,
11
],
[
134,
13
],
[
17,
16
],
[
120,
19
],
[
122,
21
],
[
135,
34
],
[
123,
36
],
[
125,
38
],
[
132,
42
],
[
47,
44
],
[
126,
45
],
[
128,
49
],
[
132,
53
],
[
56,
55
],
[
135,
55
],
[
65,
58
],
[
129,
59
],
[
55,
62
],
[
74,
67
],
[
129,
68
],
[
55,
71
],
[
126,
77
],
[
55,
80
],
[
91,
84
],
[
126,
85
],
[
55,
88
],
[
129,
95
],
[
55,
98
],
[
110,
103
],
[
126,
104
],
[
55,
107
],
[
126,
115
],
[
131,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
]
] | [
"n, m = map(int,input().split())\nall_li = []\nfor _ in range(m):\n li = list(map(int,input().split()))\n all_li.append(li)\n#print(all_li)\nflag_memo = [False]*n\nflag_memo[0] = True\n#print(flag_memo)\nkazu_li = [1]*n\n#print(kazu_li)\n\nfor a in all_li:\n kazu_li[a[0]-1] -= 1\n kazu_li[a[1]-1] += 1\n if flag_memo[a[0]-1]:\n flag_memo[a[1]-1] = True\n if kazu_li[a[0]-1] == 0:\n flag_memo[a[0]-1] = False\nprint(flag_memo.count(True))",
"n, m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"all_li = []",
"all_li",
"[]",
"for _ in range(m):\n li = list(map(int,input().split()))\n all_li.append(li)\n#print(all_li)",
"_",
"range(m)",
"range",
"m",
"li = list(map(int,input().split()))",
"li",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"all_li.append(li)",
"all_li.append",
"all_li",
"append",
"li",
"flag_memo = [False]*n",
"flag_memo",
"[False]*n",
"[False]",
"False",
"n",
"flag_memo[0] = True",
"flag_memo[0]",
"flag_memo",
"0",
"True",
"kazu_li = [1]*n",
"kazu_li",
"[1]*n",
"[1]",
"1",
"n",
"for a in all_li:\n kazu_li[a[0]-1] -= 1\n kazu_li[a[1]-1] += 1\n if flag_memo[a[0]-1]:\n flag_memo[a[1]-1] = True\n if kazu_li[a[0]-1] == 0:\n flag_memo[a[0]-1] = False",
"a",
"all_li",
"kazu_li[a[0]-1] -= 1",
"kazu_li[a[0]-1]",
"kazu_li",
"a[0]-1",
"a[0]",
"a",
"0",
"1",
"1",
"kazu_li[a[1]-1] += 1",
"kazu_li[a[1]-1]",
"kazu_li",
"a[1]-1",
"a[1]",
"a",
"1",
"1",
"1",
"if flag_memo[a[0]-1]:\n flag_memo[a[1]-1] = True\n ",
"flag_memo[a[0]-1]",
"flag_memo",
"a[0]-1",
"a[0]",
"a",
"0",
"1",
"flag_memo[a[1]-1] = True",
"flag_memo[a[1]-1]",
"flag_memo",
"a[1]-1",
"a[1]",
"a",
"1",
"1",
"True",
"if kazu_li[a[0]-1] == 0:\n flag_memo[a[0]-1] = False",
"kazu_li[a[0]-1] == 0",
"kazu_li[a[0]-1]",
"kazu_li",
"a[0]-1",
"a[0]",
"a",
"0",
"1",
"0",
"flag_memo[a[0]-1] = False",
"flag_memo[a[0]-1]",
"flag_memo",
"a[0]-1",
"a[0]",
"a",
"0",
"1",
"False",
"print(flag_memo.count(True))",
"print",
"flag_memo.count(True)",
"flag_memo.count",
"flag_memo",
"count",
"True",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"li = list(map(int,input().split()))",
"list(map(int,input().split()))",
"li",
"flag_memo = [False]*n",
"[False]*n",
"flag_memo",
"kazu_li = [1]*n",
"[1]*n",
"kazu_li",
"n, m = map(int,input().split())",
"map(int,input().split())",
"n",
"all_li = []",
"[]",
"all_li"
] | n, m = map(int,input().split())
all_li = []
for _ in range(m):
li = list(map(int,input().split()))
all_li.append(li)
#print(all_li)
flag_memo = [False]*n
flag_memo[0] = True
#print(flag_memo)
kazu_li = [1]*n
#print(kazu_li)
for a in all_li:
kazu_li[a[0]-1] -= 1
kazu_li[a[1]-1] += 1
if flag_memo[a[0]-1]:
flag_memo[a[1]-1] = True
if kazu_li[a[0]-1] == 0:
flag_memo[a[0]-1] = False
print(flag_memo.count(True)) |
[
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,
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,
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,
29,
4,
13,
13,
4,
13,
4,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
176,
11
],
[
161,
22
],
[
173,
37
],
[
162,
42
],
[
164,
44
],
[
155,
56
],
[
69,
68
],
[
170,
77
],
[
162,
79
],
[
170,
80
],
[
85,
84
],
[
171,
88
],
[
93,
90
],
[
84,
91
],
[
96,
95
],
[
171,
99
],
[
102,
101
],
[
159,
104
],
[
107,
106
],
[
162,
108
],
[
107,
109
],
[
112,
111
],
[
115,
114
],
[
84,
118
],
[
111,
119
],
[
106,
119
],
[
124,
121
],
[
84,
122
],
[
114,
123
],
[
109,
123
],
[
129,
126
],
[
95,
127
],
[
111,
128
],
[
106,
128
],
[
134,
131
],
[
95,
132
],
[
114,
133
],
[
109,
133
],
[
126,
137
],
[
95,
138
],
[
111,
139
],
[
106,
139
],
[
145,
142
],
[
84,
143
],
[
111,
144
],
[
106,
144
],
[
84,
149
],
[
168,
153
],
[
155,
156
],
[
170,
159
],
[
161,
162
],
[
164,
165
],
[
170,
171
],
[
173,
174
],
[
176,
177
]
] | [
"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 r = [False] * N\n r[0] = True\n cnt = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if r[x]:\n r[y] = True\n cnt[x] -= 1\n cnt[y] += 1\n if cnt[x] == 0:\n r[x] = False\n\n return sum(r)\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 r = [False] * N\n r[0] = True\n cnt = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if r[x]:\n r[y] = True\n cnt[x] -= 1\n cnt[y] += 1\n if cnt[x] == 0:\n r[x] = False\n\n return sum(r)",
"solve",
"r = [False] * N",
"r",
"[False] * N",
"[False]",
"False",
"N",
"r[0] = True",
"r[0]",
"r",
"0",
"True",
"cnt = [1] * N",
"cnt",
"[1] * N",
"[1]",
"1",
"N",
"for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if r[x]:\n r[y] = True\n cnt[x] -= 1\n cnt[y] += 1\n if cnt[x] == 0:\n r[x] = False\n\n ",
"i",
"range(M)",
"range",
"M",
"x, y = inm()",
"x",
"inm()",
"inm",
"y",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if r[x]:\n r[y] = True\n ",
"r[x]",
"r",
"x",
"r[y] = True",
"r[y]",
"r",
"y",
"True",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"if cnt[x] == 0:\n r[x] = False\n\n ",
"cnt[x] == 0",
"cnt[x]",
"cnt",
"x",
"0",
"r[x] = False",
"r[x]",
"r",
"x",
"False",
"return sum(r)",
"sum(r)",
"sum",
"r",
"print(solve())",
"print",
"solve()",
"solve",
"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",
"inm = lambda: map(int, sys.stdin.readline().split())",
"lambda: map(int, sys.stdin.readline().split())",
"inm",
"ins = lambda: sys.stdin.readline().rstrip()",
"lambda: sys.stdin.readline().rstrip()",
"ins",
"def solve():\n r = [False] * N\n r[0] = True\n cnt = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if r[x]:\n r[y] = True\n cnt[x] -= 1\n cnt[y] += 1\n if cnt[x] == 0:\n r[x] = False\n\n return sum(r)",
"def solve():\n r = [False] * N\n r[0] = True\n cnt = [1] * N\n for i in range(M):\n x, y = inm()\n x -= 1\n y -= 1\n if r[x]:\n r[y] = True\n cnt[x] -= 1\n cnt[y] += 1\n if cnt[x] == 0:\n r[x] = False\n\n return sum(r)",
"solve",
"N, M = inm()",
"inm()",
"N",
"inl = lambda: list(inm())",
"lambda: list(inm())",
"inl",
"ini = lambda: int(sys.stdin.readline())",
"lambda: int(sys.stdin.readline())",
"ini"
] | 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():
r = [False] * N
r[0] = True
cnt = [1] * N
for i in range(M):
x, y = inm()
x -= 1
y -= 1
if r[x]:
r[y] = True
cnt[x] -= 1
cnt[y] += 1
if cnt[x] == 0:
r[x] = False
return sum(r)
print(solve())
|
[
7,
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,
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,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
4,
19
],
[
22,
21
],
[
4,
25
],
[
30,
27
],
[
21,
28
],
[
33,
32
],
[
13,
35
],
[
38,
37
],
[
38,
52
],
[
57,
54
],
[
15,
55
],
[
37,
56
],
[
62,
59
],
[
15,
60
],
[
52,
61
],
[
21,
65
],
[
37,
66
],
[
71,
68
],
[
21,
69
],
[
52,
70
],
[
54,
74
],
[
15,
75
],
[
37,
76
],
[
82,
79
],
[
21,
80
],
[
37,
81
],
[
21,
87
],
[
92,
89
]
] | [
"def resolve():\n n, m = map(int, input().split())\n\n num_balls = [1] * n\n red_prov = [False] * n\n red_prov[0] = True\n\n for _ in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n\n # リストnum_ballsを更新\n num_balls[x] -= 1\n num_balls[y] += 1\n\n # リストred_provを更新\n if red_prov[x]:\n red_prov[y] = True\n\n if num_balls[x] == 0:\n red_prov[x] = False\n\n print(sum(red_prov))\n \nresolve()",
"def resolve():\n n, m = map(int, input().split())\n\n num_balls = [1] * n\n red_prov = [False] * n\n red_prov[0] = True\n\n for _ in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n\n # リストnum_ballsを更新\n num_balls[x] -= 1\n num_balls[y] += 1\n\n # リストred_provを更新\n if red_prov[x]:\n red_prov[y] = True\n\n if num_balls[x] == 0:\n red_prov[x] = False\n\n print(sum(red_prov))\n ",
"resolve",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"num_balls = [1] * n",
"num_balls",
"[1] * n",
"[1]",
"1",
"n",
"red_prov = [False] * n",
"red_prov",
"[False] * n",
"[False]",
"False",
"n",
"red_prov[0] = True",
"red_prov[0]",
"red_prov",
"0",
"True",
"for _ in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n\n # リストnum_ballsを更新\n num_balls[x] -= 1\n num_balls[y] += 1\n\n # リストred_provを更新\n if red_prov[x]:\n red_prov[y] = True\n\n if num_balls[x] == 0:\n red_prov[x] = False\n\n ",
"_",
"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",
"num_balls[x] -= 1",
"num_balls[x]",
"num_balls",
"x",
"1",
"num_balls[y] += 1",
"num_balls[y]",
"num_balls",
"y",
"1",
"if red_prov[x]:\n red_prov[y] = True\n\n ",
"red_prov[x]",
"red_prov",
"x",
"red_prov[y] = True",
"red_prov[y]",
"red_prov",
"y",
"True",
"if num_balls[x] == 0:\n red_prov[x] = False\n\n ",
"num_balls[x] == 0",
"num_balls[x]",
"num_balls",
"x",
"0",
"red_prov[x] = False",
"red_prov[x]",
"red_prov",
"x",
"False",
"print(sum(red_prov))",
"print",
"sum(red_prov)",
"sum",
"red_prov",
"resolve()",
"resolve",
"def resolve():\n n, m = map(int, input().split())\n\n num_balls = [1] * n\n red_prov = [False] * n\n red_prov[0] = True\n\n for _ in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n\n # リストnum_ballsを更新\n num_balls[x] -= 1\n num_balls[y] += 1\n\n # リストred_provを更新\n if red_prov[x]:\n red_prov[y] = True\n\n if num_balls[x] == 0:\n red_prov[x] = False\n\n print(sum(red_prov))\n ",
"def resolve():\n n, m = map(int, input().split())\n\n num_balls = [1] * n\n red_prov = [False] * n\n red_prov[0] = True\n\n for _ in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\n\n # リストnum_ballsを更新\n num_balls[x] -= 1\n num_balls[y] += 1\n\n # リストred_provを更新\n if red_prov[x]:\n red_prov[y] = True\n\n if num_balls[x] == 0:\n red_prov[x] = False\n\n print(sum(red_prov))\n ",
"resolve"
] | def resolve():
n, m = map(int, input().split())
num_balls = [1] * n
red_prov = [False] * n
red_prov[0] = True
for _ in range(m):
x, y = map(lambda x: int(x) - 1, input().split())
# リストnum_ballsを更新
num_balls[x] -= 1
num_balls[y] += 1
# リストred_provを更新
if red_prov[x]:
red_prov[y] = True
if num_balls[x] == 0:
red_prov[x] = False
print(sum(red_prov))
resolve() |
[
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,
17,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
14,
2,
40,
18,
13,
2,
18,
13,
17,
17,
17,
2,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
14,
2,
2,
18,
13,
2,
18,
13,
17,
17,
17,
2,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
0,
18,
13,
2,
18,
13,
17,
17,
17,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] | [
[
193,
2
],
[
193,
11
],
[
15,
14
],
[
188,
17
],
[
190,
30
],
[
196,
33
],
[
184,
36
],
[
194,
44
],
[
199,
47
],
[
194,
51
],
[
54,
53
],
[
191,
53
],
[
200,
59
],
[
53,
62
],
[
185,
68
],
[
53,
71
],
[
83,
76
],
[
185,
77
],
[
53,
80
],
[
92,
85
],
[
200,
86
],
[
53,
89
],
[
101,
94
],
[
200,
95
],
[
53,
98
],
[
200,
106
],
[
53,
109
],
[
185,
115
],
[
53,
118
],
[
130,
123
],
[
185,
124
],
[
53,
127
],
[
139,
132
],
[
185,
133
],
[
53,
136
],
[
148,
141
],
[
200,
142
],
[
53,
145
],
[
157,
150
],
[
200,
151
],
[
53,
154
],
[
166,
159
],
[
200,
160
],
[
53,
163
],
[
175,
168
],
[
200,
169
],
[
53,
172
],
[
185,
180
],
[
184,
185
],
[
193,
188
],
[
190,
191
],
[
193,
194
],
[
196,
197
],
[
199,
200
]
] | [
"# diff 693\nn, m = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(m)]\n# indに気を付ける\nans = 0\n\n# judについて0:red 1:white\njud = [0] + [1] * (n - 1)\nnum = [1] * n\n\nfor i in xy:\n if num[i[0] - 1] >= 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n elif num[i[0] - 1] < 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n jud[i[0] - 1] = 1\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n else:\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n\nprint(jud.count(0))",
"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)]",
"ans = 0",
"ans",
"0",
"jud = [0] + [1] * (n - 1)",
"jud",
"[0] + [1] * (n - 1)",
"[0]",
"0",
"[1] * (n - 1)",
"[1]",
"1",
"n - 1",
"n",
"1",
"num = [1] * n",
"num",
"[1] * n",
"[1]",
"1",
"n",
"for i in xy:\n if num[i[0] - 1] >= 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n elif num[i[0] - 1] < 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n jud[i[0] - 1] = 1\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n else:\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1",
"i",
"xy",
"if num[i[0] - 1] >= 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n elif num[i[0] - 1] < 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n jud[i[0] - 1] = 1\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n else:\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1",
"num[i[0] - 1] >= 2 and jud[i[0] - 1] == 0",
"num[i[0] - 1] >= 2",
"num[i[0] - 1]",
"num",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"2",
"jud[i[0] - 1] == 0",
"jud[i[0] - 1]",
"jud",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"0",
"jud[i[1] - 1] = 0",
"jud[i[1] - 1]",
"jud",
"i[1] - 1",
"i[1]",
"i",
"1",
"1",
"0",
"num[i[0] - 1] -= 1",
"num[i[0] - 1]",
"num",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"1",
"num[i[1] - 1] += 1",
"num[i[1] - 1]",
"num",
"i[1] - 1",
"i[1]",
"i",
"1",
"1",
"1",
"elif num[i[0] - 1] < 2 and jud[i[0] - 1] == 0:\n jud[i[1] - 1] = 0\n jud[i[0] - 1] = 1\n num[i[0] - 1] -= 1\n num[i[1] - 1] += 1\n ",
"num[i[0] - 1] < 2 and jud[i[0] - 1] == 0",
"num[i[0] - 1] < 2",
"num[i[0] - 1]",
"num",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"2",
"jud[i[0] - 1] == 0",
"jud[i[0] - 1]",
"jud",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"0",
"jud[i[1] - 1] = 0",
"jud[i[1] - 1]",
"jud",
"i[1] - 1",
"i[1]",
"i",
"1",
"1",
"0",
"jud[i[0] - 1] = 1",
"jud[i[0] - 1]",
"jud",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"1",
"num[i[0] - 1] -= 1",
"num[i[0] - 1]",
"num",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"1",
"num[i[1] - 1] += 1",
"num[i[1] - 1]",
"num",
"i[1] - 1",
"i[1]",
"i",
"1",
"1",
"1",
"num[i[0] - 1] -= 1",
"num[i[0] - 1]",
"num",
"i[0] - 1",
"i[0]",
"i",
"0",
"1",
"1",
"num[i[1] - 1] += 1",
"num[i[1] - 1]",
"num",
"i[1] - 1",
"i[1]",
"i",
"1",
"1",
"1",
"print(jud.count(0))",
"print",
"jud.count(0)",
"jud.count",
"jud",
"count",
"0",
"jud = [0] + [1] * (n - 1)",
"[0] + [1] * (n - 1)",
"jud",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"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",
"ans = 0",
"0",
"ans",
"num = [1] * n",
"[1] * n",
"num"
] | # diff 693
n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
# indに気を付ける
ans = 0
# judについて0:red 1:white
jud = [0] + [1] * (n - 1)
num = [1] * n
for i in xy:
if num[i[0] - 1] >= 2 and jud[i[0] - 1] == 0:
jud[i[1] - 1] = 0
num[i[0] - 1] -= 1
num[i[1] - 1] += 1
elif num[i[0] - 1] < 2 and jud[i[0] - 1] == 0:
jud[i[1] - 1] = 0
jud[i[0] - 1] = 1
num[i[0] - 1] -= 1
num[i[1] - 1] += 1
else:
num[i[0] - 1] -= 1
num[i[1] - 1] += 1
print(jud.count(0)) |
[
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,
4,
13,
13,
0,
13,
2,
18,
18,
13,
13,
17,
17,
0,
13,
2,
18,
18,
13,
13,
17,
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,
4,
13,
4,
18,
13,
13,
17,
10,
2,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13
] | [
[
125,
2
],
[
125,
11
],
[
15,
14
],
[
120,
17
],
[
113,
30
],
[
128,
33
],
[
126,
37
],
[
122,
39
],
[
126,
43
],
[
48,
45
],
[
123,
46
],
[
51,
50
],
[
120,
53
],
[
110,
55
],
[
114,
59
],
[
50,
60
],
[
116,
64
],
[
114,
68
],
[
50,
69
],
[
123,
74
],
[
111,
75
],
[
80,
77
],
[
123,
78
],
[
117,
79
],
[
98,
83
],
[
129,
84
],
[
111,
85
],
[
91,
88
],
[
123,
89
],
[
111,
90
],
[
96,
93
],
[
129,
94
],
[
117,
95
],
[
101,
98
],
[
129,
99
],
[
111,
100
],
[
123,
106
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
125,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
]
] | [
"n,m=map(int, input().split())\nxy=[list(map(int, input().split())) for _ in range(m)]\n\nball=[1]*n\nred=[False]*n\nred[0]=True\nfor i in range(m):\n x=xy[i][0]-1\n y=xy[i][1]-1\n if red[x]:\n red[y]=True\n if ball[x]==1:\n red[x]=False\n ball[y]+=1\n ball[x]-=1\nprint(red.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",
"xy=[list(map(int, input().split())) for _ in range(m)]",
"xy",
"[list(map(int, input().split())) for _ in range(m)]",
"ball=[1]*n",
"ball",
"[1]*n",
"[1]",
"1",
"n",
"red=[False]*n",
"red",
"[False]*n",
"[False]",
"False",
"n",
"red[0]=True",
"red[0]",
"red",
"0",
"True",
"for i in range(m):\n x=xy[i][0]-1\n y=xy[i][1]-1\n if red[x]:\n red[y]=True\n if ball[x]==1:\n red[x]=False\n ball[y]+=1\n ball[x]-=1",
"i",
"range(m)",
"range",
"m",
"x=xy[i][0]-1",
"x",
"xy[i][0]-1",
"xy[i][0]",
"[i]",
"xy",
"i",
"0",
"1",
"y=xy[i][1]-1",
"y",
"xy[i][1]-1",
"xy[i][1]",
"[i]",
"xy",
"i",
"1",
"1",
"if red[x]:\n red[y]=True\n if ball[x]==1:\n red[x]=False\n ",
"red[x]",
"red",
"x",
"red[y]=True",
"red[y]",
"red",
"y",
"True",
"if ball[x]==1:\n red[x]=False\n ",
"ball[x]==1",
"ball[x]",
"ball",
"x",
"1",
"red[x]=False",
"red[x]",
"red",
"x",
"False",
"ball[y]+=1",
"ball[y]",
"ball",
"y",
"1",
"ball[x]-=1",
"ball[x]",
"ball",
"x",
"1",
"print(red.count(True))",
"print",
"red.count(True)",
"red.count",
"red",
"count",
"True",
"x=xy[i][0]-1",
"xy[i][0]-1",
"x",
"xy=[list(map(int, input().split())) for _ in range(m)]",
"[list(map(int, input().split())) for _ in range(m)]",
"xy",
"y=xy[i][1]-1",
"xy[i][1]-1",
"y",
"m=map(int, input().split())",
"map(int, input().split())",
"m",
"red=[False]*n",
"[False]*n",
"red",
"n,m=map(int, input().split())",
"map(int, input().split())",
"n",
"ball=[1]*n",
"[1]*n",
"ball"
] | n,m=map(int, input().split())
xy=[list(map(int, input().split())) for _ in range(m)]
ball=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
x=xy[i][0]-1
y=xy[i][1]-1
if red[x]:
red[y]=True
if ball[x]==1:
red[x]=False
ball[y]+=1
ball[x]-=1
print(red.count(True))
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
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,
14,
2,
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,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
135,
4
],
[
144,
11
],
[
136,
18
],
[
144,
20
],
[
150,
22
],
[
142,
27
],
[
129,
30
],
[
142,
35
],
[
41,
38
],
[
130,
39
],
[
44,
43
],
[
145,
46
],
[
147,
48
],
[
136,
55
],
[
147,
57
],
[
130,
61
],
[
139,
62
],
[
68,
65
],
[
130,
66
],
[
148,
67
],
[
130,
73
],
[
139,
74
],
[
92,
77
],
[
151,
78
],
[
148,
79
],
[
85,
82
],
[
130,
83
],
[
148,
84
],
[
90,
87
],
[
151,
88
],
[
139,
89
],
[
95,
92
],
[
151,
93
],
[
148,
94
],
[
126,
97
],
[
101,
100
],
[
142,
105
],
[
151,
111
],
[
100,
112
],
[
130,
116
],
[
100,
117
],
[
132,
120
],
[
133,
124
],
[
127,
124
],
[
126,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
],
[
147,
139
],
[
144,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
]
] | [
"import sys\ninput = sys.stdin.readline\nn,m = map(int,input().split())\nhako = [1]*(n+1)\niro = ['white']*(n+1)\niro[1] = 'red'\n\nfor _ in range(m):\n \n x,y = map(int,input().split())\n if iro[x] == 'red':\n iro[y] ='red'\n elif iro[x] == 'white' and hako[y] == 0:\n iro[y] = 'white'\n hako[x] -= 1\n hako[y] += 1\nans = 0\nfor i in range(1,n+1):\n if hako[i] > 0 and iro[i] == 'red':\n ans += 1\nprint(ans)",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"hako = [1]*(n+1)",
"hako",
"[1]*(n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"iro = ['white']*(n+1)",
"iro",
"['white']*(n+1)",
"['white']",
"'white'",
"n+1",
"n",
"1",
"iro[1] = 'red'",
"iro[1]",
"iro",
"1",
"'red'",
"for _ in range(m):\n \n x,y = map(int,input().split())\n if iro[x] == 'red':\n iro[y] ='red'\n elif iro[x] == 'white' and hako[y] == 0:\n iro[y] = 'white'\n hako[x] -= 1\n hako[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 iro[x] == 'red':\n iro[y] ='red'\n elif iro[x] == 'white' and hako[y] == 0:\n iro[y] = 'white'\n ",
"iro[x] == 'red'",
"iro[x]",
"iro",
"x",
"'red'",
"iro[y] ='red'",
"iro[y]",
"iro",
"y",
"'red'",
"elif iro[x] == 'white' and hako[y] == 0:\n iro[y] = 'white'\n ",
"iro[x] == 'white' and hako[y] == 0",
"iro[x] == 'white'",
"iro[x]",
"iro",
"x",
"'white'",
"hako[y] == 0",
"hako[y]",
"hako",
"y",
"0",
"iro[y] = 'white'",
"iro[y]",
"iro",
"y",
"'white'",
"hako[x] -= 1",
"hako[x]",
"hako",
"x",
"1",
"hako[y] += 1",
"hako[y]",
"hako",
"y",
"1",
"ans = 0",
"ans",
"0",
"for i in range(1,n+1):\n if hako[i] > 0 and iro[i] == 'red':\n ans += 1",
"i",
"range(1,n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if hako[i] > 0 and iro[i] == 'red':\n ans += 1",
"hako[i] > 0 and iro[i] == 'red'",
"hako[i] > 0",
"hako[i]",
"hako",
"i",
"0",
"iro[i] == 'red'",
"iro[i]",
"iro",
"i",
"'red'",
"ans += 1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"ans = 0",
"0",
"ans",
"iro = ['white']*(n+1)",
"['white']*(n+1)",
"iro",
"ans += 1",
"1",
"ans",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"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",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"hako = [1]*(n+1)",
"[1]*(n+1)",
"hako"
] | import sys
input = sys.stdin.readline
n,m = map(int,input().split())
hako = [1]*(n+1)
iro = ['white']*(n+1)
iro[1] = 'red'
for _ in range(m):
x,y = map(int,input().split())
if iro[x] == 'red':
iro[y] ='red'
elif iro[x] == 'white' and hako[y] == 0:
iro[y] = 'white'
hako[x] -= 1
hako[y] += 1
ans = 0
for i in range(1,n+1):
if hako[i] > 0 and iro[i] == 'red':
ans += 1
print(ans) |
[
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,
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,
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,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
98,
2
],
[
98,
11
],
[
110,
13
],
[
99,
17
],
[
22,
19
],
[
111,
20
],
[
101,
24
],
[
99,
28
],
[
31,
30
],
[
96,
33
],
[
107,
35
],
[
107,
44
],
[
111,
48
],
[
108,
50
],
[
59,
54
],
[
111,
55
],
[
105,
57
],
[
102,
63
],
[
108,
65
],
[
74,
69
],
[
111,
70
],
[
108,
72
],
[
81,
76
],
[
102,
77
],
[
108,
79
],
[
88,
83
],
[
102,
84
],
[
105,
86
],
[
111,
93
],
[
98,
96
],
[
98,
99
],
[
101,
102
],
[
107,
105
],
[
107,
108
],
[
110,
111
]
] | [
"n, m = map(int, input().split())\n\nexist = [0] * n\nexist[0] = 1\ncnt = [1] * n\nfor i in range(m):\n x, y = map(int, input().split())\n if exist[x - 1] == 1:\n exist[y - 1] = 1\n if cnt[x - 1] == 1:\n exist[x - 1] = 0\n\n \n cnt[x - 1] -= 1\n cnt[y - 1] += 1\nprint(sum(exist))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"exist = [0] * n",
"exist",
"[0] * n",
"[0]",
"0",
"n",
"exist[0] = 1",
"exist[0]",
"exist",
"0",
"1",
"cnt = [1] * n",
"cnt",
"[1] * n",
"[1]",
"1",
"n",
"for i in range(m):\n x, y = map(int, input().split())\n if exist[x - 1] == 1:\n exist[y - 1] = 1\n if cnt[x - 1] == 1:\n exist[x - 1] = 0\n\n \n cnt[x - 1] -= 1\n cnt[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",
"if exist[x - 1] == 1:\n exist[y - 1] = 1\n if cnt[x - 1] == 1:\n exist[x - 1] = 0\n\n \n ",
"exist[x - 1] == 1",
"exist[x - 1]",
"exist",
"x - 1",
"x",
"1",
"1",
"exist[y - 1] = 1",
"exist[y - 1]",
"exist",
"y - 1",
"y",
"1",
"1",
"if cnt[x - 1] == 1:\n exist[x - 1] = 0\n\n \n ",
"cnt[x - 1] == 1",
"cnt[x - 1]",
"cnt",
"x - 1",
"x",
"1",
"1",
"exist[x - 1] = 0",
"exist[x - 1]",
"exist",
"x - 1",
"x",
"1",
"0",
"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",
"print(sum(exist))",
"print",
"sum(exist)",
"sum",
"exist",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"cnt = [1] * n",
"[1] * n",
"cnt",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"exist = [0] * n",
"[0] * n",
"exist"
] | n, m = map(int, input().split())
exist = [0] * n
exist[0] = 1
cnt = [1] * n
for i in range(m):
x, y = map(int, input().split())
if exist[x - 1] == 1:
exist[y - 1] = 1
if cnt[x - 1] == 1:
exist[x - 1] = 0
cnt[x - 1] -= 1
cnt[y - 1] += 1
print(sum(exist)) |
[
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,
0,
13,
17,
28,
13,
13,
14,
13,
0,
13,
17,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
18,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
18,
13
] | [
[
130,
2
],
[
130,
13
],
[
17,
16
],
[
128,
19
],
[
133,
32
],
[
124,
35
],
[
131,
39
],
[
44,
41
],
[
125,
42
],
[
145,
46
],
[
131,
50
],
[
55,
52
],
[
146,
53
],
[
58,
57
],
[
128,
60
],
[
148,
62
],
[
134,
64
],
[
57,
65
],
[
148,
66
],
[
73,
68
],
[
125,
69
],
[
149,
71
],
[
80,
75
],
[
125,
76
],
[
137,
78
],
[
146,
83
],
[
137,
85
],
[
93,
88
],
[
146,
89
],
[
149,
91
],
[
125,
97
],
[
137,
99
],
[
108,
103
],
[
146,
104
],
[
137,
106
],
[
142,
110
],
[
114,
113
],
[
146,
113
],
[
139,
118
],
[
140,
122
],
[
143,
122
],
[
124,
125
],
[
130,
128
],
[
130,
131
],
[
133,
134
],
[
148,
137
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
148,
149
]
] | [
"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 = [False] * (n)\nball[0] = True\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] = True\n if ans[x-1] == 0:\n ball[x-1] = False\n \ncnt = 0\nfor i in ball:\n if i:\n cnt += 1\n\nprint(cnt)",
"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 = [False] * (n)",
"ball",
"[False] * (n)",
"[False]",
"False",
"n",
"ball[0] = True",
"ball[0]",
"ball",
"0",
"True",
"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] = True\n if ans[x-1] == 0:\n ball[x-1] = False\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] = True\n ",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"ball[y-1] = True",
"ball[y-1]",
"ball",
"y-1",
"y",
"1",
"True",
"if ans[x-1] == 0:\n ball[x-1] = False\n ",
"ans[x-1] == 0",
"ans[x-1]",
"ans",
"x-1",
"x",
"1",
"0",
"ball[x-1] = False",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"False",
"cnt = 0",
"cnt",
"0",
"for i in ball:\n if i:\n cnt += 1",
"i",
"ball",
"if i:\n cnt += 1",
"i",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"ans = [1] * (n)",
"[1] * (n)",
"ans",
"m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"m",
"n, m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"n",
"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",
"cnt += 1",
"1",
"cnt",
"cnt = 0",
"0",
"cnt",
"ball = [False] * (n)",
"[False] * (n)",
"ball",
"y = xy[i]",
"xy[i]",
"y"
] | 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 = [False] * (n)
ball[0] = True
for i in range(m):
x, y = xy[i]
ans[y-1] += 1
ans[x-1] -= 1
if ball[x-1]:
ball[y-1] = True
if ans[x-1] == 0:
ball[x-1] = False
cnt = 0
for i in ball:
if i:
cnt += 1
print(cnt) |
[
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,
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,
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,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
2,
13
] | [
[
169,
16
],
[
167,
23
],
[
169,
25
],
[
154,
27
],
[
158,
31
],
[
36,
33
],
[
155,
34
],
[
172,
38
],
[
158,
42
],
[
45,
44
],
[
170,
47
],
[
163,
49
],
[
167,
56
],
[
163,
58
],
[
160,
60
],
[
151,
63
],
[
104,
67
],
[
155,
68
],
[
161,
69
],
[
149,
69
],
[
75,
72
],
[
173,
73
],
[
161,
74
],
[
149,
74
],
[
80,
77
],
[
173,
78
],
[
152,
79
],
[
164,
79
],
[
104,
84
],
[
155,
85
],
[
161,
86
],
[
149,
86
],
[
126,
89
],
[
94,
89
],
[
72,
89
],
[
173,
90
],
[
161,
91
],
[
149,
91
],
[
97,
94
],
[
173,
95
],
[
161,
96
],
[
149,
96
],
[
102,
99
],
[
173,
100
],
[
152,
101
],
[
164,
101
],
[
107,
104
],
[
155,
105
],
[
161,
106
],
[
149,
106
],
[
112,
109
],
[
155,
110
],
[
152,
111
],
[
164,
111
],
[
104,
116
],
[
155,
117
],
[
161,
118
],
[
149,
118
],
[
126,
121
],
[
94,
121
],
[
72,
121
],
[
173,
122
],
[
161,
123
],
[
149,
123
],
[
129,
126
],
[
173,
127
],
[
161,
128
],
[
149,
128
],
[
134,
131
],
[
173,
132
],
[
152,
133
],
[
164,
133
],
[
139,
136
],
[
155,
137
],
[
152,
138
],
[
164,
138
],
[
155,
144
],
[
163,
149
],
[
151,
152
],
[
154,
155
],
[
169,
158
],
[
160,
161
],
[
163,
164
],
[
169,
170
],
[
172,
173
]
] | [
"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] == 0:\n # 箱Xには赤玉がない場合\n box[x] -= 1\n box[y] += 1\n elif red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n box[x] -= 1\n box[y] += 1\n red[x] -= 1\n red[y] = 1\n elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n box[x] -= 1\n box[y] += 1\n red[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] == 0:\n # 箱Xには赤玉がない場合\n box[x] -= 1\n box[y] += 1\n elif red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n box[x] -= 1\n box[y] += 1\n red[x] -= 1\n red[y] = 1\n elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n box[x] -= 1\n box[y] += 1\n red[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] == 0:\n # 箱Xには赤玉がない場合\n box[x] -= 1\n box[y] += 1\n elif red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n box[x] -= 1\n box[y] += 1\n red[x] -= 1\n red[y] = 1\n elif red[x] == 1 and box[x] >= 2:\n # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合\n box[x] -= 1\n box[y] += 1\n red[y] = 1",
"red[x] == 0",
"red[x]",
"red",
"x",
"0",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"box[y] += 1",
"box[y]",
"box",
"y",
"1",
"elif red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n box[x] -= 1\n box[y] += 1\n red[x] -= 1\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",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"box[y] += 1",
"box[y]",
"box",
"y",
"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 box[x] -= 1\n box[y] += 1\n red[y] = 1",
"red[x] == 1 and box[x] >= 2",
"red[x] == 1",
"red[x]",
"red",
"x",
"1",
"box[x] >= 2",
"box[x]",
"box",
"x",
"2",
"box[x] -= 1",
"box[x]",
"box",
"x",
"1",
"box[y] += 1",
"box[y]",
"box",
"y",
"1",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"print(red.count(1))",
"print",
"red.count(1)",
"red.count",
"red",
"count",
"1",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"y -= 1",
"1",
"y",
"red = [0]*N",
"[0]*N",
"red",
"N, M = map(int, input().split())",
"map(int, input().split())",
"N",
"x -= 1",
"1",
"x",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"def input():\n return sys.stdin.readline()[:-1]",
"def input():\n return sys.stdin.readline()[:-1]",
"input",
"M = map(int, input().split())",
"map(int, input().split())",
"M",
"box = [1]*N",
"[1]*N",
"box"
] | 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] == 0:
# 箱Xには赤玉がない場合
box[x] -= 1
box[y] += 1
elif red[x] == 1 and box[x] == 1:
# 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合
box[x] -= 1
box[y] += 1
red[x] -= 1
red[y] = 1
elif red[x] == 1 and box[x] >= 2:
# 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合
box[x] -= 1
box[y] += 1
red[y] = 1
print(red.count(1))
|
[
7,
12,
13,
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,
2,
13,
17,
4,
17,
0,
13,
2,
39,
17,
17,
13,
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,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
5,
4
],
[
5,
13
],
[
17,
16
],
[
4,
20
],
[
26,
25
],
[
34,
33
],
[
4,
37
],
[
43,
42
],
[
50,
49
],
[
13,
52
],
[
55,
54
],
[
55,
63
],
[
92,
66
],
[
42,
67
],
[
54,
68
],
[
74,
71
],
[
42,
72
],
[
63,
73
],
[
79,
76
],
[
25,
77
],
[
54,
78
],
[
84,
81
],
[
25,
82
],
[
63,
83
],
[
76,
87
],
[
25,
88
],
[
54,
89
],
[
95,
92
],
[
42,
93
],
[
54,
94
],
[
98,
97
],
[
42,
101
],
[
97,
106
],
[
115,
112
]
] | [
"def main3():\n N, M = map(int, input().split())\n\n ball = [0, 1] + [1 for i in range(N - 1)]\n rflag = [0, 1] + [0 for i in range(N - 1)] \n\n for i in range(M):\n x, y = map(int, input().split())\n\n if rflag[x] == 1:\n rflag[y] = 1\n\n ball[x] -= 1\n ball[y] += 1\n\n if ball[x] == 0:\n rflag[x] = 0\n\n ans = sum(rflag[1:])\n print(ans)\n \nif __name__ == \"__main__\":\n main3()",
"def main3():\n N, M = map(int, input().split())\n\n ball = [0, 1] + [1 for i in range(N - 1)]\n rflag = [0, 1] + [0 for i in range(N - 1)] \n\n for i in range(M):\n x, y = map(int, input().split())\n\n if rflag[x] == 1:\n rflag[y] = 1\n\n ball[x] -= 1\n ball[y] += 1\n\n if ball[x] == 0:\n rflag[x] = 0\n\n ans = sum(rflag[1:])\n print(ans)\n ",
"main3",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"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)",
"1",
"ball = [0, 1] + [1 for i in range(N - 1)]",
"ball",
"[0, 1] + [1 for i in range(N - 1)]",
"[0, 1]",
"0",
"1",
"[1 for i in range(N - 1)]",
"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",
"rflag = [0, 1] + [0 for i in range(N - 1)]",
"rflag",
"[0, 1] + [0 for i in range(N - 1)]",
"[0, 1]",
"0",
"1",
"[0 for i in range(N - 1)]",
"for i in range(M):\n x, y = map(int, input().split())\n\n if rflag[x] == 1:\n rflag[y] = 1\n\n ball[x] -= 1\n ball[y] += 1\n\n if ball[x] == 0:\n rflag[x] = 0\n\n ",
"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 rflag[x] == 1:\n rflag[y] = 1\n\n ",
"rflag[x] == 1",
"rflag[x]",
"rflag",
"x",
"1",
"rflag[y] = 1",
"rflag[y]",
"rflag",
"y",
"1",
"ball[x] -= 1",
"ball[x]",
"ball",
"x",
"1",
"ball[y] += 1",
"ball[y]",
"ball",
"y",
"1",
"if ball[x] == 0:\n rflag[x] = 0\n\n ",
"ball[x] == 0",
"ball[x]",
"ball",
"x",
"0",
"rflag[x] = 0",
"rflag[x]",
"rflag",
"x",
"0",
"ans = sum(rflag[1:])",
"ans",
"sum(rflag[1:])",
"sum",
"rflag[1:]",
"rflag",
"1:",
"1",
"print(ans)",
"print",
"ans",
"if __name__ == \"__main__\":\n main3()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main3()",
"main3",
"def main3():\n N, M = map(int, input().split())\n\n ball = [0, 1] + [1 for i in range(N - 1)]\n rflag = [0, 1] + [0 for i in range(N - 1)] \n\n for i in range(M):\n x, y = map(int, input().split())\n\n if rflag[x] == 1:\n rflag[y] = 1\n\n ball[x] -= 1\n ball[y] += 1\n\n if ball[x] == 0:\n rflag[x] = 0\n\n ans = sum(rflag[1:])\n print(ans)\n ",
"def main3():\n N, M = map(int, input().split())\n\n ball = [0, 1] + [1 for i in range(N - 1)]\n rflag = [0, 1] + [0 for i in range(N - 1)] \n\n for i in range(M):\n x, y = map(int, input().split())\n\n if rflag[x] == 1:\n rflag[y] = 1\n\n ball[x] -= 1\n ball[y] += 1\n\n if ball[x] == 0:\n rflag[x] = 0\n\n ans = sum(rflag[1:])\n print(ans)\n ",
"main3"
] | def main3():
N, M = map(int, input().split())
ball = [0, 1] + [1 for i in range(N - 1)]
rflag = [0, 1] + [0 for i in range(N - 1)]
for i in range(M):
x, y = map(int, input().split())
if rflag[x] == 1:
rflag[y] = 1
ball[x] -= 1
ball[y] += 1
if ball[x] == 0:
rflag[x] = 0
ans = sum(rflag[1:])
print(ans)
if __name__ == "__main__":
main3() |
[
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,
2,
13,
17,
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,
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,
4,
13,
13,
18,
13,
39,
17,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
104,
2
],
[
104,
13
],
[
98,
15
],
[
96,
20
],
[
101,
23
],
[
96,
28
],
[
34,
31
],
[
102,
32
],
[
37,
36
],
[
105,
39
],
[
110,
41
],
[
110,
52
],
[
57,
54
],
[
99,
55
],
[
108,
56
],
[
62,
59
],
[
99,
60
],
[
111,
61
],
[
102,
65
],
[
108,
66
],
[
71,
68
],
[
102,
69
],
[
111,
70
],
[
54,
74
],
[
99,
75
],
[
108,
76
],
[
82,
79
],
[
102,
80
],
[
108,
81
],
[
102,
91
],
[
104,
96
],
[
98,
99
],
[
101,
102
],
[
104,
105
],
[
110,
108
],
[
110,
111
]
] | [
"n,m = list(map(int, input().split()))\n\nbox = [1] * (n+1) \nredbox = [False] * (n+1) \nredbox[1] = True\nfor _ in range(m):\n x,y = list(map(int, input().split()))\n box[x]-=1\n box[y]+=1\n if redbox[x]:\n redbox[y] = True\n if box[x]==0:\n redbox[x] = False\n# print(box)\n# print(redbox)\nprint(sum(map(int, redbox[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",
"box = [1] * (n+1)",
"box",
"[1] * (n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"redbox = [False] * (n+1)",
"redbox",
"[False] * (n+1)",
"[False]",
"False",
"n+1",
"n",
"1",
"redbox[1] = True",
"redbox[1]",
"redbox",
"1",
"True",
"for _ in range(m):\n x,y = list(map(int, input().split()))\n box[x]-=1\n box[y]+=1\n if redbox[x]:\n redbox[y] = True\n if box[x]==0:\n redbox[x] = False\n# print(box)\n# print(redbox)",
"_",
"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",
"box[x]-=1",
"box[x]",
"box",
"x",
"1",
"box[y]+=1",
"box[y]",
"box",
"y",
"1",
"if redbox[x]:\n redbox[y] = True\n ",
"redbox[x]",
"redbox",
"x",
"redbox[y] = True",
"redbox[y]",
"redbox",
"y",
"True",
"if box[x]==0:\n redbox[x] = False\n# print(box)\n# print(redbox)",
"box[x]==0",
"box[x]",
"box",
"x",
"0",
"redbox[x] = False",
"redbox[x]",
"redbox",
"x",
"False",
"print(sum(map(int, redbox[1:])))",
"print",
"sum(map(int, redbox[1:]))",
"sum",
"map(int, redbox[1:])",
"map",
"int",
"redbox[1:]",
"redbox",
"1:",
"1",
"n,m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"n",
"box = [1] * (n+1)",
"[1] * (n+1)",
"box",
"redbox = [False] * (n+1)",
"[False] * (n+1)",
"redbox",
"m = list(map(int, input().split()))",
"list(map(int, input().split()))",
"m",
"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"
] | n,m = list(map(int, input().split()))
box = [1] * (n+1)
redbox = [False] * (n+1)
redbox[1] = True
for _ in range(m):
x,y = list(map(int, input().split()))
box[x]-=1
box[y]+=1
if redbox[x]:
redbox[y] = True
if box[x]==0:
redbox[x] = False
# print(box)
# print(redbox)
print(sum(map(int, redbox[1:]))) |
[
7,
15,
12,
13,
0,
13,
12,
18,
4,
18,
13,
13,
39,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
2,
39,
17,
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,
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,
40,
18,
13,
13,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
4,
13,
10,
12,
13
] | [
[
6,
5
],
[
16,
15
],
[
5,
22
],
[
16,
24
],
[
28,
27
],
[
24,
31
],
[
5,
41
],
[
45,
44
],
[
48,
47
],
[
15,
52
],
[
56,
55
],
[
15,
60
],
[
66,
63
],
[
47,
64
],
[
70,
67
],
[
55,
68
],
[
79,
76
],
[
47,
77
],
[
84,
81
],
[
47,
82
],
[
55,
87
],
[
93,
90
],
[
55,
91
],
[
76,
96
],
[
47,
97
],
[
103,
100
],
[
55,
101
],
[
55,
108
],
[
113,
110
]
] | [
"from sys import stdin\n\n\ndef main():\n input = lambda: stdin.readline()[:-1]\n N, M = map(int, input().split())\n XY = [tuple(map(int, input().split())) for _ in [0] * M]\n\n box = [1] * (N + 1)\n red = [0] * (N + 1)\n box[0], red[1] = 0, 1\n for x, y in XY:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = 1\n if not box[x]:\n red[x] = 0\n print(sum(red))\n\n\nmain()",
"from sys import stdin",
"def main():\n input = lambda: stdin.readline()[:-1]\n N, M = map(int, input().split())\n XY = [tuple(map(int, input().split())) for _ in [0] * M]\n\n box = [1] * (N + 1)\n red = [0] * (N + 1)\n box[0], red[1] = 0, 1\n for x, y in XY:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = 1\n if not box[x]:\n red[x] = 0\n print(sum(red))",
"main",
"input = lambda: stdin.readline()[:-1]",
"input",
"lambda: stdin.readline()[:-1]",
"stdin.readline()[:-1]",
"stdin.readline()",
"stdin.readline",
"stdin",
"readline",
":-1",
"-1",
"N, M = map(int, input().split())",
"N",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"tuple(map(int, input().split())) for _ in [0] * M",
"for _ in [0] * M",
"_",
"[0] * M",
"[0]",
"0",
"M",
"for _ in [0] * M",
"tuple(map(int, input().split()))",
"tuple",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"XY = [tuple(map(int, input().split())) for _ in [0] * M]",
"XY",
"[tuple(map(int, input().split())) for _ in [0] * M]",
"box = [1] * (N + 1)",
"box",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"red = [0] * (N + 1)",
"red",
"[0] * (N + 1)",
"[0]",
"0",
"N + 1",
"N",
"1",
"box[0], red[1] = 0, 1",
"box[0]",
"box",
"0",
"0",
"red[1]",
"red",
"1",
"1",
"for x, y in XY:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = 1\n if not box[x]:\n red[x] = 0\n ",
"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] = 1\n ",
"red[x]",
"red",
"x",
"red[y] = 1",
"red[y]",
"red",
"y",
"1",
"if not box[x]:\n red[x] = 0\n ",
"not box[x]",
"box[x]",
"box",
"x",
"red[x] = 0",
"red[x]",
"red",
"x",
"0",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"main()",
"main",
"def main():\n input = lambda: stdin.readline()[:-1]\n N, M = map(int, input().split())\n XY = [tuple(map(int, input().split())) for _ in [0] * M]\n\n box = [1] * (N + 1)\n red = [0] * (N + 1)\n box[0], red[1] = 0, 1\n for x, y in XY:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = 1\n if not box[x]:\n red[x] = 0\n print(sum(red))",
"def main():\n input = lambda: stdin.readline()[:-1]\n N, M = map(int, input().split())\n XY = [tuple(map(int, input().split())) for _ in [0] * M]\n\n box = [1] * (N + 1)\n red = [0] * (N + 1)\n box[0], red[1] = 0, 1\n for x, y in XY:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = 1\n if not box[x]:\n red[x] = 0\n print(sum(red))",
"main"
] | from sys import stdin
def main():
input = lambda: stdin.readline()[:-1]
N, M = map(int, input().split())
XY = [tuple(map(int, input().split())) for _ in [0] * M]
box = [1] * (N + 1)
red = [0] * (N + 1)
box[0], red[1] = 0, 1
for x, y in XY:
box[x] -= 1
box[y] += 1
if red[x]:
red[y] = 1
if not box[x]:
red[x] = 0
print(sum(red))
main()
|
[
7,
15,
13,
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,
18,
18,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
13,
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,
14,
2,
18,
13,
13,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13
] | [
[
124,
4
],
[
124,
13
],
[
17,
16
],
[
113,
20
],
[
118,
25
],
[
30,
29
],
[
113,
33
],
[
121,
38
],
[
44,
41
],
[
122,
42
],
[
47,
46
],
[
115,
54
],
[
46,
60
],
[
115,
62
],
[
67,
64
],
[
119,
65
],
[
110,
66
],
[
72,
69
],
[
119,
70
],
[
116,
71
],
[
84,
76
],
[
122,
77
],
[
116,
78
],
[
99,
80
],
[
122,
81
],
[
110,
82
],
[
87,
84
],
[
122,
85
],
[
116,
86
],
[
99,
90
],
[
122,
91
],
[
110,
92
],
[
64,
94
],
[
119,
95
],
[
110,
96
],
[
102,
99
],
[
122,
100
],
[
110,
101
],
[
122,
107
],
[
115,
110
],
[
124,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
]
] | [
"import sys\nn, m = map(int, input().split())\nball = [1 for i in range(n+1)]\nbox = [0 for i in range(n+1)]\nbox[1] = 1\nfor a in sys.stdin.readlines():\n x, y = map(int, a.split())\n ball[x] -= 1\n ball[y] += 1\n if box[y] == 0 and box[x]:\n box[y] = 1\n if box[x] and ball[x] == 0:\n box[x] = 0\n\nprint(sum(box))",
"import sys",
"sys",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"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)",
"1",
"ball = [1 for i in range(n+1)]",
"ball",
"[1 for i in range(n+1)]",
"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",
"box = [0 for i in range(n+1)]",
"box",
"[0 for i in range(n+1)]",
"box[1] = 1",
"box[1]",
"box",
"1",
"1",
"for a in sys.stdin.readlines():\n x, y = map(int, a.split())\n ball[x] -= 1\n ball[y] += 1\n if box[y] == 0 and box[x]:\n box[y] = 1\n if box[x] and ball[x] == 0:\n box[x] = 0",
"a",
"sys.stdin.readlines()",
"sys.stdin.readlines",
"sys.stdin",
"sys",
"stdin",
"readlines",
"x, y = map(int, a.split())",
"x",
"map(int, a.split())",
"map",
"int",
"a.split()",
"a.split",
"a",
"split",
"y",
"ball[x] -= 1",
"ball[x]",
"ball",
"x",
"1",
"ball[y] += 1",
"ball[y]",
"ball",
"y",
"1",
"if box[y] == 0 and box[x]:\n box[y] = 1\n ",
"box[y] == 0 and box[x]",
"box[y] == 0",
"box[y]",
"box",
"y",
"0",
"box[x]",
"box",
"x",
"box[y] = 1",
"box[y]",
"box",
"y",
"1",
"if box[x] and ball[x] == 0:\n box[x] = 0",
"box[x] and ball[x] == 0",
"box[x]",
"box",
"x",
"ball[x] == 0",
"ball[x]",
"ball",
"x",
"0",
"box[x] = 0",
"box[x]",
"box",
"x",
"0",
"print(sum(box))",
"print",
"sum(box)",
"sum",
"box",
"x, y = map(int, a.split())",
"map(int, a.split())",
"x",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"y = map(int, a.split())",
"map(int, a.split())",
"y",
"ball = [1 for i in range(n+1)]",
"[1 for i in range(n+1)]",
"ball",
"box = [0 for i in range(n+1)]",
"[0 for i in range(n+1)]",
"box",
"m = map(int, input().split())",
"map(int, input().split())",
"m"
] | import sys
n, m = map(int, input().split())
ball = [1 for i in range(n+1)]
box = [0 for i in range(n+1)]
box[1] = 1
for a in sys.stdin.readlines():
x, y = map(int, a.split())
ball[x] -= 1
ball[y] += 1
if box[y] == 0 and box[x]:
box[y] = 1
if box[x] and ball[x] == 0:
box[x] = 0
print(sum(box)) |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
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,
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,
13,
13,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
12,
13
] | [
[
115,
11
],
[
22,
21
],
[
116,
25
],
[
21,
30
],
[
33,
32
],
[
33,
34
],
[
38,
37
],
[
34,
40
],
[
45,
44
],
[
48,
47
],
[
32,
52
],
[
58,
55
],
[
47,
56
],
[
61,
60
],
[
32,
65
],
[
89,
73
],
[
47,
74
],
[
81,
78
],
[
47,
79
],
[
94,
84
],
[
60,
85
],
[
92,
89
],
[
47,
90
],
[
97,
94
],
[
60,
95
],
[
102,
99
],
[
60,
100
],
[
47,
107
],
[
119,
113
],
[
115,
116
]
] | [
"import sys\n\nsys.setrecursionlimit(10 ** 8)\n\ninput = sys.stdin.readline\n\n\ndef main():\n N, M = [int(x) for x in input().split()]\n XY = [[int(x) for x in input().split()] for _ in range(M)]\n ans = [0] * (N + 1)\n ans[1] = 1\n cnt = [1] * (N + 1)\n for x, y in XY:\n if ans[x] == 1:\n ans[y] = 1\n if cnt[x] == 1:\n ans[x] = 0\n cnt[x] -= 1\n cnt[y] += 1\n\n print(sum(ans))\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"sys.setrecursionlimit(10 ** 8)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 8",
"10",
"8",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def main():\n N, M = [int(x) for x in input().split()]\n XY = [[int(x) for x in input().split()] for _ in range(M)]\n ans = [0] * (N + 1)\n ans[1] = 1\n cnt = [1] * (N + 1)\n for x, y in XY:\n if ans[x] == 1:\n ans[y] = 1\n if cnt[x] == 1:\n ans[x] = 0\n cnt[x] -= 1\n cnt[y] += 1\n\n print(sum(ans))",
"main",
"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",
"[int(x) for x in input().split()] for _ in range(M)",
"for _ in range(M)",
"_",
"range(M)",
"range",
"M",
"for _ in range(M)",
"[int(x) for x in input().split()]",
"XY = [[int(x) for x in input().split()] for _ in range(M)]",
"XY",
"[[int(x) for x in input().split()] for _ in range(M)]",
"ans = [0] * (N + 1)",
"ans",
"[0] * (N + 1)",
"[0]",
"0",
"N + 1",
"N",
"1",
"ans[1] = 1",
"ans[1]",
"ans",
"1",
"1",
"cnt = [1] * (N + 1)",
"cnt",
"[1] * (N + 1)",
"[1]",
"1",
"N + 1",
"N",
"1",
"for x, y in XY:\n if ans[x] == 1:\n ans[y] = 1\n if cnt[x] == 1:\n ans[x] = 0\n cnt[x] -= 1\n cnt[y] += 1\n\n ",
"x",
"y",
"XY",
"if ans[x] == 1:\n ans[y] = 1\n ",
"ans[x] == 1",
"ans[x]",
"ans",
"x",
"1",
"ans[y] = 1",
"ans[y]",
"ans",
"y",
"1",
"if cnt[x] == 1:\n ans[x] = 0\n ",
"cnt[x] == 1",
"cnt[x]",
"cnt",
"x",
"1",
"ans[x] = 0",
"ans[x]",
"ans",
"x",
"0",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"print(sum(ans))",
"print",
"sum(ans)",
"sum",
"ans",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def main():\n N, M = [int(x) for x in input().split()]\n XY = [[int(x) for x in input().split()] for _ in range(M)]\n ans = [0] * (N + 1)\n ans[1] = 1\n cnt = [1] * (N + 1)\n for x, y in XY:\n if ans[x] == 1:\n ans[y] = 1\n if cnt[x] == 1:\n ans[x] = 0\n cnt[x] -= 1\n cnt[y] += 1\n\n print(sum(ans))",
"def main():\n N, M = [int(x) for x in input().split()]\n XY = [[int(x) for x in input().split()] for _ in range(M)]\n ans = [0] * (N + 1)\n ans[1] = 1\n cnt = [1] * (N + 1)\n for x, y in XY:\n if ans[x] == 1:\n ans[y] = 1\n if cnt[x] == 1:\n ans[x] = 0\n cnt[x] -= 1\n cnt[y] += 1\n\n print(sum(ans))",
"main"
] | import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
def main():
N, M = [int(x) for x in input().split()]
XY = [[int(x) for x in input().split()] for _ in range(M)]
ans = [0] * (N + 1)
ans[1] = 1
cnt = [1] * (N + 1)
for x, y in XY:
if ans[x] == 1:
ans[y] = 1
if cnt[x] == 1:
ans[x] = 0
cnt[x] -= 1
cnt[y] += 1
print(sum(ans))
if __name__ == '__main__':
main()
|
[
7,
15,
13,
13,
13,
13,
13,
13,
15,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
2,
39,
17,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
40,
18,
13,
13,
17,
0,
13,
4,
13,
13,
4,
13,
13,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] | [
[
22,
21
],
[
118,
23
],
[
22,
24
],
[
28,
27
],
[
21,
30
],
[
35,
34
],
[
42,
41
],
[
21,
44
],
[
49,
48
],
[
57,
54
],
[
48,
55
],
[
60,
59
],
[
24,
62
],
[
65,
64
],
[
118,
66
],
[
65,
67
],
[
72,
69
],
[
34,
70
],
[
67,
71
],
[
77,
74
],
[
48,
75
],
[
67,
76
],
[
86,
77
],
[
48,
78
],
[
64,
79
],
[
84,
81
],
[
34,
82
],
[
64,
83
],
[
89,
86
],
[
48,
87
],
[
64,
88
],
[
81,
90
],
[
34,
91
],
[
64,
92
],
[
96,
95
],
[
48,
98
],
[
95,
101
],
[
109,
103
]
] | [
"import bisect,collections,copy,itertools,math,string\nimport sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S(): return sys.stdin.readline().rstrip()\ndef LS(): return list(sys.stdin.readline().rstrip().split())\ndef main():\n n, m = LI()\n cnt = [None] + [1 for _ in range(n)]\n exist = [False] + [False for _ in range(n)]\n exist[1] = True\n\n for _ in range(m):\n x, y = LI()\n\n cnt[y] += 1\n exist[y] |= exist[x]\n\n cnt[x] -= 1\n exist[x] &= cnt[x] != 0\n \n ans = sum(exist)\n print(ans)\nmain()",
"import bisect,collections,copy,itertools,math,string",
"bisect",
"collections",
"copy",
"itertools",
"math",
"string",
"import sys",
"sys",
"def I(): return int(sys.stdin.readline().rstrip())",
"I",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"LI",
"def S(): return sys.stdin.readline().rstrip()",
"S",
"def LS(): return list(sys.stdin.readline().rstrip().split())",
"LS",
"def main():\n n, m = LI()\n cnt = [None] + [1 for _ in range(n)]\n exist = [False] + [False for _ in range(n)]\n exist[1] = True\n\n for _ in range(m):\n x, y = LI()\n\n cnt[y] += 1\n exist[y] |= exist[x]\n\n cnt[x] -= 1\n exist[x] &= cnt[x] != 0\n \n ans = sum(exist)\n print(ans)",
"main",
"n, m = LI()",
"n",
"LI()",
"LI",
"m",
"1 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"1",
"cnt = [None] + [1 for _ in range(n)]",
"cnt",
"[None] + [1 for _ in range(n)]",
"[None]",
"None",
"[1 for _ in range(n)]",
"False for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"False",
"exist = [False] + [False for _ in range(n)]",
"exist",
"[False] + [False for _ in range(n)]",
"[False]",
"False",
"[False for _ in range(n)]",
"exist[1] = True",
"exist[1]",
"exist",
"1",
"True",
"for _ in range(m):\n x, y = LI()\n\n cnt[y] += 1\n exist[y] |= exist[x]\n\n cnt[x] -= 1\n exist[x] &= cnt[x] != 0\n \n ",
"_",
"range(m)",
"range",
"m",
"x, y = LI()",
"x",
"LI()",
"LI",
"y",
"cnt[y] += 1",
"cnt[y]",
"cnt",
"y",
"1",
"exist[y] |= exist[x]",
"exist[y]",
"exist",
"y",
"exist[x]",
"exist",
"x",
"cnt[x] -= 1",
"cnt[x]",
"cnt",
"x",
"1",
"exist[x] &= cnt[x] != 0",
"exist[x]",
"exist",
"x",
"cnt[x] != 0",
"cnt[x]",
"cnt",
"x",
"0",
"ans = sum(exist)",
"ans",
"sum(exist)",
"sum",
"exist",
"print(ans)",
"print",
"ans",
"main()",
"main",
"def I(): return int(sys.stdin.readline().rstrip())",
"def I(): return int(sys.stdin.readline().rstrip())",
"I",
"def main():\n n, m = LI()\n cnt = [None] + [1 for _ in range(n)]\n exist = [False] + [False for _ in range(n)]\n exist[1] = True\n\n for _ in range(m):\n x, y = LI()\n\n cnt[y] += 1\n exist[y] |= exist[x]\n\n cnt[x] -= 1\n exist[x] &= cnt[x] != 0\n \n ans = sum(exist)\n print(ans)",
"def main():\n n, m = LI()\n cnt = [None] + [1 for _ in range(n)]\n exist = [False] + [False for _ in range(n)]\n exist[1] = True\n\n for _ in range(m):\n x, y = LI()\n\n cnt[y] += 1\n exist[y] |= exist[x]\n\n cnt[x] -= 1\n exist[x] &= cnt[x] != 0\n \n ans = sum(exist)\n print(ans)",
"main",
"def LS(): return list(sys.stdin.readline().rstrip().split())",
"def LS(): return list(sys.stdin.readline().rstrip().split())",
"LS",
"def S(): return sys.stdin.readline().rstrip()",
"def S(): return sys.stdin.readline().rstrip()",
"S",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))",
"LI"
] | import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
n, m = LI()
cnt = [None] + [1 for _ in range(n)]
exist = [False] + [False for _ in range(n)]
exist[1] = True
for _ in range(m):
x, y = LI()
cnt[y] += 1
exist[y] |= exist[x]
cnt[x] -= 1
exist[x] &= cnt[x] != 0
ans = sum(exist)
print(ans)
main()
|
[
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,
0,
18,
13,
2,
13,
17,
17,
41,
28,
13,
4,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
4,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] | [
[
120,
2
],
[
120,
11
],
[
123,
13
],
[
115,
17
],
[
22,
19
],
[
124,
20
],
[
111,
24
],
[
115,
28
],
[
31,
30
],
[
121,
33
],
[
117,
35
],
[
117,
44
],
[
51,
46
],
[
124,
47
],
[
118,
49
],
[
124,
52
],
[
109,
54
],
[
62,
57
],
[
112,
58
],
[
109,
60
],
[
69,
64
],
[
112,
65
],
[
118,
67
],
[
112,
73
],
[
109,
75
],
[
84,
79
],
[
124,
80
],
[
109,
82
],
[
88,
87
],
[
115,
90
],
[
112,
94
],
[
87,
95
],
[
124,
98
],
[
87,
99
],
[
117,
109
],
[
111,
112
],
[
120,
115
],
[
117,
118
],
[
120,
121
],
[
123,
124
]
] | [
"N, M = map(int, input().split())\n\nred = [0]*N\nred[0] = 1\n\nq = [1]*N\n\nfor _ in range(M):\n x, y = map(int, input().split())\n red[y-1] |= red[x-1]\n q[x-1] -= 1\n q[y-1] += 1\n if q[x-1] == 0:\n red[x-1] = 0\n\nprint(sum([1 for i in range(N) if q[i]>0 and red[i]]))",
"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",
"q = [1]*N",
"q",
"[1]*N",
"[1]",
"1",
"N",
"for _ in range(M):\n x, y = map(int, input().split())\n red[y-1] |= red[x-1]\n q[x-1] -= 1\n q[y-1] += 1\n if q[x-1] == 0:\n red[x-1] = 0",
"_",
"range(M)",
"range",
"M",
"x, y = map(int, input().split())",
"x",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"red[y-1] |= red[x-1]",
"red[y-1]",
"red",
"y-1",
"y",
"1",
"red[x-1]",
"red",
"x-1",
"x",
"1",
"q[x-1] -= 1",
"q[x-1]",
"q",
"x-1",
"x",
"1",
"1",
"q[y-1] += 1",
"q[y-1]",
"q",
"y-1",
"y",
"1",
"1",
"if q[x-1] == 0:\n red[x-1] = 0",
"q[x-1] == 0",
"q[x-1]",
"q",
"x-1",
"x",
"1",
"0",
"red[x-1] = 0",
"red[x-1]",
"red",
"x-1",
"x",
"1",
"0",
"1 for i in range(N) if q[i]>0 and red[i]",
"for i in range(N) if q[i]>0 and red[i]",
"i",
"range(N)",
"range",
"N",
"q[i]>0 and red[i]",
"q[i]>0",
"q[i]",
"q",
"i",
"0",
"red[i]",
"red",
"i",
"if q[i]>0 and red[i]",
"1",
"print(sum([1 for i in range(N) if q[i]>0 and red[i]]))",
"print",
"sum([1 for i in range(N) if q[i]>0 and red[i]])",
"sum",
"[1 for i in range(N) if q[i]>0 and red[i]]",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"q = [1]*N",
"[1]*N",
"q",
"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",
"red = [0]*N",
"[0]*N",
"red"
] | N, M = map(int, input().split())
red = [0]*N
red[0] = 1
q = [1]*N
for _ in range(M):
x, y = map(int, input().split())
red[y-1] |= red[x-1]
q[x-1] -= 1
q[y-1] += 1
if q[x-1] == 0:
red[x-1] = 0
print(sum([1 for i in range(N) if q[i]>0 and red[i]])) |
[
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,
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,
18,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13
] | [
[
98,
2
],
[
98,
11
],
[
92,
13
],
[
99,
17
],
[
107,
19
],
[
99,
23
],
[
28,
25
],
[
108,
26
],
[
31,
30
],
[
90,
33
],
[
110,
35
],
[
110,
44
],
[
104,
46
],
[
95,
49
],
[
55,
52
],
[
93,
53
],
[
105,
54
],
[
111,
54
],
[
60,
57
],
[
93,
58
],
[
96,
59
],
[
102,
59
],
[
108,
63
],
[
105,
64
],
[
111,
64
],
[
69,
66
],
[
108,
67
],
[
96,
68
],
[
102,
68
],
[
52,
72
],
[
93,
73
],
[
105,
74
],
[
111,
74
],
[
80,
77
],
[
108,
78
],
[
105,
79
],
[
111,
79
],
[
108,
85
],
[
98,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
110,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] | [
"n,m=map(int,input().split())\nnuml=[1]*n\nl=[False]*n\nl[0]=True\nfor i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n numl[x]-=1\n numl[y]+=1\n if l[x]:\n l[y]=True\n if numl[x]==0:\n l[x]=False\nprint(l.count(True))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"numl=[1]*n",
"numl",
"[1]*n",
"[1]",
"1",
"n",
"l=[False]*n",
"l",
"[False]*n",
"[False]",
"False",
"n",
"l[0]=True",
"l[0]",
"l",
"0",
"True",
"for i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n numl[x]-=1\n numl[y]+=1\n if l[x]:\n l[y]=True\n if numl[x]==0:\n l[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",
"numl[x]-=1",
"numl[x]",
"numl",
"x",
"1",
"numl[y]+=1",
"numl[y]",
"numl",
"y",
"1",
"if l[x]:\n l[y]=True\n if numl[x]==0:\n l[x]=False",
"l[x]",
"l",
"x",
"l[y]=True",
"l[y]",
"l",
"y",
"True",
"if numl[x]==0:\n l[x]=False",
"numl[x]==0",
"numl[x]",
"numl",
"x",
"0",
"l[x]=False",
"l[x]",
"l",
"x",
"False",
"print(l.count(True))",
"print",
"l.count(True)",
"l.count",
"l",
"count",
"True",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"numl=[1]*n",
"[1]*n",
"numl",
"y-=1",
"1",
"y",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"x-=1",
"1",
"x",
"l=[False]*n",
"[False]*n",
"l",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x"
] | n,m=map(int,input().split())
numl=[1]*n
l=[False]*n
l[0]=True
for i in range(m):
x,y=map(int,input().split())
x-=1
y-=1
numl[x]-=1
numl[y]+=1
if l[x]:
l[y]=True
if numl[x]==0:
l[x]=False
print(l.count(True)) |
[
7,
12,
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,
0,
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,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
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,
4,
13,
4,
13,
13,
13,
13,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] | [
[
5,
4
],
[
76,
9
],
[
13,
12
],
[
76,
17
],
[
23,
20
],
[
4,
21
],
[
26,
25
],
[
80,
25
],
[
29,
28
],
[
25,
29
],
[
29,
30
],
[
4,
33
],
[
28,
34
],
[
39,
36
],
[
4,
37
],
[
30,
38
],
[
44,
41
],
[
12,
42
],
[
28,
43
],
[
49,
46
],
[
12,
47
],
[
30,
48
],
[
41,
52
],
[
62,
52
],
[
12,
53
],
[
28,
54
],
[
60,
57
],
[
4,
58
],
[
28,
59
],
[
65,
62
],
[
12,
63
],
[
28,
64
],
[
70,
67
],
[
12,
68
],
[
30,
69
],
[
4,
74
],
[
76,
76
],
[
78,
78
],
[
80,
80
],
[
85,
84
],
[
85,
93
],
[
97,
96
],
[
93,
99
],
[
113,
112
],
[
130,
117
],
[
84,
118
],
[
93,
119
],
[
112,
120
],
[
133,
127
]
] | [
"#!/usr/bin/env python3\n\n# from numba import njit\n\n# input = stdin.readline\n\n# @njit\ndef solve(n,m,queries):\n redInBox = [False] * (n+1)\n amountOfBalls = [1] * (n+1)\n redInBox[1] = True\n \n for query in queries:\n x,y = query\n if redInBox[x]:\n redInBox[y] = True\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n if amountOfBalls[x] == 0:\n redInBox[x] = False\n else:\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n \n return sum(redInBox)\n\n\n\ndef main():\n N,M = map(int,input().split())\n queries = [list(map(int,input().split())) for _ in range(M)]\n print(solve(N,M,queries))\n return\n\nif __name__ == '__main__':\n main()",
"def solve(n,m,queries):\n redInBox = [False] * (n+1)\n amountOfBalls = [1] * (n+1)\n redInBox[1] = True\n \n for query in queries:\n x,y = query\n if redInBox[x]:\n redInBox[y] = True\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n if amountOfBalls[x] == 0:\n redInBox[x] = False\n else:\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n \n return sum(redInBox)",
"solve",
"redInBox = [False] * (n+1)",
"redInBox",
"[False] * (n+1)",
"[False]",
"False",
"n+1",
"n",
"1",
"amountOfBalls = [1] * (n+1)",
"amountOfBalls",
"[1] * (n+1)",
"[1]",
"1",
"n+1",
"n",
"1",
"redInBox[1] = True",
"redInBox[1]",
"redInBox",
"1",
"True",
"for query in queries:\n x,y = query\n if redInBox[x]:\n redInBox[y] = True\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n if amountOfBalls[x] == 0:\n redInBox[x] = False\n else:\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n \n ",
"query",
"queries",
"x,y = query",
"x",
"query",
"y",
"if redInBox[x]:\n redInBox[y] = True\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n if amountOfBalls[x] == 0:\n redInBox[x] = False\n else:\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n \n ",
"redInBox[x]",
"redInBox",
"x",
"redInBox[y] = True",
"redInBox[y]",
"redInBox",
"y",
"True",
"amountOfBalls[x] -= 1",
"amountOfBalls[x]",
"amountOfBalls",
"x",
"1",
"amountOfBalls[y] += 1",
"amountOfBalls[y]",
"amountOfBalls",
"y",
"1",
"if amountOfBalls[x] == 0:\n redInBox[x] = False\n ",
"amountOfBalls[x] == 0",
"amountOfBalls[x]",
"amountOfBalls",
"x",
"0",
"redInBox[x] = False",
"redInBox[x]",
"redInBox",
"x",
"False",
"amountOfBalls[x] -= 1",
"amountOfBalls[x]",
"amountOfBalls",
"x",
"1",
"amountOfBalls[y] += 1",
"amountOfBalls[y]",
"amountOfBalls",
"y",
"1",
"return sum(redInBox)",
"sum(redInBox)",
"sum",
"redInBox",
"n",
"n",
"m",
"m",
"queries",
"queries",
"def main():\n N,M = map(int,input().split())\n queries = [list(map(int,input().split())) for _ in range(M)]\n print(solve(N,M,queries))\n return",
"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 _ 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",
"queries = [list(map(int,input().split())) for _ in range(M)]",
"queries",
"[list(map(int,input().split())) for _ in range(M)]",
"print(solve(N,M,queries))",
"print",
"solve(N,M,queries)",
"solve",
"N",
"M",
"queries",
"return",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def solve(n,m,queries):\n redInBox = [False] * (n+1)\n amountOfBalls = [1] * (n+1)\n redInBox[1] = True\n \n for query in queries:\n x,y = query\n if redInBox[x]:\n redInBox[y] = True\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n if amountOfBalls[x] == 0:\n redInBox[x] = False\n else:\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n \n return sum(redInBox)",
"def solve(n,m,queries):\n redInBox = [False] * (n+1)\n amountOfBalls = [1] * (n+1)\n redInBox[1] = True\n \n for query in queries:\n x,y = query\n if redInBox[x]:\n redInBox[y] = True\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n if amountOfBalls[x] == 0:\n redInBox[x] = False\n else:\n amountOfBalls[x] -= 1\n amountOfBalls[y] += 1\n \n return sum(redInBox)",
"solve",
"def main():\n N,M = map(int,input().split())\n queries = [list(map(int,input().split())) for _ in range(M)]\n print(solve(N,M,queries))\n return",
"def main():\n N,M = map(int,input().split())\n queries = [list(map(int,input().split())) for _ in range(M)]\n print(solve(N,M,queries))\n return",
"main"
] | #!/usr/bin/env python3
# from numba import njit
# input = stdin.readline
# @njit
def solve(n,m,queries):
redInBox = [False] * (n+1)
amountOfBalls = [1] * (n+1)
redInBox[1] = True
for query in queries:
x,y = query
if redInBox[x]:
redInBox[y] = True
amountOfBalls[x] -= 1
amountOfBalls[y] += 1
if amountOfBalls[x] == 0:
redInBox[x] = False
else:
amountOfBalls[x] -= 1
amountOfBalls[y] += 1
return sum(redInBox)
def main():
N,M = map(int,input().split())
queries = [list(map(int,input().split())) for _ in range(M)]
print(solve(N,M,queries))
return
if __name__ == '__main__':
main()
|
[
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,
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,
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,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] | [
[
117,
2
],
[
117,
11
],
[
15,
14
],
[
118,
18
],
[
108,
23
],
[
28,
27
],
[
118,
31
],
[
111,
36
],
[
42,
39
],
[
109,
40
],
[
47,
44
],
[
112,
45
],
[
50,
49
],
[
106,
52
],
[
114,
54
],
[
114,
63
],
[
92,
66
],
[
109,
67
],
[
115,
68
],
[
74,
71
],
[
109,
72
],
[
103,
73
],
[
79,
76
],
[
112,
77
],
[
103,
78
],
[
84,
81
],
[
112,
82
],
[
115,
83
],
[
81,
87
],
[
112,
88
],
[
115,
89
],
[
95,
92
],
[
109,
93
],
[
115,
94
],
[
109,
100
],
[
114,
103
],
[
117,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
],
[
117,
118
]
] | [
"N,M = map(int,input().split())\nA = [0 for _ in range(N+1)]\nB = [1 for _ in range(N+1)]\nA[1] = 1\nB[0] = 0\nfor _ in range(M):\n x,y = map(int,input().split())\n if A[x]==1:\n A[y]=1\n B[y] += 1\n B[x] -= 1\n if B[x]==0:\n A[x] = 0\nprint(sum(A))",
"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",
"A = [0 for _ in range(N+1)]",
"A",
"[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",
"B = [1 for _ in range(N+1)]",
"B",
"[1 for _ in range(N+1)]",
"A[1] = 1",
"A[1]",
"A",
"1",
"1",
"B[0] = 0",
"B[0]",
"B",
"0",
"0",
"for _ in range(M):\n x,y = map(int,input().split())\n if A[x]==1:\n A[y]=1\n B[y] += 1\n B[x] -= 1\n if B[x]==0:\n A[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",
"if A[x]==1:\n A[y]=1\n ",
"A[x]==1",
"A[x]",
"A",
"x",
"1",
"A[y]=1",
"A[y]",
"A",
"y",
"1",
"B[y] += 1",
"B[y]",
"B",
"y",
"1",
"B[x] -= 1",
"B[x]",
"B",
"x",
"1",
"if B[x]==0:\n A[x] = 0",
"B[x]==0",
"B[x]",
"B",
"x",
"0",
"A[x] = 0",
"A[x]",
"A",
"x",
"0",
"print(sum(A))",
"print",
"sum(A)",
"sum",
"A",
"y = map(int,input().split())",
"map(int,input().split())",
"y",
"M = map(int,input().split())",
"map(int,input().split())",
"M",
"A = [0 for _ in range(N+1)]",
"[0 for _ in range(N+1)]",
"A",
"B = [1 for _ in range(N+1)]",
"[1 for _ in range(N+1)]",
"B",
"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())
A = [0 for _ in range(N+1)]
B = [1 for _ in range(N+1)]
A[1] = 1
B[0] = 0
for _ in range(M):
x,y = map(int,input().split())
if A[x]==1:
A[y]=1
B[y] += 1
B[x] -= 1
if B[x]==0:
A[x] = 0
print(sum(A)) |
[
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,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
2,
18,
13,
2,
13,
17,
17,
4,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13
] | [
[
4,
3
],
[
3,
15
],
[
21,
18
],
[
21,
22
],
[
89,
25
],
[
92,
36
],
[
51,
46
],
[
93,
47
],
[
58,
53
],
[
93,
54
],
[
65,
60
],
[
90,
61
],
[
90,
66
],
[
76,
71
],
[
90,
72
],
[
93,
78
],
[
90,
87
],
[
89,
90
],
[
92,
93
]
] | [
"#!/usr/bin/env python3\n(n, m), *q = [[*map(int, i.split())] for i in open(0)]\nb = [1] + [0] * (n - 1)\nc = [1] * n\nfor x, y in q:\n c[x - 1] -= 1\n c[y - 1] += 1\n b[y - 1] |= b[x - 1]\n b[x - 1] *= c[x - 1] > 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 = [1] + [0] * (n - 1)",
"b",
"[1] + [0] * (n - 1)",
"[1]",
"1",
"[0] * (n - 1)",
"[0]",
"0",
"n - 1",
"n",
"1",
"c = [1] * n",
"c",
"[1] * n",
"[1]",
"1",
"n",
"for x, y in q:\n c[x - 1] -= 1\n c[y - 1] += 1\n b[y - 1] |= b[x - 1]\n b[x - 1] *= c[x - 1] > 0",
"x",
"y",
"q",
"c[x - 1] -= 1",
"c[x - 1]",
"c",
"x - 1",
"x",
"1",
"1",
"c[y - 1] += 1",
"c[y - 1]",
"c",
"y - 1",
"y",
"1",
"1",
"b[y - 1] |= b[x - 1]",
"b[y - 1]",
"b",
"y - 1",
"y",
"1",
"b[x - 1]",
"b",
"x - 1",
"x",
"1",
"b[x - 1] *= c[x - 1] > 0",
"b[x - 1]",
"b",
"x - 1",
"x",
"1",
"c[x - 1] > 0",
"c[x - 1]",
"c",
"x - 1",
"x",
"1",
"0",
"print(sum(b))",
"print",
"sum(b)",
"sum",
"b",
"b = [1] + [0] * (n - 1)",
"[1] + [0] * (n - 1)",
"b",
"c = [1] * n",
"[1] * n",
"c"
] | #!/usr/bin/env python3
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [1] + [0] * (n - 1)
c = [1] * n
for x, y in q:
c[x - 1] -= 1
c[y - 1] += 1
b[y - 1] |= b[x - 1]
b[x - 1] *= c[x - 1] > 0
print(sum(b))
|
[
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,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
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,
18,
13,
18,
13,
13,
8,
18,
13,
18,
13,
13,
17,
18,
13,
18,
13,
13,
0,
18,
13,
18,
13,
13,
8,
2,
18,
13,
18,
13,
13,
17,
18,
13,
18,
13,
13,
17,
0,
18,
13,
18,
13,
13,
17,
0,
18,
13,
18,
13,
13,
17,
4,
13,
4,
13,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13
] | [
[
166,
2
],
[
166,
11
],
[
15,
14
],
[
167,
17
],
[
160,
21
],
[
26,
25
],
[
167,
28
],
[
157,
32
],
[
36,
35
],
[
167,
38
],
[
43,
40
],
[
161,
41
],
[
35,
42
],
[
43,
51
],
[
158,
52
],
[
35,
53
],
[
58,
55
],
[
161,
56
],
[
35,
57
],
[
63,
60
],
[
158,
61
],
[
35,
62
],
[
67,
66
],
[
155,
69
],
[
169,
73
],
[
78,
77
],
[
155,
80
],
[
163,
84
],
[
90,
87
],
[
164,
88
],
[
93,
92
],
[
167,
95
],
[
102,
97
],
[
164,
98
],
[
60,
99
],
[
51,
99
],
[
158,
100
],
[
92,
101
],
[
115,
103
],
[
164,
104
],
[
55,
105
],
[
40,
105
],
[
161,
106
],
[
92,
107
],
[
97,
109
],
[
164,
110
],
[
60,
111
],
[
51,
111
],
[
158,
112
],
[
92,
113
],
[
120,
115
],
[
164,
116
],
[
55,
117
],
[
40,
117
],
[
161,
118
],
[
92,
119
],
[
135,
122
],
[
170,
123
],
[
55,
124
],
[
40,
124
],
[
161,
125
],
[
92,
126
],
[
115,
128
],
[
164,
129
],
[
55,
130
],
[
40,
130
],
[
161,
131
],
[
92,
132
],
[
140,
135
],
[
170,
136
],
[
55,
137
],
[
40,
137
],
[
161,
138
],
[
92,
139
],
[
147,
142
],
[
170,
143
],
[
60,
144
],
[
51,
144
],
[
158,
145
],
[
92,
146
],
[
164,
152
],
[
166,
155
],
[
157,
158
],
[
160,
161
],
[
163,
164
],
[
166,
167
],
[
169,
170
]
] | [
"n,m = map(int,input().split())\nx = [0 for _ in range(m)]\ny = [0 for _ in range(m)]\nfor i in range(m):\n x[i],y[i] = map(int,input().split())\n x[i] -= 1\n y[i] -= 1\n\nbox = [1 for _ in range(n)]\nred = [0 for _ in range(n)]\nred[0] = 1\nfor i in range(m):\n red[y[i]] = 1 if red[x[i]] else red[y[i]]\n red[x[i]] = red[x[i]] if box[x[i]]-1 else 0\n box[x[i]] -= 1\n box[y[i]] += 1\nprint(sum(red))",
"n,m = map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"0 for _ in range(m)",
"for _ in range(m)",
"_",
"range(m)",
"range",
"m",
"for _ in range(m)",
"0",
"x = [0 for _ in range(m)]",
"x",
"[0 for _ in range(m)]",
"0 for _ in range(m)",
"for _ in range(m)",
"_",
"range(m)",
"range",
"m",
"for _ in range(m)",
"0",
"y = [0 for _ in range(m)]",
"y",
"[0 for _ in range(m)]",
"for i in range(m):\n x[i],y[i] = map(int,input().split())\n x[i] -= 1\n y[i] -= 1",
"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",
"x[i] -= 1",
"x[i]",
"x",
"i",
"1",
"y[i] -= 1",
"y[i]",
"y",
"i",
"1",
"1 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"1",
"box = [1 for _ in range(n)]",
"box",
"[1 for _ in range(n)]",
"0 for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"0",
"red = [0 for _ in range(n)]",
"red",
"[0 for _ in range(n)]",
"red[0] = 1",
"red[0]",
"red",
"0",
"1",
"for i in range(m):\n red[y[i]] = 1 if red[x[i]] else red[y[i]]\n red[x[i]] = red[x[i]] if box[x[i]]-1 else 0\n box[x[i]] -= 1\n box[y[i]] += 1",
"i",
"range(m)",
"range",
"m",
"red[y[i]] = 1 if red[x[i]] else red[y[i]]",
"red[y[i]]",
"red",
"y[i]",
"y",
"i",
"1 if red[x[i]] else red[y[i]]",
"red[x[i]]",
"red",
"x[i]",
"x",
"i",
"1",
"red[y[i]]",
"red",
"y[i]",
"y",
"i",
"red[x[i]] = red[x[i]] if box[x[i]]-1 else 0",
"red[x[i]]",
"red",
"x[i]",
"x",
"i",
"red[x[i]] if box[x[i]]-1 else 0",
"box[x[i]]-1",
"box[x[i]]",
"box",
"x[i]",
"x",
"i",
"1",
"red[x[i]]",
"red",
"x[i]",
"x",
"i",
"0",
"box[x[i]] -= 1",
"box[x[i]]",
"box",
"x[i]",
"x",
"i",
"1",
"box[y[i]] += 1",
"box[y[i]]",
"box",
"y[i]",
"y",
"i",
"1",
"print(sum(red))",
"print",
"sum(red)",
"sum",
"red",
"n,m = map(int,input().split())",
"map(int,input().split())",
"n",
"y = [0 for _ in range(m)]",
"[0 for _ in range(m)]",
"y",
"x = [0 for _ in range(m)]",
"[0 for _ in range(m)]",
"x",
"red = [0 for _ in range(n)]",
"[0 for _ in range(n)]",
"red",
"m = map(int,input().split())",
"map(int,input().split())",
"m",
"box = [1 for _ in range(n)]",
"[1 for _ in range(n)]",
"box"
] | n,m = map(int,input().split())
x = [0 for _ in range(m)]
y = [0 for _ in range(m)]
for i in range(m):
x[i],y[i] = map(int,input().split())
x[i] -= 1
y[i] -= 1
box = [1 for _ in range(n)]
red = [0 for _ in range(n)]
red[0] = 1
for i in range(m):
red[y[i]] = 1 if red[x[i]] else red[y[i]]
red[x[i]] = red[x[i]] if box[x[i]]-1 else 0
box[x[i]] -= 1
box[y[i]] += 1
print(sum(red)) |
[
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,
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,
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,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
14,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13
] | [
[
141,
2
],
[
141,
11
],
[
15,
14
],
[
142,
18
],
[
138,
23
],
[
28,
27
],
[
142,
31
],
[
132,
36
],
[
42,
39
],
[
139,
40
],
[
47,
44
],
[
133,
45
],
[
50,
49
],
[
130,
52
],
[
135,
54
],
[
135,
63
],
[
77,
66
],
[
133,
67
],
[
124,
68
],
[
87,
72
],
[
139,
73
],
[
124,
74
],
[
80,
77
],
[
133,
78
],
[
124,
79
],
[
85,
82
],
[
133,
83
],
[
136,
84
],
[
90,
87
],
[
139,
88
],
[
124,
89
],
[
95,
92
],
[
139,
93
],
[
136,
94
],
[
120,
97
],
[
101,
100
],
[
142,
105
],
[
133,
110
],
[
100,
111
],
[
126,
114
],
[
127,
118
],
[
121,
118
],
[
120,
121
],
[
135,
124
],
[
126,
127
],
[
141,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
]
] | [
"n, m = map(int, input().split())\nl = [1 for i in range(n+1)]\nb = [False for i in range(n+1)]\nl[1] = 1\nb[1] = True\nfor i in range(m):\n x, y = map(int, input().split())\n if b[x] == True:\n if l[x] == 1:\n b[x] = False\n b[y] = True\n l[x] -= 1\n l[y] += 1\ncnt = 0\nfor i in range(1, n+1):\n if b[i] == True:\n cnt += 1\nprint(cnt)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"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)",
"1",
"l = [1 for i in range(n+1)]",
"l",
"[1 for i in range(n+1)]",
"False 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)",
"False",
"b = [False for i in range(n+1)]",
"b",
"[False for i in range(n+1)]",
"l[1] = 1",
"l[1]",
"l",
"1",
"1",
"b[1] = True",
"b[1]",
"b",
"1",
"True",
"for i in range(m):\n x, y = map(int, input().split())\n if b[x] == True:\n if l[x] == 1:\n b[x] = False\n b[y] = True\n l[x] -= 1\n l[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",
"if b[x] == True:\n if l[x] == 1:\n b[x] = False\n b[y] = True\n ",
"b[x] == True",
"b[x]",
"b",
"x",
"True",
"if l[x] == 1:\n b[x] = False\n ",
"l[x] == 1",
"l[x]",
"l",
"x",
"1",
"b[x] = False",
"b[x]",
"b",
"x",
"False",
"b[y] = True",
"b[y]",
"b",
"y",
"True",
"l[x] -= 1",
"l[x]",
"l",
"x",
"1",
"l[y] += 1",
"l[y]",
"l",
"y",
"1",
"cnt = 0",
"cnt",
"0",
"for i in range(1, n+1):\n if b[i] == True:\n cnt += 1",
"i",
"range(1, n+1)",
"range",
"1",
"n+1",
"n",
"1",
"if b[i] == True:\n cnt += 1",
"b[i] == True",
"b[i]",
"b",
"i",
"True",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"cnt = 0",
"0",
"cnt",
"x, y = map(int, input().split())",
"map(int, input().split())",
"x",
"cnt += 1",
"1",
"cnt",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"b = [False for i in range(n+1)]",
"[False for i in range(n+1)]",
"b",
"y = map(int, input().split())",
"map(int, input().split())",
"y",
"l = [1 for i in range(n+1)]",
"[1 for i in range(n+1)]",
"l",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n"
] | n, m = map(int, input().split())
l = [1 for i in range(n+1)]
b = [False for i in range(n+1)]
l[1] = 1
b[1] = True
for i in range(m):
x, y = map(int, input().split())
if b[x] == True:
if l[x] == 1:
b[x] = False
b[y] = True
l[x] -= 1
l[y] += 1
cnt = 0
for i in range(1, n+1):
if b[i] == True:
cnt += 1
print(cnt) |
[
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,
4,
13,
12,
2,
13,
17,
23,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
8,
2,
18,
13,
13,
17,
17,
18,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
8,
2,
18,
13,
13,
17,
17,
18,
13,
13,
4,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
107,
2
],
[
107,
11
],
[
98,
13
],
[
105,
17
],
[
101,
19
],
[
105,
27
],
[
31,
30
],
[
108,
33
],
[
113,
35
],
[
113,
53
],
[
58,
55
],
[
102,
56
],
[
114,
57
],
[
79,
60
],
[
102,
61
],
[
111,
62
],
[
55,
65
],
[
102,
66
],
[
114,
67
],
[
72,
69
],
[
99,
70
],
[
111,
71
],
[
77,
74
],
[
99,
75
],
[
114,
76
],
[
82,
79
],
[
102,
80
],
[
111,
81
],
[
69,
84
],
[
99,
85
],
[
111,
86
],
[
79,
89
],
[
102,
90
],
[
111,
91
],
[
102,
96
],
[
98,
99
],
[
101,
102
],
[
107,
105
],
[
107,
108
],
[
113,
111
],
[
113,
114
]
] | [
"n, m = map(int, input().split())\nN = [1]*n\nP = [True] + [False]*(n-1)\nfor i in range(m):\n x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))\n P[y] = True if P[x]==True else P[y]\n N[x] -= 1\n N[y] += 1\n P[x] = False if N[x]==0 else P[x]\nprint(sum(P))",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"N = [1]*n",
"N",
"[1]*n",
"[1]",
"1",
"n",
"P = [True] + [False]*(n-1)",
"P",
"[True] + [False]*(n-1)",
"[True]",
"True",
"[False]*(n-1)",
"[False]",
"False",
"n-1",
"n",
"1",
"for i in range(m):\n x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))\n P[y] = True if P[x]==True else P[y]\n N[x] -= 1\n N[y] += 1\n P[x] = False if N[x]==0 else P[x]",
"i",
"range(m)",
"range",
"m",
"x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))",
"x",
"list(map(lambda tmp: tmp-1, map(int, input().split())))",
"list",
"map(lambda tmp: tmp-1, map(int, input().split()))",
"map",
"lambda tmp: tmp-1",
"tmp-1",
"tmp",
"1",
"tmp",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"P[y] = True if P[x]==True else P[y]",
"P[y]",
"P",
"y",
"True if P[x]==True else P[y]",
"P[x]==True",
"P[x]",
"P",
"x",
"True",
"True",
"P[y]",
"P",
"y",
"N[x] -= 1",
"N[x]",
"N",
"x",
"1",
"N[y] += 1",
"N[y]",
"N",
"y",
"1",
"P[x] = False if N[x]==0 else P[x]",
"P[x]",
"P",
"x",
"False if N[x]==0 else P[x]",
"N[x]==0",
"N[x]",
"N",
"x",
"0",
"False",
"P[x]",
"P",
"x",
"print(sum(P))",
"print",
"sum(P)",
"sum",
"P",
"N = [1]*n",
"[1]*n",
"N",
"P = [True] + [False]*(n-1)",
"[True] + [False]*(n-1)",
"P",
"n, m = map(int, input().split())",
"map(int, input().split())",
"n",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))",
"list(map(lambda tmp: tmp-1, map(int, input().split())))",
"x",
"y = list(map(lambda tmp: tmp-1, map(int, input().split())))",
"list(map(lambda tmp: tmp-1, map(int, input().split())))",
"y"
] | n, m = map(int, input().split())
N = [1]*n
P = [True] + [False]*(n-1)
for i in range(m):
x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))
P[y] = True if P[x]==True else P[y]
N[x] -= 1
N[y] += 1
P[x] = False if N[x]==0 else P[x]
print(sum(P)) |
[
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,
4,
13,
13,
0,
13,
18,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
2,
17,
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,
4,
13,
4,
13,
13,
10,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13
] | [
[
125,
2
],
[
125,
11
],
[
15,
14
],
[
126,
17
],
[
107,
30
],
[
110,
33
],
[
117,
37
],
[
128,
39
],
[
117,
43
],
[
48,
45
],
[
129,
46
],
[
51,
50
],
[
126,
53
],
[
131,
55
],
[
108,
57
],
[
50,
58
],
[
131,
59
],
[
113,
61
],
[
123,
63
],
[
114,
63
],
[
119,
65
],
[
132,
67
],
[
120,
67
],
[
97,
72
],
[
129,
73
],
[
114,
74
],
[
123,
74
],
[
79,
76
],
[
129,
77
],
[
120,
78
],
[
132,
78
],
[
84,
81
],
[
111,
82
],
[
114,
83
],
[
123,
83
],
[
89,
86
],
[
111,
87
],
[
120,
88
],
[
132,
88
],
[
81,
92
],
[
111,
93
],
[
114,
94
],
[
123,
94
],
[
100,
97
],
[
129,
98
],
[
114,
99
],
[
123,
99
],
[
129,
105
],
[
107,
108
],
[
110,
111
],
[
113,
114
],
[
125,
117
],
[
119,
120
],
[
131,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
]
] | [
"N,M = map(int,input().split())\n\nXY = [list(map(int,input().split())) for _ in range(M)]\n\nball_count = [1]*N\n\nred_ball_cand = [0]*N\nred_ball_cand[0] = 1\n\nfor i in range(M):\n x,y = XY[i]\n x,y = x-1,y-1\n if 0 < red_ball_cand[x]:\n red_ball_cand[y] = 1\n \n ball_count[x] -= 1\n ball_count[y] += 1\n \n if ball_count[x] == 0:\n red_ball_cand[x] = 0\nprint(sum(red_ball_cand))",
"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)]",
"ball_count = [1]*N",
"ball_count",
"[1]*N",
"[1]",
"1",
"N",
"red_ball_cand = [0]*N",
"red_ball_cand",
"[0]*N",
"[0]",
"0",
"N",
"red_ball_cand[0] = 1",
"red_ball_cand[0]",
"red_ball_cand",
"0",
"1",
"for i in range(M):\n x,y = XY[i]\n x,y = x-1,y-1\n if 0 < red_ball_cand[x]:\n red_ball_cand[y] = 1\n \n ball_count[x] -= 1\n ball_count[y] += 1\n \n if ball_count[x] == 0:\n red_ball_cand[x] = 0",
"i",
"range(M)",
"range",
"M",
"x,y = XY[i]",
"x",
"XY[i]",
"XY",
"i",
"y",
"x,y = x-1,y-1",
"x",
"x-1",
"x",
"1",
"y",
"y-1",
"y",
"1",
"if 0 < red_ball_cand[x]:\n red_ball_cand[y] = 1\n \n ",
"0 < red_ball_cand[x]",
"0",
"red_ball_cand[x]",
"red_ball_cand",
"x",
"red_ball_cand[y] = 1",
"red_ball_cand[y]",
"red_ball_cand",
"y",
"1",
"ball_count[x] -= 1",
"ball_count[x]",
"ball_count",
"x",
"1",
"ball_count[y] += 1",
"ball_count[y]",
"ball_count",
"y",
"1",
"if ball_count[x] == 0:\n red_ball_cand[x] = 0",
"ball_count[x] == 0",
"ball_count[x]",
"ball_count",
"x",
"0",
"red_ball_cand[x] = 0",
"red_ball_cand[x]",
"red_ball_cand",
"x",
"0",
"print(sum(red_ball_cand))",
"print",
"sum(red_ball_cand)",
"sum",
"red_ball_cand",
"XY = [list(map(int,input().split())) for _ in range(M)]",
"[list(map(int,input().split())) for _ in range(M)]",
"XY",
"ball_count = [1]*N",
"[1]*N",
"ball_count",
"x,y = x-1,y-1",
"x-1",
"x",
"N,M = map(int,input().split())",
"map(int,input().split())",
"N",
"y = x-1,y-1",
"y-1",
"y",
"x,y = XY[i]",
"XY[i]",
"x",
"M = map(int,input().split())",
"map(int,input().split())",
"M",
"red_ball_cand = [0]*N",
"[0]*N",
"red_ball_cand",
"y = XY[i]",
"XY[i]",
"y"
] | N,M = map(int,input().split())
XY = [list(map(int,input().split())) for _ in range(M)]
ball_count = [1]*N
red_ball_cand = [0]*N
red_ball_cand[0] = 1
for i in range(M):
x,y = XY[i]
x,y = x-1,y-1
if 0 < red_ball_cand[x]:
red_ball_cand[y] = 1
ball_count[x] -= 1
ball_count[y] += 1
if ball_count[x] == 0:
red_ball_cand[x] = 0
print(sum(red_ball_cand)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
2,
18,
13,
17,
17,
4,
18,
13,
13,
2,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
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,
13,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
2,
13,
10,
39,
13
] | [
[
155,
2
],
[
155,
11
],
[
152,
13
],
[
170,
16
],
[
20,
19
],
[
156,
22
],
[
149,
24
],
[
153,
37
],
[
150,
41
],
[
171,
46
],
[
150,
50
],
[
161,
54
],
[
147,
58
],
[
63,
60
],
[
162,
61
],
[
167,
65
],
[
147,
69
],
[
72,
71
],
[
156,
74
],
[
81,
76
],
[
168,
77
],
[
153,
79
],
[
71,
80
],
[
88,
83
],
[
168,
84
],
[
171,
86
],
[
71,
87
],
[
113,
91
],
[
162,
92
],
[
153,
94
],
[
71,
95
],
[
103,
98
],
[
162,
99
],
[
171,
101
],
[
71,
102
],
[
76,
106
],
[
168,
107
],
[
153,
109
],
[
71,
110
],
[
118,
113
],
[
162,
114
],
[
153,
116
],
[
71,
117
],
[
164,
120
],
[
124,
123
],
[
147,
126
],
[
162,
131
],
[
123,
132
],
[
168,
136
],
[
123,
137
],
[
158,
140
],
[
159,
144
],
[
165,
144
],
[
155,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
],
[
161,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
]
] | [
"n,m=map(int,input().split())\nx=[]\ny=[]\nfor i in range(m):\n xy=list(map(int,input().split()))\n x.append(xy[0]-1)\n y.append(xy[1]-1)\n\nred=[0]*n\nred[0]=1\ncnt=[1]*n\n\nfor i in range(m):\n cnt[x[i]]-=1\n cnt[y[i]]+=1\n\n if red[x[i]]==1:\n red[y[i]]=1\n \n if cnt[x[i]]==0:\n red[x[i]]=0\n\nans=0\nfor i in range(n):\n if red[i]==1 and cnt[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",
"x=[]",
"x",
"[]",
"y=[]",
"y",
"[]",
"for i in range(m):\n xy=list(map(int,input().split()))\n x.append(xy[0]-1)\n y.append(xy[1]-1)",
"i",
"range(m)",
"range",
"m",
"xy=list(map(int,input().split()))",
"xy",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"x.append(xy[0]-1)",
"x.append",
"x",
"append",
"xy[0]-1",
"xy[0]",
"xy",
"0",
"1",
"y.append(xy[1]-1)",
"y.append",
"y",
"append",
"xy[1]-1",
"xy[1]",
"xy",
"1",
"1",
"red=[0]*n",
"red",
"[0]*n",
"[0]",
"0",
"n",
"red[0]=1",
"red[0]",
"red",
"0",
"1",
"cnt=[1]*n",
"cnt",
"[1]*n",
"[1]",
"1",
"n",
"for i in range(m):\n cnt[x[i]]-=1\n cnt[y[i]]+=1\n\n if red[x[i]]==1:\n red[y[i]]=1\n \n if cnt[x[i]]==0:\n red[x[i]]=0",
"i",
"range(m)",
"range",
"m",
"cnt[x[i]]-=1",
"cnt[x[i]]",
"cnt",
"x[i]",
"x",
"i",
"1",
"cnt[y[i]]+=1",
"cnt[y[i]]",
"cnt",
"y[i]",
"y",
"i",
"1",
"if red[x[i]]==1:\n red[y[i]]=1\n \n ",
"red[x[i]]==1",
"red[x[i]]",
"red",
"x[i]",
"x",
"i",
"1",
"red[y[i]]=1",
"red[y[i]]",
"red",
"y[i]",
"y",
"i",
"1",
"if cnt[x[i]]==0:\n red[x[i]]=0",
"cnt[x[i]]==0",
"cnt[x[i]]",
"cnt",
"x[i]",
"x",
"i",
"0",
"red[x[i]]=0",
"red[x[i]]",
"red",
"x[i]",
"x",
"i",
"0",
"ans=0",
"ans",
"0",
"for i in range(n):\n if red[i]==1 and cnt[i]>0:\n ans+=1",
"i",
"range(n)",
"range",
"n",
"if red[i]==1 and cnt[i]>0:\n ans+=1",
"red[i]==1 and cnt[i]>0",
"red[i]==1",
"red[i]",
"red",
"i",
"1",
"cnt[i]>0",
"cnt[i]",
"cnt",
"i",
"0",
"ans+=1",
"ans",
"1",
"print(ans)",
"print",
"ans",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"xy=list(map(int,input().split()))",
"list(map(int,input().split()))",
"xy",
"x=[]",
"[]",
"x",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"ans+=1",
"1",
"ans",
"red=[0]*n",
"[0]*n",
"red",
"ans=0",
"0",
"ans",
"cnt=[1]*n",
"[1]*n",
"cnt",
"y=[]",
"[]",
"y"
] | n,m=map(int,input().split())
x=[]
y=[]
for i in range(m):
xy=list(map(int,input().split()))
x.append(xy[0]-1)
y.append(xy[1]-1)
red=[0]*n
red[0]=1
cnt=[1]*n
for i in range(m):
cnt[x[i]]-=1
cnt[y[i]]+=1
if red[x[i]]==1:
red[y[i]]=1
if cnt[x[i]]==0:
red[x[i]]=0
ans=0
for i in range(n):
if red[i]==1 and cnt[i]>0:
ans+=1
print(ans) |
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
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,
29,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] | [
[
17,
16
],
[
17,
25
],
[
28,
27
],
[
16,
31
],
[
33,
32
],
[
16,
36
],
[
41,
38
],
[
32,
39
],
[
44,
43
],
[
25,
46
],
[
49,
48
],
[
49,
57
],
[
32,
61
],
[
48,
63
],
[
72,
67
],
[
32,
68
],
[
57,
70
],
[
79,
74
],
[
27,
75
],
[
48,
77
],
[
86,
81
],
[
27,
82
],
[
57,
84
],
[
27,
90
],
[
48,
92
],
[
101,
96
],
[
32,
97
],
[
48,
99
],
[
32,
106
],
[
119,
116
]
] | [
"import math\nimport collections\nimport fractions\nimport itertools\nimport functools\nimport operator\n\ndef solve():\n n, m = map(int, input().split())\n ball, can = [1]*n, [False]*n\n can[0] = True\n for _ in range(m):\n x, y = map(int, input().split())\n if can[x-1] == True:\n can[y-1] = True\n ball[x-1] -= 1\n ball[y-1] += 1\n if ball[x-1] == 0:\n can[x-1] = False\n print(can.count(True))\n return 0\n\nif __name__ == \"__main__\":\n solve()",
"import math",
"math",
"import collections",
"collections",
"import fractions",
"fractions",
"import itertools",
"itertools",
"import functools",
"functools",
"import operator",
"operator",
"def solve():\n n, m = map(int, input().split())\n ball, can = [1]*n, [False]*n\n can[0] = True\n for _ in range(m):\n x, y = map(int, input().split())\n if can[x-1] == True:\n can[y-1] = True\n ball[x-1] -= 1\n ball[y-1] += 1\n if ball[x-1] == 0:\n can[x-1] = False\n print(can.count(True))\n return 0",
"solve",
"n, m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"ball, can = [1]*n, [False]*n",
"ball",
"[1]*n",
"[1]",
"1",
"n",
"can",
"[False]*n",
"[False]",
"False",
"n",
"can[0] = True",
"can[0]",
"can",
"0",
"True",
"for _ in range(m):\n x, y = map(int, input().split())\n if can[x-1] == True:\n can[y-1] = True\n ball[x-1] -= 1\n ball[y-1] += 1\n if ball[x-1] == 0:\n can[x-1] = False\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 can[x-1] == True:\n can[y-1] = True\n ",
"can[x-1] == True",
"can[x-1]",
"can",
"x-1",
"x",
"1",
"True",
"can[y-1] = True",
"can[y-1]",
"can",
"y-1",
"y",
"1",
"True",
"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 ball[x-1] == 0:\n can[x-1] = False\n ",
"ball[x-1] == 0",
"ball[x-1]",
"ball",
"x-1",
"x",
"1",
"0",
"can[x-1] = False",
"can[x-1]",
"can",
"x-1",
"x",
"1",
"False",
"print(can.count(True))",
"print",
"can.count(True)",
"can.count",
"can",
"count",
"True",
"return 0",
"0",
"if __name__ == \"__main__\":\n solve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"solve()",
"solve",
"def solve():\n n, m = map(int, input().split())\n ball, can = [1]*n, [False]*n\n can[0] = True\n for _ in range(m):\n x, y = map(int, input().split())\n if can[x-1] == True:\n can[y-1] = True\n ball[x-1] -= 1\n ball[y-1] += 1\n if ball[x-1] == 0:\n can[x-1] = False\n print(can.count(True))\n return 0",
"def solve():\n n, m = map(int, input().split())\n ball, can = [1]*n, [False]*n\n can[0] = True\n for _ in range(m):\n x, y = map(int, input().split())\n if can[x-1] == True:\n can[y-1] = True\n ball[x-1] -= 1\n ball[y-1] += 1\n if ball[x-1] == 0:\n can[x-1] = False\n print(can.count(True))\n return 0",
"solve"
] | import math
import collections
import fractions
import itertools
import functools
import operator
def solve():
n, m = map(int, input().split())
ball, can = [1]*n, [False]*n
can[0] = True
for _ in range(m):
x, y = map(int, input().split())
if can[x-1] == True:
can[y-1] = True
ball[x-1] -= 1
ball[y-1] += 1
if ball[x-1] == 0:
can[x-1] = False
print(can.count(True))
return 0
if __name__ == "__main__":
solve()
|
[
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,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
2,
39,
17,
13,
28,
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,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
17,
13
] | [
[
118,
2
],
[
118,
11
],
[
15,
14
],
[
113,
17
],
[
121,
30
],
[
35,
34
],
[
119,
37
],
[
124,
41
],
[
46,
45
],
[
119,
49
],
[
109,
54
],
[
115,
64
],
[
127,
67
],
[
87,
71
],
[
110,
72
],
[
116,
73
],
[
79,
76
],
[
110,
77
],
[
128,
78
],
[
92,
82
],
[
125,
83
],
[
116,
84
],
[
90,
87
],
[
110,
88
],
[
116,
89
],
[
95,
92
],
[
125,
93
],
[
116,
94
],
[
100,
97
],
[
125,
98
],
[
128,
99
],
[
110,
105
],
[
109,
110
],
[
118,
113
],
[
115,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
],
[
127,
128
]
] | [
"n,m=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(m)]\n\nnum_l=[1 for i in range(n)]\nbit_l=[1]+[0 for i in range(n-1)]\n\nfor x,y in l:\n x-=1\n y-=1\n\n if bit_l[x]==1:\n bit_l[y]=1\n if num_l[x]==1:\n bit_l[x]=0\n num_l[x]-=1\n num_l[y]+=1\n\nprint(bit_l.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 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",
"l=[list(map(int,input().split())) for i in range(m)]",
"l",
"[list(map(int,input().split())) for i in range(m)]",
"1 for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"1",
"num_l=[1 for i in range(n)]",
"num_l",
"[1 for i in range(n)]",
"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",
"bit_l=[1]+[0 for i in range(n-1)]",
"bit_l",
"[1]+[0 for i in range(n-1)]",
"[1]",
"1",
"[0 for i in range(n-1)]",
"for x,y in l:\n x-=1\n y-=1\n\n if bit_l[x]==1:\n bit_l[y]=1\n if num_l[x]==1:\n bit_l[x]=0\n num_l[x]-=1\n num_l[y]+=1",
"x",
"y",
"l",
"x-=1",
"x",
"1",
"y-=1",
"y",
"1",
"if bit_l[x]==1:\n bit_l[y]=1\n if num_l[x]==1:\n bit_l[x]=0\n ",
"bit_l[x]==1",
"bit_l[x]",
"bit_l",
"x",
"1",
"bit_l[y]=1",
"bit_l[y]",
"bit_l",
"y",
"1",
"if num_l[x]==1:\n bit_l[x]=0\n ",
"num_l[x]==1",
"num_l[x]",
"num_l",
"x",
"1",
"bit_l[x]=0",
"bit_l[x]",
"bit_l",
"x",
"0",
"num_l[x]-=1",
"num_l[x]",
"num_l",
"x",
"1",
"num_l[y]+=1",
"num_l[y]",
"num_l",
"y",
"1",
"print(bit_l.count(1))",
"print",
"bit_l.count(1)",
"bit_l.count",
"bit_l",
"count",
"1",
"bit_l=[1]+[0 for i in range(n-1)]",
"[1]+[0 for i in range(n-1)]",
"bit_l",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"x-=1",
"1",
"x",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"l=[list(map(int,input().split())) for i in range(m)]",
"[list(map(int,input().split())) for i in range(m)]",
"l",
"num_l=[1 for i in range(n)]",
"[1 for i in range(n)]",
"num_l",
"y-=1",
"1",
"y"
] | n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
num_l=[1 for i in range(n)]
bit_l=[1]+[0 for i in range(n-1)]
for x,y in l:
x-=1
y-=1
if bit_l[x]==1:
bit_l[y]=1
if num_l[x]==1:
bit_l[x]=0
num_l[x]-=1
num_l[y]+=1
print(bit_l.count(1)) |
[
7,
15,
13,
15,
13,
15,
15,
15,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
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,
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,
13,
13,
14,
2,
40,
18,
13,
2,
13,
17,
17,
40,
13,
13,
0,
13,
17,
14,
2,
18,
13,
2,
13,
17,
17,
4,
18,
13,
13,
13,
14,
2,
13,
13,
0,
13,
17,
4,
18,
13,
13,
13,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] | [
[
138,
11
],
[
138,
20
],
[
123,
22
],
[
139,
26
],
[
141,
28
],
[
142,
33
],
[
117,
37
],
[
41,
40
],
[
127,
43
],
[
132,
45
],
[
132,
54
],
[
61,
56
],
[
124,
57
],
[
121,
59
],
[
68,
63
],
[
124,
64
],
[
133,
66
],
[
121,
71
],
[
142,
72
],
[
124,
77
],
[
121,
79
],
[
133,
83
],
[
142,
84
],
[
129,
86
],
[
124,
91
],
[
121,
93
],
[
142,
98
],
[
121,
100
],
[
133,
103
],
[
142,
104
],
[
135,
106
],
[
142,
110
],
[
133,
112
],
[
136,
115
],
[
130,
115
],
[
118,
115
],
[
117,
118
],
[
132,
121
],
[
123,
124
],
[
138,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
],
[
138,
139
],
[
141,
142
]
] | [
"#import sys\n#import numpy as np\nimport math\n#from fractions import Fraction\nimport itertools\nfrom collections import deque\nfrom collections import Counter\n#import heapq\nfrom fractions import gcd\n#input=sys.stdin.readline\nimport bisect\nn,m=map(int,input().split())\nnum=[1]*n\ns=set()\ns.add(1)\nans=1\nfor i in range(m):\n x,y=map(int,input().split())\n num[x-1]-=1\n num[y-1]+=1\n if x in s:\n if num[x-1]!=0 and y not in s:\n ans+=1\n elif num[x-1]==0:\n s.discard(x)\n if y in s:\n ans-=1\n s.add(y)\nprint(ans)",
"import math",
"math",
"import itertools",
"itertools",
"from collections import deque",
"from collections import Counter",
"from fractions import gcd",
"import bisect",
"bisect",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"num=[1]*n",
"num",
"[1]*n",
"[1]",
"1",
"n",
"s=set()",
"s",
"set()",
"set",
"s.add(1)",
"s.add",
"s",
"add",
"1",
"ans=1",
"ans",
"1",
"for i in range(m):\n x,y=map(int,input().split())\n num[x-1]-=1\n num[y-1]+=1\n if x in s:\n if num[x-1]!=0 and y not in s:\n ans+=1\n elif num[x-1]==0:\n s.discard(x)\n if y in s:\n ans-=1\n s.add(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",
"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 x in s:\n if num[x-1]!=0 and y not in s:\n ans+=1\n elif num[x-1]==0:\n s.discard(x)\n if y in s:\n ans-=1\n s.add(y)",
"x in s",
"x",
"s",
"if num[x-1]!=0 and y not in s:\n ans+=1\n elif num[x-1]==0:\n s.discard(x)\n if y in s:\n ans-=1\n ",
"num[x-1]!=0 and y not in s",
"num[x-1]!=0",
"num[x-1]",
"num",
"x-1",
"x",
"1",
"0",
"y not in s",
"y",
"s",
"ans+=1",
"ans",
"1",
"elif num[x-1]==0:\n s.discard(x)\n if y in s:\n ans-=1\n ",
"num[x-1]==0",
"num[x-1]",
"num",
"x-1",
"x",
"1",
"0",
"s.discard(x)",
"s.discard",
"s",
"discard",
"x",
"if y in s:\n ans-=1\n ",
"y in s",
"y",
"s",
"ans-=1",
"ans",
"1",
"s.add(y)",
"s.add",
"s",
"add",
"y",
"print(ans)",
"print",
"ans",
"ans=1",
"1",
"ans",
"x,y=map(int,input().split())",
"map(int,input().split())",
"x",
"num=[1]*n",
"[1]*n",
"num",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"ans+=1",
"1",
"ans",
"y=map(int,input().split())",
"map(int,input().split())",
"y",
"ans-=1",
"1",
"ans",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"s=set()",
"set()",
"s"
] | #import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions import gcd
#input=sys.stdin.readline
import bisect
n,m=map(int,input().split())
num=[1]*n
s=set()
s.add(1)
ans=1
for i in range(m):
x,y=map(int,input().split())
num[x-1]-=1
num[y-1]+=1
if x in s:
if num[x-1]!=0 and y not in s:
ans+=1
elif num[x-1]==0:
s.discard(x)
if y in s:
ans-=1
s.add(y)
print(ans) |
[
7,
15,
13,
0,
13,
39,
17,
17,
17,
0,
13,
17,
0,
13,
18,
13,
13,
0,
13,
12,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
12,
4,
13,
4,
13,
0,
13,
17,
12,
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,
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,
29,
4,
13,
13,
0,
13,
17,
12,
13,
14,
13,
4,
13,
13,
23,
13,
12,
13,
15,
13,
0,
13,
4,
18,
13,
13,
0,
13,
4,
18,
13,
13,
28,
13,
13,
27,
13,
14,
2,
13,
17,
14,
2,
18,
13,
13,
17,
14,
2,
13,
18,
13,
17,
0,
13,
4,
13,
0,
13,
12,
4,
18,
13,
13,
14,
2,
13,
18,
13,
17,
0,
18,
13,
13,
4,
13,
17,
0,
13,
17,
0,
13,
4,
13,
14,
40,
13,
17,
4,
13,
13,
10,
39,
13,
10,
12,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13
] | [
[
205,
4
],
[
214,
10
],
[
241,
13
],
[
206,
15
],
[
215,
16
],
[
226,
18
],
[
244,
29
],
[
227,
34
],
[
235,
36
],
[
42,
41
],
[
227,
43
],
[
42,
44
],
[
47,
46
],
[
41,
50
],
[
55,
52
],
[
46,
53
],
[
58,
57
],
[
41,
61
],
[
64,
63
],
[
44,
66
],
[
69,
68
],
[
227,
70
],
[
69,
71
],
[
74,
73
],
[
68,
75
],
[
73,
75
],
[
78,
77
],
[
71,
79
],
[
77,
79
],
[
85,
82
],
[
57,
83
],
[
73,
84
],
[
68,
84
],
[
90,
87
],
[
57,
88
],
[
77,
89
],
[
71,
89
],
[
109,
93
],
[
46,
94
],
[
73,
95
],
[
68,
95
],
[
101,
98
],
[
46,
99
],
[
77,
100
],
[
71,
100
],
[
82,
104
],
[
57,
105
],
[
73,
106
],
[
68,
106
],
[
112,
109
],
[
46,
110
],
[
73,
111
],
[
68,
111
],
[
46,
116
],
[
220,
118
],
[
128,
126
],
[
128,
128
],
[
135,
134
],
[
141,
140
],
[
134,
143
],
[
147,
146
],
[
140,
146
],
[
146,
149
],
[
242,
162
],
[
206,
164
],
[
217,
167
],
[
239,
169
],
[
223,
171
],
[
218,
175
],
[
242,
179
],
[
206,
181
],
[
187,
184
],
[
211,
191
],
[
232,
194
],
[
209,
196
],
[
233,
199
],
[
233,
203
],
[
205,
206
],
[
211,
212
],
[
214,
215
],
[
217,
218
],
[
220,
221
],
[
223,
224
],
[
226,
227
],
[
232,
233
],
[
235,
236
],
[
241,
242
],
[
244,
245
]
] | [
"import sys\n\ninput_methods=['clipboard','file','key']\nusing_method=0\ninput_method=input_methods[using_method]\n\ntin=lambda : map(int, input().split())\nlin=lambda : list(tin())\nmod=1000000007\n\n#+++++\n\ndef main():\n\t#a = int(input())\n\tn, m = tin()\n\t#s = input()\n\tis_red_in = [0]*n\n\tis_red_in[0] = 1\n\tnum_of_ball = [1] * n\n\tfor _ in range(m):\n\t\tf, t = tin()\n\t\tf, t = f-1, t-1\n\t\tnum_of_ball[f] -= 1\n\t\tnum_of_ball[t] += 1\n\t\tif is_red_in[f] == 1:\n\t\t\tis_red_in[t] = 1\n\t\tif num_of_ball[f] == 0:\n\t\t\tis_red_in[f] = 0\n\treturn sum(is_red_in)\n\t\n\t\n#+++++\nisTest=False\n\ndef pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t\ndef input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l\n\nif __name__ == \"__main__\":\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)",
"import sys",
"sys",
"input_methods=['clipboard','file','key']",
"input_methods",
"['clipboard','file','key']",
"'clipboard'",
"'file'",
"'key'",
"using_method=0",
"using_method",
"0",
"input_method=input_methods[using_method]",
"input_method",
"input_methods[using_method]",
"input_methods",
"using_method",
"tin=lambda : map(int, input().split())",
"tin",
"lambda : map(int, input().split())",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"lin=lambda : list(tin())",
"lin",
"lambda : list(tin())",
"list(tin())",
"list",
"tin()",
"tin",
"mod=1000000007",
"mod",
"1000000007",
"def main():\n\t#a = int(input())\n\tn, m = tin()\n\t#s = input()\n\tis_red_in = [0]*n\n\tis_red_in[0] = 1\n\tnum_of_ball = [1] * n\n\tfor _ in range(m):\n\t\tf, t = tin()\n\t\tf, t = f-1, t-1\n\t\tnum_of_ball[f] -= 1\n\t\tnum_of_ball[t] += 1\n\t\tif is_red_in[f] == 1:\n\t\t\tis_red_in[t] = 1\n\t\tif num_of_ball[f] == 0:\n\t\t\tis_red_in[f] = 0\n\treturn sum(is_red_in)\n\t\n\t\n#+++++",
"main",
"n, m = tin()",
"n",
"tin()",
"tin",
"m",
"is_red_in = [0]*n",
"is_red_in",
"[0]*n",
"[0]",
"0",
"n",
"is_red_in[0] = 1",
"is_red_in[0]",
"is_red_in",
"0",
"1",
"num_of_ball = [1] * n",
"num_of_ball",
"[1] * n",
"[1]",
"1",
"n",
"for _ in range(m):\n\t\tf, t = tin()\n\t\tf, t = f-1, t-1\n\t\tnum_of_ball[f] -= 1\n\t\tnum_of_ball[t] += 1\n\t\tif is_red_in[f] == 1:\n\t\t\tis_red_in[t] = 1\n\t\tif num_of_ball[f] == 0:\n\t\t\tis_red_in[f] = 0\n\t",
"_",
"range(m)",
"range",
"m",
"f, t = tin()",
"f",
"tin()",
"tin",
"t",
"f, t = f-1, t-1",
"f",
"f-1",
"f",
"1",
"t",
"t-1",
"t",
"1",
"num_of_ball[f] -= 1",
"num_of_ball[f]",
"num_of_ball",
"f",
"1",
"num_of_ball[t] += 1",
"num_of_ball[t]",
"num_of_ball",
"t",
"1",
"if is_red_in[f] == 1:\n\t\t\tis_red_in[t] = 1\n\t\t",
"is_red_in[f] == 1",
"is_red_in[f]",
"is_red_in",
"f",
"1",
"is_red_in[t] = 1",
"is_red_in[t]",
"is_red_in",
"t",
"1",
"if num_of_ball[f] == 0:\n\t\t\tis_red_in[f] = 0\n\t",
"num_of_ball[f] == 0",
"num_of_ball[f]",
"num_of_ball",
"f",
"0",
"is_red_in[f] = 0",
"is_red_in[f]",
"is_red_in",
"f",
"0",
"return sum(is_red_in)",
"sum(is_red_in)",
"sum",
"is_red_in",
"isTest=False",
"isTest",
"False",
"def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t",
"pa",
"if isTest:\n\t\tprint(v)\n\t\t",
"isTest",
"print(v)",
"print",
"v",
"v",
"v",
"def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l",
"input_clipboard",
"import clipboard",
"clipboard",
"input_text=clipboard.get()",
"input_text",
"clipboard.get()",
"clipboard.get",
"clipboard",
"get",
"input_l=input_text.splitlines()",
"input_l",
"input_text.splitlines()",
"input_text.splitlines",
"input_text",
"splitlines",
"for l in input_l:\n\t\tyield l",
"l",
"input_l",
"yield l",
"l",
"if __name__ == \"__main__\":\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"if sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\t",
"sys.platform =='ios'",
"sys.platform",
"sys",
"platform",
"'ios'",
"if input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\t",
"input_method==input_methods[0]",
"input_method",
"input_methods[0]",
"input_methods",
"0",
"ic=input_clipboard()",
"ic",
"input_clipboard()",
"input_clipboard",
"input = lambda : ic.__next__()",
"input",
"lambda : ic.__next__()",
"ic.__next__()",
"ic.__next__",
"ic",
"__next__",
"elif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\t",
"input_method==input_methods[1]",
"input_method",
"input_methods[1]",
"input_methods",
"1",
"sys.stdin=open('inputFile.txt')",
"sys.stdin",
"sys",
"stdin",
"open('inputFile.txt')",
"open",
"'inputFile.txt'",
"isTest=True",
"isTest",
"True",
"ret = main()",
"ret",
"main()",
"main",
"if ret is not None:\n\t\tprint(ret)",
"ret is not None",
"ret",
"None",
"print(ret)",
"print",
"ret",
"input_methods=['clipboard','file','key']",
"['clipboard','file','key']",
"input_methods",
"def main():\n\t#a = int(input())\n\tn, m = tin()\n\t#s = input()\n\tis_red_in = [0]*n\n\tis_red_in[0] = 1\n\tnum_of_ball = [1] * n\n\tfor _ in range(m):\n\t\tf, t = tin()\n\t\tf, t = f-1, t-1\n\t\tnum_of_ball[f] -= 1\n\t\tnum_of_ball[t] += 1\n\t\tif is_red_in[f] == 1:\n\t\t\tis_red_in[t] = 1\n\t\tif num_of_ball[f] == 0:\n\t\t\tis_red_in[f] = 0\n\treturn sum(is_red_in)\n\t\n\t\n#+++++",
"def main():\n\t#a = int(input())\n\tn, m = tin()\n\t#s = input()\n\tis_red_in = [0]*n\n\tis_red_in[0] = 1\n\tnum_of_ball = [1] * n\n\tfor _ in range(m):\n\t\tf, t = tin()\n\t\tf, t = f-1, t-1\n\t\tnum_of_ball[f] -= 1\n\t\tnum_of_ball[t] += 1\n\t\tif is_red_in[f] == 1:\n\t\t\tis_red_in[t] = 1\n\t\tif num_of_ball[f] == 0:\n\t\t\tis_red_in[f] = 0\n\treturn sum(is_red_in)\n\t\n\t\n#+++++",
"main",
"isTest=True",
"True",
"isTest",
"using_method=0",
"0",
"using_method",
"ic=input_clipboard()",
"input_clipboard()",
"ic",
"isTest=False",
"False",
"isTest",
"input = lambda : ic.__next__()",
"lambda : ic.__next__()",
"input",
"tin=lambda : map(int, input().split())",
"lambda : map(int, input().split())",
"tin",
"def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t",
"def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t",
"pa",
"ret = main()",
"main()",
"ret",
"mod=1000000007",
"1000000007",
"mod",
"def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l",
"def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l",
"input_clipboard",
"input_method=input_methods[using_method]",
"input_methods[using_method]",
"input_method",
"lin=lambda : list(tin())",
"lambda : list(tin())",
"lin"
] | import sys
input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]
tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007
#+++++
def main():
#a = int(input())
n, m = tin()
#s = input()
is_red_in = [0]*n
is_red_in[0] = 1
num_of_ball = [1] * n
for _ in range(m):
f, t = tin()
f, t = f-1, t-1
num_of_ball[f] -= 1
num_of_ball[t] += 1
if is_red_in[f] == 1:
is_red_in[t] = 1
if num_of_ball[f] == 0:
is_red_in[f] = 0
return sum(is_red_in)
#+++++
isTest=False
def pa(v):
if isTest:
print(v)
def input_clipboard():
import clipboard
input_text=clipboard.get()
input_l=input_text.splitlines()
for l in input_l:
yield l
if __name__ == "__main__":
if sys.platform =='ios':
if input_method==input_methods[0]:
ic=input_clipboard()
input = lambda : ic.__next__()
elif input_method==input_methods[1]:
sys.stdin=open('inputFile.txt')
else:
pass
isTest=True
else:
pass
#input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret) |
[
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,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
14,
2,
2,
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,
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,
13,
13,
10,
2,
13
] | [
[
125,
2
],
[
125,
11
],
[
15,
14
],
[
123,
17
],
[
128,
21
],
[
119,
24
],
[
126,
28
],
[
33,
30
],
[
120,
31
],
[
131,
35
],
[
126,
39
],
[
120,
48
],
[
132,
55
],
[
66,
61
],
[
120,
62
],
[
120,
71
],
[
132,
78
],
[
89,
84
],
[
120,
85
],
[
96,
91
],
[
120,
92
],
[
103,
98
],
[
132,
99
],
[
110,
105
],
[
132,
106
],
[
120,
115
],
[
132,
116
],
[
119,
120
],
[
125,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
]
] | [
"n,m=map(int,input().split())\na=[[int(i) for i in input().split()] for i in range(m)]\n\npossibility=[False]*n\npossibility[0]=True\ncount=[1]*n\n\nfor x,y in a:\n if possibility[x-1]==True and count[x-1]>1:\n possibility[y-1]=True\n elif possibility[x-1]==True and count[x-1]==1:\n possibility[x-1]=False\n possibility[y-1]=True\n count[x-1]-=1\n count[y-1]+=1\n\nprint(possibility.count(True))",
"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 i in range(m)",
"for i in range(m)",
"i",
"range(m)",
"range",
"m",
"for i in range(m)",
"[int(i) for i in input().split()]",
"a=[[int(i) for i in input().split()] for i in range(m)]",
"a",
"[[int(i) for i in input().split()] for i in range(m)]",
"possibility=[False]*n",
"possibility",
"[False]*n",
"[False]",
"False",
"n",
"possibility[0]=True",
"possibility[0]",
"possibility",
"0",
"True",
"count=[1]*n",
"count",
"[1]*n",
"[1]",
"1",
"n",
"for x,y in a:\n if possibility[x-1]==True and count[x-1]>1:\n possibility[y-1]=True\n elif possibility[x-1]==True and count[x-1]==1:\n possibility[x-1]=False\n possibility[y-1]=True\n count[x-1]-=1\n count[y-1]+=1",
"x",
"y",
"a",
"if possibility[x-1]==True and count[x-1]>1:\n possibility[y-1]=True\n elif possibility[x-1]==True and count[x-1]==1:\n possibility[x-1]=False\n possibility[y-1]=True\n ",
"possibility[x-1]==True and count[x-1]>1",
"possibility[x-1]==True",
"possibility[x-1]",
"possibility",
"x-1",
"x",
"1",
"True",
"count[x-1]>1",
"count[x-1]",
"count",
"x-1",
"x",
"1",
"1",
"possibility[y-1]=True",
"possibility[y-1]",
"possibility",
"y-1",
"y",
"1",
"True",
"elif possibility[x-1]==True and count[x-1]==1:\n possibility[x-1]=False\n possibility[y-1]=True\n ",
"possibility[x-1]==True and count[x-1]==1",
"possibility[x-1]==True",
"possibility[x-1]",
"possibility",
"x-1",
"x",
"1",
"True",
"count[x-1]==1",
"count[x-1]",
"count",
"x-1",
"x",
"1",
"1",
"possibility[x-1]=False",
"possibility[x-1]",
"possibility",
"x-1",
"x",
"1",
"False",
"possibility[y-1]=True",
"possibility[y-1]",
"possibility",
"y-1",
"y",
"1",
"True",
"count[x-1]-=1",
"count[x-1]",
"count",
"x-1",
"x",
"1",
"1",
"count[y-1]+=1",
"count[y-1]",
"count",
"y-1",
"y",
"1",
"1",
"print(possibility.count(True))",
"print",
"possibility.count(True)",
"possibility.count",
"possibility",
"count",
"True",
"possibility=[False]*n",
"[False]*n",
"possibility",
"m=map(int,input().split())",
"map(int,input().split())",
"m",
"n,m=map(int,input().split())",
"map(int,input().split())",
"n",
"a=[[int(i) for i in input().split()] for i in range(m)]",
"[[int(i) for i in input().split()] for i in range(m)]",
"a",
"count=[1]*n",
"[1]*n",
"count"
] | n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
possibility=[False]*n
possibility[0]=True
count=[1]*n
for x,y in a:
if possibility[x-1]==True and count[x-1]>1:
possibility[y-1]=True
elif possibility[x-1]==True and count[x-1]==1:
possibility[x-1]=False
possibility[y-1]=True
count[x-1]-=1
count[y-1]+=1
print(possibility.count(True))
|
[
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,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
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,
4,
13,
4,
13,
13,
10,
2,
13,
10,
2,
13
] | [
[
4,
3
],
[
3,
15
],
[
21,
18
],
[
21,
22
],
[
91,
25
],
[
94,
36
],
[
51,
46
],
[
95,
47
],
[
58,
53
],
[
95,
54
],
[
65,
60
],
[
92,
61
],
[
92,
66
],
[
95,
73
],
[
84,
79
],
[
92,
80
],
[
92,
89
],
[
91,
92
],
[
94,
95
]
] | [
"#!/usr/bin/env python3\n(n, m), *q = [[*map(int, i.split())] for i in open(0)]\nb = [1] + [0] * (n - 1)\nc = [1] * n\nfor x, y in q:\n c[x - 1] -= 1\n c[y - 1] += 1\n b[y - 1] |= b[x - 1]\n if c[x - 1] == 0:\n b[x - 1] = 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 = [1] + [0] * (n - 1)",
"b",
"[1] + [0] * (n - 1)",
"[1]",
"1",
"[0] * (n - 1)",
"[0]",
"0",
"n - 1",
"n",
"1",
"c = [1] * n",
"c",
"[1] * n",
"[1]",
"1",
"n",
"for x, y in q:\n c[x - 1] -= 1\n c[y - 1] += 1\n b[y - 1] |= b[x - 1]\n if c[x - 1] == 0:\n b[x - 1] = 0",
"x",
"y",
"q",
"c[x - 1] -= 1",
"c[x - 1]",
"c",
"x - 1",
"x",
"1",
"1",
"c[y - 1] += 1",
"c[y - 1]",
"c",
"y - 1",
"y",
"1",
"1",
"b[y - 1] |= b[x - 1]",
"b[y - 1]",
"b",
"y - 1",
"y",
"1",
"b[x - 1]",
"b",
"x - 1",
"x",
"1",
"if c[x - 1] == 0:\n b[x - 1] = 0",
"c[x - 1] == 0",
"c[x - 1]",
"c",
"x - 1",
"x",
"1",
"0",
"b[x - 1] = 0",
"b[x - 1]",
"b",
"x - 1",
"x",
"1",
"0",
"print(sum(b))",
"print",
"sum(b)",
"sum",
"b",
"b = [1] + [0] * (n - 1)",
"[1] + [0] * (n - 1)",
"b",
"c = [1] * n",
"[1] * n",
"c"
] | #!/usr/bin/env python3
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [1] + [0] * (n - 1)
c = [1] * n
for x, y in q:
c[x - 1] -= 1
c[y - 1] += 1
b[y - 1] |= b[x - 1]
if c[x - 1] == 0:
b[x - 1] = 0
print(sum(b))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
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,
14,
2,
13,
13,
4,
18,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
13,
4,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] | [
[
88,
2
],
[
88,
11
],
[
79,
13
],
[
83,
20
],
[
85,
22
],
[
29,
28
],
[
89,
31
],
[
94,
33
],
[
94,
42
],
[
92,
45
],
[
86,
46
],
[
86,
49
],
[
95,
51
],
[
56,
53
],
[
80,
54
],
[
92,
55
],
[
61,
58
],
[
80,
59
],
[
95,
60
],
[
53,
64
],
[
80,
65
],
[
92,
66
],
[
86,
70
],
[
92,
72
],
[
86,
77
],
[
79,
80
],
[
88,
83
],
[
85,
86
],
[
88,
89
],
[
94,
92
],
[
94,
95
]
] | [
"N,M = map(int,input().split())\n\nlisN = [0] + [1]*N\nansSet = set([1])\n\nfor _ in range(M):\n # print(ansSet,lisN)\n x,y = map(int,input().split())\n if x in ansSet:\n ansSet.add(y)\n lisN[x] -= 1\n lisN[y] += 1\n if lisN[x] == 0:\n ansSet.discard(x)\n\nprint(len(ansSet))",
"N,M = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M",
"lisN = [0] + [1]*N",
"lisN",
"[0] + [1]*N",
"[0]",
"0",
"[1]*N",
"[1]",
"1",
"N",
"ansSet = set([1])",
"ansSet",
"set([1])",
"set",
"[1]",
"1",
"for _ in range(M):\n # print(ansSet,lisN)\n x,y = map(int,input().split())\n if x in ansSet:\n ansSet.add(y)\n lisN[x] -= 1\n lisN[y] += 1\n if lisN[x] == 0:\n ansSet.discard(x)",
"_",
"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 ansSet:\n ansSet.add(y)\n ",
"x in ansSet",
"x",
"ansSet",
"ansSet.add(y)",
"ansSet.add",
"ansSet",
"add",
"y",
"lisN[x] -= 1",
"lisN[x]",
"lisN",
"x",
"1",
"lisN[y] += 1",
"lisN[y]",
"lisN",
"y",
"1",
"if lisN[x] == 0:\n ansSet.discard(x)",
"lisN[x] == 0",
"lisN[x]",
"lisN",
"x",
"0",
"ansSet.discard(x)",
"ansSet.discard",
"ansSet",
"discard",
"x",
"print(len(ansSet))",
"print",
"len(ansSet)",
"len",
"ansSet",
"lisN = [0] + [1]*N",
"[0] + [1]*N",
"lisN",
"N,M = map(int,input().split())",
"map(int,input().split())",
"N",
"ansSet = set([1])",
"set([1])",
"ansSet",
"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"
] | N,M = map(int,input().split())
lisN = [0] + [1]*N
ansSet = set([1])
for _ in range(M):
# print(ansSet,lisN)
x,y = map(int,input().split())
if x in ansSet:
ansSet.add(y)
lisN[x] -= 1
lisN[y] += 1
if lisN[x] == 0:
ansSet.discard(x)
print(len(ansSet))
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.