Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env pypy3

import math
import itertools


INVALID = -1
INF = 10 ** 12


def dijkstra_dense(num_vs, adj_matrix, source, dest):
    dist = [INF for _ in range(num_vs)]
    visited = [False for _ in range(num_vs)]
    dist[source] = 0
    while True:
        u = min((j for j in range(num_vs) if not visited[j]),
                key=lambda i: dist[i], default=INVALID)
        if u == INVALID or dist[u] == INF:
            break
        visited[u] = True
        for v in range(num_vs):
            w = adj_matrix[u][v]
            if u != v and w < INF:
                new_len = dist[u] + w
                if new_len < dist[v]:
                    dist[v] = new_len
    return dist[dest]


def main():
    # 始点を頂点0、終点を頂点N + 1とする
    x0, y0, xf, yf = (int(x) for x in input().split())
    n = int(input())
    xs = [None for _ in range(n + 2)]
    ys = [None for _ in range(n + 2)]
    rs = [None for _ in range(n + 2)]
    xs[0], ys[0], rs[0] = x0, y0, 0
    xs[n + 1], ys[n + 1], rs[n + 1] = xf, yf, 0
    for i in range(1, n + 1):
        xs[i], ys[i], rs[i] = (int(z) for z in input().split())
    adj_matrix = [[INF for _ in range(n + 2)] for _ in range(n + 2)]
    for i, j in itertools.product(range(n + 2), repeat=2):
        adj_matrix[i][j] = max(0, math.hypot(xs[i] - xs[j],
                                             ys[i] - ys[j]) - (rs[i] + rs[j]))
    res = dijkstra_dense(n + 2, adj_matrix, 0, n + 1)
    print("{:.12f}".format(res))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3

import math
import itertools


INVALID = -1
INF = 10 ** 12


def dijkstra_dense(num_vs, adj_matrix, source, dest):
    dist = [INF for _ in range(num_vs)]
    visited = [False for _ in range(num_vs)]
    dist[source] = 0
    while True:
        u = min((j for j in range(num_vs) if not visited[j]),
                key=lambda i: dist[i], default=INVALID)
        if u == INVALID or dist[u] == INF:
            break
        visited[u] = True
        for v in range(num_vs):
            w = adj_matrix[u][v]
            if u != v and w < INF:
                new_len = dist[u] + w
                if new_len < dist[v]:
                    dist[v] = new_len
    return dist[dest]


def main():
    # 始点を頂点0、終点を頂点N + 1とする
    x0, y0, xf, yf = (int(x) for x in input().split())
    n = int(input())
    xs = [None for _ in range(n + 2)]
    ys = [None for _ in range(n + 2)]
    rs = [None for _ in range(n + 2)]
    xs[0], ys[0], rs[0] = x0, y0, 0
    xs[n + 1], ys[n + 1], rs[n + 1] = xf, yf, 0
    for i in range(1, n + 1):
        xs[i], ys[i], rs[i] = (int(z) for z in input().split())
    adj_matrix = [[INF for _ in range(n + 2)] for _ in range(n + 2)]
    for i, j in itertools.product(range(n + 2), repeat=2):
        adj_matrix[i][j] = max(0, math.hypot(xs[i] - xs[j],
                                             ys[i] - ys[j]) - (rs[i] + rs[j]))
    res = dijkstra_dense(n + 2, adj_matrix, 0, n + 1)
    print("{:.12f}".format(res))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import collections


def solve(n, t, xs):
    trades = collections.defaultdict(int)
    for i in range(n):
        for j in range(i + 1, n):
            delta = xs[j] - xs[i]
            if delta > 0:
                trades[delta] += 1
    max_delta = max(trades.keys())
    return trades[max_delta]


def main():
    n, t = map(int, input().split())
    xs = list(map(int, input().split()))
    print(solve(n, t, xs))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env pypy3

import collections


INF = 10 ** 10


def solve(n, t, xs):
    trades = collections.Counter()
    maxs = [INF for _ in range(n)]
    maxs[n - 1] = xs[n - 1]
    for i in range(n - 1)[::-1]:
        maxs[i] = max(xs[i], maxs[i + 1])
    for i in range(n):
        delta = maxs[i] - xs[i]
        if delta > 0:
            trades[delta] += 1
    max_delta = max(trades.keys())
    return trades[max_delta]


def main():
    n, t = map(int, input().split())
    xs = list(map(int, input().split()))
    print(solve(n, t, xs))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import itertools
import numpy


def solve(n, a, xs0):
    xs = numpy.insert(xs0, 0, 0)
    xs.sort()
    y = max(xs.max(), a)
    dp = numpy.zeros((n + 1, n + 1, n * y + 1), numpy.int64)
    g = itertools.product(range(n + 1), range(n + 1), range(n * y + 1))
    for j, k, s in g:
        if j == k == s == 0:
            dp[j, k, s] = 1
        elif j >= 1 and s < xs[j]:
            dp[j, k, s] = dp[j - 1, k, s]
        elif j >= 1 and k >= 1 and s >= xs[j]:
            dp[j, k, s] = dp[j - 1, k, s] + dp[j - 1, k - 1, s - xs[j]]
    ans = sum(dp[n][k][k * a] for k in range(1, n + 1))
    return ans


def main():
    n, a = (int(x) for x in input().split())
    xs = numpy.fromiter((int(x) for x in input().split()), numpy.int64)
    ans = solve(n, a, xs)
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env pypy3

import itertools


def solve(n, a, xs0):
    xs = sorted(xs0)
    xs.insert(0, 0)
    y = max(a, *xs)
    dp = [[[0 for _ in range(n * y + 1)]
          for _ in range(n + 1)] for _ in range(n + 1)]
    g = itertools.product(range(n + 1), range(n + 1), range(n * y + 1))
    for j, k, s in g:
        if j == k == s == 0:
            dp[j][k][s] = 1
        elif j >= 1 and s < xs[j]:
            dp[j][k][s] = dp[j - 1][k][s]
        elif j >= 1 and k >= 1 and s >= xs[j]:
            dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xs[j]]
    ans = sum(dp[n][k][k * a] for k in range(1, n + 1))
    return ans


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    ans = solve(n, a, xs)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env pypy3

import collections
import itertools


MAX_S = 100
NO_SOL = (-1, -1)


def is_unbalanced(s):
    ctr = collections.Counter(s)
    total = sum(ctr.values())
    m = max(ctr.values())
    return m >= total // 2 + 1


def find_unbalanced_substr(s):
    l = len(s)
    for start, end in itertools.combinations(range(l), 2):
        if is_unbalanced(s[start:end + 1]):
            return start, end
    return NO_SOL


def main():
    s = input()
    assert len(s) <= MAX_S
    ans = find_unbalanced_substr(s)
    if ans == NO_SOL:
        print(*ans)
    else:
        print(*(x + 1 for x in ans))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3

NO_SOL = (-1, -1)


# 所与の文字列の部分文字列であって、アンバランスなものを1つ探す
# 対象とするのは、"AA"および"ABA"のみ
# 結果のインデックスは0始まりである
def search_unbalanced_substr(s):
    n = len(s)
    # "AA"を探す
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            return i, i + 1
    # "ABA"を探す
    for i in range(n - 2):
        if s[i] == s[i + 2]:
            return i, i + 2
    # 見つからなければ
    return NO_SOL


def main():
    ans = search_unbalanced_substr(input())
    if ans == NO_SOL:
        print(*ans)
    else:
        print(*(i + 1 for i in ans))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
O = list()
a = 0
for i in range (len(S) - len(T)):
    b = 0
    m = 0
    for i in range (len(T)):
        if S[b + a] != T[b]:
            m = m + 1
        b = b + 1
    O.append(m)
    a = a + 1
O.sort()
print(O[0])

Fixed submission:
S = list(input())
T = list(input())
O = list()
a = 0
for i in range (len(S) - len(T) + 1):
    b = 0
    m = 0
    for i in range (len(T)):
        if S[b + a] != T[b]:
            m = m + 1
        b = b + 1
    O.append(m)
    a = a + 1
O.sort()
print(O[0])
Buggy python submission (verdict: Runtime Error):
S = input()
a = list()
b = 0
u = 0
for i in range (len(S)):
    if S[u] == 'R':
        b = b + 1
    else:
        a.append(b)
        b = 0
    u = u + 1
a.sort()
a.reverse()
print(a[0])


Fixed submission:
S = input()
a = list()
b = 0
u = 0
for i in range (len(S)):
    if S[u] == 'R':
        b = b + 1
    else:
        a.append(b)
        b = 0
    u = u + 1
a.append(b)
a.sort()
a.reverse()
print(a[0])
Buggy python submission (verdict: Time Limit Exceeded):
N, D = input().split()
N = int(N)
D = int(D)
X = list()
Y = list()
s = 0
for i in range(N):
    x, y = input().split()
    x = int(x)
    y = int(y)
    X.append(x)
    Y.append(y)
for i in range(N):
    if X[0] ** 2 + Y[0] ** 2 <= D ** 2:
        s = s + 1
    del X[0]
    del Y[0]
print(s)


Fixed submission:
N, D = input().split()
N = int(N)
D = int(D)
X = list()
Y = list()
s = 0
for i in range(N):
    x, y = input().split()
    x = int(x)
    y = int(y)
    if x ** 2 + y ** 2 <= D ** 2:
        s = s + 1
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = list(map(int,input().split()))
ans = 1
for i in range(int(n)):
  ans *= a[i]
if ans>1000000000000000000: print(-1)
else: print(ans) 

Fixed submission:
n = input()
a = list(map(int,input().split()))
ans = 1
for i in range(int(n)):
  ans *= a[i]
  if ans>1000000000000000000:
    ans = -1
    break
for i in range(int(n)):
  if a[i] == 0:
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

checked = [False]*n
q = deque([])
cnt = 0

#連結成分のカウント

for i in range(n):
    if checked[i]:
        continue
    checked[i] = True
    q.append(i)
    while q:
        v = q.pop()
        s = g[v]
        for j in s:
            if checked[j]:
                continue
            checked[j] = True
            q.append(j)
    cnt += 1

print(cnt - 1

Fixed submission:
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

dist = [-1]*n
q = deque([])
cnt = 0

#連結成分のカウント

for i in range(n):
    if dist[i] != -1:
        continue
    dist[i] = 0
    q.append(i)
    while q:
        v = q.pop()
        s = g[v]
        for j in s:
            if dist[j] != -1:
                continue
            dist[j] = 0
            q.append(j)
    cnt += 1

print(cnt - 1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
M = [[0 for _ in range(n)] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    M[a][b] = 1
    
cnt = 0   
for i in range(n-1):
    if all(M[i][j] == 0 for j in range(1+i, n)):
        cnt += 1

print(cnt)

Fixed submission:
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

dist = [-1]*n
q = deque([])
cnt = 0

#連結成分のカウント

for i in range(n):
    if dist[i] != -1:
        continue
    dist[i] = 0
    q.append(i)
    while q:
        v = q.pop()
        s = g[v]
        for j in s:
            if dist[j] != -1:
                continue
            dist[j] = 0
            q.append(j)
    cnt += 1

print(cnt - 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
M = [[0 for _ in range(n)] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    M[a][b] = 1
    M[b][a] = 1
    
cnt = 0   
for i in range(n-1):
    if all(M[i][j] == 0 for j in range(1+i, n)):
        cnt += 1

print(cnt)

Fixed submission:
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

dist = [-1]*n
q = deque([])
cnt = 0

#連結成分のカウント

for i in range(n):
    if dist[i] != -1:
        continue
    dist[i] = 0
    q.append(i)
    while q:
        v = q.pop()
        s = g[v]
        for j in s:
            if dist[j] != -1:
                continue
            dist[j] = 0
            q.append(j)
    cnt += 1

print(cnt - 1)
Buggy python submission (verdict: Runtime Error):
!

Fixed submission:
x = int(input())
print(1 if x ==0 else 0)
Buggy python submission (verdict: Runtime Error):
s = int(input())
a = [0]*2001
a[3] = 1
for i in range(4,n+1):
    a[i] = a[i-3] + a[i-1]
mod = 10**9+7
print(a[s]%mod)

Fixed submission:
n = int(input())
mod = 10**9 + 7
import math

def cnt(n, i):
    if i == 1:
        return 1
    else:
        l = n - 3*i
        m = i-1
        return  math.factorial(l + m)//(math.factorial(l)*math.factorial(m))
        

if n == 2 or n == 1:
    print(0)
    exit()
if n == 3:
    print(1)
    exit()
else:
    ans = 0
    iter = n // 3
    for i in range(1, iter + 1):
        if i*3 <= n:
            ans += cnt(n, i)%mod
        else:
            continue
        
print(ans % mod)

Buggy python submission (verdict: Runtime Error):
n = int(input())
mod = 10**9 + 7
import math

def cnt(n, i):
    if i == 1:
        return 1
    else:
        l = n - 3*i
        m = i-1
        return  math.factorial(l + m)//(math.factorial(l)*math.factorial(m))
        

if n == 2 or n == 1:
    print(0)
if n == 3:
    print(1)
if n > 3:
    ans = 0
    iter = n // 3
    for i in range(1, iter + 1):
        if i*3 <= n:
            ans += cnt(n, i)%mod
        else:
            continue
        
print(ans % mod)

Fixed submission:
n = int(input())
mod = 10**9 + 7
import math

def cnt(n, i):
    if i == 1:
        return 1
    else:
        l = n - 3*i
        m = i-1
        return  math.factorial(l + m)//(math.factorial(l)*math.factorial(m))
        

if n == 2 or n == 1:
    print(0)
    exit()
if n == 3:
    print(1)
    exit()
else:
    ans = 0
    iter = n // 3
    for i in range(1, iter + 1):
        if i*3 <= n:
            ans += cnt(n, i)%mod
        else:
            continue
        
print(ans % mod)
Buggy python submission (verdict: Runtime Error):
def solve():    
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    b = b[::-1]
    
    l = []
    num -= 1
    for i in range(n):
        if a[i] == b[i]:
            l.append(i)
            num = a[i]
    
    ind = 0
    for i in range(n):
        if b[i] != num and a[i] != num and ind < len(l):
            b[i], b[l[ind]] = b[l[ind]], b[i]
            ind += 1
    
    if ind < len(l):
        print('No')
    else:
        print('Yes')
        print(*b)
    
                        
if __name__ == "__main__":
    solve()
             

Fixed submission:
def solve():    
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    b = b[::-1]
    
    l = []
    num = -1
    for i in range(n):
        if a[i] == b[i]:
            l.append(i)
            num = a[i]
    
    ind = 0
    for i in range(n):
        if b[i] != num and a[i] != num and ind < len(l):
            b[i], b[l[ind]] = b[l[ind]], b[i]
            ind += 1
    
    if ind < len(l):
        print('No')
    else:
        print('Yes')
        print(*b)
    
                        
if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=list(map(int,input().split()))
h=[]
for i in range(n-k+1):
    l=1
    for j in range(k):
        l*=A[k+i-1-j]
    h.append(l)
for i in range(n-k):
    if h[i]<h[i+1]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n-k):
    if A[k+i]>A[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
count=0
a=0
b=0

while count<k:
    if A[a]<B[b]:
        if k-count>=A[a]:
            count+=A[a]
            ans+=1
            if a<len(A)-1:
                a+=1
            else:
                A[a]=10**10
        else:
            print(ans)
            break
                
    if A[a]>B[b]:
        if k-count>=B[b]:
            count+=B[b]
            ans+=1
            if b<len(B)-1:
                b+=1
            else:
                B[b]=10**10
    
        else:
            print(ans)
            break
    
    if A[a]==B[b]:
        if k-count>=B[b]:
            if A[a+1]<B[b+1]:
                count+=A[a]
                ans+=1
                if a<len(A)-1:
                    a+=1
                else:
                    A[a]=10**10
            else:
                count+=B[b]
                ans+=1
                if b<len(B)-1:
                    b+=1
                else:
                    B[b]=10**10
        else:
            print(ans)
            break

Fixed submission:
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
count=0
a=0
b=0

while count<k:
    if A[a]<B[b]:
        if k-count>=A[a]:
            count+=A[a]
            ans+=1
            if a<len(A)-1:
                a+=1
            else:
                A[a]=10**10
        else:
            print(ans)
            break
                
    if A[a]>B[b]:
        if k-count>=B[b]:
            count+=B[b]
            ans+=1
            if b<len(B)-1:
                b+=1
            else:
                B[b]=10**10
    
        else:
            print(ans)
            break
    
    if A[a]==B[b]:
        if k-count>=B[b]:
            if A[a+1]<B[b+1]:
                count+=A[a]
                ans+=1
                if a<len(A)-1:
                    a+=1
                else:
                    A[a]=10**10
            else:
                count+=B[b]
                ans+=1
                if b<len(B)-1:
                    b+=1
                else:
                    B[b]=10**10
        else:
            print(ans)
            break

Fixed submission:
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=i*len(make_divisors(i))

print(ans)
    

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
    y=n//i
    ans+=i*(y*(y+1)//2)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sympy as sy
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=i*len(sy.divisors(i))
print(ans)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
    y=n//i
    ans+=i*(y*(y+1)//2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    for j in range(len(A)):
        if A[j]==b:
            A[j]=c
    #print(A)
    print(sum(A))
    

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
q=int(input())
B=[0 for i in range(10**5)]
for a in A:
    B[a-1]+=1
suma=sum(A)
for i in range(q):
    b,c=map(int,input().split())
    print(B[b-1]*(c-b)+suma)
    suma+=B[b-1]*(c-b)
    B[c-1]+=B[b-1]
    B[b-1]=0
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(len(a)):
    b[a[i]-1]+=1

for b2 in b:
    print(b2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(len(a)):
    b[a[i]-1]+=1

for b2 in b:
    print(b2)
Buggy python submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=[list(map(int,input().split()))]
del A[index(min(A))]
for a in A:
  a-=min(A)
print(max(A)-min(A))

Fixed submission:
K,N=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(A)
C=[]
for i in range(N-1):
    C.append(B[i+1]-B[i])
C.append(B[0]+K-B[N-1])
print(K-max(C))

Buggy python submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=[list(map(int,input().split()))]
print(max(A)-min(A))

Fixed submission:
K,N=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(A)
C=[]
for i in range(N-1):
    C.append(B[i+1]-B[i])
C.append(B[0]+K-B[N-1])
print(K-max(C))
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int,input().split())
x, y = x-1, y-1
d=[0 for i in range(n)]

for i in range(n):
    for j in range(n):
        m = min(abs(i-j), abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1)
        d[m] += 1
for i in range(n-1):
    print(d[i+1]//2)

Fixed submission:
n, x, y = map(int,input().split())
g = [[] for _ in range(n)]
g[0].append(1)
g[n-1].append(n-2)
g[x-1].append(y-1)
g[y-1].append(x-1)
for i in range(n-2):
    g[i+1].append(i)
    g[i+1].append(i+2)


from collections import deque
def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    return d

ans_dist = [0 for i in range(n)]

for i in range(n):
    D = bfs(i)
    for d in D:
        ans_dist[d] += 1

for i in range(n-1):
    print(ans_dist[i+1]//2)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
ans=-1
for i in range(1000):
  if int(i/100*8)==a and int(i/10)==b:
    ans==i
    break
print(ans)

Fixed submission:
a, b = map(int, input().split())
ans = -1
for i in range(1, 1250):
    if int(i/100*8) == a and int(i/10) == b:
        ans = i
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(n):
    if min(A[:i+1])==A[i]:
        cnt+=1
print(cnt)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
cnt=0
x=A[0]
for i in range(n):
    if A[i]<=x:
        cnt+=1
        x=min(x,A[i])
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
if n == 0:
    print(0)
if n == 1:
    print(0)
else:
    if n % 2 ==1:
        print(0)
    else:
        ans = 0
        l = 10
        while n>=l:
            ans += floor(n/(l))
            l *= 5
        print(ans)

Fixed submission:
n = input()
m = len(n)
n = int(n)
if n%2==1:
    print(0)
else:
    if m==1:
        print(0)
    else:
        ans = 0
        i = 1
        while  True:
            ans_plus=n//(2*5**i)
            if ans_plus==0:
                break
            ans += ans_plus
            
            i += 1
        print(ans)
Buggy python submission (verdict: Runtime Error):
x=int(input())
p=[100+i for i in range(6)]
def dp(x):
    if x<99:
        return False
    if x in p:
        return True
    else:
        if any(dp(x-i) for i in range(100,106)):
            return True
        else:
            False
print(1 if dp(x) else 0)

Fixed submission:
X = int(input())
dp = [0 for _ in range(X + 110)]
dp[0] = 1
for i in range(X + 1):
    if dp[i] == 0:
        continue
    dp[i + 100] = 1
    dp[i + 101] = 1
    dp[i + 102] = 1
    dp[i + 103] = 1
    dp[i + 104] = 1
    dp[i + 105] = 1
print(dp[X])