node_ids listlengths 4 1.4k | edge_index listlengths 1 2.22k | text listlengths 4 1.4k | source stringlengths 14 427k |
|---|---|---|---|
[
7,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
4,
13,
4,
18,
... | [
[
141,
3
],
[
141,
12
],
[
132,
14
],
[
135,
16
],
[
20,
19
],
[
130,
22
],
[
138,
24
],
[
138,
33
],
[
133,
36
],
[
124,
38
],
[
136,
41
],
[
139,
43
],
[
147,
45
... | [
"# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 7 14:28:00 2020\n\n@author: NEC-PCuser\n\"\"\"\n\nN, M = map(int, input().split())\nx, y = [], []\n\nfor i in range(M):\n x_tmp, y_tmp = map(int, input().split())\n x.append(x_tmp)\n y.append(y_tmp)\n\nbox = [1] * N \nball_set = set()\nball_set.add(1)\n... | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 7 14:28:00 2020
@author: NEC-PCuser
"""
N, M = map(int, input().split())
x, y = [], []
for i in range(M):
x_tmp, y_tmp = map(int, input().split())
x.append(x_tmp)
y.append(y_tmp)
box = [1] * N
ball_set = set()
ball_set.add(1)
start_flg = True
for i in ran... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
13,
17,
39,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
0,
13,
17... | [
[
148,
2
],
[
148,
12
],
[
16,
15
],
[
149,
18
],
[
133,
24
],
[
30,
27
],
[
134,
28
],
[
139,
34
],
[
38,
37
],
[
131,
40
],
[
142,
42
],
[
142,
52
],
[
145,
54
... | [
"n,m = map(int,input().split(\" \"))\nar = [[0,1] for i in range(n)]\nar[0] = [1,1]\nr = 0\nfor i in range(m):\n a,b = map(int,input().split(\" \"))\n a -= 1\n b -= 1\n if ar[a][0] == 1 and ar[a][1] >= 1:\n ar[b][0] = 1\n ar[b][1] += 1\n ar[a][1] -= 1\n if ar[a][1] == 0:\n ar[a][0... | n,m = map(int,input().split(" "))
ar = [[0,1] for i in range(n)]
ar[0] = [1,1]
r = 0
for i in range(m):
a,b = map(int,input().split(" "))
a -= 1
b -= 1
if ar[a][0] == 1 and ar[a][1] >= 1:
ar[b][0] = 1
ar[b][1] += 1
ar[a][1] -= 1
if ar[a][1] == 0:
ar[a][0] = 0
count = 0
for r ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
17,
0,
13,
4,
13,
39,
17,
13,
13,
28,
13,
13,
13,... | [
[
98,
2
],
[
98,
11
],
[
15,
14
],
[
99,
17
],
[
92,
30
],
[
35,
34
],
[
96,
39
],
[
34,
42
],
[
104,
45
],
[
101,
50
],
[
105,
59
],
[
105,
62
],
[
77,
67
],
[... | [
"n, m = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(m)]\n\nred, cnt = set([1]), {i: 1 for i in range(1, n + 1)}\nfor xi, yi in xy:\n if xi in red:\n red.add(yi)\n if cnt[xi] == 1:\n red.remove(xi)\n cnt[xi] -= 1\n cnt[yi] += 1\nprint(len(red))",
... | n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
red, cnt = set([1]), {i: 1 for i in range(1, n + 1)}
for xi, yi in xy:
if xi in red:
red.add(yi)
if cnt[xi] == 1:
red.remove(xi)
cnt[xi] -= 1
cnt[yi] += 1
print(len(red))
|
[
7,
0,
13,
12,
2,
4,
13,
13,
17,
23,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
... | [
[
106,
2
],
[
115,
11
],
[
115,
20
],
[
112,
22
],
[
116,
30
],
[
109,
33
],
[
116,
37
],
[
40,
39
],
[
101,
42
],
[
118,
44
],
[
107,
47
],
[
118,
53
],
[
113,
56
... | [
"int1 = lambda x: int(x) - 1\n\nN, M = map(int, input().split())\n\nred = [True] + [False] * (N-1)\nn_ball = [1] * N\n\nfor _ in range(M):\n x,y = map(int1, input().split())\n if red[x]:\n red[y] = True\n n_ball[x] -= 1\n n_ball[y] += 1\n if n_ball[x] == 0:\n red[x] = Fa... | int1 = lambda x: int(x) - 1
N, M = map(int, input().split())
red = [True] + [False] * (N-1)
n_ball = [1] * N
for _ in range(M):
x,y = map(int1, input().split())
if red[x]:
red[y] = True
n_ball[x] -= 1
n_ball[y] += 1
if n_ball[x] == 0:
red[x] = False
else:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
2,
39,
17,
39,
17,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
39,
17,
13,
28,
... | [
[
107,
2
],
[
107,
11
],
[
15,
14
],
[
102,
17
],
[
110,
30
],
[
113,
33
],
[
108,
44
],
[
104,
47
],
[
108,
54
],
[
63,
60
],
[
105,
61
],
[
68,
65
],
[
105,
66
... | [
"N,M=map(int,input().split())\nxy=[list(map(int,input().split()))for _ in range(M)]\n\ncountR=[0]+[1]+[0]*(N-1)\ncountBall=[0]+[1]*N\n\nfor x,y in xy:\n countBall[x]-=1\n countBall[y]+=1\n if countR[x]>0:\n countR[y]+=1\n if countBall[x]<1:\n countR[x]=0\n\nprint(sum(r*b>0 for r,b in zip(c... | N,M=map(int,input().split())
xy=[list(map(int,input().split()))for _ in range(M)]
countR=[0]+[1]+[0]*(N-1)
countBall=[0]+[1]*N
for x,y in xy:
countBall[x]-=1
countBall[y]+=1
if countR[x]>0:
countR[y]+=1
if countBall[x]<1:
countR[x]=0
print(sum(r*b>0 for r,b in zip(countR,countBall))) |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
... | [
[
148,
4
],
[
145,
13
],
[
142,
22
],
[
157,
38
],
[
146,
45
],
[
157,
47
],
[
51,
50
],
[
158,
53
],
[
146,
63
],
[
139,
66
],
[
154,
69
],
[
152,
73
],
[
78,
75
... | [
"import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn, m = map(int, readline().split())\nxy = [list(map(int, readline().split())) for _ in range(m)]\nflag = [False] * n\nflag[0] = True\ncnt = [1] * n\nfor x, y in ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, m = map(int, readline().split())
xy = [list(map(int, readline().split())) for _ in range(m)]
flag = [False] * n
flag[0] = True
cnt = [1] * n
for x, y in xy:
if flag[... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
... | [
[
102,
2
],
[
102,
11
],
[
99,
13
],
[
103,
17
],
[
22,
19
],
[
100,
20
],
[
93,
24
],
[
103,
28
],
[
31,
30
],
[
97,
33
],
[
90,
35
],
[
90,
44
],
[
108,
46
],
... | [
"N, M = map(int, input().split())\n\nRed = [0]*N\nRed[0] = 1\nNum = [1]*N\n\nfor i in range(M):\n In, Out = map(int, input().split())\n In -= 1\n Out -= 1\n Num[In] -= 1\n Num[Out] += 1\n if Red[In]:\n Red[Out] = 1\n if Num[In] == 0:\n Red[In] = 0\n\nprint(sum(Red))",
"N, M = map(int, input().split()... | N, M = map(int, input().split())
Red = [0]*N
Red[0] = 1
Num = [1]*N
for i in range(M):
In, Out = map(int, input().split())
In -= 1
Out -= 1
Num[In] -= 1
Num[Out] += 1
if Red[In]:
Red[Out] = 1
if Num[In] == 0:
Red[In] = 0
print(sum(Red)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
... | [
[
114,
2
],
[
114,
11
],
[
15,
14
],
[
115,
17
],
[
108,
30
],
[
111,
33
],
[
106,
38
],
[
44,
41
],
[
112,
42
],
[
49,
46
],
[
112,
47
],
[
102,
51
],
[
106,
56
... | [
"N, M = map(int, input().split())\nxy = [list(map(int, input().split())) for _ in range(M)]\nred = [0] * (N+1) #赤になりうる場所を1とする\nred[1] = 1\nred[0] = \"\"\nball = [1] * (N+1) #個数\nball[0] = \"\"\nfor x, y in xy:\n ball[y] += 1\n ball[x] -= 1\n if red[x] == 1:\n red[y] = 1\n if ball[x] == 0: red[x] = 0\nprint... | N, M = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(M)]
red = [0] * (N+1) #赤になりうる場所を1とする
red[1] = 1
red[0] = ""
ball = [1] * (N+1) #個数
ball[0] = ""
for x, y in xy:
ball[y] += 1
ball[x] -= 1
if red[x] == 1:
red[y] = 1
if ball[x] == 0: red[x] = 0
print(red.count(1)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
... | [
[
143,
2
],
[
143,
11
],
[
15,
14
],
[
144,
17
],
[
140,
21
],
[
26,
25
],
[
144,
28
],
[
137,
32
],
[
38,
35
],
[
138,
36
],
[
41,
40
],
[
132,
43
],
[
134,
45
]... | [
"N,M=map(int,input().split())\nballs=[1 for _ in range(N)]\nanswers=[0 for _ in range(N)]\nanswers[0]=1\nfor _ in range(M):\n x,y=map(int,input().split())\n balls[x-1]-=1\n balls[y-1]+=1\n if balls[x-1]>=1 and answers[x-1]==1:\n answers[y-1]=1\n elif balls[x-1]==0 and answers[x-1]==1:\n ... | N,M=map(int,input().split())
balls=[1 for _ in range(N)]
answers=[0 for _ in range(N)]
answers[0]=1
for _ in range(M):
x,y=map(int,input().split())
balls[x-1]-=1
balls[y-1]+=1
if balls[x-1]>=1 and answers[x-1]==1:
answers[y-1]=1
elif balls[x-1]==0 and answers[x-1]==1:
answers[x-1]=0
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
40,
... | [
[
135,
2
],
[
135,
11
],
[
138,
13
],
[
133,
17
],
[
123,
19
],
[
133,
23
],
[
28,
25
],
[
124,
26
],
[
31,
30
],
[
136,
33
],
[
129,
35
],
[
129,
44
],
[
120,
46
... | [
"n, m = map(int, input().split())\nC = [1]*n\nP = [0]*n\nP[0] = 1\n\nfor i in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n if P[x] != 0:\n if C[x] == 1:\n P[x] = 0\n C[x] -= 1\n P[y] = 1\n C[y] += 1\n else:\n C[x] -= 1... | n, m = map(int, input().split())
C = [1]*n
P = [0]*n
P[0] = 1
for i in range(m):
x, y = map(int, input().split())
x, y = x-1, y-1
if P[x] != 0:
if C[x] == 1:
P[x] = 0
C[x] -= 1
P[y] = 1
C[y] += 1
else:
C[x] -= 1
P[y] = ... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
17,
0,
13,
4,
18,
13,
13,
39,
13,
17,
0,
18,
13,
39,
17,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
17,
14,
2... | [
[
131,
4
],
[
131,
13
],
[
137,
16
],
[
28,
25
],
[
138,
26
],
[
33,
30
],
[
138,
31
],
[
122,
35
],
[
39,
38
],
[
117,
41
],
[
125,
43
],
[
125,
52
],
[
138,
57
... | [
"import numpy as np\nn, m = map(int, input().split())\n'''\nxx = []\nyy = []\n'''\nbox = np.zeros((n, 2))\nbox[:, 0] = 1\nbox[0, 1] = 1\n\n\ncount = 0\nfor _ in range(m):\n x, y = map(int, input().split())\n '''\n xx.append(x)\n yy.append(y)\n '''\n if (box[x - 1, 1] == 1):\n box[y - 1, 1] ... | import numpy as np
n, m = map(int, input().split())
'''
xx = []
yy = []
'''
box = np.zeros((n, 2))
box[:, 0] = 1
box[0, 1] = 1
count = 0
for _ in range(m):
x, y = map(int, input().split())
'''
xx.append(x)
yy.append(y)
'''
if (box[x - 1, 1] == 1):
box[y - 1, 1] = 1
box[x - 1, 0] -... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
... | [
[
102,
2
],
[
102,
11
],
[
96,
13
],
[
103,
17
],
[
87,
19
],
[
103,
23
],
[
28,
25
],
[
88,
26
],
[
31,
30
],
[
91,
33
],
[
99,
35
],
[
99,
50
],
[
55,
52
],
[... | [
"n, m = map(int, input().split())\ncounts = [1] * n\ncands = [False] * n\ncands[0] = True\nfor _ in range(m):\n x, y = map(lambda t: int(t) - 1, input().split())\n counts[x] -= 1\n counts[y] += 1\n if cands[x]:\n cands[y] = True\n if counts[x] == 0:\n cands[x] = False\nprint(sum(cands))",
"n, m = m... | n, m = map(int, input().split())
counts = [1] * n
cands = [False] * n
cands[0] = True
for _ in range(m):
x, y = map(lambda t: int(t) - 1, input().split())
counts[x] -= 1
counts[y] += 1
if cands[x]:
cands[y] = True
if counts[x] == 0:
cands[x] = False
print(sum(cands)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
... | [
[
109,
2
],
[
109,
11
],
[
106,
13
],
[
110,
17
],
[
97,
19
],
[
110,
23
],
[
28,
25
],
[
98,
26
],
[
31,
30
],
[
101,
33
],
[
112,
35
],
[
112,
44
],
[
98,
48
],... | [
"N,M=map(int,input().split())\nL=[1]*N\nS=[-1]*N\nS[0]=1\nfor i in range(M):\n\tx,y=map(int,input().split())\n\tif S[x-1]==1:\n\t\tS[y-1]=1\n\tL[x-1]-=1\n\tL[y-1]+=1\n\tif L[x-1]==0:\n\t\tS[x-1]=-1\nprint(S.count(1))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input... | N,M=map(int,input().split())
L=[1]*N
S=[-1]*N
S[0]=1
for i in range(M):
x,y=map(int,input().split())
if S[x-1]==1:
S[y-1]=1
L[x-1]-=1
L[y-1]+=1
if L[x-1]==0:
S[x-1]=-1
print(S.count(1)) |
[
7,
15,
13,
12,
13,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
0,
18,
18,
13,
13,
17,
17,
14,
2,
18,
18,
13,
... | [
[
11,
6
],
[
65,
8
],
[
67,
9
],
[
18,
13
],
[
65,
15
],
[
69,
16
],
[
65,
23
],
[
67,
24
],
[
65,
31
],
[
67,
32
],
[
41,
36
],
[
65,
38
],
[
67,
39
],
[
4... | [
"import numpy as np\n\ndef transfer(state, x, y):\n state[x][0] -= 1\n state[y][0] += 1\n if state[x][0] == 0:\n if state[x][1] == 1:\n state[x][1] = 0\n state[y][1] = 1\n else:\n if state[x][1] == 1:\n state[y][1] = 1\n \nn, m = map(int, input()... | import numpy as np
def transfer(state, x, y):
state[x][0] -= 1
state[y][0] += 1
if state[x][0] == 0:
if state[x][1] == 1:
state[x][1] = 0
state[y][1] = 1
else:
if state[x][1] == 1:
state[y][1] = 1
n, m = map(int, input().split())
state =... |
[
7,
0,
13,
2,
2,
17,
17,
17,
0,
13,
2,
17,
17,
15,
13,
4,
18,
13,
13,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
... | [
[
121,
2
],
[
127,
9
],
[
24,
23
],
[
24,
32
],
[
35,
34
],
[
23,
38
],
[
43,
40
],
[
34,
41
],
[
46,
45
],
[
23,
49
],
[
52,
51
],
[
32,
54
],
[
57,
56
],
[
... | [
"MOD = 10 ** 9 + 7\nINF = 10 ** 11\nimport sys\nsys.setrecursionlimit(100000000)\n\ndef main():\n N,M = map(int,input().split())\n possible = [0] * N\n possible[0] = 1\n ball_cnt = [1] * N\n for _ in range(M):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n if possibl... | MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)
def main():
N,M = map(int,input().split())
possible = [0] * N
possible[0] = 1
ball_cnt = [1] * N
for _ in range(M):
x,y = map(int,input().split())
x -= 1
y -= 1
if possible[x]:
p... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
... | [
[
109,
2
],
[
109,
11
],
[
15,
14
],
[
110,
17
],
[
97,
30
],
[
103,
33
],
[
107,
38
],
[
100,
41
],
[
107,
46
],
[
52,
49
],
[
104,
50
],
[
61,
58
],
[
104,
59
]... | [
"#!/usr/bin/env python3\n\n#import\n#import math\n#import numpy as np\nN, M = map(int, input().split())\nQ = [list(map(int, input().split())) for _ in range(M)]\n\nR = [False] * (N + 1)\nnum = [1] * (N + 1)\n\nR[1] = True\n\nfor x, y in Q:\n R[y] = R[x] or R[y]\n num[x] -= 1\n num[y] += 1\n\n if num[x] ... | #!/usr/bin/env python3
#import
#import math
#import numpy as np
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(M)]
R = [False] * (N + 1)
num = [1] * (N + 1)
R[1] = True
for x, y in Q:
R[y] = R[x] or R[y]
num[x] -= 1
num[y] += 1
if num[x] <= 0:
R[x] = Fa... |
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
12,
13,
29,
18,
4,
18,
18,
13,
13,
13,
39,
17,
12,
13,
29,
2,
39,
17,
4,
13,
4,
13,
13,
23,
13,
4,
18,
13,
13,
17,
0,
13,
2,
4,
13,
17,
17,
17,
41,
28,
1... | [
[
38,
36
],
[
38,
38
],
[
195,
45
],
[
55,
54
],
[
54,
65
],
[
183,
67
],
[
207,
70
],
[
210,
85
],
[
190,
92
],
[
210,
94
],
[
98,
97
],
[
211,
100
],
[
190,
110
... | [
"import bisect\nimport copy\nimport heapq\nimport math\nimport sys\nfrom collections import *\nfrom functools import lru_cache\nfrom itertools import accumulate, combinations, permutations, product\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\nsys.setr... | import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0]+list(accumulate(lst))
sys.setrecursionlimit(500... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
0,
18,
... | [
[
113,
2
],
[
113,
11
],
[
92,
13
],
[
114,
17
],
[
104,
19
],
[
114,
27
],
[
31,
30
],
[
99,
33
],
[
110,
35
],
[
110,
44
],
[
101,
46
],
[
111,
48
],
[
102,
48
... | [
"n, m = map(int, input().split())\n\nball = [1] * n\nflag = [1] + [0] * (n-1)\n\nfor _ in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n\n ball[x] -= 1\n ball[y] += 1\n\n if flag[x] == 1:\n flag[y] = 1\n\n if ball[x] == 0:\n flag[x] = 0\n\nprint(sum(flag))",
"n, m... | n, m = map(int, input().split())
ball = [1] * n
flag = [1] + [0] * (n-1)
for _ in range(m):
x, y = map(int, input().split())
x, y = x-1, y-1
ball[x] -= 1
ball[y] += 1
if flag[x] == 1:
flag[y] = 1
if ball[x] == 0:
flag[x] = 0
print(sum(flag)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
18,
18,
13,
13,
17,
0,... | [
[
158,
2
],
[
158,
11
],
[
15,
14
],
[
159,
17
],
[
149,
21
],
[
137,
24
],
[
144,
28
],
[
131,
30
],
[
144,
34
],
[
39,
36
],
[
132,
37
],
[
134,
41
],
[
45,
44
... | [
"n,m = map(int,input().split())\nxy = [[int(i) for i in input().split()] for _ in range(m)]\nnum = [1]*n\nred = [False]*n\nred[0] = True\nflag = True\nfor i in range(m):\n p = xy[i][0]\n q = xy[i][1]\n num[p-1] -= 1\n num[q-1] += 1\n if red[p-1]==True:\n red[q-1] = True\n \n if num[p-1]=... | n,m = map(int,input().split())
xy = [[int(i) for i in input().split()] for _ in range(m)]
num = [1]*n
red = [False]*n
red[0] = True
flag = True
for i in range(m):
p = xy[i][0]
q = xy[i][1]
num[p-1] -= 1
num[q-1] += 1
if red[p-1]==True:
red[q-1] = True
if num[p-1]==0:
red[p-1... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
... | [
[
124,
2
],
[
124,
11
],
[
109,
13
],
[
125,
17
],
[
22,
19
],
[
110,
20
],
[
118,
24
],
[
125,
28
],
[
31,
30
],
[
116,
33
],
[
127,
35
],
[
127,
44
],
[
121,
46
... | [
"n, m = map(int, input().split())\n\nr = [False] * n\nr[0] = True\nl = [1] * n\n\nfor _ in range(m):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n l[x] -= 1\n l[y] += 1\n r[y] = r[x] | r[y]\n if not l[x]:\n r[x] = False\n\nc = 0\nfor i in range(n):\n if r[i] == True and l[i] ... | n, m = map(int, input().split())
r = [False] * n
r[0] = True
l = [1] * n
for _ in range(m):
x, y = map(int, input().split())
x -= 1
y -= 1
l[x] -= 1
l[y] += 1
r[y] = r[x] | r[y]
if not l[x]:
r[x] = False
c = 0
for i in range(n):
if r[i] == True and l[i] > 0:
c += 1
pr... |
[
7,
15,
13,
15,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,... | [
[
205,
5
],
[
202,
21
],
[
199,
26
],
[
36,
35
],
[
206,
42
],
[
36,
44
],
[
47,
46
],
[
35,
50
],
[
53,
52
],
[
35,
56
],
[
61,
58
],
[
46,
59
],
[
66,
63
],
[... | [
"import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, M = map(int, readline().split())\n R = [0]*(N)\n W = [1]*(N)\n R[0] = 1\n W[0] = 0\n for _ in range(M):\n x, y = map(... | import sys
from collections import Counter
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
N, M = map(int, readline().split())
R = [0]*(N)
W = [1]*(N)
R[0] = 1
W[0] = 0
for _ in range(M):
x, y = map(int, readline().spl... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
18,
13... | [
[
153,
2
],
[
153,
11
],
[
15,
14
],
[
154,
17
],
[
150,
23
],
[
31,
26
],
[
151,
28
],
[
156,
33
],
[
37,
36
],
[
139,
39
],
[
147,
41
],
[
147,
50
],
[
151,
55
... | [
"n, m = map(int,input().split())\nbox = [[1,0] for i in range(n)]#個数、赤の可能性\nbox[0][1] = 1\nans = 1\n\nfor i in range(m):\n x, y = map(int,input().split())\n if box[x-1][0] == 0:\n continue\n box[x-1][0] -= 1\n box[y-1][0] += 1\n if box[x-1][1] == 1:\n if box[y-1][1] == 0:\n b... | n, m = map(int,input().split())
box = [[1,0] for i in range(n)]#個数、赤の可能性
box[0][1] = 1
ans = 1
for i in range(m):
x, y = map(int,input().split())
if box[x-1][0] == 0:
continue
box[x-1][0] -= 1
box[y-1][0] += 1
if box[x-1][1] == 1:
if box[y-1][1] == 0:
box[y-1][1] = 1
... |
[
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,
... | [
[
117,
2
],
[
117,
11
],
[
123,
13
],
[
97,
17
],
[
99,
19
],
[
97,
23
],
[
28,
25
],
[
124,
26
],
[
31,
30
],
[
118,
33
],
[
120,
35
],
[
120,
44
],
[
111,
46
],... | [
"n,m = map(int,input().split())\nans = [False]*n\ncnt = [1]*n\nans[0] = True\nfor i in range(m):\n x,y = map(int,input().split())\n x -= 1\n y -= 1\n cnt[y] += 1\n if ans[x]:\n ans[y] = True\n cnt[x] -= 1\n if cnt[x]==0:\n ans[x] = False\nc = 0\nfor i in ans:\n if i:\n c... | n,m = map(int,input().split())
ans = [False]*n
cnt = [1]*n
ans[0] = True
for i in range(m):
x,y = map(int,input().split())
x -= 1
y -= 1
cnt[y] += 1
if ans[x]:
ans[y] = True
cnt[x] -= 1
if cnt[x]==0:
ans[x] = False
c = 0
for i in ans:
if i:
c += 1
print(c)
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
18,
13,
2,
13,
17,
... | [
[
89,
2
],
[
89,
11
],
[
95,
13
],
[
87,
17
],
[
22,
19
],
[
96,
20
],
[
92,
24
],
[
87,
28
],
[
31,
30
],
[
90,
33
],
[
101,
35
],
[
101,
44
],
[
51,
46
],
[
... | [
"n,m=map(int,input().split())\nans=[False]*n\nans[0]=True\nco=[1]*n\nfor i in range(m):\n x,y=map(int,input().split())\n ans[y-1]|=ans[x-1]\n co[x-1]-=1\n co[y-1]+=1\n if co[x-1]==0:ans[x-1]=False\nprint(ans.count(True))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",... | n,m=map(int,input().split())
ans=[False]*n
ans[0]=True
co=[1]*n
for i in range(m):
x,y=map(int,input().split())
ans[y-1]|=ans[x-1]
co[x-1]-=1
co[y-1]+=1
if co[x-1]==0:ans[x-1]=False
print(ans.count(True)) |
[
7,
15,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
... | [
[
6,
5
],
[
5,
14
],
[
104,
16
],
[
104,
18
],
[
107,
20
],
[
99,
24
],
[
95,
26
],
[
99,
30
],
[
35,
32
],
[
108,
33
],
[
38,
37
],
[
105,
40
],
[
44,
43
],
[
... | [
"import copy\nN,M = [int(hoge) for hoge in input().split()]\nBall = [False]*N\nBallNum = [1] * N\nBall[0] = True\nfor i in range(M):\n x,y = [int(hoge) - 1 for hoge in input().split()]\n BallNum[x] -= 1\n BallNum[y] += 1\n if Ball[x]:\n Ball[y] = True \n if BallNum[x] == 0:\n Ball[x] =... | import copy
N,M = [int(hoge) for hoge in input().split()]
Ball = [False]*N
BallNum = [1] * N
Ball[0] = True
for i in range(M):
x,y = [int(hoge) - 1 for hoge in input().split()]
BallNum[x] -= 1
BallNum[y] += 1
if Ball[x]:
Ball[y] = True
if BallNum[x] == 0:
Ball[x] = False
print(sum(... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
39,
13,
17,
0,
18,
18,
13,
17,
17,
17,
28... | [
[
195,
4
],
[
195,
13
],
[
204,
15
],
[
19,
18
],
[
196,
21
],
[
198,
23
],
[
205,
36
],
[
199,
38
],
[
177,
40
],
[
54,
49
],
[
178,
51
],
[
57,
56
],
[
187,
59
... | [
"import numpy as np\n\nn,m = map(int,input().split())\nl = []\nfor _ in range(m):\n a = list(map(int,input().split()))\n l.append(a)\n\nmemo = np.zeros((n,2))\nmemo[0][1] = 1\n\nfor i in range(n):\n memo[i][0] = 1\n\ntmp1 = 0\ntmp2 = 0\n\nfor j in range(m):\n tmp1 = l[j][0]-1\n tmp2 = l[j][1]-1\n ... | import numpy as np
n,m = map(int,input().split())
l = []
for _ in range(m):
a = list(map(int,input().split()))
l.append(a)
memo = np.zeros((n,2))
memo[0][1] = 1
for i in range(n):
memo[i][0] = 1
tmp1 = 0
tmp2 = 0
for j in range(m):
tmp1 = l[j][0]-1
tmp2 = l[j][1]-1
memo[tmp1][0] -= 1
me... |
[
7,
15,
13,
12,
13,
29,
18,
4,
18,
18,
13,
13,
13,
39,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4... | [
[
143,
16
],
[
129,
23
],
[
143,
25
],
[
122,
27
],
[
138,
31
],
[
36,
33
],
[
123,
34
],
[
140,
38
],
[
138,
42
],
[
45,
44
],
[
144,
47
],
[
134,
49
],
[
129,
56
... | [
"import sys\n\n\ndef input():\n return sys.stdin.readline()[:-1]\n\n\nN, M = map(int, input().split())\n\nred = [0]*N\nred[0] = 1\nbox = [1]*N\nfor _ in range(M):\n x, y = map(int, input().split())\n x -= 1\n y -= 1\n\n if red[x] == 1 and box[x] == 1:\n # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合\n ... | import sys
def input():
return sys.stdin.readline()[:-1]
N, M = map(int, input().split())
red = [0]*N
red[0] = 1
box = [1]*N
for _ in range(M):
x, y = map(int, input().split())
x -= 1
y -= 1
if red[x] == 1 and box[x] == 1:
# 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合
red[x] -= 1
... |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
12,
4,
13,
4,
18,
18,
13,
13,
13,
0,
13,
12,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
12,
4,
13,
4,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,... | [
[
156,
11
],
[
168,
22
],
[
147,
37
],
[
169,
42
],
[
153,
44
],
[
159,
56
],
[
69,
68
],
[
165,
77
],
[
169,
79
],
[
165,
80
],
[
85,
84
],
[
88,
87
],
[
166,
91
... | [
"import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninm = lambda: map(int, sys.stdin.readline().split())\ninl = lambda: list(inm())\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\nN, M... | import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
N, M = inm()
def solve... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
18,
13,
2,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
... | [
[
114,
2
],
[
114,
11
],
[
105,
13
],
[
106,
18
],
[
108,
22
],
[
26,
25
],
[
112,
28
],
[
35,
30
],
[
109,
31
],
[
25,
33
],
[
38,
37
],
[
115,
40
],
[
117,
42
]... | [
"n,m = map(int,input().split())\n\nin_group = set()\nin_group.add(1)\n\nboll_num = {}\nfor i in range(n):\n boll_num[i+1] = 1\n\n\nfor i in range(m):\n x,y = map(int,input().split())\n if(x in in_group):\n in_group.add(y)\n if(boll_num[x] == 1):\n in_group.remove(x)\n \n boll... | n,m = map(int,input().split())
in_group = set()
in_group.add(1)
boll_num = {}
for i in range(n):
boll_num[i+1] = 1
for i in range(m):
x,y = map(int,input().split())
if(x in in_group):
in_group.add(y)
if(boll_num[x] == 1):
in_group.remove(x)
boll_num[x] = boll_num.set... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2... | [
[
138,
4
],
[
138,
20
],
[
126,
22
],
[
26,
25
],
[
139,
28
],
[
132,
30
],
[
132,
46
],
[
127,
49
],
[
133,
53
],
[
130,
56
],
[
141,
59
],
[
142,
64
],
[
70,
69
... | [
"import sys\n\nN, M = map(int, sys.stdin.readline().rstrip().split())\n\nopes = []\nfor _ in range(M):\n x, y = map(int, sys.stdin.readline().rstrip().split())\n opes.append((x-1, y-1))\n\ntransported = set()\ntransported.add(0)\nboxes = [1 for _ in range(N)]\n\nfor (x, y) in opes:\n boxes[x] -= 1\n box... | import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
opes = []
for _ in range(M):
x, y = map(int, sys.stdin.readline().rstrip().split())
opes.append((x-1, y-1))
transported = set()
transported.add(0)
boxes = [1 for _ in range(N)]
for (x, y) in opes:
boxes[x] -= 1
boxes[y] += 1
if x ... |
[
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,
... | [
[
114,
2
],
[
114,
11
],
[
108,
13
],
[
112,
17
],
[
22,
19
],
[
109,
20
],
[
117,
24
],
[
112,
28
],
[
31,
30
],
[
115,
33
],
[
120,
35
],
[
120,
44
],
[
102,
46
... | [
"n,m=map(int,input().split())\ncheck=[False]*n\ncheck[0]=True\nball=[1]*n\nfor i in range(m):\n x,y=map(int,input().split())\n x-=1\n y-=1\n if check[x]:\n check[y]=True\n\n ball[y]+=1\n ball[x]-=1\n if ball[x]==0:\n check[x]=False\n\nans=0\n\nfor chk in check:\n if chk:\n ... | n,m=map(int,input().split())
check=[False]*n
check[0]=True
ball=[1]*n
for i in range(m):
x,y=map(int,input().split())
x-=1
y-=1
if check[x]:
check[y]=True
ball[y]+=1
ball[x]-=1
if ball[x]==0:
check[x]=False
ans=0
for chk in check:
if chk:
ans+=1
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
2,
39,
17,
17,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
2,
39,
17,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
... | [
[
123,
2
],
[
123,
11
],
[
15,
14
],
[
124,
18
],
[
132,
23
],
[
32,
31
],
[
124,
34
],
[
126,
38
],
[
129,
44
],
[
48,
47
],
[
121,
50
],
[
130,
53
],
[
67,
66
]... | [
"n, m = map(int, input().split())\nrednow = [-1, 1] + [0 for i in range(n-1)] # maybe there's red ball\nbalnum = [-1] + [1 for i in range(n)] # the number of ball, each box\norder = []\nfor i in range(m):\n order.append(list(map(int, input().split()))) \n\nfor q in order:\n if rednow[q[0]] == 1:\n rednow[q[1]]... | n, m = map(int, input().split())
rednow = [-1, 1] + [0 for i in range(n-1)] # maybe there's red ball
balnum = [-1] + [1 for i in range(n)] # the number of ball, each box
order = []
for i in range(m):
order.append(list(map(int, input().split())))
for q in order:
if rednow[q[0]] == 1:
rednow[q[1]] = 1
if ba... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
0,
18,
13,
... | [
[
94,
2
],
[
94,
11
],
[
103,
13
],
[
89,
18
],
[
24,
21
],
[
104,
22
],
[
106,
26
],
[
89,
31
],
[
35,
34
],
[
95,
37
],
[
100,
39
],
[
100,
48
],
[
104,
51
],
... | [
"n, m = map(int, input().split())\nC = [0]*(n+1)\nC[1] = 1\nD = [1]*(n+1)\nfor _ in range(m):\n x, y = map(int, input().split())\n if C[x]:\n C[y] = 1\n if D[x] == 1:\n C[x] = 0\n D[x] -= 1\n D[y] += 1\nans = sum(C)\nprint(ans)",
"n, m = map(int, input().split())",
"n",
"map(int, input().split(... | n, m = map(int, input().split())
C = [0]*(n+1)
C[1] = 1
D = [1]*(n+1)
for _ in range(m):
x, y = map(int, input().split())
if C[x]:
C[y] = 1
if D[x] == 1:
C[x] = 0
D[x] -= 1
D[y] += 1
ans = sum(C)
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
17,
13,
4,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
... | [
[
118,
2
],
[
118,
11
],
[
15,
14
],
[
119,
17
],
[
127,
21
],
[
26,
25
],
[
119,
29
],
[
121,
33
],
[
40,
39
],
[
107,
42
],
[
115,
44
],
[
115,
53
],
[
109,
55
... | [
"n,m = map(int,input().split())\n\nballs = [1 for _ in range(n)]\nred = [1] + [0 for _ in range(1,n)]\n\nfor _ in range(m):\n x, y = map(int,input().split())\n x,y = x-1, y-1\n \n if balls[x] ==0:\n continue\n \n balls[x] -= 1\n balls[y] += 1\n if red[x]:\n red[y] = 1\n if balls[x]==0:\n red[x]... | n,m = map(int,input().split())
balls = [1 for _ in range(n)]
red = [1] + [0 for _ in range(1,n)]
for _ in range(m):
x, y = map(int,input().split())
x,y = x-1, y-1
if balls[x] ==0:
continue
balls[x] -= 1
balls[y] += 1
if red[x]:
red[y] = 1
if balls[x]==0:
red[x] = 0
print(sum(red))
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
39,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
... | [
[
95,
2
],
[
95,
11
],
[
98,
13
],
[
83,
19
],
[
90,
23
],
[
26,
25
],
[
96,
28
],
[
32,
31
],
[
31,
41
],
[
92,
44
],
[
92,
46
],
[
51,
48
],
[
84,
49
],
[
... | [
"N,M = map(int, input().split())\n\nans = set([0])\ncnt = [1] * N\nfor _ in range(M):\n x,y = [int(i) - 1 for i in input().split()]\n cnt[x] -= 1; cnt[y] += 1\n \n if x in ans:\n ans.add(y)\n if cnt[x] == 0: # 絶対に赤いボールがyに移される\n ans.remove(x)\n \nprint(len(ans))",
"N,M = map(int, ... | N,M = map(int, input().split())
ans = set([0])
cnt = [1] * N
for _ in range(M):
x,y = [int(i) - 1 for i in input().split()]
cnt[x] -= 1; cnt[y] += 1
if x in ans:
ans.add(y)
if cnt[x] == 0: # 絶対に赤いボールがyに移される
ans.remove(x)
print(len(ans)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
... | [
[
94,
2
],
[
94,
11
],
[
85,
13
],
[
89,
18
],
[
97,
21
],
[
89,
26
],
[
32,
29
],
[
86,
30
],
[
35,
34
],
[
95,
37
],
[
100,
39
],
[
100,
48
],
[
53,
50
],
[
... | [
"n,m=map(int, input().split())\naka = [0]*(n+1)\nsiroaka = [1]*(n+1)\naka[1] = 1\nfor i in range(m):\n x,y=map(int, input().split())\n siroaka[x]-=1\n siroaka[y]+=1\n if(aka[x]):\n aka[y]=1\n if(siroaka[x]==0):\n aka[x]=0\n\nprint(sum(aka))",
"n,m=map(int, input().split())",
"n",
... | n,m=map(int, input().split())
aka = [0]*(n+1)
siroaka = [1]*(n+1)
aka[1] = 1
for i in range(m):
x,y=map(int, input().split())
siroaka[x]-=1
siroaka[y]+=1
if(aka[x]):
aka[y]=1
if(siroaka[x]==0):
aka[x]=0
print(sum(aka))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
18,
... | [
[
143,
2
],
[
143,
11
],
[
15,
14
],
[
144,
17
],
[
131,
30
],
[
137,
34
],
[
129,
39
],
[
140,
42
],
[
129,
47
],
[
53,
50
],
[
138,
51
],
[
58,
55
],
[
141,
56
... | [
"N, M = map(int, input().split())\nXY = [list(map(int, input().split())) for _ in range(M)]\n\n\"\"\"\nボールの数が入ったリストと,赤い玉が一回でもきたことがあるかのリスト\nどちらもが0じゃないのが,終わったときに赤が入っている可能性のあるリスト\nただし,ボールリストが0になる時,seenは0になる\n\"\"\"\nball_list = [1] * (N+1)\nseen = [0] * (N+1)\nball_list[0] = 0\nseen[1] = 1\n\nfor i in range(M):\n x... | N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]
"""
ボールの数が入ったリストと,赤い玉が一回でもきたことがあるかのリスト
どちらもが0じゃないのが,終わったときに赤が入っている可能性のあるリスト
ただし,ボールリストが0になる時,seenは0になる
"""
ball_list = [1] * (N+1)
seen = [0] * (N+1)
ball_list[0] = 0
seen[1] = 1
for i in range(M):
x = XY[i][0]
y = XY[i]... |
[
7,
15,
13,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,... | [
[
135,
6
],
[
135,
15
],
[
19,
18
],
[
133,
21
],
[
141,
25
],
[
30,
29
],
[
133,
32
],
[
144,
36
],
[
42,
39
],
[
142,
40
],
[
45,
44
],
[
136,
47
],
[
150,
49
]... | [
"import numpy as np\nimport math\n\nn, m = map(int, input().split())\nprobability = [0 for _ in range(n)]\nball = [1 for _ in range(n)]\nprobability[0] = 1\nfor i in range(m):\n x, y = map(int, input().split())\n prob = math.ceil(probability[x-1])\n probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]\n ... | import numpy as np
import math
n, m = map(int, input().split())
probability = [0 for _ in range(n)]
ball = [1 for _ in range(n)]
probability[0] = 1
for i in range(m):
x, y = map(int, input().split())
prob = math.ceil(probability[x-1])
probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]
probability[y-... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
... | [
[
114,
2
],
[
114,
13
],
[
111,
15
],
[
109,
19
],
[
24,
21
],
[
112,
22
],
[
126,
26
],
[
109,
30
],
[
33,
32
],
[
115,
35
],
[
123,
37
],
[
123,
48
],
[
129,
50
... | [
"n, m = list(map(int, input().split()))\n\nredball = [0]*n\nredball[0] = 1\nball_cnt = [1]*n\n\nfor _ in range(m):\n x, y = list(map(int, input().split()))\n x -= 1\n y -= 1\n\n if ball_cnt[x] == 1 and redball[x]:\n redball[x] = 0\n redball[y] = 1\n\n if ball_cnt[x] > 1 and redball[x]:\... | n, m = list(map(int, input().split()))
redball = [0]*n
redball[0] = 1
ball_cnt = [1]*n
for _ in range(m):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
if ball_cnt[x] == 1 and redball[x]:
redball[x] = 0
redball[y] = 1
if ball_cnt[x] > 1 and redball[x]:
redball[y] =... |
[
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,
... | [
[
114,
2
],
[
114,
11
],
[
15,
14
],
[
115,
18
],
[
99,
23
],
[
28,
27
],
[
115,
31
],
[
111,
36
],
[
42,
39
],
[
100,
40
],
[
45,
44
],
[
109,
47
],
[
105,
49
],... | [
"N, M = map(int, input().split())\n\nR = [0 for _ in range(N+1)] # possibility to include the red ball\nC = [1 for _ in range(N+1)] # number of balls\nR[1] = 1\n\n\nfor i in range(M):\n x, y = map(int, input().split())\n if R[x] == 1:\n R[y] = 1\n if C[x] == 1:\n R[x] = 0\n C[x] -=... | N, M = map(int, input().split())
R = [0 for _ in range(N+1)] # possibility to include the red ball
C = [1 for _ in range(N+1)] # number of balls
R[1] = 1
for i in range(M):
x, y = map(int, input().split())
if R[x] == 1:
R[y] = 1
if C[x] == 1:
R[x] = 0
C[x] -= 1
C[y] += 1
#... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
17,
28,
13,
... | [
[
5,
4
],
[
5,
13
],
[
17,
16
],
[
13,
19
],
[
33,
32
],
[
36,
35
],
[
4,
39
],
[
42,
41
],
[
4,
45
],
[
50,
47
],
[
41,
48
],
[
53,
52
],
[
56,
55
],
[
13,... | [
"#!/usr/bin/env python3\n\ndef main():\n N, M = map(int, input().split())\n xy = [list(map(int, input().split())) for i in range(M)]\n box = [1] * N\n red_flag = [0] * N\n red_flag[0] = 1\n ans = 0\n for i in range(M):\n if red_flag[xy[i][0] - 1] == 1:\n red_flag[xy[i][1] - 1]... | #!/usr/bin/env python3
def main():
N, M = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(M)]
box = [1] * N
red_flag = [0] * N
red_flag[0] = 1
ans = 0
for i in range(M):
if red_flag[xy[i][0] - 1] == 1:
red_flag[xy[i][1] - 1] = 1
box... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
... | [
[
110,
2
],
[
110,
11
],
[
104,
13
],
[
96,
17
],
[
98,
19
],
[
96,
23
],
[
28,
25
],
[
99,
26
],
[
31,
30
],
[
111,
33
],
[
107,
35
],
[
107,
44
],
[
99,
48
],
... | [
"N,M=map(int,input().split())\nli=[1]*N\nri=[0]*N\nri[0]=1\n\nfor i in range(M):\n x,y=map(int,input().split())\n if ri[x-1]==1:\n ri[y-1]=1\n li[x-1]-=1\n li[y-1]+=1\n if li[x-1]==0:\n ri[x-1]=0\nprint(sum(ri))",
"N,M=map(int,input().split())",
"N",
"map(int,input().split())",
... | N,M=map(int,input().split())
li=[1]*N
ri=[0]*N
ri[0]=1
for i in range(M):
x,y=map(int,input().split())
if ri[x-1]==1:
ri[y-1]=1
li[x-1]-=1
li[y-1]+=1
if li[x-1]==0:
ri[x-1]=0
print(sum(ri)) |
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
17,
0,
13,
13,
4,
18,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
17,... | [
[
4,
3
],
[
3,
12
],
[
132,
14
],
[
132,
16
],
[
126,
18
],
[
22,
21
],
[
130,
24
],
[
28,
27
],
[
27,
37
],
[
138,
40
],
[
127,
44
],
[
139,
46
],
[
50,
49
],
... | [
"n,m = [int(x) for x in input().split()]\nxy = []\nfor _ in range(m):\n tmp = [int(x)-1 for x in input().split()]\n xy.append(tmp)\n\nbox = {x: 1 for x in range(n)}\nred = {x: False for x in range(n)}\nred[0] = True\n\nfor x,y in xy:\n box[x] -= 1\n box[y] += 1\n if red[x]:\n red[y] = True\n ... | n,m = [int(x) for x in input().split()]
xy = []
for _ in range(m):
tmp = [int(x)-1 for x in input().split()]
xy.append(tmp)
box = {x: 1 for x in range(n)}
red = {x: False for x in range(n)}
red[0] = True
for x,y in xy:
box[x] -= 1
box[y] += 1
if red[x]:
red[y] = True
if box[x] == 0:
... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
0... | [
[
142,
4
],
[
14,
13
],
[
143,
20
],
[
14,
22
],
[
25,
24
],
[
22,
28
],
[
31,
30
],
[
22,
34
],
[
37,
36
],
[
22,
39
],
[
44,
41
],
[
24,
42
],
[
36,
43
],
[
... | [
"import sys\ninput = sys.stdin.readline\n\n\ndef main():\n N, M = map(int, input().split())\n x = [0] * M\n y = [0] * M\n for i in range(M):\n x[i], y[i] = map(int, input().split())\n\n ball = [1] * N\n exist = [0] * N\n exist[0] = 1\n for a, b in zip(x, y):\n ball[a-1] -= 1\n ... | import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
x = [0] * M
y = [0] * M
for i in range(M):
x[i], y[i] = map(int, input().split())
ball = [1] * N
exist = [0] * N
exist[0] = 1
for a, b in zip(x, y):
ball[a-1] -= 1
ball[b-1] += 1... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
13,
13,
... | [
[
110,
2
],
[
110,
11
],
[
107,
13
],
[
111,
18
],
[
119,
21
],
[
111,
26
],
[
32,
29
],
[
120,
30
],
[
35,
34
],
[
105,
39
],
[
116,
42
],
[
116,
51
],
[
120,
54
... | [
"n, m = map(int, input().split())\n\nA = [1] * (n + 1)\nred = [False] * (n + 1)\nred[1] = True\n\nfor i in range(1, m + 1):\n\tx, y = map(int, input().split())\n\tif red[x]:\n\t\tred[y] = True\n\tA[x] -= 1\n\tA[y] += 1\n\tif A[x] == 0:\n\t\tred[x] = False\n\nprint(len([red[i] for i in range(1, n + 1) if red[i]]))",... | n, m = map(int, input().split())
A = [1] * (n + 1)
red = [False] * (n + 1)
red[1] = True
for i in range(1, m + 1):
x, y = map(int, input().split())
if red[x]:
red[y] = True
A[x] -= 1
A[y] += 1
if A[x] == 0:
red[x] = False
print(len([red[i] for i in range(1, n + 1) if red[i]])) |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
31,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
... | [
[
134,
4
],
[
131,
11
],
[
125,
18
],
[
28,
27
],
[
135,
34
],
[
28,
36
],
[
28,
37
],
[
41,
40
],
[
27,
44
],
[
49,
46
],
[
40,
47
],
[
52,
51
],
[
27,
55
],
[... | [
"import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N,M,*xy = map(int, read().split())\n\n check = [False] * N\n check[0] = True\n num = [1] * N\n\n for x, y in zip(*[iter(xy)]*2):\n num[x-1] -= 1\n num[y-1] += 1\n i... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N,M,*xy = map(int, read().split())
check = [False] * N
check[0] = True
num = [1] * N
for x, y in zip(*[iter(xy)]*2):
num[x-1] -= 1
num[y-1] += 1
if check[x-1]:
... |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
13,
0,
13,
13,
12,
13,
23,
13,
17,
23,
12,
13,
12,
13,
12,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
... | [
[
155,
11
],
[
185,
18
],
[
182,
21
],
[
27,
26
],
[
38,
37
],
[
41,
40
],
[
69,
43
],
[
37,
46
],
[
156,
56
],
[
37,
67
],
[
69,
69
],
[
167,
71
],
[
180,
73
],
... | [
"# https://atcoder.jp/contests/agc002/tasks/agc002_b\nimport sys\nsys.setrecursionlimit(1 << 25)\nread = sys.stdin.readline\nra = range\nenu = enumerate\n\n\ndef mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))\n# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと\n\n\ndef read_a_int(): return int(read())\n\n\nde... | # https://atcoder.jp/contests/agc002/tasks/agc002_b
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def read_a_int(): return int(read())
def read_ints(): retur... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
... | [
[
129,
2
],
[
129,
11
],
[
135,
13
],
[
127,
17
],
[
22,
19
],
[
136,
20
],
[
138,
24
],
[
127,
28
],
[
31,
30
],
[
130,
33
],
[
144,
35
],
[
144,
44
],
[
147,
46
... | [
"N, M = map(int,input().split())\nred = [0] * N\nred[0] = 1\nboal = [1] * N\n\nfor i in range(M):\n x, y = map(int,input().split())\n x -= 1\n y -= 1\n if red[x] == 1 and boal[x] == 1:\n red[x] = 0\n boal[x] -= 1\n red[y] = 1\n boal[y] += 1\n elif red[x] == 1 and boal[x] >... | N, M = map(int,input().split())
red = [0] * N
red[0] = 1
boal = [1] * N
for i in range(M):
x, y = map(int,input().split())
x -= 1
y -= 1
if red[x] == 1 and boal[x] == 1:
red[x] = 0
boal[x] -= 1
red[y] = 1
boal[y] += 1
elif red[x] == 1 and boal[x] > 1:
boal[x]... |
[
7,
15,
12,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,... | [
[
6,
5
],
[
13,
12
],
[
5,
19
],
[
13,
21
],
[
24,
23
],
[
12,
27
],
[
32,
29
],
[
23,
30
],
[
35,
34
],
[
12,
38
],
[
41,
40
],
[
44,
43
],
[
21,
46
],
[
4... | [
"#!/usr/bin/env python3\n\nfrom sys import stdin, setrecursionlimit\n\n\ndef main():\n input = stdin.buffer.readline\n n, m = map(int, input().split())\n red = [False] * n\n red[0] = True\n balls = [1] * n\n ans = 1\n for _ in range(m):\n x, y = map(int, input().split())\n if red[... | #!/usr/bin/env python3
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n, m = map(int, input().split())
red = [False] * n
red[0] = True
balls = [1] * n
ans = 1
for _ in range(m):
x, y = map(int, input().split())
if red[x - 1]:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
18,
... | [
[
103,
2
],
[
103,
11
],
[
85,
13
],
[
95,
18
],
[
24,
21
],
[
86,
22
],
[
88,
26
],
[
95,
31
],
[
37,
34
],
[
89,
35
],
[
40,
39
],
[
104,
42
],
[
97,
44
],
[
... | [
"n,m = map(int, input().split())\nredl = [False]*(n+1)\nredl[1] = True\ncnts = [1]*(n+1)\ncnts[0] = 1\n\nfor _ in range(m):\n x,y = map(int, input().split())\n if redl[x]: redl[y] = True\n if cnts[x] == 1: redl[x] = False\n cnts[x] -= 1\n cnts[y] += 1\n\nans = redl.count(True)\nprint(ans)",
"n,m = ... | n,m = map(int, input().split())
redl = [False]*(n+1)
redl[1] = True
cnts = [1]*(n+1)
cnts[0] = 1
for _ in range(m):
x,y = map(int, input().split())
if redl[x]: redl[y] = True
if cnts[x] == 1: redl[x] = False
cnts[x] -= 1
cnts[y] += 1
ans = redl.count(True)
print(ans) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
17,
0,
13,
39,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
18,
13,
13,
... | [
[
177,
2
],
[
177,
11
],
[
174,
13
],
[
165,
17
],
[
183,
21
],
[
160,
26
],
[
162,
29
],
[
160,
34
],
[
38,
37
],
[
178,
40
],
[
171,
42
],
[
171,
51
],
[
175,
54
... | [
"N, M = map(int, input().split())\nx = [0]\ny = [0]\nmemo = [1] * (N + 1) #各箱の中のボールの数\nflag = [0] * (N + 1) #赤ボールがある可能性\nfor _ in range(M):\n _x, _y = map(int, input().split())\n x.append(_x)\n y.append(_y)\n\nflag[1] = 1\nfor i in range(1, M + 1):\n if memo[x[i]] == 0: #移動するボール無し\n continue\n ... | N, M = map(int, input().split())
x = [0]
y = [0]
memo = [1] * (N + 1) #各箱の中のボールの数
flag = [0] * (N + 1) #赤ボールがある可能性
for _ in range(M):
_x, _y = map(int, input().split())
x.append(_x)
y.append(_y)
flag[1] = 1
for i in range(1, M + 1):
if memo[x[i]] == 0: #移動するボール無し
continue
memo[x[i]] -= 1
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
13,
39,
41,
28,
13,
4,
13,
13,
4,
13,
17,
0,
13,
13,
0,
13,
4,
13,
39,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
... | [
[
121,
2
],
[
121,
11
],
[
112,
13
],
[
127,
15
],
[
20,
19
],
[
122,
22
],
[
19,
24
],
[
115,
27
],
[
124,
30
],
[
37,
36
],
[
119,
39
],
[
130,
41
],
[
130,
50
... | [
"N, M = map(int, input().split())\nX, Y = [], []\nd = {n:1 for n in range(N)}\nr = set([0])\nfor _ in range(M):\n x, y = map(int, input().split())\n d[x-1] -= 1\n d[y-1] += 1\n if x - 1 in r:\n r.add(y - 1)\n if d[x - 1] == 0:\n r.remove(x - 1)\n X.append(x)\n Y.append(y)\... | N, M = map(int, input().split())
X, Y = [], []
d = {n:1 for n in range(N)}
r = set([0])
for _ in range(M):
x, y = map(int, input().split())
d[x-1] -= 1
d[y-1] += 1
if x - 1 in r:
r.add(y - 1)
if d[x - 1] == 0:
r.remove(x - 1)
X.append(x)
Y.append(y)
print(len(r)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
2,
13,
13,
4,
18,
13,
13,
... | [
[
102,
2
],
[
102,
11
],
[
105,
13
],
[
106,
18
],
[
24,
23
],
[
103,
26
],
[
99,
30
],
[
34,
33
],
[
97,
36
],
[
93,
38
],
[
93,
47
],
[
91,
50
],
[
106,
51
],
... | [
"n,m = map(int,input().split())\ncanred = set()\ncanred.add(1)\nballs = [1 for i in range(n)]\nfor i in range(m):\n x,y = map(int,input().split())\n if x in canred:\n canred.add(y)\n balls[x-1]-=1\n balls[y-1] += 1\n if balls[x-1] == 0:\n canred.discard(x)\n\n\nprint(len(canred))",
"n... | n,m = map(int,input().split())
canred = set()
canred.add(1)
balls = [1 for i in range(n)]
for i in range(m):
x,y = map(int,input().split())
if x in canred:
canred.add(y)
balls[x-1]-=1
balls[y-1] += 1
if balls[x-1] == 0:
canred.discard(x)
print(len(canred)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
17,
0,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
... | [
[
116,
2
],
[
116,
11
],
[
15,
14
],
[
117,
17
],
[
107,
21
],
[
26,
25
],
[
117,
28
],
[
113,
32
],
[
38,
35
],
[
114,
36
],
[
41,
40
],
[
105,
43
],
[
122,
45
]... | [
"n,m = map(int,input().split())\nkosu = [1 for _ in range(n)]\naka = [0 for _ in range(n)]\naka[0] += 1\nfor i in range(m):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n if aka[a]==1:\n #論理和\n aka[b] |= 1\n if kosu[a]<2:\n aka[a] -=1\n kosu[a] -=1\n kosu[b] += 1\n # print(\"kosu\",kosu)\n... | n,m = map(int,input().split())
kosu = [1 for _ in range(n)]
aka = [0 for _ in range(n)]
aka[0] += 1
for i in range(m):
a,b = map(int,input().split())
a -= 1
b -= 1
if aka[a]==1:
#論理和
aka[b] |= 1
if kosu[a]<2:
aka[a] -=1
kosu[a] -=1
kosu[b] += 1
# print("kosu",kosu)
#print("aka",aka)
pri... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17... | [
[
175,
2
],
[
175,
12
],
[
163,
14
],
[
18,
17
],
[
176,
20
],
[
164,
23
],
[
39,
38
],
[
173,
41
],
[
166,
47
],
[
55,
50
],
[
167,
52
],
[
58,
57
],
[
176,
60
]... | [
"boxnum, sousanum = map(int, input().split(\" \"))\nsousa = []\nfor i in range(sousanum):\n sousa.append(list(map(int, input().split(\" \"))))\n\n#aka[0][0] ...[ボール個数][赤フラグ]\nball = [[1, 0] for i in range(boxnum)]\nball[0][1] = 1\nfor i in range(sousanum):\n if ball[sousa[i][0] - 1][1] == 1:#赤色あり\n ball[sousa[... | boxnum, sousanum = map(int, input().split(" "))
sousa = []
for i in range(sousanum):
sousa.append(list(map(int, input().split(" "))))
#aka[0][0] ...[ボール個数][赤フラグ]
ball = [[1, 0] for i in range(boxnum)]
ball[0][1] = 1
for i in range(sousanum):
if ball[sousa[i][0] - 1][1] == 1:#赤色あり
ball[sousa[i][1] - 1][1] = 1
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
... | [
[
126,
2
],
[
126,
11
],
[
117,
13
],
[
124,
17
],
[
114,
19
],
[
23,
22
],
[
124,
27
],
[
33,
30
],
[
115,
31
],
[
22,
32
],
[
38,
35
],
[
115,
36
],
[
41,
40
],... | [
"n,m = map(int,input().split())\n\nball = [1]*n\nd={}\nfor i in range(1,n+1):\n d[i]=0\nd[1]=1\n\nfor _ in range(m):\n x,y = map(int,input().split())\n\n ball[x-1]-=1\n if d[x]==1:\n if ball[x-1]==0:\n d[x]=0\n d[y]=1\n ball[y-1]+=1\n\ncnt=0\nfor _ ,v in d.items():\n if v=... | n,m = map(int,input().split())
ball = [1]*n
d={}
for i in range(1,n+1):
d[i]=0
d[1]=1
for _ in range(m):
x,y = map(int,input().split())
ball[x-1]-=1
if d[x]==1:
if ball[x-1]==0:
d[x]=0
d[y]=1
ball[y-1]+=1
cnt=0
for _ ,v in d.items():
if v==1:
cnt+=1
prin... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
4,
13,
39,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
14,
2,
... | [
[
100,
2
],
[
100,
11
],
[
91,
13
],
[
101,
17
],
[
94,
19
],
[
26,
25
],
[
98,
28
],
[
103,
30
],
[
103,
39
],
[
46,
41
],
[
92,
42
],
[
104,
44
],
[
53,
48
],
... | [
"n, m = map(int, input().split())\nball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。\nred = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。\nfor _ in range(m):\n x, y = map(int, input().split())\n ball[x-1] -= 1 # x-1番目の箱のボールを1つ減らす\n ball[y-1] += 1 # y-1番目の箱のボールを1つ増やす\n if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の... | n, m = map(int, input().split())
ball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。
red = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。
for _ in range(m):
x, y = map(int, input().split())
ball[x-1] -= 1 # x-1番目の箱のボールを1つ減らす
ball[y-1] += 1 # y-1番目の箱のボールを1つ増やす
if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。
... |
[
7,
15,
12,
13,
0,
13,
18,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
13,
4,
18,
4,
13,
13,
18,
13,
13,
0,
13,
2,
39,... | [
[
6,
5
],
[
11,
10
],
[
5,
17
],
[
11,
19
],
[
22,
21
],
[
19,
25
],
[
28,
27
],
[
19,
31
],
[
34,
33
],
[
19,
36
],
[
41,
38
],
[
21,
39
],
[
33,
40
],
[
5... | [
"from sys import stdin\ndef main():\n #入力\n readline=stdin.readline\n N,M=map(int,readline().split())\n x=[0]*M\n y=[0]*M\n for i in range(M):\n x[i],y[i]=map(int,readline().split())\n\n box=[1]*(N+1)\n flags=[False]*(N+1)\n flags[1]=True\n\n for i in range(M):\n out=x[i]... | from sys import stdin
def main():
#入力
readline=stdin.readline
N,M=map(int,readline().split())
x=[0]*M
y=[0]*M
for i in range(M):
x[i],y[i]=map(int,readline().split())
box=[1]*(N+1)
flags=[False]*(N+1)
flags[1]=True
for i in range(M):
out=x[i]
inn=y[i]
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
... | [
[
112,
2
],
[
112,
11
],
[
106,
13
],
[
104,
17
],
[
100,
19
],
[
104,
27
],
[
31,
30
],
[
113,
33
],
[
109,
35
],
[
109,
44
],
[
51,
46
],
[
107,
47
],
[
98,
49
... | [
"n,m=map(int,input().split())\ndata=[1]*n\nd=[1]+[0]*(n-1)\nfor i in range(m):\n x,y=map(int,input().split())\n data[x-1]-=1\n data[y-1]+=1\n if d[x-1]==1:\n d[y-1]=1\n if data[x-1]==0:\n d[x-1]=0\nprint(d.count(1))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int"... | n,m=map(int,input().split())
data=[1]*n
d=[1]+[0]*(n-1)
for i in range(m):
x,y=map(int,input().split())
data[x-1]-=1
data[y-1]+=1
if d[x-1]==1:
d[y-1]=1
if data[x-1]==0:
d[x-1]=0
print(d.count(1)) |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
17,
2,
39,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
14,
... | [
[
168,
2
],
[
168,
13
],
[
144,
15
],
[
166,
20
],
[
147,
23
],
[
166,
32
],
[
156,
35
],
[
39,
38
],
[
169,
41
],
[
171,
43
],
[
171,
54
],
[
148,
57
],
[
151,
58
... | [
"N, M = list(map(int, input().split()))\nC = [1] * (N + 1)\nB = [True, True] + [False] * (N - 1)\nflg = False\nfor _ in range(M):\n x, y = list(map(int, input().split()))\n if B[x]:\n B[y] = True\n if x == 1 and not flg and C[1] == 1:\n B[1] = False\n flg = True\n if y == 1 and not ... | N, M = list(map(int, input().split()))
C = [1] * (N + 1)
B = [True, True] + [False] * (N - 1)
flg = False
for _ in range(M):
x, y = list(map(int, input().split()))
if B[x]:
B[y] = True
if x == 1 and not flg and C[1] == 1:
B[1] = False
flg = True
if y == 1 and not flg:
flg... |
[
7,
15,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
4,
13,
17,
2,
17,
17,
0,
13,
12,
4,
18,
18,
13,
13,
13,
2,
13,
17,
23,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,... | [
[
158,
4
],
[
137,
26
],
[
149,
39
],
[
159,
46
],
[
149,
48
],
[
143,
50
],
[
150,
54
],
[
146,
56
],
[
63,
62
],
[
135,
65
],
[
161,
67
],
[
159,
74
],
[
161,
76
... | [
"import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn,m = map(int, input().split())\nc = [1]*n\nr = set([0])\nfor i in range(m):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if c[x]==1 and x in ... | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n,m = map(int, input().split())
c = [1]*n
r = set([0])
for i in range(m):
x,y = map(int, input().split())
x -= 1
y -= 1
if c[x]==1 and x in r:
r.remove(x... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
12,
13,
14,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,... | [
[
125,
2
],
[
125,
11
],
[
113,
13
],
[
108,
17
],
[
110,
19
],
[
108,
23
],
[
28,
25
],
[
111,
26
],
[
111,
34
],
[
76,
36
],
[
45,
40
],
[
111,
41
],
[
78,
43
]... | [
"n,m=map(int,input().split())\n\np=[1]*n\nc=['w']*n\nc[0]='r'\n\n\ndef ope(x,y):\n if c[x-1]=='r':\n c[y-1]='r'\n p[x-1] -= 1\n p[y-1] += 1\n if p[x-1]==0:\n c[x-1]='w'\n\nfor i in range(m):\n x,y=map(int,input().split())\n ope(x,y)\n\n\nprint(c.count('r'))",
"n,m=map(int,input().s... | n,m=map(int,input().split())
p=[1]*n
c=['w']*n
c[0]='r'
def ope(x,y):
if c[x-1]=='r':
c[y-1]='r'
p[x-1] -= 1
p[y-1] += 1
if p[x-1]==0:
c[x-1]='w'
for i in range(m):
x,y=map(int,input().split())
ope(x,y)
print(c.count('r'))
|
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,... | [
[
108,
4
],
[
30,
29
],
[
130,
31
],
[
30,
32
],
[
35,
34
],
[
29,
39
],
[
43,
42
],
[
29,
47
],
[
53,
50
],
[
42,
51
],
[
56,
55
],
[
32,
58
],
[
61,
60
],
[
... | [
"import sys\n\ninput=sys.stdin.buffer.readline\n\n\n#sys.setrecursionlimit(10**9)\n#from functools import lru_cache\n\ndef RD(): return sys.stdin.read()\n\n\ndef II(): return int(input())\n\n\ndef MI(): return map(int,input().split())\n\n\ndef MF(): return map(float,input().split())\n\n\ndef LI(): return list(map(i... | import sys
input=sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
de... |
[
7,
15,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
14,
18,
13,
2,
13,
17,
0,
18,
13,
2,
13,
17,
17,
0,
18,
13,
2,
13,
17... | [
[
7,
6
],
[
7,
9
],
[
12,
11
],
[
6,
15
],
[
18,
17
],
[
6,
21
],
[
26,
23
],
[
17,
24
],
[
29,
28
],
[
9,
31
],
[
34,
33
],
[
34,
36
],
[
17,
39
],
[
33,
... | [
"# import sys\n# input = sys.stdin.readline\nimport itertools\n\n\n# 持っているビスケットを叩き、1枚増やす\n# ビスケット A枚を 1円に交換する\n# 1円をビスケット B枚に交換する\ndef main():\n n, m = input_list()\n balls = [1] * n\n reds = [False] * n\n reds[0] = True\n for _ in range(m):\n x, y = input_list()\n if reds[x-1]:\n ... | # import sys
# input = sys.stdin.readline
import itertools
# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
n, m = input_list()
balls = [1] * n
reds = [False] * n
reds[0] = True
for _ in range(m):
x, y = input_list()
if reds[x-1]:
reds[y-1] = Tru... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
0,
13,
2,
18,
... | [
[
128,
2
],
[
128,
11
],
[
15,
14
],
[
129,
17
],
[
113,
30
],
[
116,
33
],
[
126,
37
],
[
110,
39
],
[
126,
43
],
[
48,
45
],
[
111,
46
],
[
51,
50
],
[
114,
50
... | [
"N, M = map(int,input().split())\nB = [list(map(int,input().split())) for k in range(M)]\nH = [1]*N\nE = [0]*N\nE[0] = 1\nfor e in B:\n x, y = e[0]-1, e[1]-1\n if E[x] == 1:\n if H[x] == 1:\n E[x] = 0\n E[y] = 1\n else:\n E[y] = 1\n H[x] -= 1\n H[y] += 1\np... | N, M = map(int,input().split())
B = [list(map(int,input().split())) for k in range(M)]
H = [1]*N
E = [0]*N
E[0] = 1
for e in B:
x, y = e[0]-1, e[1]-1
if E[x] == 1:
if H[x] == 1:
E[x] = 0
E[y] = 1
else:
E[y] = 1
H[x] -= 1
H[y] += 1
print(E.count(1))
|
[
7,
15,
15,
15,
15,
13,
15,
13,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13... | [
[
135,
16
],
[
150,
43
],
[
154,
45
],
[
150,
46
],
[
159,
48
],
[
142,
52
],
[
57,
54
],
[
160,
55
],
[
144,
59
],
[
142,
63
],
[
66,
65
],
[
151,
68
],
[
147,
70
... | [
"#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3回\n#from collections import deque\nfrom collections import deque,defa... | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Cou... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
4,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
2,
13,
17,
4,
18,
13,
13,
39,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,... | [
[
140,
2
],
[
140,
13
],
[
134,
15
],
[
135,
19
],
[
26,
25
],
[
129,
29
],
[
135,
33
],
[
40,
39
],
[
141,
42
],
[
137,
44
],
[
137,
55
],
[
143,
57
],
[
149,
60
... | [
"N, M = list(map(int, input().split()))\n\nbox = []\nbox.append([1, True])\nfor _ in range(N - 1):\n box.append([1, False])\n\nfor _ in range(M):\n x, y = list(map(int, input().split()))\n x -= 1\n y -= 1\n\n box[x][0] -= 1\n box[y][0] += 1\n\n if box[x][1]:\n box[y][1] = True\n\n if ... | N, M = list(map(int, input().split()))
box = []
box.append([1, True])
for _ in range(N - 1):
box.append([1, False])
for _ in range(M):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
box[x][0] -= 1
box[y][0] += 1
if box[x][1]:
box[y][1] = True
if box[x][0] == 0:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
39,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
14,
2,
13,
13,
... | [
[
93,
2
],
[
93,
11
],
[
81,
13
],
[
87,
19
],
[
94,
24
],
[
28,
27
],
[
79,
30
],
[
90,
32
],
[
90,
41
],
[
46,
43
],
[
88,
44
],
[
85,
45
],
[
51,
48
],
[
... | [
"n,m=map(int,input().split())\ns=set([1])\nb=[1]*(n+1)\nfor i in range(m):\n x,y=map(int,input().split())\n b[x]-=1\n b[y]+=1\n if x in s:\n s.add(y)\n if b[x]==0:\n s.remove(x)\nprint(len(s))",
"n,m=map(int,input().split())",
"n",
"map(int,input().split())",
"map",
"int",
"input().split(... | n,m=map(int,input().split())
s=set([1])
b=[1]*(n+1)
for i in range(m):
x,y=map(int,input().split())
b[x]-=1
b[y]+=1
if x in s:
s.add(y)
if b[x]==0:
s.remove(x)
print(len(s)) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
13,
17,
13,
2,
13,
17,
14,
2,
... | [
[
123,
2
],
[
123,
11
],
[
105,
13
],
[
121,
17
],
[
117,
19
],
[
121,
23
],
[
28,
25
],
[
106,
26
],
[
31,
30
],
[
124,
33
],
[
129,
35
],
[
129,
44
],
[
111,
46
... | [
"n, m = map(int, input().split())\n\nX = [0]*n\nC = [1]*n\nX[0] = 1\n\nfor i in range(m):\n x, y = map(int, input().split())\n x, y = x-1, y-1\n if X[x] == 1:\n X[y] = 1\n if C[x] == 1:\n X[x] = 0\n C[x] -= 1\n C[y] += 1\n else:\n C[x] -= 1\n C[y] += ... | n, m = map(int, input().split())
X = [0]*n
C = [1]*n
X[0] = 1
for i in range(m):
x, y = map(int, input().split())
x, y = x-1, y-1
if X[x] == 1:
X[y] = 1
if C[x] == 1:
X[x] = 0
C[x] -= 1
C[y] += 1
else:
C[x] -= 1
C[y] += 1
ans = sum(X)
print(... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
... | [
[
127,
2
],
[
127,
13
],
[
17,
16
],
[
128,
19
],
[
115,
32
],
[
130,
35
],
[
125,
39
],
[
44,
41
],
[
131,
42
],
[
133,
46
],
[
125,
50
],
[
55,
52
],
[
134,
53
... | [
"n, m = list(map(int, input().split()))\nxy = [list(map(int, input().split())) for i in range(m)]\n\nans = [1] * (n)\nans[0] = 1\nball = [0] * (n)\nball[0] = 1\nfor i in range(m):\n x, y = xy[i]\n ans[y-1] += 1\n ans[x-1] -= 1\n if ball[x-1]:\n ball[y-1] = 1\n if ans[x-1] == 0:\n ball[x-1] ... | n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]
ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
x, y = xy[i]
ans[y-1] += 1
ans[x-1] -= 1
if ball[x-1]:
ball[y-1] = 1
if ans[x-1] == 0:
ball[x-1] = 0
print(su... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
18,
13,
2,
13,
17,
2,
... | [
[
118,
2
],
[
118,
13
],
[
103,
15
],
[
119,
19
],
[
112,
21
],
[
119,
25
],
[
30,
27
],
[
113,
28
],
[
33,
32
],
[
110,
35
],
[
115,
37
],
[
115,
48
],
[
55,
50
... | [
"n, m = list(map(int, input().split()))\ncnt = [1] * n\nhas_red = [False] * n\nhas_red[0] = True\nfor i in range(m):\n a, b = list(map(int, input().split()))\n has_red[b - 1] = has_red[b - 1] or has_red[a - 1]\n if cnt[a - 1] == 1:\n has_red[a - 1] = False\n cnt[a - 1] -= 1\n cnt[b - 1] += 1\n... | n, m = list(map(int, input().split()))
cnt = [1] * n
has_red = [False] * n
has_red[0] = True
for i in range(m):
a, b = list(map(int, input().split()))
has_red[b - 1] = has_red[b - 1] or has_red[a - 1]
if cnt[a - 1] == 1:
has_red[a - 1] = False
cnt[a - 1] -= 1
cnt[b - 1] += 1
print(has_red.co... |
[
7,
12,
13,
0,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
18,
13,
13,
17,... | [
[
5,
4
],
[
8,
7
],
[
8,
16
],
[
19,
18
],
[
7,
22
],
[
27,
24
],
[
18,
25
],
[
30,
29
],
[
16,
32
],
[
35,
34
],
[
35,
43
],
[
46,
45
],
[
49,
48
],
[
106,... | [
"def solve():\n ans = 0\n N, M = map(int, input().split())\n lis = [1]*N\n lis[0] = -1 #赤が入っている可能性があればマイナス\n for _ in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if lis[x]<0:\n lis[y] = -(abs(lis[y])+1)\n lis[x] += 1\n else:... | def solve():
ans = 0
N, M = map(int, input().split())
lis = [1]*N
lis[0] = -1 #赤が入っている可能性があればマイナス
for _ in range(M):
x,y = map(int, input().split())
x -= 1
y -= 1
if lis[x]<0:
lis[y] = -(abs(lis[y])+1)
lis[x] += 1
else:
if l... |
[
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,
... | [
[
157,
2
],
[
157,
11
],
[
15,
14
],
[
158,
17
],
[
160,
21
],
[
26,
25
],
[
158,
28
],
[
163,
32
],
[
38,
35
],
[
161,
36
],
[
41,
40
],
[
146,
43
],
[
166,
45
]... | [
"N,M = map(int, input().split())\nred = [0 for i in range(N)]\ncnt = [1 for i in range(N)]\nred[0] = 1\nfor i in range(M):\n x,y = map(int, input().split())\n x -= 1\n y -= 1\n if red[x] > 0:\n if cnt[x] >= 2:\n cnt[x] -= 1\n cnt[y] += 1\n red[y] = 1\n else... | N,M = map(int, input().split())
red = [0 for i in range(N)]
cnt = [1 for i in range(N)]
red[0] = 1
for i in range(M):
x,y = map(int, input().split())
x -= 1
y -= 1
if red[x] > 0:
if cnt[x] >= 2:
cnt[x] -= 1
cnt[y] += 1
red[y] = 1
else:
cnt[... |
[
7,
41,
28,
13,
4,
13,
17,
4,
39,
31,
4,
13,
13,
4,
18,
13,
13,
0,
39,
13,
13,
13,
31,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
0,
13,
2,
39,
17,
2,
13,
17,
28,
13,
13,
13,
0,
18,
13,
13,
17,
0,
1... | [
[
4,
3
],
[
3,
15
],
[
21,
18
],
[
21,
22
],
[
81,
25
],
[
36,
33
],
[
82,
34
],
[
84,
38
],
[
53,
50
],
[
85,
51
],
[
58,
55
],
[
85,
56
],
[
63,
60
],
[
8... | [
"(n, m), *q = [[*map(int, i.split())] for i in open(0)]\nb = [0] * (n + 1)\nb[1] = 1\nc = [1] * (n + 1)\nfor x, y in q:\n c[x] -= 1\n c[y] += 1\n b[y] |= b[x]\n b[x] *= c[x] > 0\nprint(sum(b))",
"[*map(int, i.split())] for i in open(0)",
"for i in open(0)",
"i",
"open(0)",
"open",
"0",
"fo... | (n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [0] * (n + 1)
b[1] = 1
c = [1] * (n + 1)
for x, y in q:
c[x] -= 1
c[y] += 1
b[y] |= b[x]
b[x] *= c[x] > 0
print(sum(b))
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2... | [
[
101,
4
],
[
101,
20
],
[
98,
22
],
[
42,
41
],
[
96,
45
],
[
99,
51
],
[
41,
52
],
[
99,
54
],
[
41,
56
],
[
102,
58
],
[
64,
63
],
[
41,
68
],
[
63,
72
],
[
... | [
"import sys\n\nN, L = map(int, sys.stdin.readline().rstrip().split())\nA = list(map(int, sys.stdin.readline().rstrip().split()))\n\nfor i in range(N-1):\n if A[i] + A[i+1] >= L:\n print(\"Possible\")\n for j in range(1, i+1):\n print(j)\n for j in range(i+1, N)[::-1]:\n ... | import sys
N, L = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
for i in range(N-1):
if A[i] + A[i+1] >= L:
print("Possible")
for j in range(1, i+1):
print(j)
for j in range(i+1, N)[::-1]:
print(j)
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
13,
3,
14,
2,
13,
17,
4,
13,
... | [
[
93,
2
],
[
93,
11
],
[
96,
13
],
[
102,
25
],
[
29,
28
],
[
91,
32
],
[
97,
38
],
[
28,
39
],
[
97,
41
],
[
28,
43
],
[
94,
45
],
[
99,
47
],
[
28,
48
],
[
... | [
"n,l = map(int,input().split())\na = list(map(int,input().split()))\nx = -1\nfor i in range(n-1):\n if a[i]+a[i+1] >= l:\n x = i\n break\nif x == -1:\n print('Impossible')\nelse:\n print('Possible')\n for i in range(x):\n print(i+1)\n for i in range(n-2,x,-1):\n print(i+1)\n print(x+1)",
"n,l = ... | n,l = map(int,input().split())
a = list(map(int,input().split()))
x = -1
for i in range(n-1):
if a[i]+a[i+1] >= l:
x = i
break
if x == -1:
print('Impossible')
else:
print('Possible')
for i in range(x):
print(i+1)
for i in range(n-2,x,-1):
print(i+1)
print(x+1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
3,
14,
2,
13,
17,
4,
13,
... | [
[
121,
2
],
[
121,
11
],
[
115,
13
],
[
127,
25
],
[
29,
28
],
[
122,
32
],
[
116,
38
],
[
28,
39
],
[
116,
41
],
[
28,
43
],
[
113,
45
],
[
124,
47
],
[
125,
52
... | [
"n,l=map(int,input().split())\na=list(map(int,input().split()))\n\nflag=0\nfor i in range(n-1):\n if a[i]+a[i+1]>=l:\n flag=1\n break\n\nif flag==0:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n if i>0:\n for j in range(1,i+1):\n print(j)\n if i+2<n:\n ... | n,l=map(int,input().split())
a=list(map(int,input().split()))
flag=0
for i in range(n-1):
if a[i]+a[i+1]>=l:
flag=1
break
if flag==0:
print("Impossible")
else:
print("Possible")
if i>0:
for j in range(1,i+1):
print(j)
if i+2<n:
tmp=[]
for j in ra... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
... | [
[
115,
2
],
[
115,
11
],
[
106,
13
],
[
103,
25
],
[
121,
28
],
[
32,
31
],
[
116,
35
],
[
107,
41
],
[
31,
42
],
[
107,
44
],
[
31,
46
],
[
104,
48
],
[
119,
48
... | [
"n,l=map(int,input().split())\na=list(map(int,input().split()))\nm=0\nx=0\nfor i in range(n-1):\n if((a[i]+a[i+1])>=m):\n m=a[i]+a[i+1]\n x=i\nif(m<l):\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for j in range(x):\n print(j+1)\n for k in range(n-1,x+1,-1):\n print(k)\n print(x+1)",
"... | n,l=map(int,input().split())
a=list(map(int,input().split()))
m=0
x=0
for i in range(n-1):
if((a[i]+a[i+1])>=m):
m=a[i]+a[i+1]
x=i
if(m<l):
print("Impossible")
else:
print("Possible")
for j in range(x):
print(j+1)
for k in range(n-1,x+1,-1):
print(k)
print(x+1) |
[
7,
15,
12,
13,
0,
13,
39,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
13,
3,
29,
39,... | [
[
6,
5
],
[
10,
9
],
[
10,
18
],
[
21,
20
],
[
33,
32
],
[
9,
36
],
[
20,
42
],
[
32,
43
],
[
20,
45
],
[
32,
47
],
[
18,
49
],
[
52,
51
],
[
32,
52
],
[
59... | [
"from collections import deque\ndef solve():\n ans = ['Possible']\n N, L = map(int, input().split())\n A = list(map(int, input().split()))\n for i in range(N-1):\n if A[i]+A[i+1]>=L:\n ind = i\n break\n else:\n return ['Impossible']\n for i in range(1,ind+1):\n ans.append(i)\n for i in ran... | from collections import deque
def solve():
ans = ['Possible']
N, L = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N-1):
if A[i]+A[i+1]>=L:
ind = i
break
else:
return ['Impossible']
for i in range(1,ind+1):
ans.append(i)
for i in range(N-1,ind+1,-1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
13,
13,
4,
18,
17,
13,
4,
13,
13,
2,
2,
4,
13,
17,
2,
... | [
[
77,
2
],
[
77,
11
],
[
80,
13
],
[
24,
23
],
[
78,
27
],
[
81,
33
],
[
23,
34
],
[
81,
36
],
[
23,
38
],
[
75,
40
],
[
23,
56
],
[
78,
61
],
[
23,
64
],
[
... | [
"n, l = map(int, raw_input().split())\nA = map(int, raw_input().split())\n\nfor i in xrange(n-1):\n if A[i]+A[i+1] >= l:\n print \"Possible\"\n print \"\\n\".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))\n break\nelse:\n print \"Impossible\"",
"n, l = map(int, raw_input().... | n, l = map(int, raw_input().split())
A = map(int, raw_input().split())
for i in xrange(n-1):
if A[i]+A[i+1] >= l:
print "Possible"
print "\n".join(map(str, range(1, i+1) + range(n-1, i+1, -1) + [i+1]))
break
else:
print "Impossible"
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
13,
17,
13,
2,
13,
17,
13,
39,
13,
17,
13,
17,
28,
13,
4,
13,
2,
13,
17... | [
[
4,
3
],
[
3,
12
],
[
105,
14
],
[
105,
16
],
[
20,
19
],
[
19,
28
],
[
96,
30
],
[
123,
33
],
[
97,
36
],
[
114,
37
],
[
108,
39
],
[
106,
41
],
[
117,
43
],
... | [
"n,l = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\ns,x,y,ans,num,z = sum(a),0,n-1,[],0,0\nfor i in range(n-1):\n\tnum2 = a[i]+a[i+1]\n\tif num<num2: num,z = num2,i+1\nif num>=l:\n\tprint(\"Possible\")\n\tfor i in range(1,z): print(i)\n\tfor i in range(n-1,z-1,-1): print(i)\nelse: print... | n,l = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
s,x,y,ans,num,z = sum(a),0,n-1,[],0,0
for i in range(n-1):
num2 = a[i]+a[i+1]
if num<num2: num,z = num2,i+1
if num>=l:
print("Possible")
for i in range(1,z): print(i)
for i in range(n-1,z-1,-1): print(i)
else: print("Impossible") |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
18,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
40,
2,
13,
18,
13,
13,
13,
0,
13,
13,
3,
0,
13,
18,
13,
13,
14,... | [
[
120,
2
],
[
120,
11
],
[
123,
13
],
[
114,
25
],
[
124,
27
],
[
102,
30
],
[
34,
33
],
[
112,
37
],
[
115,
41
],
[
100,
41
],
[
124,
43
],
[
33,
44
],
[
121,
45
... | [
"N, L = map(int, input().split())\nA = list(map(int, input().split()))\npre = A[0]\nindex = -1\nfor i in range(1, N):\n if pre + A[i] >= L:\n index = i\n break\n pre = A[i]\n\nif index == -1:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n i = 1\n while i < index:\n pri... | N, L = map(int, input().split())
A = list(map(int, input().split()))
pre = A[0]
index = -1
for i in range(1, N):
if pre + A[i] >= L:
index = i
break
pre = A[i]
if index == -1:
print("Impossible")
else:
print("Possible")
i = 1
while i < index:
print(i)
i += 1
... |
[
7,
0,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
18,
13,
17,
0,
13,
4,
13,
18,
13,
17,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
... | [
[
159,
2
],
[
156,
9
],
[
160,
13
],
[
150,
16
],
[
160,
20
],
[
25,
24
],
[
24,
33
],
[
162,
35
],
[
165,
38
],
[
153,
41
],
[
45,
44
],
[
157,
48
],
[
163,
54
]... | [
"temp=input().split()\nN=int(temp[0])\nL=int(temp[1])\na=[int(i) for i in input().split()]\nflag=False\nans=[]\n\nfor i in range(N-1):\n\tif a[i]+a[i+1]>=L:\n\t\tprint(\"Possible\")\n\t\tflag=True\n\t\tans.append(i)\n\t\tbreak\nelse:\n\tprint(\"Impossible\")\n\nif flag==True:\n\twhile ans[-1]>0:\n\t\tans.append(ans... | temp=input().split()
N=int(temp[0])
L=int(temp[1])
a=[int(i) for i in input().split()]
flag=False
ans=[]
for i in range(N-1):
if a[i]+a[i+1]>=L:
print("Possible")
flag=True
ans.append(i)
break
else:
print("Impossible")
if flag==True:
while ans[-1]>0:
ans.append(ans[-1]-1)
if ans[0]<N-1:
ans.append(ans... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
... | [
[
115,
2
],
[
115,
11
],
[
106,
13
],
[
100,
25
],
[
118,
28
],
[
32,
31
],
[
116,
35
],
[
107,
41
],
[
31,
42
],
[
107,
44
],
[
31,
46
],
[
101,
48
],
[
104,
48
... | [
"N,L=map(int,input().split())\na=list(map(int,input().split()))\n\naa_max=-1\naa_i=-1\nfor i in range(N-1):\n if a[i]+a[i+1]>aa_max:\n aa_max=a[i]+a[i+1]\n aa_i=i\n#print(aa_max,aa_i)\n\nif aa_max<L:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(aa_i):\n print(i+1)\n for i in r... | N,L=map(int,input().split())
a=list(map(int,input().split()))
aa_max=-1
aa_i=-1
for i in range(N-1):
if a[i]+a[i+1]>aa_max:
aa_max=a[i]+a[i+1]
aa_i=i
#print(aa_max,aa_i)
if aa_max<L:
print("Impossible")
else:
print("Possible")
for i in range(aa_i):
print(i+1)
for i in range(N-2,aa_i-1,-1):
p... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
2,
18,
13,
13,
18,
... | [
[
115,
2
],
[
115,
11
],
[
106,
13
],
[
109,
25
],
[
112,
28
],
[
32,
31
],
[
104,
35
],
[
107,
41
],
[
31,
42
],
[
107,
44
],
[
31,
46
],
[
110,
48
],
[
119,
48
... | [
"N, L = map(int,input().split())\n\nA = list(map(int,input().split()))\n\nMAX = 0\nindex = -1\n\nfor i in range(N-1):\n if A[i] + A[i+1] > MAX:\n MAX = A[i] + A[i+1]\n index = i+1\n\nif MAX < L:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(1,index):\n print(... | N, L = map(int,input().split())
A = list(map(int,input().split()))
MAX = 0
index = -1
for i in range(N-1):
if A[i] + A[i+1] > MAX:
MAX = A[i] + A[i+1]
index = i+1
if MAX < L:
print("Impossible")
else:
print("Possible")
for i in range(1,index):
print(i)
for i in range(N-1,... |
[
7,
15,
13,
15,
15,
13,
15,
13,
12,
13,
14,
2,
13,
17,
29,
13,
29,
18,
13,
13,
23,
13,
12,
13,
14,
2,
4,
13,
18,
13,
13,
17,
0,
13,
4,
13,
18,
18,
13,
13,
17,
0,
13,
17,
0,
13,
4,
13,
13,
0,
13,
4,
18,
4,
18,
... | [
[
21,
12
],
[
21,
18
],
[
21,
21
],
[
34,
33
],
[
43,
42
],
[
46,
45
],
[
229,
47
],
[
42,
48
],
[
33,
48
],
[
51,
50
],
[
45,
56
],
[
63,
60
],
[
50,
67
],
[
... | [
"import sys\nfrom collections import deque\nimport copy\nimport math\ndef get_read_func(fileobject):\n if fileobject == None :\n return raw_input\n else:\n return fileobject.readline\n\n\ndef main():\n if len(sys.argv) > 1:\n f = open(sys.argv[1])\n else:\n f = None\n read... | import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
if fileobject == None :
return raw_input
else:
return fileobject.readline
def main():
if len(sys.argv) > 1:
f = open(sys.argv[1])
else:
f = None
read_func = get_read_func... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
13,
17,
0,
13,
2,
13,
17,
28,
13,
4,
... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
28,
27
],
[
4,
31
],
[
15,
37
],
[
27,
38
],
[
15,
40
],
[
27,
42
],
[
13,
44
],
[
50,
49
],
[
27,
51
],
[
55,
54
],
[
49... | [
"#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\ndef solve():\n N,L = map(int,input().split())\n As = list(map(int,input().split()))\n for i in range(N-1):\n if As[i] + As[i+1] >= L:\n print(\"Possible\")\n keep = i + 1\n for n in range(1,keep):\n p... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def solve():
N,L = map(int,input().split())
As = list(map(int,input().split()))
for i in range(N-1):
if As[i] + As[i+1] >= L:
print("Possible")
keep = i + 1
for n in range(1,keep):
print(n)
... |
[
7,
15,
15,
15,
15,
15,
0,
13,
2,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
3,... | [
[
93,
7
],
[
15,
14
],
[
15,
23
],
[
26,
25
],
[
38,
37
],
[
14,
41
],
[
25,
47
],
[
37,
48
],
[
25,
50
],
[
37,
52
],
[
23,
54
],
[
65,
64
],
[
64,
73
],
[
... | [
"from collections import defaultdict, Counter\nfrom itertools import product, groupby, count, permutations, combinations\nfrom math import pi, sqrt\nfrom collections import deque\nfrom bisect import bisect, bisect_left, bisect_right\nINF = 10 ** 10\n\n\ndef main():\n N, L = map(int, input().split())\n a_list ... | from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
def main():
N, L = map(int, input().split())
a_list = list(map(int,... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
13,
0,
13,
39,
42,
2,
13,
13,
14,
2,
13,
13,
3,
14,
2,
2,
13,
1... | [
[
211,
2
],
[
211,
11
],
[
15,
14
],
[
14,
23
],
[
208,
25
],
[
202,
28
],
[
199,
31
],
[
179,
33
],
[
190,
36
],
[
209,
39
],
[
184,
41
],
[
203,
45
],
[
182,
45
... | [
"N,L = map(int, input().split())\nA = [int(a) for a in input().split()]\n\nl = 0\nr = N-1\ns = sum(A)\nans = []\nwhile l < r:\n if s < L:\n break\n if r-l > 1:\n if A[l]+A[l+1] < L:\n s -= A[l]\n ans.append(l+1)\n l += 1\n continue\n if A[r]+A[r... | N,L = map(int, input().split())
A = [int(a) for a in input().split()]
l = 0
r = N-1
s = sum(A)
ans = []
while l < r:
if s < L:
break
if r-l > 1:
if A[l]+A[l+1] < L:
s -= A[l]
ans.append(l+1)
l += 1
continue
if A[r]+A[r-1] < L:
... |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17... | [
[
128,
4
],
[
143,
13
],
[
129,
20
],
[
143,
22
],
[
152,
24
],
[
129,
33
],
[
140,
36
],
[
40,
39
],
[
135,
43
],
[
153,
49
],
[
39,
50
],
[
153,
52
],
[
39,
54
... | [
"import sys\ninput = sys.stdin.buffer.readline\nN, L = map(int, input().split())\na = list(map(int, input().split()))\nres = []\nfor i in range(N - 1):\n if a[i] + a[i + 1] >= L:\n res.append(i + 1)\n break\nif len(res):\n i = res[0] - 1\n while i > 0:\n res.append(i)\n i -= 1\n i = res[0] + 1\n wh... | import sys
input = sys.stdin.buffer.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in range(N - 1):
if a[i] + a[i + 1] >= L:
res.append(i + 1)
break
if len(res):
i = res[0] - 1
while i > 0:
res.append(i)
i -= 1
i = res[0] + 1
while i < N:
res.a... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
17,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
14,
40,
13,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
... | [
[
130,
2
],
[
130,
13
],
[
121,
15
],
[
122,
28
],
[
112,
32
],
[
115,
35
],
[
39,
38
],
[
131,
41
],
[
119,
44
],
[
122,
47
],
[
38,
48
],
[
122,
50
],
[
38,
52
... | [
"N,L = list(map(int,input().split()))\na = list(map(int,input().split()))\na.append(0)\nb = []\nres = \"Impossible\"\n\nfor i in range(N):\n if L <= (a[i]+a[i+1]):\n count = i\n res = \"Possible\"\n break\n\nif res ==\"Possible\":\n for j in range(count):\n b.append(j+1)\n for k... | N,L = list(map(int,input().split()))
a = list(map(int,input().split()))
a.append(0)
b = []
res = "Impossible"
for i in range(N):
if L <= (a[i]+a[i+1]):
count = i
res = "Possible"
break
if res =="Possible":
for j in range(count):
b.append(j+1)
for k in range(count+1,N)[::-1]... |
[
7,
12,
13,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
13,
14,
40,
13,
29,
39,
17,
0,
13,
39,
13,
28,
13,
4,
13,
2,
13,
17,
13,
4,
18,
13,
13,
13,
28,
13,... | [
[
5,
4
],
[
8,
7
],
[
76,
11
],
[
80,
16
],
[
7,
17
],
[
80,
19
],
[
7,
21
],
[
78,
23
],
[
26,
25
],
[
29,
28
],
[
7,
29
],
[
25,
32
],
[
4,
32
],
[
38,
... | [
"\ndef know(N, K, A):\n isOK = False\n for i in range(1, N):\n if A[i] + A[i - 1] >= K:\n isOK = True\n first = i\n\n if not isOK:\n return [\"Impossible\"]\n\n ans = [first]\n for i in range(first + 1, N):\n ans.append(i)\n for i in range(first - 1, 0, -... |
def know(N, K, A):
isOK = False
for i in range(1, N):
if A[i] + A[i - 1] >= K:
isOK = True
first = i
if not isOK:
return ["Impossible"]
ans = [first]
for i in range(first + 1, N):
ans.append(i)
for i in range(first - 1, 0, -1):
ans.appen... |
[
7,
15,
15,
15,
15,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
... | [
[
240,
17
],
[
279,
24
],
[
45,
44
],
[
235,
50
],
[
54,
54
],
[
58,
57
],
[
283,
63
],
[
67,
67
],
[
71,
70
],
[
271,
76
],
[
80,
80
],
[
84,
83
],
[
283,
89
],
... | [
"#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\nde... | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
0,
13,
17,
0,
13,
17,
28,
13,
39,
13,
13,
4,
13,
4,
13,
13,
18,
13,
39,
17,
17,
14,
2,
2,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
13,
14,
2,
13... | [
[
96,
2
],
[
96,
15
],
[
96,
16
],
[
99,
19
],
[
99,
22
],
[
88,
44
],
[
85,
44
],
[
84,
46
],
[
93,
51
],
[
85,
55
],
[
88,
55
],
[
97,
56
],
[
94,
69
],
[
... | [
"n,l,*a=map(int,open(0).read().split())\ni=m=0\nfor j,(x,y)in enumerate(zip(a,a[1:]),1):\n if x+y>m:\n m=x+y\n i=j\nif m<l:\n print('Impossible')\nelse:\n print('Possible')\n print(*range(1,i))\n print(*range(n-1,i,-1))\n print(i)",
"n,l,*a=map(int,open(0).read().split())",
"n",
"map(int,open(0).r... | n,l,*a=map(int,open(0).read().split())
i=m=0
for j,(x,y)in enumerate(zip(a,a[1:]),1):
if x+y>m:
m=x+y
i=j
if m<l:
print('Impossible')
else:
print('Possible')
print(*range(1,i))
print(*range(n-1,i,-1))
print(i) |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
31,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
13,
4,... | [
[
128,
4
],
[
137,
13
],
[
131,
22
],
[
140,
31
],
[
129,
38
],
[
140,
40
],
[
140,
41
],
[
47,
46
],
[
119,
49
],
[
119,
56
],
[
119,
58
],
[
117,
66
],
[
69,
68
... | [
"import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, L, *A = map(int, read().split())\n\ndef main(L, A):\n N = len(A)\n is_long = [x + y >= L for x, y in zip(A, A[1:])]\n if not any(is_long):\n print('Impossible')\n re... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, L, *A = map(int, read().split())
def main(L, A):
N = len(A)
is_long = [x + y >= L for x, y in zip(A, A[1:])]
if not any(is_long):
print('Impossible')
return
print('Po... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
17,
15,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
15,
13,
0,
13,
2,
17,
17,
12,
13,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
... | [
[
213,
4
],
[
214,
22
],
[
214,
34
],
[
210,
39
],
[
49,
46
],
[
122,
47
],
[
126,
48
],
[
54,
51
],
[
124,
52
],
[
126,
53
],
[
57,
56
],
[
65,
64
],
[
56,
67
],... | [
"import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nfrom collections import deque, Counter\ndef getN():\n return int(input())\ndef getList():\n return list(map(int, input().split()))\nimport math\nINF = 10**10\ndef bfs(graph, visited, position, root):\n visited[root] = 1\n position[... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
return int(input())
def getList():
return list(map(int, input().split()))
import math
INF = 10**10
def bfs(graph, visited, position, root):
visited[root] = 1
position[root] = 0
deq... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
0,
13,
17,
0,
13,
13,
3,
... | [
[
107,
2
],
[
107,
11
],
[
95,
13
],
[
101,
25
],
[
98,
28
],
[
32,
31
],
[
108,
35
],
[
96,
41
],
[
31,
42
],
[
96,
44
],
[
31,
46
],
[
105,
48
],
[
110,
50
],
... | [
"n,l=map(int,input().split())\narr=list(map(int,input().split()))\npsbl=False\npos=0\nfor i in range(n-1):\n if arr[i]+arr[i+1]>=l:\n psbl=True\n pos=i\n break\nif psbl:\n print(\"Possible\")\n for i in range(0,pos):\n print(i+1)\n for i in range(n-2,pos,-1):\n print(i... | n,l=map(int,input().split())
arr=list(map(int,input().split()))
psbl=False
pos=0
for i in range(n-1):
if arr[i]+arr[i+1]>=l:
psbl=True
pos=i
break
if psbl:
print("Possible")
for i in range(0,pos):
print(i+1)
for i in range(n-2,pos,-1):
print(i+1)
print(pos+1)
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
40,
2,
18,
13,
2,
13,
17,
18,
13,
13,
13,
0,
13,
13,
3,
14,
2,
13,
17,
4,
13,
17,
... | [
[
90,
2
],
[
90,
11
],
[
84,
13
],
[
96,
25
],
[
29,
28
],
[
91,
32
],
[
85,
37
],
[
28,
39
],
[
85,
42
],
[
28,
43
],
[
88,
44
],
[
93,
46
],
[
28,
47
],
[
... | [
"n,k=map(int,input().split())\nl=list(map(int,input().split()))\ntmp=0\nfor i in range(1,n):\n if l[i-1]+l[i]>=k:\n tmp=i\n break\nif tmp==0:\n print(\"Impossible\")\nelse:\n print(\"Possible\")\n for i in range(1,tmp):\n print(i)\n for i in range(n-1,tmp,-1):\n print(i)\n... | n,k=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
for i in range(1,n):
if l[i-1]+l[i]>=k:
tmp=i
break
if tmp==0:
print("Impossible")
else:
print("Possible")
for i in range(1,tmp):
print(i)
for i in range(n-1,tmp,-1):
print(i)
print(tmp) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
0,
13,
39,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
13,
4,
18,
13,
13,
2,
13,
17,
9,
14,
2,
2,
1... | [
[
132,
2
],
[
132,
11
],
[
120,
13
],
[
123,
25
],
[
141,
28
],
[
135,
31
],
[
144,
34
],
[
38,
37
],
[
130,
41
],
[
142,
47
],
[
37,
50
],
[
121,
57
],
[
37,
58
... | [
"# 2019/09/18\n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nans=[]\nres=[]\nlast=0\n\nflag=False\nfor i in range(n-1):\n if flag:\n res.append(i+1)\n continue\n if a[i]+a[i+1]<k:\n ans.append(i+1)\n elif not flag:\n last=i\n flag=True\n\nif not flag:\... | # 2019/09/18
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[]
res=[]
last=0
flag=False
for i in range(n-1):
if flag:
res.append(i+1)
continue
if a[i]+a[i+1]<k:
ans.append(i+1)
elif not flag:
last=i
flag=True
if not flag:
print('Impossible')
... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
31,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
2,
13,
17,
14,
40,
2,
18,
13,
13,
18,
13,
2,
13,
17,
13,
4,
18,
13,
13,
2,
13,
17,
3,
4,
13,
... | [
[
113,
3
],
[
113,
12
],
[
16,
14
],
[
98,
25
],
[
29,
28
],
[
114,
32
],
[
28,
39
],
[
28,
43
],
[
102,
45
],
[
99,
48
],
[
28,
51
],
[
107,
60
],
[
99,
62
],
... | [
"from itertools import accumulate as ac\n\nn,l=map(int,input().split())\n*a,=map(int,input().split())\nv=[]\n\nfor i in range(n-1):\n if a[i]+a[i+1]>=l:\n v.append(i+1)\n break\nelse:\n print(\"Impossible\")\n\nif v:\n st=v[0]\n v+=list(range(1,st)[::-1])\n v+=list(range(st+1,n))\n print(\"Possible\")\n... | from itertools import accumulate as ac
n,l=map(int,input().split())
*a,=map(int,input().split())
v=[]
for i in range(n-1):
if a[i]+a[i+1]>=l:
v.append(i+1)
break
else:
print("Impossible")
if v:
st=v[0]
v+=list(range(1,st)[::-1])
v+=list(range(st+1,n))
print("Possible")
for i in v[::-1]:
pri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.