Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
K = int(input())
A = [int(_) for _ in input().split()]
l = r = 2
'''
if x children form groups consisting of y children each
 then z children are left
=> z=y*(x//y)
=> y*(math.ceil(z/y))<=x<y*(math.floor(z/y)+1)
'''
#necessary conditions
for a in A[::-1]:
    l = a * math.ceil(l / a)
    r = a * (math.floor(r / a) + 1) - 1
#sufficient conditions
for x in [l, r]:
    for a in A:
        x = a * (x // a)
    if x != 2:
        print(-1)
        exit()
print(l, r)


Fixed submission:
N, A, B = [int(_) for _ in input().split()]
if (B - A) % 2:
    print('Borys')
else:
    print('Alice')
Buggy python submission (verdict: Runtime Error):
N, Z, W = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
#[abs(a-A[-1]) for a in A[i:-1]]が広義単調増加になるような最小のiを選ぶと、
#Xさんは最初にA[i]までとるのが最善策の候補
#このときYさんは最後までとるのが最善
#ただしabs(A[i]-A[-1])がWより小さいならXさんは最初に全部とってしまうのが最善
ans = 0
b = A[-1]
j = N - 2
for i in range(N - 3, -1, -1):
    if abs(A[i] - b) <= abs(A[i + 1] - b):
        j -= 1
    else:
        break
print(max(abs(A[i] - b), abs(W - b)))


Fixed submission:
N, Z, W = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
#Xさんが最初に全部引くか、Xさんが最後から2枚目まで引く
print(max(abs(W - A[-1]), abs(A[N - 2] - A[-1])))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf


Fixed submission:
import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10 % K, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf

Buggy python submission (verdict: Time Limit Exceeded):
import collections
K = int(input())
Q = collections.deque([[1, 1]])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append([n + 1, d + 1])
            Q.appendleft([n * 10, d])
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf


Fixed submission:
import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10 % K, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf

Buggy python submission (verdict: Time Limit Exceeded):
import collections
K = int(input())
Q = collections.deque([[1, 1]])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append([n + 1, d + 1])
            Q.appendleft([n * 10, d])
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf


Fixed submission:
import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10 % K, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T = [int(_) for _ in input().split()]
for i in range(N - 1):
    T[i + 1] += T[i]
T = [0] + T
V = [int(_) for _ in input().split()]
V = V
vel = [min(i / 2, T[-1] - i / 2) for i in range(2 * T[-1] + 1)]
for i in range(N):
    for j in range(2 * T[-1] + 1):
        vel[j] = min(vel[j],
                     max(V[i], -j / 2 + T[i] + V[i], j / 2 - T[i + 1] + V[i]))
print((2 * sum(vel) - vel[0] - vel[-1]) / 4)


Fixed submission:
N = int(input())
T = [int(_) for _ in input().split()]
for i in range(N - 1):
    T[i + 1] += T[i]
T = [0] + T
V = [int(_) for _ in input().split()]
V = V
vel = [min(i / 2, T[-1] - i / 2) for i in range(2 * T[-1] + 1)]
for i in range(N):
    for j in range(2 * T[-1] + 1):
        vel[j] = min(vel[j],
                     max(V[i], -j / 2 + T[i] + V[i], j / 2 - T[i + 1] + V[i]))
print((2 * sum(vel) - vel[0] - vel[-1]) / 4)
Buggy python submission (verdict: Runtime Error):
N = int(input())

maxh = int(3 * N / 4)

for h in range(1, min(maxh, 3501)):
    maxn = int(2 / (4 / N - 1 / h))
    for n in range(h, min(maxn, 3501)):
        w_reciprocal = (4 / N) - (1 / h) - (1 / n)
        if w_reciprocal > 0:
            w = 1 / w_reciprocal
            if w < 3501 and int(w) == w:
                w = int(w)
                print(h, n, w, sep = ' ')
                exit()

Fixed submission:
N = int(input())
for h in range(N//4 + 1, 3501):
    for n in (N * h // (4 * h - N) + 1, 3501):
        w = N * h * n // (4 * h * n - N * h - N * n)
        if w * (4 * h * n - N * h - N * n) == N * h * n:
            print(h, n, w)
            exit()
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = [int(_) for _ in input().split()]


def main(A, B, C, D, E, F):
    conc = -1
    ans = (1, 2)
    for na in range(F // (100 * A) + 1):
        for nb in range(F // (100 * B) + 1):
            if na == nb == 0:
                continue
            G = F - na * 100 * A - nb * 100 * B
            for nc in range(G // C + 1):
                for nd in range(G // D + 1):
                    W = na * 100 * A + nb * 100 * B + nc * C + nd * D
                    if 0 < W <= F and nc * C + nd * D <= E * (na * A + nb * B):
                        conc2 = 100 * (nc * C + nd * D) / W
                        if conc < conc2 <= 100 * E / (100 + E):
                            ans = (W, nc * C + nd * D)
                            conc = conc2
    return ans


print(*main(A, B, C, D, E, F))


Fixed submission:
N = int(input())
A = int(input())
print(N * N - A)
Buggy python submission (verdict: Runtime Error):
N, *A = [int(_) for _ in open(0).read().split()]
sumB = max(0, sum(A) - N * (N - 1))
while True:
    B = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]
    if sumB == sum(B):
        break
    sumB += 1
print(sumB)


Fixed submission:
N = int(input())
A = sorted([int(_) for _ in input().split()])
#B[i]回の操作をすると全項N-1以下になる
#A[i]-N*B[i]+sum(B)-B[i]<=N-1 が全iで成り立つ
#B[i]=0-(-(a+x+1-N))//(N+1)

def check(x):
    b = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]
    return sum(b) == x

p = max(0, sum(A) - (N - 1) * N)
while True:
    q = check(p)
    if q:
        break
    p += 1
print(p)
Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


g = A.pop()
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


g = A[0]
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import math
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
g = A.pop()
for a in A:
    g = math.gcd(g, a)

Fixed submission:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


g = A[0]
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import math
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
g = A.pop()
for a in A:
    g = math.gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif y == 0:
        return x
    else:
        return gcd(y, x % y)


g = A[0]
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted([int(_) for _ in input().split()], key=lambda x: abs(x))
ans = 0
pos = False
neg = False
while A:
    a = A.pop()
    if ans * a > 0:
        ans -= a
        neg = True
    else:
        ans += a
        pos = True
if pos & neg:
    print(abs(ans))
else:
    print(abs(A[0]-sum(A[1:])))


Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]+[0]
sumsub = A[0]
sumall = sum(A)
ans = abs(2*sumsub-sumall)
for i in range(1, N-1):
    sumsub += A[i]
    ans = min(ans, abs(2*sumsub-sumall))
print(ans)
Buggy python submission (verdict: Runtime Error):
import re
def kezuru(str):
    if str.find('()') == -1:
        return str
    else:
        return kezuru(str.replace('()',''))

n = input()
str = input()
kezutta = kezuru(str)
#print('(' * len(re.search('\)+',kezutta).group(0)) + str + ')' * len(re.search('\(+',kezutta).group(0)))
n1 = 0
m1 = re.search('\)+',kezutta)
if m1:
    n1 = len(m1.group(0))
n2 = 0
m2 = re.search('\(+',kezutta)
if m2:
    n2 = len(m2.group(0))
print(n1 * '(' + str + n2 * ')')

Fixed submission:
num = input().split()
a = int(num[0]) * 100 + int(num[1]) * 10 + int(num[2])
if a % 4 == 0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
import re
input()
strorig = input()
closeFirst = re.search('^\)*',strorig).group(0)
openLast = re.search('\(*$',strorig).group(0)
strModified = '(' * len(list(closeFirst)) + strorig + ')' * len(list(openLast))
nums = [-1 if i == '(' else 1 for i in list(strModified)]
sumnums = sum(nums)
if sumnums < 0:
    result = strModified + ')' * (-1 * sumnums)
else:
    result = '(' * sumnums + strModified
print(result)


Fixed submission:
num = input().split()
a = int(num[0]) * 100 + int(num[1]) * 10 + int(num[2])
if a % 4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(_) for _ in input().split()]
colors = [0] * 9
for a in A:
    c = a // 400
    if c < 8:
        colors[c] = 1
    else:
        colors[c] += 1
print(max(sum(colors[:8]), 1), min(sum(colors[:8]) + colors[8], 8))

Fixed submission:
N = input()
a = input().split()
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i in a:
    check = int(int(i) / 400)
    if check > 7:
        score8 += 1
    else:
        scores[check] = 1
score1to7 = sum(scores)
saidai = score1to7 + score8
if score1to7 < 1:
    saisho = 1
else:
    saisho = score1to7
print(str(saisho) + " " + str(saidai))

Buggy python submission (verdict: Runtime Error):
N = input()
a = [int(int(i)/400) for i in input().split()]
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i,v in enumerate(a):
    if v > 7:
        score8 += 1
    else:
        scores[i] = 1
score1to7 = sum(scores)
saidai = min(score1to7 + score8, 8)
saisho = min(max(score1to7, score8), 8)
print(str(saisho) + " " + str(saidai))

Fixed submission:
N = input()
a = input().split()
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i in a:
    check = int(int(i) / 400)
    if check > 7:
        score8 += 1
    else:
        scores[check] = 1
score1to7 = sum(scores)
saidai = score1to7 + score8
if score1to7 < 1:
    saisho = 1
else:
    saisho = score1to7
print(str(saisho) + " " + str(saidai))

Buggy python submission (verdict: Runtime Error):
N = input()
a = [int(int(i)/400) for i in input().split()]
print(a)
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i,v in enumerate(a):
    if v > 7:
        score8 += 1
    else:
        scores[i] = 1
score1to7 = sum(scores)
saidai = min(score1to7 + score8, 8)
saisho = min(max(score1to7, score8), 8)
print(str(saisho) + " " + str(saidai))

Fixed submission:
N = input()
a = input().split()
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i in a:
    check = int(int(i) / 400)
    if check > 7:
        score8 += 1
    else:
        scores[check] = 1
score1to7 = sum(scores)
saidai = score1to7 + score8
if score1to7 < 1:
    saisho = 1
else:
    saisho = score1to7
print(str(saisho) + " " + str(saidai))
Buggy python submission (verdict: Runtime Error):
H, W = [int(_) for _ in input().split()]
A = [input() for _ in range(N)]
print('#'*(W+2))
for a in A:
    print('#'+a+'#')
print('#'*(W+2))


Fixed submission:
H, W = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
print('#'*(W+2))
for a in A:
    print('#'+a+'#')
print('#'*(W+2))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N = int(input())
A = [int(_) for _ in input().split()]

X = A[0:N]
B = A[N:2*N]
Y = [-_ for _ in A[2*N:3*N]]

heapq.heapify(X)
heapq.heapify(Y)

x = [sum(X)]
y = [sum(Y)]

for i in range(N):
    x += [B[i] - heapq.heappushpop(X, B[i])]
    y += [-B[-1-i] - heapq.heappushpop(Y, -B[-1-i])]

for i in range(N):
    x[i+1] = x[i]+x[i+1]
    y[i+1] = y[i]+y[i+1]

print(max([x[_] + y[::-1][_] for _ in range(N+1)]))

Fixed submission:
import heapq
N = int(input())
A = [int(_) for _ in input().split()]

X = A[0:N]
B = A[N:2*N]
Y = [-_ for _ in A[2*N:3*N]]

heapq.heapify(X)
heapq.heapify(Y)

x = [sum(X)]
y = [sum(Y)]

for i in range(N):
    x += [B[i] - heapq.heappushpop(X, B[i])]
    y += [-B[-1-i] - heapq.heappushpop(Y, -B[-1-i])]

for i in range(N):
    x[i+1] = x[i]+x[i+1]
    y[i+1] = y[i]+y[i+1]

print(max([x[_] + y[-1 - _] for _ in range(N+1)]))
Buggy python submission (verdict: Runtime Error):
import math
V, E = [int(_) for _ in input().split()]
G = {}

for i in range(V):
    G[i] = {}
for _ in range(E):
    s, t, c = [int(_) for _ in input().split()]
    s -= 1  # 0を始点とする場合
    t -= 1  # 0を始点とする場合
    G[s][t] = -c

INF = math.inf

D = [INF] * V
D[0] = 0  # 0を始点とする場合
count = 0
while True:
    count += 1
    update = False
    for s in G.keys():
        for t in G[s].keys():
            if D[s] != INF and D[t] > D[s] + G[s][t]:
                D[t] = D[s] + G[s][t]
                update = True
    if not update:
        break
    if count == V:
        print('inf')
        exit()
print(-D[-1])


Fixed submission:
V, E = [int(_) for _ in input().split()]
G = {}

for i in range(V):
    G[i] = {}
for _ in range(E):
    s, t, c = [int(_) for _ in input().split()]
    s -= 1  # 0を始点とする場合
    t -= 1  # 0を始点とする場合
    G[s][t] = -c

INF = float('inf')

D = [INF] * V
D[0] = 0  # 0を始点とする場合
count = 0
while True:
    count += 1
    update = False
    update_n = False
    for s in G.keys():
        for t in G[s].keys():
            if D[s] != INF and D[t] > D[s] + G[s][t]:
                D[t] = D[s] + G[s][t]
                update = True
                if t == V - 1:
                    update_n = True
    if not update or count == V:
        break
if update_n:
    print('inf')
else:
    print(-D[-1])
Buggy python submission (verdict: Runtime Error):
c = input()
if 'a' in 'aeiuo'.split(''):
    print('vowel')
else:
    print('consonant')

Fixed submission:
c = input()
if c in 'aeiuo':
    print('vowel')
else:
    print('consonant')
Buggy python submission (verdict: Runtime Error):
if sorted([int(_) for _ in input().split()]) == [5, 5, 7]:
    print('YES')
else:
    print('NO')


Fixed submission:
print('A'+input().split()[1][0]+'C')
Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse import csgraph

xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = np.array([[xs, ys, 0]] + [[int(_) for _ in input().split()]
                                for _ in range(N)] + [[xt, yt, 0]])
edge = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        edge[i][j] = edge[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)
G = csgraph.csgraph_from_dense(edge, null_value=np.inf)
print(csgraph.dijkstra(G, directed=False, indices=0)[-1])


Fixed submission:
from heapq import *

xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = [[xs, ys, 0]] + [[int(_) for _ in input().split()]
                       for _ in range(N)] + [[xt, yt, 0]]
G = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        G[i][j] = G[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)


def dijkstra(V, G, start):
    INF = float('inf')
    D = [INF for _ in range(V)]
    D[start] = 0
    H = [(0, start)]
    while H:
        du, u = heappop(H)
        if D[u] < du:
            continue
        for v, d in enumerate(G[u]):
            if D[v] > du + d:
                D[v] = du + d
                heappush(H, (D[v], v))
    return D


D = dijkstra(N + 2, G, 0)
print(D[-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import *
xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = np.array([[xs, ys, 0]] + [[int(_) for _ in input().split()]
                                for _ in range(N)] + [[xt, yt, 0]])
edge = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        edge[i][j] = edge[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)
G = csgraph_from_dense(edge, null_value=10**10)
print(dijkstra(G, directed=False, indices=0)[-1])


Fixed submission:
from heapq import *

xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = [[xs, ys, 0]] + [[int(_) for _ in input().split()]
                       for _ in range(N)] + [[xt, yt, 0]]
G = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        G[i][j] = G[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)


def dijkstra(V, G, start):
    INF = float('inf')
    D = [INF for _ in range(V)]
    D[start] = 0
    H = [(0, start)]
    while H:
        du, u = heappop(H)
        if D[u] < du:
            continue
        for v, d in enumerate(G[u]):
            if D[v] > du + d:
                D[v] = du + d
                heappush(H, (D[v], v))
    return D


D = dijkstra(N + 2, G, 0)
print(D[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = sorted(int(input()) for _ in range(N))
B = sorted(int(input()) for _ in range(N))
mod = 10**9 + 7
ans = 1
b = bisect.bisect
for i in range(N):
    if A[i] < B[i]:
        ans *= 1 + i - b(B[:i], A[i])
    else:
        ans *= 1 + i - b(A[:i], B[i])
    ans %= mod
print(ans)


Fixed submission:
N = int(input())
E = []
for _ in range(N):
    E += [(int(input()), 1)]
for _ in range(N):
    E += [(int(input()), -1)]
E.sort()
mod = 10**9 + 7
ans = 1
ab = 0
for e in E:
    if e[1] * ab < 0:
        ans *= abs(ab)
        ans %= mod
    ab += e[1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(_) for _ in input().split()]
dp = [-1] * (N + 1)
count = [0] * N
for i in range(N):
    count[i] = i - dp[A[i]]
    dp = dp[:A[i]] + [i] * (N - A[i] + 1)
dp_r = [N] * (N + 1)
ans = 0
for i in range(N - 1, -1, -1):
    ans += A[i] * (dp_r[A[i]] - i) * count[i]
    dp_r = dp_r[:A[i]] + [i] * (N - A[i] + 1)
print(ans)


Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]
left = list(range(N + 2))
right = list(range(N + 2))
index = {A[i - 1]: i for i in range(1, N + 1)}
ans = 0
for a in range(N, 0, -1):
    i = index[a]
    l = left[i]
    r = right[i]
    ans += a * (i - l + 1) * (r - i + 1)
    left[r + 1] = l
    right[l - 1] = r
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = [int(_) for _ in input().split()]
XY = [[int(_) - 1 for _ in input().split()] for _ in range(M)]

red = [False] * M
red[0] = True
num = [1] * M

for x, y in XY:
    num[x] -= 1
    num[y] += 1
    if red[x] == True:
        red[y] = True
        if num[x] == 0:
            red[x] = False
print(sum(red))

# http://agc002.contest.atcoder.jp/data/agc/002/editorial.pdf


Fixed submission:
N, M = [int(_) for _ in input().split()]
XY = [[int(_) - 1 for _ in input().split()] for _ in range(M)]

red = [False] * N
red[0] = True
num = [1] * N

for x, y in XY:
    num[x] -= 1
    num[y] += 1
    if red[x] == True:
        red[y] = True
        if num[x] == 0:
            red[x] = False
print(sum(red))

# http://agc002.contest.atcoder.jp/data/agc/002/editorial.pdf
Buggy python submission (verdict: Runtime Error):
n = input()
if n%9==0:
  print('Yes')
else:
  print('No')


Fixed submission:
n = int(input())
if n%9==0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n = input()
if n%==0:
  print('Yes')
else:
  print('No')

Fixed submission:
n = int(input())
if n%9==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
point = list(map(int,input().split()))
def seki(k,b,point):
    a = 1
    score = []
    for i in range(b,b+k):
        a = a*point[i]
    return a

for j in range(n-k):
    if seki(k,j,point)< seki(k,j+1,point):
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k = map(int,input().split())
point = list(map(int,input().split()))
for j in range(n-k):
    if point[j] < point[j+k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
x = math.ceil(N)
ans = [0]*N

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,x):
    for j in range(i,x):
        for k in range(j,x):
            s = f(i,j,k)
            t = len(set([i,j,k]))
            if N < s:
                pass
            else:
                if t == 3:
                    ans[s-1] += 6
                elif t == 2:
                    ans[s-1] += 3
                elif t ==1:
                    ans[s-1] += 1
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
import math
N = int(input())
x = math.ceil(math.sqrt(N))
ans = [0]*N

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,x):
    for j in range(i,x):
        for k in range(j,x):
            s = f(i,j,k)
            t = len(set([i,j,k]))
            if N >= s:
                if t == 3:
                    ans[s-1] += 6
                elif t == 2:
                    ans[s-1] += 3
                elif t ==1:
                    ans[s-1] += 1
for i in range(len(ans)):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
x = math.ceil(n)
ans = [0]*N

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,x):
    for j in range(i,x):
        for k in range(j,x):
            s = f(i,j,k)
            t = len(set([i,j,k]))
            if n < s:
                pass
            else:
                if t == 3:
                    ans[s-1] += 6
                elif t == 2:
                    ans[s-1] += 3
                elif t ==1:
                    ans[s-1] += 1
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
import math
N = int(input())
x = math.ceil(math.sqrt(N))
ans = [0]*N

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,x):
    for j in range(i,x):
        for k in range(j,x):
            s = f(i,j,k)
            t = len(set([i,j,k]))
            if N >= s:
                if t == 3:
                    ans[s-1] += 6
                elif t == 2:
                    ans[s-1] += 3
                elif t ==1:
                    ans[s-1] += 1
for i in range(len(ans)):
    print(ans[i])