node_ids listlengths 4 1.4k | edge_index listlengths 1 2.22k | text listlengths 4 1.4k | source stringlengths 14 427k |
|---|---|---|---|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
... | [
[
131,
2
],
[
131,
11
],
[
128,
13
],
[
17,
16
],
[
126,
19
],
[
129,
22
],
[
134,
35
],
[
132,
40
],
[
46,
43
],
[
135,
44
],
[
122,
48
],
[
132,
53
],
[
57,
56
... | [
"n,m=map(int,input().split())\nl=[]\nfor _ in range(m):\n l.append(list(map(int,input().split())))\na=[0]*(n+1)\na[1]=1\nc=[1]*(n+1)\nfor i in range(m):\n c[l[i][0]]-=1\n c[l[i][1]]+=1\n if a[l[i][0]]:\n a[l[i][1]]=1\n if c[l[i][0]]==0:\n a[l[i][0]]=0\nprint(a.count(1))",
"n,m=map(int... | n,m=map(int,input().split())
l=[]
for _ in range(m):
l.append(list(map(int,input().split())))
a=[0]*(n+1)
a[1]=1
c=[1]*(n+1)
for i in range(m):
c[l[i][0]]-=1
c[l[i][1]]+=1
if a[l[i][0]]:
a[l[i][1]]=1
if c[l[i][0]]==0:
a[l[i][0]]=0
print(a.count(1)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
39,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
17,
17,
4,
17,
0,
13,
13,
0,
18,
13,
... | [
[
179,
2
],
[
179,
11
],
[
152,
13
],
[
17,
16
],
[
180,
19
],
[
155,
21
],
[
161,
24
],
[
153,
37
],
[
162,
39
],
[
156,
39
],
[
43,
42
],
[
170,
51
],
[
57,
54
... | [
"n, m = map(int,input().split())\nb_list = []\n\nfor i in range(m):\n x = []\n x = list(map(int,input().split()))\n b_list.append(x)\n\nans_list = [0 for i in range(10**5)]\nans_list[0] = 1\nball_list = [1 for i in range(10**5)]\n\nfor tmp in b_list:\n x, y = tmp[0], tmp[1]\n if ans_list[x-1] == 1 an... | n, m = map(int,input().split())
b_list = []
for i in range(m):
x = []
x = list(map(int,input().split()))
b_list.append(x)
ans_list = [0 for i in range(10**5)]
ans_list[0] = 1
ball_list = [1 for i in range(10**5)]
for tmp in b_list:
x, y = tmp[0], tmp[1]
if ans_list[x-1] == 1 and ans_list[y-1] == ... |
[
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,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,... | [
[
166,
2
],
[
166,
11
],
[
163,
13
],
[
17,
16
],
[
149,
19
],
[
151,
21
],
[
151,
30
],
[
164,
33
],
[
152,
37
],
[
143,
40
],
[
45,
44
],
[
167,
47
],
[
139,
51
... | [
"n,m = map(int, input().split())\nxy = []\n\nfor i in range(m):\n x,y = map(int, input().split())\n xy.append([x-1,y-1])\n\nbox = [1 for i in range(n)]\n\nchk = [False for i in range(n)]\nchk[0] = True\nfor i in range(m):\n x, y = xy[i][0],xy[i][1]\n if chk[x]:\n if box[x] >= 2:\n chk[y] = True \n el... | n,m = map(int, input().split())
xy = []
for i in range(m):
x,y = map(int, input().split())
xy.append([x-1,y-1])
box = [1 for i in range(n)]
chk = [False for i in range(n)]
chk[0] = True
for i in range(m):
x, y = xy[i][0],xy[i][1]
if chk[x]:
if box[x] >= 2:
chk[y] = True
else:
chk[y] = Tr... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
29,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
18,
4,
13,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
... | [
[
144,
4
],
[
145,
16
],
[
145,
24
],
[
145,
34
],
[
145,
42
],
[
48,
47
],
[
130,
49
],
[
48,
50
],
[
54,
53
],
[
50,
56
],
[
130,
61
],
[
64,
63
],
[
68,
67
],
... | [
"import sys\ninput = sys.stdin.readline\n\n\ndef readstr():\n return input().strip()\n\n\ndef readint():\n return int(input())\n\n\ndef readnums():\n return map(int, input().split())\n\n\ndef readstrs():\n return input().split()\n\n\ndef main():\n N, M = readnums()\n xy = [tuple(readnums()) for _ ... | import sys
input = sys.stdin.readline
def readstr():
return input().strip()
def readint():
return int(input())
def readnums():
return map(int, input().split())
def readstrs():
return input().split()
def main():
N, M = readnums()
xy = [tuple(readnums()) for _ in range(M)]
dic = {i: ... |
[
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,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
13,
13,
0,
13,
2,
... | [
[
116,
2
],
[
116,
11
],
[
15,
14
],
[
99,
17
],
[
107,
30
],
[
104,
33
],
[
117,
37
],
[
42,
39
],
[
105,
40
],
[
113,
44
],
[
117,
48
],
[
101,
54
],
[
102,
56
... | [
"N,M = map(int,input().split())\nXY = [tuple(map(int,input().split())) for i in range(M)]\n\nmay_red = [0] * N\nmay_red[0] = 1\nballs = [1] * N\n\nfor x,y in XY:\n x,y = x-1,y-1\n if may_red[x]:\n may_red[y] = 1\n if balls[x] == 1:\n may_red[x] = 0\n balls[x] -= 1\n balls[y] += ... | N,M = map(int,input().split())
XY = [tuple(map(int,input().split())) for i in range(M)]
may_red = [0] * N
may_red[0] = 1
balls = [1] * N
for x,y in XY:
x,y = x-1,y-1
if may_red[x]:
may_red[y] = 1
if balls[x] == 1:
may_red[x] = 0
balls[x] -= 1
balls[y] += 1
print(sum(may_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,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
2,
18,
13,
2,
13,
17,
17,
2,
18,
... | [
[
197,
2
],
[
197,
11
],
[
194,
13
],
[
189,
17
],
[
22,
19
],
[
195,
20
],
[
185,
24
],
[
189,
28
],
[
31,
30
],
[
198,
33
],
[
191,
35
],
[
191,
44
],
[
195,
49
... | [
"n,m=map(int,input().split())\nans=[0]*n\nans[0]=1\nb=[1]*n\nfor i in range(m):\n x,y=map(int,input().split())\n if ans[x-1]==1 and b[x-1]>1:\n ans[y-1]=1\n b[x-1]=b[x-1]-1\n b[y-1]=b[y-1]+1\n elif ans[x-1]==1 and b[x-1]==1:\n ans[x-1]=0\n ans[y-1]=1\n b[x-1]=b[x-1]-1\n b[y-1]=b[y-1]+1\n el... | n,m=map(int,input().split())
ans=[0]*n
ans[0]=1
b=[1]*n
for i in range(m):
x,y=map(int,input().split())
if ans[x-1]==1 and b[x-1]>1:
ans[y-1]=1
b[x-1]=b[x-1]-1
b[y-1]=b[y-1]+1
elif ans[x-1]==1 and b[x-1]==1:
ans[x-1]=0
ans[y-1]=1
b[x-1]=b[x-1]-1
b[y-1]=b[y-1]+1
else:
b[x-1]=b[x-1... |
[
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,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
... | [
[
121,
2
],
[
121,
11
],
[
118,
13
],
[
122,
17
],
[
130,
19
],
[
122,
23
],
[
28,
25
],
[
131,
26
],
[
109,
30
],
[
127,
33
],
[
37,
36
],
[
116,
39
],
[
124,
41
... | [
"N,M=map(int,input().split())\nnum=[1]*N\nex=[0]*N\nex[0]=1\nP=[]\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 ex[x-1]==1 and ex[y-1]==0:\n ex[y-1]=1\n if num[x-1]==0:\n ex[x-1]=0\nprint(sum(ex))",
"N,M=map(int,input().split())",
"N",
... | N,M=map(int,input().split())
num=[1]*N
ex=[0]*N
ex[0]=1
P=[]
ans=1
for i in range(M):
x,y=map(int,input().split())
num[x-1]-=1
num[y-1]+=1
if ex[x-1]==1 and ex[y-1]==0:
ex[y-1]=1
if num[x-1]==0:
ex[x-1]=0
print(sum(ex)) |
[
7,
15,
15,
15,
13,
13,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
17,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
2... | [
[
128,
18
],
[
131,
25
],
[
137,
34
],
[
123,
36
],
[
137,
37
],
[
116,
39
],
[
138,
43
],
[
48,
45
],
[
117,
46
],
[
119,
50
],
[
138,
54
],
[
57,
56
],
[
114,
59
... | [
"from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush,heapify\nimport sys,bisect,math,itertools,fractions,pprint\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
n,m = ... |
[
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,
0,
13,
2,
13,
17,
13,
2,
13,
17,
0,
18,
... | [
[
126,
2
],
[
126,
11
],
[
102,
13
],
[
112,
21
],
[
99,
24
],
[
112,
28
],
[
31,
30
],
[
127,
33
],
[
123,
35
],
[
123,
44
],
[
114,
46
],
[
106,
48
],
[
115,
48
... | [
"n, m = map(int, input().split())\njud = [True] + [False]*(n - 1)\nl = [1]*n\n\nfor i in range(m):\n x, y = map(int, input().split())\n x, y = x - 1, y - 1\n l[x] -= 1\n l[y] += 1\n if jud[x]:\n jud[y] = True\n if l[x] == 0:\n jud[x] = False\n\nans = 0\nfor i in jud:\n if i:\n ... | n, m = map(int, input().split())
jud = [True] + [False]*(n - 1)
l = [1]*n
for i in range(m):
x, y = map(int, input().split())
x, y = x - 1, y - 1
l[x] -= 1
l[y] += 1
if jud[x]:
jud[y] = True
if l[x] == 0:
jud[x] = False
ans = 0
for i in jud:
if i:
ans += 1
print(ans... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
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,
18,
18,
13,
13,
1... | [
[
112,
2
],
[
112,
11
],
[
15,
14
],
[
110,
18
],
[
100,
25
],
[
31,
28
],
[
101,
29
],
[
36,
35
],
[
113,
38
],
[
106,
40
],
[
106,
49
],
[
101,
53
],
[
104,
54
... | [
"n, m = map(int, input().split())\n\na = [[1, False] for _ in range(n+1)]\na[1] = [1, True]\n\nfor _ in range(m):\n x, y = map(int, input().split())\n if a[x][1]:\n a[y][1] = True\n \n a[x][0] -= 1\n if a[x][0] == 0:\n a[x][1] = False\n a[y][0] += 1\n\nprint(sum(x[1] for x in a))",
... | n, m = map(int, input().split())
a = [[1, False] for _ in range(n+1)]
a[1] = [1, True]
for _ in range(m):
x, y = map(int, input().split())
if a[x][1]:
a[y][1] = True
a[x][0] -= 1
if a[x][0] == 0:
a[x][1] = False
a[y][0] += 1
print(sum(x[1] for x in a)) |
[
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,
0,
13,
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,
... | [
[
132,
2
],
[
132,
11
],
[
126,
13
],
[
133,
17
],
[
120,
19
],
[
133,
23
],
[
28,
25
],
[
127,
26
],
[
135,
30
],
[
34,
33
],
[
115,
36
],
[
123,
38
],
[
123,
47
... | [
"N, M = map(int, input().split())\ns = [0]*N\nt = [1]*N\ns[0] = 1\nres = 1\nfor _ in range(M):\n x, y = map(int, input().split())\n x-=1\n y-=1\n t[x] -= 1\n t[y] += 1\n if s[x] == 1:\n if t[x]==0:\n s[x] = 0\n if s[y]==1:\n res -= 1\n else:\n ... | N, M = map(int, input().split())
s = [0]*N
t = [1]*N
s[0] = 1
res = 1
for _ in range(M):
x, y = map(int, input().split())
x-=1
y-=1
t[x] -= 1
t[y] += 1
if s[x] == 1:
if t[x]==0:
s[x] = 0
if s[y]==1:
res -= 1
else:
if s[y]!=1:
... |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
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... | [
[
119,
4
],
[
122,
20
],
[
120,
27
],
[
122,
29
],
[
128,
31
],
[
114,
36
],
[
116,
39
],
[
114,
44
],
[
50,
47
],
[
129,
48
],
[
55,
52
],
[
117,
53
],
[
58,
57
... | [
"import sys\ninput = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 7)\n\nN, M = map(int, input().split())\nred = [0] * (N + 1)\nwhite = [1] * (N + 1)\nred[1] = 1\nwhite[1] = 0\n\nfor _ in range(M):\n x, y = map(int, input().split())\n if red[x]:\n red[y] += 1\n else:\n white[y] += 1\... | import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N, M = map(int, input().split())
red = [0] * (N + 1)
white = [1] * (N + 1)
red[1] = 1
white[1] = 0
for _ in range(M):
x, y = map(int, input().split())
if red[x]:
red[y] += 1
else:
white[y] += 1
if white[x]:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
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,
17,
0,
... | [
[
134,
2
],
[
134,
11
],
[
113,
13
],
[
137,
25
],
[
129,
29
],
[
116,
31
],
[
129,
35
],
[
40,
37
],
[
117,
38
],
[
43,
42
],
[
135,
45
],
[
125,
47
],
[
114,
49
... | [
"n, m = map(int, input().split())\nXY = list(map(int, input().split()) for _ in range(m))\n\nBall = [1] * n\nDone = [False] * n\nDone[0] = True\n\nfor i in range(m):\n\tx, y = XY[i]\n\tx -= 1\n\ty -= 1\n\tif Done[x]:\n\t\tDone[y] = True\n\t\n\tBall[x] -= 1\n\tBall[y] += 1\n\t\n\tif Ball[x] == 0:\n\t\tDone[x] = Fals... | n, m = map(int, input().split())
XY = list(map(int, input().split()) for _ in range(m))
Ball = [1] * n
Done = [False] * n
Done[0] = True
for i in range(m):
x, y = XY[i]
x -= 1
y -= 1
if Done[x]:
Done[y] = True
Ball[x] -= 1
Ball[y] += 1
if Ball[x] == 0:
Done[x] = False
res = 0
for i in range(n):
i... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
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,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,... | [
[
138,
2
],
[
138,
11
],
[
15,
14
],
[
139,
17
],
[
135,
21
],
[
27,
24
],
[
136,
25
],
[
31,
30
],
[
139,
33
],
[
126,
37
],
[
41,
40
],
[
130,
43
],
[
147,
45
]... | [
"n, m = map(int, input().split())\nred = [0 for _ in range(n)]\nred[0] = 1\nballs = [1 for _ in range(n)]\nfor _ in range(m):\n x, y = map(int, input().split())\n if balls[x-1]:\n balls[x-1] -= 1\n balls[y-1] += 1\n if red[x-1]:\n red[y-1] = 1\n if balls[x-1] == 0:\n... | n, m = map(int, input().split())
red = [0 for _ in range(n)]
red[0] = 1
balls = [1 for _ in range(n)]
for _ in range(m):
x, y = map(int, input().split())
if balls[x-1]:
balls[x-1] -= 1
balls[y-1] += 1
if red[x-1]:
red[y-1] = 1
if balls[x-1] == 0:
r... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
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,
... | [
[
159,
2
],
[
159,
11
],
[
162,
13
],
[
160,
17
],
[
168,
19
],
[
160,
23
],
[
28,
25
],
[
169,
26
],
[
31,
30
],
[
154,
33
],
[
171,
35
],
[
171,
44
],
[
51,
46
... | [
"n,m=map(int,input().split())\ncnt=[1]*n\nyn=[0]*n\nyn[0]=1\nfor i in range(m):\n x,y=map(int,input().split())\n cnt[x-1]-=1\n cnt[y-1]+=1\n if x==1:\n if cnt[0]==0:\n yn[0]=0\n yn[y-1]=1\n for j in range(i+1,m):\n x,y=map(int,input().split())\n if y... | n,m=map(int,input().split())
cnt=[1]*n
yn=[0]*n
yn[0]=1
for i in range(m):
x,y=map(int,input().split())
cnt[x-1]-=1
cnt[y-1]+=1
if x==1:
if cnt[0]==0:
yn[0]=0
yn[y-1]=1
for j in range(i+1,m):
x,y=map(int,input().split())
if yn[x-1]==1:
... |
[
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,
0,
18,
13,
2,
13,
... | [
[
118,
2
],
[
118,
11
],
[
124,
13
],
[
116,
17
],
[
22,
19
],
[
125,
20
],
[
106,
24
],
[
116,
28
],
[
31,
30
],
[
119,
33
],
[
127,
35
],
[
127,
44
],
[
125,
47
... | [
"N,M = map(int,input().split())\nrboxes = [False]*N\nrboxes[0] = True\nballC = [1]*N\nfor i in range(M):\n x, y = map(int, input().split())\n if rboxes[x-1]:\n rboxes[y-1] = True\n ballC[x-1] -= 1\n ballC[y-1] += 1\n if ballC[x-1] == 0:\n rboxes[x-1] = False\nc = 0\nfor i in range(N):\n... | N,M = map(int,input().split())
rboxes = [False]*N
rboxes[0] = True
ballC = [1]*N
for i in range(M):
x, y = map(int, input().split())
if rboxes[x-1]:
rboxes[y-1] = True
ballC[x-1] -= 1
ballC[y-1] += 1
if ballC[x-1] == 0:
rboxes[x-1] = False
c = 0
for i in range(N):
if rboxes[i]:
... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
2,
2,
17,
17,
17,
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,
1... | [
[
109,
4
],
[
20,
19
],
[
27,
26
],
[
119,
28
],
[
27,
29
],
[
32,
31
],
[
26,
35
],
[
40,
37
],
[
31,
38
],
[
43,
42
],
[
26,
46
],
[
49,
48
],
[
29,
51
],
[
... | [
"import sys\ninput = sys.stdin.readline\n\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\ndef main():\n mod=10**9+7\n N,M=MI()\n L=[0]*N\n L[0]=1\n cnt=[1]*N\n for i in range(M):\n x,y=MI()\n x-=1\n ... | import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N,M=MI()
L=[0]*N
L[0]=1
cnt=[1]*N
for i in range(M):
x,y=MI()
x-=1
y-=1
if L[x]... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
... | [
[
118,
2
],
[
118,
11
],
[
121,
13
],
[
113,
18
],
[
24,
21
],
[
122,
22
],
[
100,
26
],
[
113,
31
],
[
35,
34
],
[
119,
37
],
[
109,
39
],
[
109,
48
],
[
53,
50
... | [
"n,m = map(int, input().split())\nr = [0]*(n+1)\nr[1] = 1\nb0 = [1]*(n+1)\nfor i in range(m):\n x,y = map(int, input().split())\n b0[x] -= 1\n b0[y] += 1\n if r[x]:\n r[y] = 1\n if b0[x]==0:\n r[x]=0\nans = 0\nfor j in range(n+1):\n if r[j]:\n ans += 1\nprint(ans)",
"n,m = m... | n,m = map(int, input().split())
r = [0]*(n+1)
r[1] = 1
b0 = [1]*(n+1)
for i in range(m):
x,y = map(int, input().split())
b0[x] -= 1
b0[y] += 1
if r[x]:
r[y] = 1
if b0[x]==0:
r[x]=0
ans = 0
for j in range(n+1):
if r[j]:
ans += 1
print(ans)
|
[
7,
15,
13,
15,
0,
13,
4,
13,
17,
15,
13,
4,
18,
13,
13,
2,
17,
17,
15,
13,
15,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
12,
13,... | [
[
215,
5
],
[
30,
29
],
[
201,
35
],
[
39,
39
],
[
43,
42
],
[
210,
48
],
[
52,
52
],
[
62,
61
],
[
204,
66
],
[
70,
70
],
[
74,
73
],
[
198,
79
],
[
83,
83
],
... | [
"import math\nfrom math import gcd,pi\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for... | import math
from math import gcd,pi
INF = float("inf")
import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
de... |
[
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,
17,
0,
18,
13,
2,
... | [
[
101,
2
],
[
101,
11
],
[
98,
13
],
[
102,
17
],
[
22,
19
],
[
99,
20
],
[
110,
24
],
[
102,
28
],
[
31,
30
],
[
96,
33
],
[
107,
35
],
[
107,
44
],
[
51,
46
],
... | [
"N, M = map(int, input().split())\nans = [0] * N\nans[0] = 1\nw = [1] * N\n\nfor i in range(M):\n x, y = map(int, input().split())\n w[x-1] -= 1\n w[y-1] += 1\n if ans[x-1] == 1:\n ans[y-1] = 1\n if w[x-1] == 0:\n ans[x-1] = 0\n \nprint(sum(ans))",
"N, M = map(int, input().split())",
"N",
"m... | N, M = map(int, input().split())
ans = [0] * N
ans[0] = 1
w = [1] * N
for i in range(M):
x, y = map(int, input().split())
w[x-1] -= 1
w[y-1] += 1
if ans[x-1] == 1:
ans[y-1] = 1
if w[x-1] == 0:
ans[x-1] = 0
print(sum(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,
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,
28,... | [
[
218,
2
],
[
218,
11
],
[
212,
13
],
[
219,
17
],
[
206,
19
],
[
219,
23
],
[
28,
25
],
[
213,
26
],
[
215,
30
],
[
34,
33
],
[
210,
36
],
[
203,
38
],
[
203,
47
... | [
"n,m = map(int,input().split())\npossible = [0]*n\nkosuu = [1]*n\npossible[0] = 1\nL = []\n\nfor i in range(m):\n x,y = map(int,input().split())\n L.append((x,y))\n\nfor i in range(m):\n x,y = L[i][0],L[i][1]\n x,y = x-1,y-1\n if kosuu[x] >=2 and possible[x] == 1:\n possible[y] = 1\n ko... | n,m = map(int,input().split())
possible = [0]*n
kosuu = [1]*n
possible[0] = 1
L = []
for i in range(m):
x,y = map(int,input().split())
L.append((x,y))
for i in range(m):
x,y = L[i][0],L[i][1]
x,y = x-1,y-1
if kosuu[x] >=2 and possible[x] == 1:
possible[y] = 1
kosuu[x] -=1
k... |
[
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,
0,
18,
13,
2,
13,
... | [
[
125,
2
],
[
125,
11
],
[
119,
13
],
[
111,
17
],
[
22,
19
],
[
120,
20
],
[
122,
24
],
[
111,
28
],
[
31,
30
],
[
126,
33
],
[
116,
35
],
[
116,
44
],
[
120,
47
... | [
"n, m = map(int, input().split())\n\ns = [0] * n\ns[0] = 1\nb = [1] * n\nfor i in range(m):\n x, y = map(int, input().split())\n if s[x-1]:\n s[y-1] = 1\n if b[x-1] == 1:\n s[x-1] = 0\n b[x-1] -= 1\n b[y-1] += 1\n\nans = 0\nfor i in range(n):\n if s[i] and b[i]:\n ans += 1\n\n... | n, m = map(int, input().split())
s = [0] * n
s[0] = 1
b = [1] * n
for i in range(m):
x, y = map(int, input().split())
if s[x-1]:
s[y-1] = 1
if b[x-1] == 1:
s[x-1] = 0
b[x-1] -= 1
b[y-1] += 1
ans = 0
for i in range(n):
if s[i] and b[i]:
ans += 1
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
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,
... | [
[
106,
2
],
[
106,
11
],
[
15,
14
],
[
107,
18
],
[
109,
23
],
[
28,
27
],
[
107,
31
],
[
112,
36
],
[
42,
39
],
[
110,
40
],
[
45,
44
],
[
104,
47
],
[
100,
49
]... | [
"n,m=map(int,input().split())\nans=[0 for _ in range(n+1)]\ncnt=[1 for _ in range(n+1)]\nans[1]=1\nfor i in range(m):\n a,b=map(int,input().split())\n if ans[a]==1:\n ans[b]=1\n if cnt[a]==1:\n ans[a]=0\n cnt[a]-=1\n cnt[b]+=1\nprint(sum(ans))",
"n,m=map(int,input().split())",
"n",
"map(int,inp... | n,m=map(int,input().split())
ans=[0 for _ in range(n+1)]
cnt=[1 for _ in range(n+1)]
ans[1]=1
for i in range(m):
a,b=map(int,input().split())
if ans[a]==1:
ans[b]=1
if cnt[a]==1:
ans[a]=0
cnt[a]-=1
cnt[b]+=1
print(sum(ans)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
39,
17,
13,
0,
13,
2,
2,
39,
17,
39,
17,
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,
... | [
[
113,
2
],
[
113,
11
],
[
107,
13
],
[
114,
20
],
[
101,
22
],
[
114,
33
],
[
37,
36
],
[
105,
39
],
[
116,
41
],
[
116,
50
],
[
79,
53
],
[
102,
54
],
[
111,
55
... | [
"n,m=map(int,input().split())\nkosuu=[0]+[1]*n\nhaitteru=[0]+[1]+[0]*(n-1)\nfor _ in range(m):\n x,y=map(int,input().split())\n if haitteru[x]==1:\n kosuu[x]-=1\n kosuu[y]+=1\n haitteru[y]=1\n if kosuu[x]==0:\n haitteru[x]=0\n else:\n kosuu[x]-=1\n kosuu... | n,m=map(int,input().split())
kosuu=[0]+[1]*n
haitteru=[0]+[1]+[0]*(n-1)
for _ in range(m):
x,y=map(int,input().split())
if haitteru[x]==1:
kosuu[x]-=1
kosuu[y]+=1
haitteru[y]=1
if kosuu[x]==0:
haitteru[x]=0
else:
kosuu[x]-=1
kosuu[y]+=1
print(haitt... |
[
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,
17,
17,
0,
13,
2,
39,
17,
2,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
... | [
[
122,
2
],
[
122,
11
],
[
15,
14
],
[
123,
17
],
[
110,
30
],
[
116,
33
],
[
125,
41
],
[
52,
49
],
[
126,
50
],
[
55,
54
],
[
123,
57
],
[
128,
59
],
[
111,
62
... | [
"n, m = map(int, input().split())\nli = [list(map(int, input().split())) for _ in range(m)]\n\nball_cnt = [1] * 10**6\ncheck = [0] * 10**6\n\ncheck[1] += 1\n\nfor i in range(m):\n x = li[i][0]\n y = li[i][1]\n \n if check[x] == 1:\n check[y] = 1\n \n ball_cnt[x] -= 1\n ball_cnt[y] += 1\n... | n, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)]
ball_cnt = [1] * 10**6
check = [0] * 10**6
check[1] += 1
for i in range(m):
x = li[i][0]
y = li[i][1]
if check[x] == 1:
check[y] = 1
ball_cnt[x] -= 1
ball_cnt[y] += 1
if ball_cnt[x... |
[
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,
13,
4,
17,
0,
13,
13,
0,
18,
... | [
[
168,
2
],
[
168,
11
],
[
15,
14
],
[
148,
17
],
[
150,
30
],
[
35,
34
],
[
169,
37
],
[
171,
41
],
[
46,
45
],
[
169,
48
],
[
153,
52
],
[
58,
55
],
[
154,
56
]... | [
"N, M = map(int, input().split())\nZ = [list(map(int,input().split())) for i in range(M)]\nkosuu = [1 for _ in range(N)]\nred = [False for _ in range(N)]\nred[0] = True\n\nfor i in range(M):\n x = Z[i][0] - 1\n y = Z[i][1] - 1\n if (kosuu[x] != 0 and red[x] == True):\n red[y] = True\n if (kosuu[x] == 1 and r... | N, M = map(int, input().split())
Z = [list(map(int,input().split())) for i in range(M)]
kosuu = [1 for _ in range(N)]
red = [False for _ in range(N)]
red[0] = True
for i in range(M):
x = Z[i][0] - 1
y = Z[i][1] - 1
if (kosuu[x] != 0 and red[x] == True):
red[y] = True
if (kosuu[x] == 1 and red[x] == True):
... |
[
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,
14,
18,
13,
13,
14,... | [
[
117,
2
],
[
117,
11
],
[
120,
13
],
[
106,
17
],
[
108,
19
],
[
106,
23
],
[
28,
25
],
[
109,
26
],
[
31,
30
],
[
118,
33
],
[
114,
35
],
[
114,
44
],
[
102,
46
... | [
"n, m = map(int, input().split())\nbox = [1] * n\nred = [0] * n\nred[0] = 1\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n\n if box[a]:\n if red[a] == 1:\n red[b] = 1\n\n if box[a] == 1:\n if red[a] == 1:\n red[a] = 0\n\n ... | n, m = map(int, input().split())
box = [1] * n
red = [0] * n
red[0] = 1
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
if box[a]:
if red[a] == 1:
red[b] = 1
if box[a] == 1:
if red[a] == 1:
red[a] = 0
box[a] -= 1
... |
[
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,
... | [
[
128,
2
],
[
128,
11
],
[
113,
13
],
[
129,
18
],
[
125,
21
],
[
129,
26
],
[
32,
29
],
[
114,
30
],
[
35,
34
],
[
111,
37
],
[
122,
39
],
[
122,
48
],
[
53,
50
... | [
"n, m = map(int, input().split())\nused = [False] * (n+1)\nball = [1] * (n+1)\nused[1] = True\nfor _ in range(m):\n x,y = map(int, input().split())\n ball[x] -= 1\n ball[y] += 1\n if used[x]:\n used[y] = True\n if ball[x] == 0:\n used[x] = False\nres = 0\nfor i in range(1, n + 1):\n ... | n, m = map(int, input().split())
used = [False] * (n+1)
ball = [1] * (n+1)
used[1] = True
for _ in range(m):
x,y = map(int, input().split())
ball[x] -= 1
ball[y] += 1
if used[x]:
used[y] = True
if ball[x] == 0:
used[x] = False
res = 0
for i in range(1, n + 1):
if used[i] and ball... |
[
7,
15,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
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,... | [
[
9,
8
],
[
124,
15
],
[
9,
17
],
[
20,
19
],
[
8,
23
],
[
26,
25
],
[
8,
29
],
[
34,
31
],
[
25,
32
],
[
37,
36
],
[
17,
39
],
[
42,
41
],
[
124,
48
],
[
4... | [
"import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef main():\n n,m=map(int,input().split())\n lis=[1]*n\n rlis=[False]*n\n rlis[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]==1:\n lis[x]-=1\n lis[... | import sys
def input(): return sys.stdin.readline().rstrip()
def main():
n,m=map(int,input().split())
lis=[1]*n
rlis=[False]*n
rlis[0]=True
for i in range(m):
x,y=map(int,input().split())
x-=1
y-=1
if lis[x]==1:
lis[x]-=1
lis[y]+=1
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
17,
0,
13,
2,
39,
17,
13,
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,
14,
2,
... | [
[
115,
2
],
[
115,
11
],
[
15,
14
],
[
101,
19
],
[
112,
24
],
[
106,
30
],
[
107,
35
],
[
40,
39
],
[
116,
42
],
[
109,
44
],
[
109,
53
],
[
110,
56
],
[
107,
57
... | [
"N,M = map(int, input().split())\n\nballs_in_box = [0] + [1 for _ in range(1,N+1)]\nred_ball_containable_box = set()\nred_ball_containable_box.add(1)\n\nfor i in range(M):\n x,y = map(int, input().split())\n if x in red_ball_containable_box:\n balls_in_box[x] -= 1\n balls_in_box[y] += 1\n ... | N,M = map(int, input().split())
balls_in_box = [0] + [1 for _ in range(1,N+1)]
red_ball_containable_box = set()
red_ball_containable_box.add(1)
for i in range(M):
x,y = map(int, input().split())
if x in red_ball_containable_box:
balls_in_box[x] -= 1
balls_in_box[y] += 1
red_ball_contai... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
... | [
[
122,
2
],
[
122,
11
],
[
125,
13
],
[
123,
17
],
[
110,
19
],
[
123,
27
],
[
31,
30
],
[
117,
33
],
[
113,
35
],
[
113,
44
],
[
111,
48
],
[
114,
50
],
[
59,
54
... | [
"n, m = map(int, input().split())\n\n# ボール個数、赤いボールがある可能性を管理\nb = [1] * n\nred = [1] + [0] * (n - 1)\n\nfor i in range(m):\n x, y = map(int, input().split())\n\n # 移す元に赤いボールがある可能性があれば、移す先に赤いボールが渡る可能性がある\n if red[x - 1] == 1:\n red[y - 1] = 1\n\n # ボール数の足し引き\n b[x - 1] -= 1\n b[y - 1] += 1\n\... | n, m = map(int, input().split())
# ボール個数、赤いボールがある可能性を管理
b = [1] * n
red = [1] + [0] * (n - 1)
for i in range(m):
x, y = map(int, input().split())
# 移す元に赤いボールがある可能性があれば、移す先に赤いボールが渡る可能性がある
if red[x - 1] == 1:
red[y - 1] = 1
# ボール数の足し引き
b[x - 1] -= 1
b[y - 1] += 1
# xのボールが0になったら赤いボ... |
[
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,
14,
18,
13,
13,
0,
... | [
[
112,
2
],
[
112,
11
],
[
118,
13
],
[
113,
17
],
[
97,
19
],
[
113,
23
],
[
28,
25
],
[
98,
26
],
[
31,
30
],
[
107,
33
],
[
115,
35
],
[
115,
44
],
[
109,
46
]... | [
"n, m = map(int, input().split())\nnum = [1] * n\nred = [False] * n\nred[0] = True\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n if red[x]:\n red[y] = True\n num[x] -= 1\n num[y] += 1\n if num[x] == 0:\n red[x] = False\nans = 0\nfor r in red:\n ans ... | n, m = map(int, input().split())
num = [1] * n
red = [False] * n
red[0] = True
for _ in range(m):
x, y = map(int, input().split())
x -= 1
y -= 1
if red[x]:
red[y] = True
num[x] -= 1
num[y] += 1
if num[x] == 0:
red[x] = False
ans = 0
for r in red:
ans += r
print(ans) |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17... | [
[
147,
4
],
[
147,
13
],
[
17,
16
],
[
127,
19
],
[
135,
25
],
[
33,
28
],
[
136,
30
],
[
36,
35
],
[
148,
38
],
[
141,
40
],
[
141,
49
],
[
132,
51
],
[
144,
54
... | [
"import collections\nn,m = map(int,input().split())\nbox = [[1,\"white\"] for i in range(n)]\nbox[0][1] = \"red\"\nfor i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if box[x][1] == \"red\":\n box[y][1] = \"red\"\n box[y][0] += 1\n box[x][0] -= 1\n if box[x][0] == 0:... | import collections
n,m = map(int,input().split())
box = [[1,"white"] for i in range(n)]
box[0][1] = "red"
for i in range(m):
x,y = map(int,input().split())
x -= 1
y -= 1
if box[x][1] == "red":
box[y][1] = "red"
box[y][0] += 1
box[x][0] -= 1
if box[x][0] == 0:
box[x][1] = "whi... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
4,
18,
13,
13,
17,
4,
18,
13,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
19,
18
],
[
22,
21
],
[
4,
25
],
[
15,
29
],
[
18,
34
],
[
41,
38
],
[
18,
39
],
[
44,
43
],
[
13,
46
],
[
49,
48
],
[
49... | [
"def solve():\n N, M = map(int, input().split())\n \n num = []\n red = []\n for i in range(N+1):\n num.append(1)\n red.append(0)\n red[1] = 1\n \n for _ in range(M):\n x, y = map(int, input().split())\n if red[x] == 1:\n red[y] = 1\n num[x] -= 1\... | def solve():
N, M = map(int, input().split())
num = []
red = []
for i in range(N+1):
num.append(1)
red.append(0)
red[1] = 1
for _ in range(M):
x, y = map(int, input().split())
if red[x] == 1:
red[y] = 1
num[x] -= 1
num[y] += 1... |
[
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,
... | [
[
110,
2
],
[
110,
11
],
[
92,
13
],
[
111,
17
],
[
95,
19
],
[
111,
23
],
[
28,
25
],
[
96,
26
],
[
31,
30
],
[
102,
33
],
[
107,
35
],
[
107,
44
],
[
89,
46
],
... | [
"n, m = map(int, input().split())\na = [1]*n\nans_box = [False]*n\nans_box[0] = True\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n a[x] -= 1\n a[y] += 1\n if ans_box[x]:\n if a[x] == 0:\n ans_box[x] = False\n ans_box[y] = True\nprint(ans_box.co... | n, m = map(int, input().split())
a = [1]*n
ans_box = [False]*n
ans_box[0] = True
for _ in range(m):
x, y = map(int, input().split())
x -= 1
y -= 1
a[x] -= 1
a[y] += 1
if ans_box[x]:
if a[x] == 0:
ans_box[x] = False
ans_box[y] = True
print(ans_box.count(True))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
2,
39,
17,
13,
2,
39,
17,
13,
0,
18,
18,
13,
17,
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,
14,
2,
18... | [
[
135,
2
],
[
135,
11
],
[
138,
13
],
[
136,
18
],
[
136,
22
],
[
29,
24
],
[
139,
26
],
[
36,
31
],
[
139,
33
],
[
39,
38
],
[
127,
41
],
[
132,
43
],
[
132,
52
... | [
"N,M = map(int,input().split())\nA = [[0]*N,[1]*N]\nA[0][0] = 1\nA[1][0] = 0\n\nfor i in range(M):\n x,y = map(int,input().split())\n if A[0][x-1] > 0:\n A[0][y-1] += 1\n else:\n A[1][y-1] += 1\n if A[1][x-1] > 0:\n A[1][x-1] -= 1\n else:\n A[0][x-1] -= 1\nprint(len([i for i in A[0] if i > 0]))",
... | N,M = map(int,input().split())
A = [[0]*N,[1]*N]
A[0][0] = 1
A[1][0] = 0
for i in range(M):
x,y = map(int,input().split())
if A[0][x-1] > 0:
A[0][y-1] += 1
else:
A[1][y-1] += 1
if A[1][x-1] > 0:
A[1][x-1] -= 1
else:
A[0][x-1] -= 1
print(len([i for i in A[0] if i > 0])) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
... | [
[
104,
2
],
[
104,
11
],
[
110,
13
],
[
102,
17
],
[
98,
19
],
[
102,
23
],
[
28,
25
],
[
99,
26
],
[
31,
30
],
[
105,
33
],
[
107,
35
],
[
107,
44
],
[
99,
47
],... | [
"n,m=map(int,input().split())\nball_in_boxes = [1]*n\nredball_flag = [False]*n\nredball_flag[0] = True\nfor _ in range(m):\n x,y = map(int,input().split())\n if redball_flag[x-1]: # x番目の箱に赤いボールが入っている可能性がある\n redball_flag[y-1] = True\n ball_in_boxes[x-1] -= 1\n ball_in_boxes[y-1] += 1\n\n if ba... | n,m=map(int,input().split())
ball_in_boxes = [1]*n
redball_flag = [False]*n
redball_flag[0] = True
for _ in range(m):
x,y = map(int,input().split())
if redball_flag[x-1]: # x番目の箱に赤いボールが入っている可能性がある
redball_flag[y-1] = True
ball_in_boxes[x-1] -= 1
ball_in_boxes[y-1] += 1
if ball_in_boxes[x-1]... |
[
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,
13,
0,
... | [
[
114,
2
],
[
114,
13
],
[
17,
16
],
[
100,
19
],
[
117,
32
],
[
105,
35
],
[
115,
39
],
[
108,
41
],
[
115,
45
],
[
50,
47
],
[
106,
48
],
[
102,
56
],
[
111,
59
... | [
"N, M = list(map(int, input().split()))\nxy = [list(map(int, input().split())) for _ in range(M)]\n\nD = [0] * N\nC = [1] * N\nD[0] = 1\n\nfor x, y in xy:\n x -= 1\n y -= 1\n if D[x] == 1:\n D[y] = 1\n C[x] -= 1\n C[y] += 1\n if C[x] == 0:\n D[x] = 0\n\nprint(sum(D))",
"N, M = list(map(int, input().sp... | N, M = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]
D = [0] * N
C = [1] * N
D[0] = 1
for x, y in xy:
x -= 1
y -= 1
if D[x] == 1:
D[y] = 1
C[x] -= 1
C[y] += 1
if C[x] == 0:
D[x] = 0
print(sum(D)) |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
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,
13,
2,
39,
17,
13,
... | [
[
156,
4
],
[
156,
13
],
[
159,
15
],
[
19,
18
],
[
157,
21
],
[
150,
23
],
[
150,
32
],
[
160,
35
],
[
148,
39
],
[
151,
42
],
[
141,
45
],
[
154,
49
],
[
165,
51
... | [
"import copy\nN, M = map(int, input().split())\nXY = []\nfor _ in range(M):\n x, y = map(int, input().split())\n XY.append([x - 1, y - 1])\n\nball_num = [1] * N\nis_red = [False] * N\nis_red[0] = True\n\nfor i in range(M):\n s = XY[i][0]\n g = XY[i][1]\n if is_red[s]:\n if ball_num[s] == 1:\n ... | import copy
N, M = map(int, input().split())
XY = []
for _ in range(M):
x, y = map(int, input().split())
XY.append([x - 1, y - 1])
ball_num = [1] * N
is_red = [False] * N
is_red[0] = True
for i in range(M):
s = XY[i][0]
g = XY[i][1]
if is_red[s]:
if ball_num[s] == 1:
ball_num[s... |
[
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,
13,
4,
17,
0,
13,
13,
0,
18,
... | [
[
155,
2
],
[
155,
11
],
[
15,
14
],
[
138,
17
],
[
143,
30
],
[
35,
34
],
[
156,
37
],
[
149,
41
],
[
46,
45
],
[
156,
48
],
[
152,
52
],
[
58,
55
],
[
153,
56
]... | [
"N, M = map(int, input().split())\nZ = [list(map(int,input().split())) for i in range(M)]\n\nB = [1 for i in range(N)]\nR = [0 for i in range(N)]\nR[0] = 1 #赤いボールが入っている可能性があるなら1、無いなら0\nfor i in range(M):\n src = Z[i][0]-1\n dst = Z[i][1]-1\n if B[src] > 1 and R[src] == 1:\n R[dst] = 1\n if B[src] == 1 and R[... | N, M = map(int, input().split())
Z = [list(map(int,input().split())) for i in range(M)]
B = [1 for i in range(N)]
R = [0 for i in range(N)]
R[0] = 1 #赤いボールが入っている可能性があるなら1、無いなら0
for i in range(M):
src = Z[i][0]-1
dst = Z[i][1]-1
if B[src] > 1 and R[src] == 1:
R[dst] = 1
if B[src] == 1 and R[src] == 1:
R... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
... | [
[
105,
2
],
[
105,
13
],
[
111,
15
],
[
106,
19
],
[
99,
21
],
[
106,
25
],
[
30,
27
],
[
100,
28
],
[
33,
32
],
[
97,
35
],
[
114,
37
],
[
114,
48
],
[
93,
50
],... | [
"N,M= list(map(int,input().split()))\ndot=[1]*N\nsw=[0] * N\nsw[0]=1\nfor i in range(M):\n a,b=list(map(int,input().split()))\n a-=1;b-=1\n dot[a]-=1\n dot[b]+=1\n if sw[a]:\n sw[b]=1\n if dot[a] == 0:\n sw[a]=0\nprint(sw.count(1))",
"N,M= list(map(int,input().split()))",
"N",
"list(map(... | N,M= list(map(int,input().split()))
dot=[1]*N
sw=[0] * N
sw[0]=1
for i in range(M):
a,b=list(map(int,input().split()))
a-=1;b-=1
dot[a]-=1
dot[b]+=1
if sw[a]:
sw[b]=1
if dot[a] == 0:
sw[a]=0
print(sw.count(1)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
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,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
... | [
[
126,
2
],
[
126,
11
],
[
120,
13
],
[
108,
16
],
[
127,
20
],
[
114,
22
],
[
127,
26
],
[
31,
28
],
[
115,
29
],
[
34,
33
],
[
106,
36
],
[
117,
38
],
[
117,
47
... | [
"#!/usr/bin/env python\n# coding: utf-8\n\n# In[27]:\n\n\nN,M = map(int, input().split())\nxy = []\nb = [1]*N\np = [False]*N\np[0] = True\nfor _ in range(M):\n x,y = map(int, input().split())\n b[x-1] -= 1\n b[y-1] += 1\n if p[x-1]:\n p[y-1] = True\n if b[x-1] == 0:\n p[x-1] = False\n\n... | #!/usr/bin/env python
# coding: utf-8
# In[27]:
N,M = map(int, input().split())
xy = []
b = [1]*N
p = [False]*N
p[0] = True
for _ in range(M):
x,y = map(int, input().split())
b[x-1] -= 1
b[y-1] += 1
if p[x-1]:
p[y-1] = True
if b[x-1] == 0:
p[x-1] = False
# In[28]:
ans = 0
for ... |
[
7,
15,
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,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
18,
13... | [
[
6,
5
],
[
5,
14
],
[
138,
16
],
[
138,
18
],
[
22,
21
],
[
139,
24
],
[
132,
28
],
[
33,
32
],
[
127,
35
],
[
135,
39
],
[
141,
46
],
[
127,
51
],
[
54,
53
],
... | [
"import numpy as np \nn,m = [int(i)for i in input().split()]\n\nl = [[int(i)-1 for i in input().split()] for _ in range(m)]\n\nline = np.array([1 for _ in range(n)])\nis_red = np.zeros(n,dtype = np.int32)\nis_red[0] = 1\n\nfor x,y in l:\n line[x] -= 1 if line[x] > 0 else 0\n line[y] += 1\n is_red[y] = 1 ... | import numpy as np
n,m = [int(i)for i in input().split()]
l = [[int(i)-1 for i in input().split()] for _ in range(m)]
line = np.array([1 for _ in range(n)])
is_red = np.zeros(n,dtype = np.int32)
is_red[0] = 1
for x,y in l:
line[x] -= 1 if line[x] > 0 else 0
line[y] += 1
is_red[y] = 1 if is_red[x] == 1... |
[
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,
13,
18,
13,
13,
... | [
[
97,
2
],
[
97,
11
],
[
121,
13
],
[
98,
17
],
[
103,
19
],
[
98,
23
],
[
28,
25
],
[
104,
26
],
[
31,
30
],
[
95,
33
],
[
115,
35
],
[
115,
44
],
[
106,
46
],
... | [
"N, M = map(int, input().split())\nnum = [1] * N\npossible = [False] * N\npossible[0] = True\n\nfor i in range(M):\n x, y = map(int, input().split())\n x -= 1; y -= 1\n nx, ny = num[x], num[y]\n if possible[x]:\n possible[y] = True\n if nx == 1:\n possible[x] = False\n \n num[x] -= 1; num[y] += 1\n... | N, M = map(int, input().split())
num = [1] * N
possible = [False] * N
possible[0] = True
for i in range(M):
x, y = map(int, input().split())
x -= 1; y -= 1
nx, ny = num[x], num[y]
if possible[x]:
possible[y] = True
if nx == 1:
possible[x] = False
num[x] -= 1; num[y] += 1
print(sum(possible)... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
... | [
[
108,
2
],
[
108,
11
],
[
15,
14
],
[
106,
17
],
[
111,
21
],
[
26,
25
],
[
106,
28
],
[
117,
32
],
[
38,
35
],
[
118,
36
],
[
41,
40
],
[
109,
43
],
[
120,
45
]... | [
"n, m = map(int, input().split())\nnums = [1 for _ in range(n)]\ntf = [False for _ in range(n)]\ntf[0] = True\n\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n nums[x] -= 1\n nums[y] += 1\n if tf[x]:\n tf[y] = True\n if nums[x] == 0:\n tf[x] = Fa... | n, m = map(int, input().split())
nums = [1 for _ in range(n)]
tf = [False for _ in range(n)]
tf[0] = True
for _ in range(m):
x, y = map(int, input().split())
x -= 1
y -= 1
nums[x] -= 1
nums[y] += 1
if tf[x]:
tf[y] = True
if nums[x] == 0:
tf[x] = False
print(tf.count(... |
[
7,
12,
13,
29,
2,
4,
13,
13,
17,
23,
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,
14,
2,
13,
13,
14,
2,
18,
13,
13,... | [
[
10,
7
],
[
10,
10
],
[
94,
12
],
[
94,
21
],
[
106,
23
],
[
95,
27
],
[
97,
29
],
[
33,
32
],
[
92,
35
],
[
103,
37
],
[
89,
40
],
[
103,
46
],
[
101,
49
],
[... | [
"def int_(num_str):\n return int(num_str) - 1\n\nN, M = map(int, input().split())\nballs = [1] * N\nred = {0}\nfor i in range(M):\n x, y = map(int_, input().split())\n if x in red:\n if balls[x] == 1:\n red.remove(x)\n red.add(y)\n else:\n red.add(y)\n ball... | def int_(num_str):
return int(num_str) - 1
N, M = map(int, input().split())
balls = [1] * N
red = {0}
for i in range(M):
x, y = map(int_, input().split())
if x in red:
if balls[x] == 1:
red.remove(x)
red.add(y)
else:
red.add(y)
balls[x] -= 1
balls... |
[
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,
17,
28,
13,
4,
13,
17,
13,
4,
18,
13,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
... | [
[
152,
2
],
[
152,
11
],
[
15,
14
],
[
147,
17
],
[
143,
30
],
[
149,
33
],
[
38,
37
],
[
153,
41
],
[
150,
44
],
[
155,
48
],
[
153,
52
],
[
55,
54
],
[
147,
57
... | [
"n, m = map(int, input().split())\nx_y = [list(map(int, input().split())) for _ in range(m)]\n\naka_list = [True]\nfor i in range(1, n):\n aka_list.append(False)\nballs = [1] * n\n\nfor i in range(m):\n if aka_list[x_y[i][0] - 1]:\n aka_list[x_y[i][1]-1] = True\n balls[x_y[i][0] - 1] -= 1\n balls... | n, m = map(int, input().split())
x_y = [list(map(int, input().split())) for _ in range(m)]
aka_list = [True]
for i in range(1, n):
aka_list.append(False)
balls = [1] * n
for i in range(m):
if aka_list[x_y[i][0] - 1]:
aka_list[x_y[i][1]-1] = True
balls[x_y[i][0] - 1] -= 1
balls[x_y[i][1] - 1] +... |
[
7,
15,
13,
0,
13,
18,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
13,
13,
13,
13,
13,
0,
... | [
[
203,
4
],
[
209,
16
],
[
200,
21
],
[
215,
28
],
[
212,
33
],
[
41,
40
],
[
204,
50
],
[
41,
54
],
[
57,
56
],
[
40,
60
],
[
65,
62
],
[
56,
63
],
[
68,
67
],
... | [
"import sys\n#import string\n#from collections import defaultdict, deque, Counter\n#import bisect\n#import heapq\n#import math\n#from itertools import accumulate\n#from itertools import permutations as perm\n#from itertools import combinations as comb\n#from itertools import combinations_with_replacement as combr\n... | import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions... |
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
2,
39,
... | [
[
4,
3
],
[
3,
12
],
[
123,
14
],
[
123,
16
],
[
126,
18
],
[
22,
21
],
[
112,
24
],
[
28,
27
],
[
27,
36
],
[
129,
38
],
[
129,
40
],
[
127,
43
],
[
130,
47
],
... | [
"n, m = (int(x) for x in input().split())\nab = []\nfor _ in range(m):\n a, b = (int(x) for x in input().split())\n ab.append([a-1, b-1])\n\nbox = [1]*n\n\nred = [0]*n\n\nred[0] = 1\n\nfor x,y in ab:\n if 0 < red[x]:\n red[y] = 1\n box[x] -= 1\n box[y] += 1\n\n if box[x] == 0:\n red[... | n, m = (int(x) for x in input().split())
ab = []
for _ in range(m):
a, b = (int(x) for x in input().split())
ab.append([a-1, b-1])
box = [1]*n
red = [0]*n
red[0] = 1
for x,y in ab:
if 0 < red[x]:
red[y] = 1
box[x] -= 1
box[y] += 1
if box[x] == 0:
red[x] = 0
print(sum(red)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
... | [
[
110,
2
],
[
110,
11
],
[
113,
13
],
[
108,
17
],
[
104,
19
],
[
108,
23
],
[
28,
25
],
[
105,
26
],
[
31,
30
],
[
111,
33
],
[
119,
35
],
[
119,
44
],
[
105,
47
... | [
"n, m = map(int, input().split())\nball = [1]*n\nflg = [False]*n\nflg[0] = True\n\nfor _ in range(m):\n x, y = map(int, input().split())\n if flg[x-1]:\n flg[y-1] = True\n if ball[x-1] == 1 and flg[x-1]:\n flg[x-1] = False\n ball[y-1] += 1\n ball[x-1] -= 1\n # print(x, y, ball, flg)\... | n, m = map(int, input().split())
ball = [1]*n
flg = [False]*n
flg[0] = True
for _ in range(m):
x, y = map(int, input().split())
if flg[x-1]:
flg[y-1] = True
if ball[x-1] == 1 and flg[x-1]:
flg[x-1] = False
ball[y-1] += 1
ball[x-1] -= 1
# print(x, y, ball, flg)
ans = flg.count(T... |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
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,
2,
39,
17,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
13... | [
[
226,
11
],
[
220,
18
],
[
227,
25
],
[
220,
27
],
[
217,
29
],
[
206,
33
],
[
214,
35
],
[
206,
39
],
[
43,
42
],
[
206,
45
],
[
199,
51
],
[
57,
54
],
[
200,
55
... | [
"import sys\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nx = [0]* n\ny = [0]* n\n\nbox = [[1, 0] for _ in range(n)]\nbox[0] = [0,1]\n\nfor i in range(m):\n x, y = map(int, input().split())\n x,y= x-1,y-1\n\n if box[x][1]>0:\n box[x][1] = box[x][1]-... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
n, m = map(int, input().split())
x = [0]* n
y = [0]* n
box = [[1, 0] for _ in range(n)]
box[0] = [0,1]
for i in range(m):
x, y = map(int, input().split())
x,y= x-1,y-1
if box[x][1]>0:
box[x][1] = box[x][1]-1
box[y][1] =... |
[
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,
13,
17,
0,
13,
4,
13,
39,
17,
0,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
... | [
[
150,
2
],
[
150,
11
],
[
135,
13
],
[
130,
17
],
[
147,
19
],
[
130,
23
],
[
138,
25
],
[
141,
28
],
[
153,
34
],
[
144,
37
],
[
151,
42
],
[
46,
45
],
[
130,
48
... | [
"N, M = map(int, input().split())\nX = [0] * (M)\nY = [0] * (M)\n\nstarted = False\ncontains_red = set([1])\nans = 1\n\nnums = [1] * (N + 1)\n\nfor _ in range(M):\n x, y = map(int, input().split())\n X[_] = x\n Y[_] = y\n\nfor _ in range(M):\n nums[X[_]] -= 1\n nums[Y[_]] += 1\n\n if X[_] in conta... | N, M = map(int, input().split())
X = [0] * (M)
Y = [0] * (M)
started = False
contains_red = set([1])
ans = 1
nums = [1] * (N + 1)
for _ in range(M):
x, y = map(int, input().split())
X[_] = x
Y[_] = y
for _ in range(M):
nums[X[_]] -= 1
nums[Y[_]] += 1
if X[_] in contains_red:
contain... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
... | [
[
107,
2
],
[
107,
11
],
[
98,
13
],
[
108,
17
],
[
95,
19
],
[
108,
27
],
[
31,
30
],
[
102,
33
],
[
110,
35
],
[
110,
44
],
[
96,
48
],
[
111,
50
],
[
59,
54
],... | [
"N, M = map(int, input().split())\nc = [1] * N\nr = [True] + [False] * (N-1)\nfor i in range(M):\n x, y = map(int, input().split())\n if r[x-1] == True:\n r[y-1] = True\n if c[x-1] == 1:\n r[x-1] = False\n c[x-1] -= 1\n c[y-1] += 1\nprint(sum(r))",
"N, M = map(int, input().split())",
... | N, M = map(int, input().split())
c = [1] * N
r = [True] + [False] * (N-1)
for i in range(M):
x, y = map(int, input().split())
if r[x-1] == True:
r[y-1] = True
if c[x-1] == 1:
r[x-1] = False
c[x-1] -= 1
c[y-1] += 1
print(sum(r))
|
[
7,
0,
13,
4,
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,
13,
17,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
18,
13,... | [
[
154,
2
],
[
154,
13
],
[
17,
16
],
[
149,
19
],
[
151,
25
],
[
31,
28
],
[
152,
29
],
[
36,
35
],
[
155,
38
],
[
142,
40
],
[
142,
51
],
[
60,
53
],
[
152,
55
]... | [
"n, m = list(map(int, input().split()))\nb = [[\"W\", 1] for _ in range(n)]\nb[0] = [\"R\", 1]\n\nfor i in range(m):\n x, y = list(map(int, input().split()))\n\n b[x-1][1] -= 1\n if b[x-1][0] == \"R\":\n b[y-1] = [\"R\", b[y-1][1]+1]\n\n if b[x-1][1] == 0:\n b[x-1][0] = \"W\"\n ... | n, m = list(map(int, input().split()))
b = [["W", 1] for _ in range(n)]
b[0] = ["R", 1]
for i in range(m):
x, y = list(map(int, input().split()))
b[x-1][1] -= 1
if b[x-1][0] == "R":
b[y-1] = ["R", b[y-1][1]+1]
if b[x-1][1] == 0:
b[x-1][0] = "W"
else:
b[y-1][1] += 1... |
[
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,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
... | [
[
161,
2
],
[
161,
11
],
[
155,
13
],
[
162,
17
],
[
22,
19
],
[
156,
20
],
[
158,
24
],
[
162,
28
],
[
33,
30
],
[
159,
31
],
[
152,
35
],
[
39,
38
],
[
150,
41
... | [
"N, M = map(int, input().split())\n\nred = [0]*N\nred[0] = 1\nwhite = [1]*N\nwhite[0] = 0\nans = 1\nfor i in range(M):\n a, b = map(int, input().split())\n if red[a-1] == 1:\n if red[b-1] == 0:\n red[b-1] += 1\n ans += 1\n else:\n white[b-1] += 1\n\n if wh... | N, M = map(int, input().split())
red = [0]*N
red[0] = 1
white = [1]*N
white[0] = 0
ans = 1
for i in range(M):
a, b = map(int, input().split())
if red[a-1] == 1:
if red[b-1] == 0:
red[b-1] += 1
ans += 1
else:
white[b-1] += 1
if white[a-1] > 0:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
... | [
[
117,
2
],
[
117,
11
],
[
15,
14
],
[
115,
17
],
[
108,
21
],
[
26,
25
],
[
115,
28
],
[
105,
32
],
[
38,
35
],
[
106,
36
],
[
41,
40
],
[
118,
43
],
[
120,
45
]... | [
"N,M=map(int,input().split())\nbox=[1 for _ in range(N)]\nans=[0 for _ in range(N)]\nans[0]=1\nfor i in range(M):\n x,y=map(int,input().split())\n box[x-1]-=1\n box[y-1]+=1\n if ans[x-1]==1:\n ans[y-1]=1\n if box[x-1]==0:\n ans[x-1]=0\nprint(sum(ans))",
"N,M=map(int,input().split())",... | N,M=map(int,input().split())
box=[1 for _ in range(N)]
ans=[0 for _ in range(N)]
ans[0]=1
for i in range(M):
x,y=map(int,input().split())
box[x-1]-=1
box[y-1]+=1
if ans[x-1]==1:
ans[y-1]=1
if box[x-1]==0:
ans[x-1]=0
print(sum(ans)) |
[
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,... | [
[
127,
16
],
[
145,
43
],
[
149,
45
],
[
145,
46
],
[
133,
48
],
[
125,
52
],
[
130,
54
],
[
125,
62
],
[
66,
65
],
[
146,
68
],
[
142,
70
],
[
142,
85
],
[
90,
87
... | [
"#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,C... | #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
impo... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
... | [
[
102,
2
],
[
102,
11
],
[
99,
13
],
[
88,
18
],
[
24,
21
],
[
100,
22
],
[
96,
26
],
[
88,
31
],
[
35,
34
],
[
103,
37
],
[
93,
39
],
[
93,
48
],
[
53,
50
],
[... | [
"# AGC002 B Box and Ball\n\nn, m = map(int, input().split())\n\nb_list = [0] * (n+1)\nb_list[1] = 1\nc_list = [1] * (n+1)\n\nfor i in range(m):\n _x, _y = map(int, input().split())\n c_list[_x] -= 1\n c_list[_y] += 1 \n if b_list[_x] == 1:\n b_list[_y] = 1\n if c_list[_x] == 0:\n ... | # AGC002 B Box and Ball
n, m = map(int, input().split())
b_list = [0] * (n+1)
b_list[1] = 1
c_list = [1] * (n+1)
for i in range(m):
_x, _y = map(int, input().split())
c_list[_x] -= 1
c_list[_y] += 1
if b_list[_x] == 1:
b_list[_y] = 1
if c_list[_x] == 0:
b_list[_x] = 0
pr... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
... | [
[
135,
4
],
[
126,
18
],
[
141,
25
],
[
144,
30
],
[
150,
35
],
[
136,
42
],
[
150,
44
],
[
123,
46
],
[
133,
50
],
[
153,
52
],
[
133,
56
],
[
61,
58
],
[
154,
59
... | [
"import sys\nreadline = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\n#mod = 998244353\nINF = 10**18\neps = 10**-7\n\nN,M = map(int,readline().split())\n\nc = [1]*N\nr = [0]*N\nr[0] = 1\n\nfor _ in range(M):\n x,y = map(int,readline().split())\n x,y = x-1,y-1\n if r[x]:\n if c[x] ... | import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7
N,M = map(int,readline().split())
c = [1]*N
r = [0]*N
r[0] = 1
for _ in range(M):
x,y = map(int,readline().split())
x,y = x-1,y-1
if r[x]:
if c[x] == 1:
r[x] ... |
[
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,
... | [
[
134,
2
],
[
134,
11
],
[
125,
13
],
[
135,
17
],
[
116,
19
],
[
135,
23
],
[
28,
25
],
[
126,
26
],
[
31,
30
],
[
129,
33
],
[
122,
35
],
[
122,
44
],
[
143,
46
... | [
"n,m = map(int,input().split())\nflag = [False]*n\nballs = [1]*n\nflag[0]= True\nfor i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n balls[x] -=1\n balls[y] += 1\n if flag[x] == True:\n flag[y] =True\n if flag[x] == True and balls[x] == 0:\n flag[x] = False\n\n... | n,m = map(int,input().split())
flag = [False]*n
balls = [1]*n
flag[0]= True
for i in range(m):
x,y = map(int,input().split())
x -= 1
y -= 1
balls[x] -=1
balls[y] += 1
if flag[x] == True:
flag[y] =True
if flag[x] == True and balls[x] == 0:
flag[x] = False
cnt = 0
for i in ran... |
[
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,
... | [
[
175,
2
],
[
175,
11
],
[
15,
14
],
[
170,
17
],
[
163,
30
],
[
35,
34
],
[
176,
37
],
[
166,
41
],
[
47,
44
],
[
167,
45
],
[
51,
50
],
[
176,
53
],
[
178,
57
]... | [
"n, m = map(int,input().split())\nxy = [list(map(int,input().split())) for i in range(m)]\n\nred_boxes = [False for i in range(n)]\nred_boxes[0] = True\nn_ball = [1 for i in range(n)]\n\n\nfor i in range(m):\n x_i = xy[i][0]-1\n y_i = xy[i][1]-1\n \n if n_ball[x_i] == 1:\n if red_boxes[x_i] == Tr... | n, m = map(int,input().split())
xy = [list(map(int,input().split())) for i in range(m)]
red_boxes = [False for i in range(n)]
red_boxes[0] = True
n_ball = [1 for i in range(n)]
for i in range(m):
x_i = xy[i][0]-1
y_i = xy[i][1]-1
if n_ball[x_i] == 1:
if red_boxes[x_i] == True:
n_... |
[
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,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
... | [
[
148,
2
],
[
148,
11
],
[
15,
14
],
[
140,
17
],
[
151,
21
],
[
26,
25
],
[
140,
29
],
[
142,
34
],
[
41,
40
],
[
149,
43
],
[
145,
45
],
[
145,
54
],
[
61,
56
]... | [
"n, m = map(int, input().split())\ncl = [1 for _ in range(n)]\nrl = [1]+[0 for _ in range(n-1)]\n\nfor i in range(m):\n x_n, y_n = map(int, input().split())\n cl[x_n-1] -= 1\n cl[y_n-1] += 1\n if rl[x_n-1] == 1 and cl[x_n-1]>0:\n rl[y_n-1] = 1\n elif rl[x_n-1] == 1 and cl[x_n-1] == 0:\n ... | n, m = map(int, input().split())
cl = [1 for _ in range(n)]
rl = [1]+[0 for _ in range(n-1)]
for i in range(m):
x_n, y_n = map(int, input().split())
cl[x_n-1] -= 1
cl[y_n-1] += 1
if rl[x_n-1] == 1 and cl[x_n-1]>0:
rl[y_n-1] = 1
elif rl[x_n-1] == 1 and cl[x_n-1] == 0:
rl[x_n-1] = 0
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
2,
18,
13,
2,
13,
17,
17,
2,
18,
... | [
[
170,
2
],
[
170,
11
],
[
173,
13
],
[
165,
17
],
[
176,
19
],
[
165,
23
],
[
28,
25
],
[
177,
26
],
[
31,
30
],
[
171,
33
],
[
167,
35
],
[
167,
44
],
[
174,
49
... | [
"n,m=map(int,input().split())\nnum=[1]*n\naka=[0]*n\naka[0]=1\nfor _ in range(m):\n x,y=map(int,input().split())\n if num[x-1]>1 and aka[x-1]==1:\n num[x-1]+=-1\n aka[x-1]=1\n aka[y-1]=1\n num[y-1]+=1\n elif num[x-1]==1 and aka[x-1]==1:\n num[x-1]=0\n aka[x-1]=0\n aka[y-1]=1\n num[y-1]+=1... | n,m=map(int,input().split())
num=[1]*n
aka=[0]*n
aka[0]=1
for _ in range(m):
x,y=map(int,input().split())
if num[x-1]>1 and aka[x-1]==1:
num[x-1]+=-1
aka[x-1]=1
aka[y-1]=1
num[y-1]+=1
elif num[x-1]==1 and aka[x-1]==1:
num[x-1]=0
aka[x-1]=0
aka[y-1]=1
num[y-1]+=1
elif aka[x-1]==0:... |
[
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,
... | [
[
118,
2
],
[
118,
11
],
[
106,
13
],
[
119,
17
],
[
22,
19
],
[
107,
20
],
[
100,
24
],
[
119,
28
],
[
31,
30
],
[
110,
33
],
[
112,
35
],
[
112,
44
],
[
121,
46
... | [
"N,M = map(int,input().split())\n\nans = [0]*N\nans[0] = 1\nball = [1]*N\n\nfor _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if ans[x]:\n ans[y] = 1\n ball[x] -= 1\n ball[y] += 1\n\n if not ball[x]:\n ans[x] = 0\n\nprint(sum([i*(j>0) for i,j in zip(ans,ball)... | N,M = map(int,input().split())
ans = [0]*N
ans[0] = 1
ball = [1]*N
for _ in range(M):
x,y = map(int,input().split())
x -= 1
y -= 1
if ans[x]:
ans[y] = 1
ball[x] -= 1
ball[y] += 1
if not ball[x]:
ans[x] = 0
print(sum([i*(j>0) for i,j in zip(ans,ball)])) |
[
7,
15,
13,
13,
15,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
29,
18,
4,
18,
18,
13,
13,
13,
39,
17,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
12,
13,
41,
28,
13,
4,
... | [
[
183,
13
],
[
187,
40
],
[
187,
48
],
[
54,
53
],
[
79,
56
],
[
205,
61
],
[
64,
63
],
[
68,
67
],
[
63,
71
],
[
67,
75
],
[
79,
79
],
[
207,
81
],
[
205,
83
],
... | [
"import sys, math\nfrom functools import lru_cache\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) ... | import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7
def input():
return sys.stdin.readline()[:-1]
def mi():
return map(int, input().split())
def ii():
return int(input())
def i2(n):
tmp = [list(mi()) for i in range(n)]
return [list(i) for i in zip(*tmp)]
... |
[
7,
15,
13,
4,
18,
13,
13,
2,
2,
17,
17,
17,
12,
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,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18... | [
[
18,
17
],
[
145,
24
],
[
18,
26
],
[
29,
28
],
[
26,
32
],
[
34,
33
],
[
26,
37
],
[
40,
39
],
[
26,
42
],
[
47,
44
],
[
28,
45
],
[
39,
46
],
[
145,
53
],
[
... | [
"import sys\nsys.setrecursionlimit(10 ** 5 + 10)\ndef input(): return sys.stdin.readline().strip()\n\ndef resolve():\n\n N,M=map(int,input().split())\n X, Y = [0] * M, [0] * M\n for i in range(M):\n X[i], Y[i] = map(int, input().split())\n\n red=[True]+[False]*(N-1)\n cnt=[1]*N\n\n for i in... | import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
N,M=map(int,input().split())
X, Y = [0] * M, [0] * M
for i in range(M):
X[i], Y[i] = map(int, input().split())
red=[True]+[False]*(N-1)
cnt=[1]*N
for i in range(M):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
... | [
[
93,
2
],
[
93,
11
],
[
15,
14
],
[
94,
17
],
[
96,
30
],
[
87,
33
],
[
91,
38
],
[
99,
41
],
[
91,
46
],
[
52,
49
],
[
100,
50
],
[
61,
58
],
[
88,
59
],
[
... | [
"n,m = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(m)]\n\nbox = [1] * (n+1)\nred = [0] * (n+1)\nred[1] = 1\nfor x,y in xy:\n box[x] -= 1\n box[y] += 1\n if red[x] == 1: red[y] = 1\n if box[x] == 0: red[x] = 0\nprint(red.count(1))",
"n,m = map(int, input().split())",... | n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
box = [1] * (n+1)
red = [0] * (n+1)
red[1] = 1
for x,y in xy:
box[x] -= 1
box[y] += 1
if red[x] == 1: red[y] = 1
if box[x] == 0: red[x] = 0
print(red.count(1)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
0,
... | [
[
109,
2
],
[
109,
11
],
[
94,
13
],
[
110,
17
],
[
97,
19
],
[
110,
23
],
[
28,
25
],
[
95,
26
],
[
31,
30
],
[
104,
33
],
[
106,
35
],
[
106,
50
],
[
95,
53
],
... | [
"n, m = map(int, input().split())\n\nred = [False] * n\nball = [1] * n\n\nred[0] = True\nfor _ in range(m):\n x, y = map(lambda x: int(x) - 1, input().split())\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(len(list(filter(l... | n, m = map(int, input().split())
red = [False] * n
ball = [1] * n
red[0] = True
for _ in range(m):
x, y = map(lambda x: int(x) - 1, input().split())
if red[x]:
red[y] = True
if ball[x] == 1:
red[x] = False
ball[y] += 1
ball[x] -= 1
print(len(list(filter(lambda x: x, 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,
41,
28,
13,
4,
13,
31,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
... | [
[
151,
2
],
[
151,
11
],
[
15,
14
],
[
143,
17
],
[
133,
30
],
[
35,
34
],
[
134,
38
],
[
34,
42
],
[
148,
44
],
[
148,
46
],
[
136,
48
],
[
152,
52
],
[
145,
54
... | [
"n,m = map(int,input().split())\nl = [list(map(int,input().split())) for i in range(m)]\nx,y = [list(i) for i in zip(*l)]\nnum = [1] * n\nred = ['out'] * n\nred[0] = 'in'\nfor i in range(m):\n if red[x[i]-1] == 'in':\n red[y[i]-1] = 'in'\n num[x[i]-1] -= 1\n num[y[i]-1] += 1\n if num[x[i]-1] == 0... | n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
x,y = [list(i) for i in zip(*l)]
num = [1] * n
red = ['out'] * n
red[0] = 'in'
for i in range(m):
if red[x[i]-1] == 'in':
red[y[i]-1] = 'in'
num[x[i]-1] -= 1
num[y[i]-1] += 1
if num[x[i]-1] == 0:
red[x[... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,... | [
[
126,
3
],
[
126,
12
],
[
16,
15
],
[
115,
18
],
[
120,
22
],
[
27,
26
],
[
115,
29
],
[
123,
33
],
[
39,
36
],
[
124,
37
],
[
42,
41
],
[
127,
44
],
[
108,
46
]... | [
"from collections import defaultdict\n\nN, M = map(int, input().split())\n\nball_count=[1 for _ in range(N)]\nredExist=[0 for _ in range(N)]\nredExist[0]=1\nfor m in range(M):\n x, y = map(int, input().split())\n #1オリジンから0オリジンに\n x-=1\n y-=1\n\n ball_count[x] -= 1\n ball_count[y] += 1\n if (redExist[x]):\n ... | from collections import defaultdict
N, M = map(int, input().split())
ball_count=[1 for _ in range(N)]
redExist=[0 for _ in range(N)]
redExist[0]=1
for m in range(M):
x, y = map(int, input().split())
#1オリジンから0オリジンに
x-=1
y-=1
ball_count[x] -= 1
ball_count[y] += 1
if (redExist[x]):
redExist[y]=True
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
14,
2,
18,
... | [
[
145,
2
],
[
145,
11
],
[
133,
13
],
[
146,
17
],
[
130,
19
],
[
146,
27
],
[
31,
30
],
[
137,
33
],
[
142,
35
],
[
142,
44
],
[
131,
48
],
[
143,
50
],
[
134,
56
... | [
"n, m = map(int,input().split())\nball = [1]*n\nred_ball = [1] + [0]*(n-1)\nfor i in range(m):\n a,b = map(int,input().split())\n if red_ball[a-1] == 1:\n if ball[a-1] == 1:\n ball[a-1] -= 1\n ball[b-1] += 1\n red_ball[a-1] = 0\n red_ball[b-1] = 1\n else:\n ball[a-1] -= 1\n bal... | n, m = map(int,input().split())
ball = [1]*n
red_ball = [1] + [0]*(n-1)
for i in range(m):
a,b = map(int,input().split())
if red_ball[a-1] == 1:
if ball[a-1] == 1:
ball[a-1] -= 1
ball[b-1] += 1
red_ball[a-1] = 0
red_ball[b-1] = 1
else:
ball[a-1] -= 1
ball[b-1] += 1
... |
[
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,
... | [
[
153,
2
],
[
153,
11
],
[
141,
13
],
[
154,
17
],
[
144,
19
],
[
154,
23
],
[
26,
25
],
[
154,
28
],
[
33,
30
],
[
142,
31
],
[
25,
32
],
[
33,
41
],
[
145,
42
]... | [
"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] and map_li[x]>1:\n red[y]=True\n elif red[x]:\n ... | 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] and map_li[x]>1:
red[y]=True
elif red[x]:
red[y]=True
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
39,
17,
13,
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,
2,
18,
13,
2,
13,
17,
17,
2,
18,
... | [
[
152,
2
],
[
152,
11
],
[
161,
13
],
[
147,
20
],
[
149,
22
],
[
147,
27
],
[
31,
30
],
[
153,
33
],
[
158,
35
],
[
158,
44
],
[
150,
49
],
[
159,
51
],
[
162,
56
... | [
"n,m = map(int,input().split())\n\ncheck = [1]+[0]*n\nnumlis = [1]*(n+1)\n\nfor i in range(m):\n x, y = map(int, input().split())\n if numlis[x-1] > 1 and check[x-1] == 1:\n check[y-1] = 1\n numlis[x-1] -= 1\n numlis[y-1] += 1\n elif numlis[x-1] == 1 and check[x-1] == 1:\n check... | n,m = map(int,input().split())
check = [1]+[0]*n
numlis = [1]*(n+1)
for i in range(m):
x, y = map(int, input().split())
if numlis[x-1] > 1 and check[x-1] == 1:
check[y-1] = 1
numlis[x-1] -= 1
numlis[y-1] += 1
elif numlis[x-1] == 1 and check[x-1] == 1:
check[y-1] = 1
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
... | [
[
151,
2
],
[
151,
11
],
[
15,
14
],
[
143,
18
],
[
160,
23
],
[
28,
27
],
[
143,
31
],
[
145,
36
],
[
42,
39
],
[
161,
40
],
[
45,
44
],
[
152,
47
],
[
163,
49
]... | [
"n , m = map(int,input().split())\naka = [False for i in range(n+1)]\nkazu = [1 for i in range(n+1)]\naka[1] = True\nfor i in range(m):\n x , y = map(int,input().split())\n if aka[x]:\n if kazu[x] >= 2:\n kazu[x] -= 1\n kazu[y] += 1\n elif kazu[x] == 1:\n kazu[x]... | n , m = map(int,input().split())
aka = [False for i in range(n+1)]
kazu = [1 for i in range(n+1)]
aka[1] = True
for i in range(m):
x , y = map(int,input().split())
if aka[x]:
if kazu[x] >= 2:
kazu[x] -= 1
kazu[y] += 1
elif kazu[x] == 1:
kazu[x] -= 1
... |
[
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,
31,
2,
39,
4,
13,
13,
17,
0,
13,
17,
0,
13,
17,
0,
18,
13,... | [
[
92,
2
],
[
92,
15
],
[
92,
16
],
[
98,
19
],
[
93,
23
],
[
95,
25
],
[
93,
29
],
[
34,
31
],
[
96,
32
],
[
104,
48
],
[
101,
51
],
[
57,
54
],
[
99,
55
],
[
... | [
"N, M, *xy = map(int, open(0).read().split())\nboxes = [1] * N\nis_red = [0] * N\nis_red[0] = 1\n\nfor x, y in zip(*[iter(xy)] * 2):\n x -= 1\n y -= 1\n boxes[x] -= 1\n boxes[y] += 1\n if is_red[x]:\n if boxes[x] == 0:\n is_red[x] = 0\n is_red[y] = 1\nprint(sum(is_red))",
"... | N, M, *xy = map(int, open(0).read().split())
boxes = [1] * N
is_red = [0] * N
is_red[0] = 1
for x, y in zip(*[iter(xy)] * 2):
x -= 1
y -= 1
boxes[x] -= 1
boxes[y] += 1
if is_red[x]:
if boxes[x] == 0:
is_red[x] = 0
is_red[y] = 1
print(sum(is_red))
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
4,
18,
13,
13,
17,
0,
13,
18,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
12,
4,
13,
4,
18,
18,
13,
13,
1... | [
[
188,
33
],
[
194,
38
],
[
200,
45
],
[
197,
56
],
[
203,
71
],
[
91,
90
],
[
198,
92
],
[
91,
93
],
[
97,
96
],
[
90,
99
],
[
104,
103
],
[
109,
106
],
[
103,
107... | [
"import sys\nimport re\nimport math\nimport collections\nimport decimal\nimport bisect\nimport itertools\nimport fractions\nimport functools\nimport copy\nimport heapq\nimport decimal\nimport statistics\n\nsys.setrecursionlimit(10000001)\nINF = sys.maxsize\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline()... | import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int,... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
... | [
[
129,
2
],
[
129,
13
],
[
132,
15
],
[
19,
18
],
[
124,
21
],
[
133,
24
],
[
39,
38
],
[
130,
42
],
[
135,
47
],
[
52,
51
],
[
130,
55
],
[
138,
60
],
[
66,
63
]... | [
"\nn,m = list(map(int, input().split()))\nmanu = []\n\nfor i in range(m):\n manu.append(list(map(int, input().split())))\n\nnum = [1 for i in range(n+1)]\nposs = [0 for i in range(n+1)]\nposs[1] = 1\n\nfor i in range(m):\n a,b = manu[i][0],manu[i][1]\n if(poss[a]==1):\n poss[b]=1\n num[a]-=1\n ... |
n,m = list(map(int, input().split()))
manu = []
for i in range(m):
manu.append(list(map(int, input().split())))
num = [1 for i in range(n+1)]
poss = [0 for i in range(n+1)]
poss[1] = 1
for i in range(m):
a,b = manu[i][0],manu[i][1]
if(poss[a]==1):
poss[b]=1
num[a]-=1
num[b]+=1
if(num... |
[
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,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
... | [
[
168,
2
],
[
168,
11
],
[
156,
13
],
[
169,
18
],
[
150,
21
],
[
169,
26
],
[
37,
29
],
[
157,
30
],
[
37,
34
],
[
151,
35
],
[
162,
39
],
[
169,
44
],
[
48,
47
... | [
"n, m = map(int, input().split())\nprob = [False] * (n + 1)\nexact = [False] * (n + 1)\nprob[1] = exact[1] = True\nnum_in = [1] * (n + 1)\nfor _ in range(m):\n x, y = map(int, input().split())\n if num_in[x] == 1 and exact[x]:\n exact[y] = True\n exact[x] = False\n prob[x] = False\n ... | n, m = map(int, input().split())
prob = [False] * (n + 1)
exact = [False] * (n + 1)
prob[1] = exact[1] = True
num_in = [1] * (n + 1)
for _ in range(m):
x, y = map(int, input().split())
if num_in[x] == 1 and exact[x]:
exact[y] = True
exact[x] = False
prob[x] = False
prob[y] = True... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
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,
... | [
[
134,
2
],
[
134,
11
],
[
125,
13
],
[
146,
16
],
[
135,
21
],
[
27,
24
],
[
147,
25
],
[
137,
29
],
[
35,
32
],
[
126,
33
],
[
38,
37
],
[
132,
40
],
[
140,
42
... | [
"n,m = map(int,input().split())\ndic = {}\nls = [1]*(n+1)\nls[0] = 0\nans = 0\ndic[1] = 1\nfor i in range(m):\n a,b = map(int,input().split())\n ls[a] -= 1\n ls[b] += 1\n if dic.get(a,0) != 0:\n if dic.get(b,0) == 0:\n dic[b] = 1\n else:\n if ls[b] == 1:\n dic[b] =... | n,m = map(int,input().split())
dic = {}
ls = [1]*(n+1)
ls[0] = 0
ans = 0
dic[1] = 1
for i in range(m):
a,b = map(int,input().split())
ls[a] -= 1
ls[b] += 1
if dic.get(a,0) != 0:
if dic.get(b,0) == 0:
dic[b] = 1
else:
if ls[b] == 1:
dic[b] = 0
for j in range(n+... |
[
7,
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,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
2,
2,
... | [
[
118,
2
],
[
118,
11
],
[
106,
13
],
[
119,
17
],
[
109,
18
],
[
119,
22
],
[
27,
24
],
[
107,
25
],
[
30,
29
],
[
113,
32
],
[
121,
34
],
[
121,
43
],
[
127,
45
... | [
"N,M = map(int,input().split())\nR,A = [0]*N,[1]*N\nR[0] = 1\nfor i in range(M):\n x,y = map(int,input().split())\n x,y = x-1,y-1\n if A[x] > 1 and R[x] == 1:\n R[y] = 1\n elif A[x] == R[x] == 1:\n R[x] = 0\n R[y] = 1\n A[x] -= 1\n A[y] += 1\nprint(sum(R))",
"N,M = map(int,... | N,M = map(int,input().split())
R,A = [0]*N,[1]*N
R[0] = 1
for i in range(M):
x,y = map(int,input().split())
x,y = x-1,y-1
if A[x] > 1 and R[x] == 1:
R[y] = 1
elif A[x] == R[x] == 1:
R[x] = 0
R[y] = 1
A[x] -= 1
A[y] += 1
print(sum(R)) |
[
7,
15,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,... | [
[
7,
6
],
[
7,
15
],
[
18,
17
],
[
6,
21
],
[
26,
23
],
[
17,
24
],
[
29,
28
],
[
6,
32
],
[
35,
34
],
[
15,
37
],
[
40,
39
],
[
40,
48
],
[
51,
50
],
[
54,... | [
"#!/usr/bin/env python3\nimport sys\n\n\ndef main():\n N, M = map(int, input().split())\n red = [0] * N\n red[0] = 1\n num = [1] * N\n\n for i in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n if red[x]:\n red[y] = 1\n \n num[... | #!/usr/bin/env python3
import sys
def main():
N, M = map(int, input().split())
red = [0] * N
red[0] = 1
num = [1] * N
for i in range(M):
x, y = map(int, input().split())
x -= 1
y -= 1
if red[x]:
red[y] = 1
num[x] -= 1
num[y]... |
[
7,
15,
13,
13,
13,
15,
15,
15,
15,
15,
15,
15,
12,
13,
14,
13,
4,
13,
31,
13,
23,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
23,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
13,... | [
[
40,
40
],
[
42,
42
],
[
200,
51
],
[
233,
56
],
[
188,
63
],
[
191,
74
],
[
176,
85
],
[
230,
88
],
[
207,
90
],
[
230,
91
],
[
95,
94
],
[
231,
97
],
[
215,
101
... | [
"import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10\nfrom itertools import permutations, combinations, product, accumulate, combinations_with_replacement\nfrom operator import itemgetter, mul\nfr... | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy im... |
[
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,
13,
17,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
... | [
[
97,
2
],
[
97,
11
],
[
103,
13
],
[
89,
18
],
[
24,
21
],
[
104,
22
],
[
100,
26
],
[
89,
31
],
[
109,
34
],
[
91,
36
],
[
40,
39
],
[
98,
42
],
[
106,
44
],
... | [
"N,M=map(int,input().split())\nX=[0]*(N+1)\nX[1]=1\nY=[1]*(N+1)\na,b=0,0\nfor i in range(M):\n a,b=map(int,input().split())\n X[b]|=X[a]\n Y[b]+=1\n Y[a]-=1\n if Y[a]==0:\n X[a]=0\nprint(sum(X))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
... | N,M=map(int,input().split())
X=[0]*(N+1)
X[1]=1
Y=[1]*(N+1)
a,b=0,0
for i in range(M):
a,b=map(int,input().split())
X[b]|=X[a]
Y[b]+=1
Y[a]-=1
if Y[a]==0:
X[a]=0
print(sum(X)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
17,
0,
13,
13,
0,
18,
13,
17,
39,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
18,
13,
2,
13... | [
[
173,
2
],
[
173,
11
],
[
15,
14
],
[
165,
17
],
[
167,
24
],
[
30,
27
],
[
168,
28
],
[
36,
35
],
[
174,
38
],
[
179,
40
],
[
179,
49
],
[
58,
51
],
[
168,
53
]... | [
"N,M=map(int,input().split())\narr=[[0,1,0] for _ in range(N)]\narr[0]=[1,1,1]\nfor i in range(M):\n a,b=map(int,input().split())\n arr[a-1][1]-=1\n arr[b-1][1]+=1\n if arr[a-1][0]==1:\n arr[b-1][0]=1\n if arr[a-1][2]==1:\n arr[a-1][2],arr[b-1][2]=0,1\n if arr[a-1][1]==0:\n arr[a-1][0]=0\nans=0\nfor ... | N,M=map(int,input().split())
arr=[[0,1,0] for _ in range(N)]
arr[0]=[1,1,1]
for i in range(M):
a,b=map(int,input().split())
arr[a-1][1]-=1
arr[b-1][1]+=1
if arr[a-1][0]==1:
arr[b-1][0]=1
if arr[a-1][2]==1:
arr[a-1][2],arr[b-1][2]=0,1
if arr[a-1][1]==0:
arr[a-1][0]=0
ans=0
for i in range(N):
if... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
... | [
[
131,
2
],
[
131,
11
],
[
15,
14
],
[
132,
17
],
[
119,
21
],
[
26,
25
],
[
132,
28
],
[
107,
32
],
[
38,
35
],
[
108,
36
],
[
134,
40
],
[
44,
43
],
[
114,
46
]... | [
"N, M = map(int, input().split())\n\nball = [1 for _ in range(N)]\nred = [0 for _ in range(N)]\nred[0] = 1\n\nnow_red = 0\n\nfor i in range(M):\n xx, yy = map(int, input().split())\n x = xx-1\n y = yy-1\n \n ball[x] -= 1\n ball[y] += 1\n \n if red[x]:\n if ball[x] == 0:\n r... | N, M = map(int, input().split())
ball = [1 for _ in range(N)]
red = [0 for _ in range(N)]
red[0] = 1
now_red = 0
for i in range(M):
xx, yy = map(int, input().split())
x = xx-1
y = yy-1
ball[x] -= 1
ball[y] += 1
if red[x]:
if ball[x] == 0:
red[x] = 0
red[... |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,... | [
[
140,
4
],
[
32,
31
],
[
123,
33
],
[
32,
34
],
[
37,
36
],
[
31,
41
],
[
45,
44
],
[
31,
49
],
[
55,
52
],
[
44,
53
],
[
58,
57
],
[
34,
60
],
[
63,
62
],
[
... | [
"import sys\ninput = sys.stdin.buffer.readline\n\n#sys.setrecursionlimit(10**9)\n#from functools import lru_cache\n\ndef RD(): return input().rstrip().decode()\ndef II(): return int(input())\ndef FI(): return int(input())\ndef MI(): return map(int,input().split())\ndef MF(): return map(float,input().split())\ndef L... | import sys
input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
21,
22,
17,
39,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
1... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
24,
23
],
[
4,
28
],
[
34,
31
],
[
15,
32
],
[
23,
33
],
[
39,
38
],
[
13,
41
],
[
44,
43
],
[
44,
52
],
[
55,
54
],
[
15... | [
"#!/usr/bin python3\n# -*- coding: utf-8 -*-\n\ndef main():\n N, M = map(int, input().split())\n dp = {1:[1,True]} #dp[i] iの箱の状態 [x個]赤がいる可能性がある\n for _ in range(2,N+1):\n dp[_] = [1,False]\n for _ in range(M):\n fm, to = map(int, input().split())\n num, state = dp[fm]\n ... | #!/usr/bin python3
# -*- coding: utf-8 -*-
def main():
N, M = map(int, input().split())
dp = {1:[1,True]} #dp[i] iの箱の状態 [x個]赤がいる可能性がある
for _ in range(2,N+1):
dp[_] = [1,False]
for _ in range(M):
fm, to = map(int, input().split())
num, state = dp[fm]
#fmの処理
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
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,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
... | [
[
157,
2
],
[
157,
11
],
[
15,
14
],
[
152,
17
],
[
154,
21
],
[
27,
24
],
[
155,
25
],
[
31,
30
],
[
152,
33
],
[
136,
37
],
[
145,
40
],
[
44,
43
],
[
158,
46
]... | [
"n,m=map(int,input().split())\nflg=[False for i in range(n)]\nflg[0]=True\nt=[1 for i in range(n)]\ntmp=1\nfor i in range(m):\n x,y=map(int,input().split())\n x,y=x-1,y-1\n t[x]-=1\n t[y]+=1\n if flg[x]:\n flg[y]=True\n if t[x]==1 and len(flg)==1:\n flg[x]=False\n\n if t[x... | n,m=map(int,input().split())
flg=[False for i in range(n)]
flg[0]=True
t=[1 for i in range(n)]
tmp=1
for i in range(m):
x,y=map(int,input().split())
x,y=x-1,y-1
t[x]-=1
t[y]+=1
if flg[x]:
flg[y]=True
if t[x]==1 and len(flg)==1:
flg[x]=False
if t[x]==0:
flg[x]... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
0,
13,
4,
13,
13,
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,
... | [
[
110,
3
],
[
110,
12
],
[
125,
14
],
[
126,
19
],
[
119,
23
],
[
29,
28
],
[
111,
31
],
[
113,
33
],
[
113,
42
],
[
47,
44
],
[
120,
45
],
[
105,
46
],
[
52,
49
... | [
"from collections import defaultdict\nn, m = map(int, input().split())\nr = set()\nr.add(1)\nd = defaultdict(int)\nfor i in range(m):\n x, y = map(int, input().split())\n d[x] -= 1\n d[y] += 1\n if x in r:\n r.add(y)\n if d[x] == -1 and x in r:\n r.remove(x)\nans = len(list(r))\nfor e in d:\n if d[e] ==... | from collections import defaultdict
n, m = map(int, input().split())
r = set()
r.add(1)
d = defaultdict(int)
for i in range(m):
x, y = map(int, input().split())
d[x] -= 1
d[y] += 1
if x in r:
r.add(y)
if d[x] == -1 and x in r:
r.remove(x)
ans = len(list(r))
for e in d:
if d[e] == -1 and e in r:
... |
[
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,
13,
2,
39,
17,
13,
0,
13,
17,
0,
13,
17,
... | [
[
285,
2
],
[
285,
11
],
[
15,
14
],
[
286,
17
],
[
267,
30
],
[
255,
33
],
[
265,
37
],
[
273,
39
],
[
265,
43
],
[
279,
45
],
[
265,
49
],
[
276,
51
],
[
288,
54
... | [
"n,m=map(int,input().split())\nxy = [list(map(int, input().split())) for _ in range(m)]\nl=[1]*n\nout_=[0]*n\nin_=[0]*n\nc=1\n\ncheck=0\nfor i in range(m):\n if check==0:\n if xy[i][0]==1:\n in_[xy[i][1]-1]+=1\n check=1\n else:\n if xy[i][1]==1:\n in_... | n,m=map(int,input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
l=[1]*n
out_=[0]*n
in_=[0]*n
c=1
check=0
for i in range(m):
if check==0:
if xy[i][0]==1:
in_[xy[i][1]-1]+=1
check=1
else:
if xy[i][1]==1:
in_[xy[i][1]-1]+=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,
0,
18,
13,
... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
4,
19
],
[
22,
21
],
[
4,
25
],
[
30,
27
],
[
21,
28
],
[
33,
32
],
[
13,
35
],
[
38,
37
],
[
38,
46
],
[
49,
48
],
[
52,... | [
"\ndef solve():\n N, M = map(int, input().split())\n exist = [1] * N\n red = [False] * N\n red[0] = True\n for i in range(M):\n x, y = map(int, input().split())\n x -= 1; y -= 1\n exist[x] -= 1; exist[y] += 1\n if red[x]:\n red[y] = True\n if exist[x] == ... |
def solve():
N, M = map(int, input().split())
exist = [1] * N
red = [False] * N
red[0] = True
for i in range(M):
x, y = map(int, input().split())
x -= 1; y -= 1
exist[x] -= 1; exist[y] += 1
if red[x]:
red[y] = True
if exist[x] == 0:
re... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
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,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,... | [
[
134,
2
],
[
134,
11
],
[
16,
15
],
[
129,
18
],
[
122,
22
],
[
27,
26
],
[
129,
29
],
[
125,
33
],
[
39,
36
],
[
126,
37
],
[
42,
41
],
[
135,
44
],
[
137,
46
]... | [
"n,m = map(int, input().split())\n\n'''\nd = dict()\nfor i in range(1,n+1):\n d[str(i)] = 1\nfrom collections import deque\nans = deque('1')'''\nbox = [1 for i in range(n)]\nans = [0 for i in range(n)]\nans[0] = 1\nfor _ in range(m):\n x,y = map(int,input().split())\n box[x-1] -= 1\n box[y-1] += 1\n ... | n,m = map(int, input().split())
'''
d = dict()
for i in range(1,n+1):
d[str(i)] = 1
from collections import deque
ans = deque('1')'''
box = [1 for i in range(n)]
ans = [0 for i in range(n)]
ans[0] = 1
for _ in range(m):
x,y = map(int,input().split())
box[x-1] -= 1
box[y-1] += 1
if ans[x-1]==1 and a... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
0,
13,
... | [
[
142,
2
],
[
142,
11
],
[
133,
13
],
[
17,
16
],
[
143,
19
],
[
134,
22
],
[
115,
35
],
[
122,
39
],
[
112,
41
],
[
122,
45
],
[
50,
47
],
[
113,
48
],
[
53,
52
... | [
"N, M = map(int, input().split())\nxy = []\nfor _ in range(M):\n xy.append(tuple(map(int, input().split())))\n\nnum = [1] * N\nred = [False] * N\nred[0] = True\n\nfor el in xy:\n x, y = el\n x, y = x - 1, y - 1\n if red[x]:\n red[y] = True\n num[x] -= 1\n if num[x] == 0:\n red[x] = F... | N, M = map(int, input().split())
xy = []
for _ in range(M):
xy.append(tuple(map(int, input().split())))
num = [1] * N
red = [False] * N
red[0] = True
for el in xy:
x, y = el
x, y = x - 1, y - 1
if red[x]:
red[y] = True
num[x] -= 1
if num[x] == 0:
red[x] = False
num[y] += 1
... |
[
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,
0,
13,
17,
0,
13,
17,
14,
2,
18,
13,
13,
... | [
[
113,
2
],
[
113,
11
],
[
125,
13
],
[
105,
21
],
[
116,
24
],
[
105,
28
],
[
31,
30
],
[
114,
33
],
[
110,
35
],
[
110,
44
],
[
119,
46
],
[
122,
49
],
[
62,
53
... | [
"n,m=map(int,input().split())\nred=[1]+[0]*(n-1)\npink=[1]*n\nfor _ in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n if red[x] and pink[x]==1:\n red[x]=0\n red[y]=1\n elif red[x] and pink[x]>1:\n red[y]=1\n pink[x]-=1\n pink[y]+=1\nprint(red.count(1))",
"n,m=ma... | n,m=map(int,input().split())
red=[1]+[0]*(n-1)
pink=[1]*n
for _ in range(m):
x,y=map(int,input().split())
x-=1
y-=1
if red[x] and pink[x]==1:
red[x]=0
red[y]=1
elif red[x] and pink[x]>1:
red[y]=1
pink[x]-=1
pink[y]+=1
print(red.count(1)) |
[
7,
15,
13,
15,
15,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
41,
28... | [
[
10,
9
],
[
9,
18
],
[
21,
20
],
[
21,
22
],
[
25,
24
],
[
30,
29
],
[
20,
34
],
[
38,
37
],
[
20,
42
],
[
48,
45
],
[
37,
46
],
[
51,
50
],
[
22,
53
],
[
... | [
"# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd\n# def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().dec... | # -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')... |
[
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,
0,
18,
13,
17,
17,
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,
... | [
[
111,
2
],
[
111,
11
],
[
15,
14
],
[
106,
18
],
[
108,
23
],
[
29,
26
],
[
109,
27
],
[
33,
32
],
[
106,
36
],
[
102,
41
],
[
47,
44
],
[
103,
45
],
[
50,
49
],... | [
"n, m = map(int, input().split())\ncount = [1 for i in range(n + 1)]\ncount[0] = 0\nflag = [False for i in range(n + 1)]\nflag[1] = True\nfor i in range(m):\n x, y = map(int, input().split())\n if flag[x] == True:\n flag[y] = True\n count[x] -= 1\n count[y] += 1\n if count[x] == 0:\n fl... | n, m = map(int, input().split())
count = [1 for i in range(n + 1)]
count[0] = 0
flag = [False for i in range(n + 1)]
flag[1] = True
for i in range(m):
x, y = map(int, input().split())
if flag[x] == True:
flag[y] = True
count[x] -= 1
count[y] += 1
if count[x] == 0:
flag[x] = False
pri... |
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13... | [
[
4,
3
],
[
3,
12
],
[
118,
14
],
[
118,
16
],
[
20,
19
],
[
104,
22
],
[
109,
26
],
[
31,
30
],
[
104,
33
],
[
106,
37
],
[
43,
40
],
[
107,
41
],
[
46,
45
],
... | [
"n, m = [int(_) for _ in input().split()]\n\nball = [1 for i in range(n)]\nred = [False for i in range(n)]\nred[0] = True\n\nfor i in range(m):\n x, y = [int(_)-1 for _ in input().split()]\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\n... | n, m = [int(_) for _ in input().split()]
ball = [1 for i in range(n)]
red = [False for i in range(n)]
red[0] = True
for i in range(m):
x, y = [int(_)-1 for _ in input().split()]
ball[x] -= 1
ball[y] += 1
if red[x]:
red[y] = True
if ball[x] == 0:
red[x] = False
print(sum(red))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
... | [
[
104,
2
],
[
104,
11
],
[
15,
14
],
[
99,
17
],
[
107,
30
],
[
95,
33
],
[
105,
38
],
[
101,
41
],
[
105,
46
],
[
52,
49
],
[
102,
50
],
[
61,
58
],
[
96,
59
],
... | [
"n,m = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(m)]\n\nball = [1] * (n+1)\nred = [0] * (n+1)\nred[1] = 1\n\nfor x,y in xy:\n ball[x] -= 1\n ball[y] += 1\n if red[x] == 1:\n red[y] = 1\n if ball[x] == 0:\n red[x] = 0\nprint(sum(red))",
"n,m =... | n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
ball = [1] * (n+1)
red = [0] * (n+1)
red[1] = 1
for x,y in xy:
ball[x] -= 1
ball[y] += 1
if red[x] == 1:
red[y] = 1
if ball[x] == 0:
red[x] = 0
print(sum(red)) |
[
7,
15,
13,
12,
13,
12,
13,
4,
18,
13,
13,
2,
17,
17,
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,
0,
18,
13,
2,
13,
17,
8,
2,
18,
13,... | [
[
119,
15
],
[
102,
17
],
[
119,
18
],
[
107,
20
],
[
120,
24
],
[
110,
26
],
[
120,
30
],
[
35,
32
],
[
108,
33
],
[
38,
37
],
[
114,
40
],
[
122,
42
],
[
102,
44
... | [
"import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN, M = mapint()\nboxes = [0]*N\nballs = [1]*N\nboxes[0] = 1\nfor _ in range(M):\n x, y = mapint()\n boxes[y-1] = 1 if boxes[x-1]==1 else boxes[y-1]\n balls[x-1] -= ... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
N, M = mapint()
boxes = [0]*N
balls = [1]*N
boxes[0] = 1
for _ in range(M):
x, y = mapint()
boxes[y-1] = 1 if boxes[x-1]==1 else boxes[y-1]
balls[x-1] -= 1
balls[y-1] ... |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
39,
... | [
[
117,
4
],
[
120,
13
],
[
123,
22
],
[
135,
31
],
[
121,
38
],
[
135,
40
],
[
129,
42
],
[
118,
49
],
[
126,
52
],
[
136,
57
],
[
132,
60
],
[
136,
65
],
[
71,
68
... | [
"import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, M = map(int, readline().split())\nm = map(int, read().split())\n\ncount = [1] * (N+1)\nred = [0] * (N+1)\nred[1] = True\nfor x, y in zip(m, m):\n count[x] -= 1\n count[y] += 1\n i... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
m = map(int, read().split())
count = [1] * (N+1)
red = [0] * (N+1)
red[1] = True
for x, y in zip(m, m):
count[x] -= 1
count[y] += 1
if red[x]:
re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.