Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

saisyo = float("inf")
for i in range(2**N):
    a = [0]*M
    gokei = 0
    for j in range(N):
        if (i>>j)&1:
            gokei += A[j][0]
            for k in range(1, M+1):
                a[k-1] += A[j][k]
    if all(a[l] >= X for l in range(M)):
        saisyo = min(saisyo, gokei)

print(saisyo if saisyo != float("inf") else -1)

Buggy submission (verdict: Runtime Error):
import itertools

N, M, X = map(int, input().split())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

saisyo = float("inf")
for i in intertools.product(range(2), N):
    a = [0]*M
    gokei = 0
    for j in range(N):
        if i[j] == 1:
            gokei += A[j][0]
            for k in range(1, M+1):
                a[k-1] += A[j][k]
    if min(a) >= X:
        saisyo = min(saisyo, gokei)

print(saisyo if saisyo != float("inf") else -1)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [i-1 for i in A]

check = [0]*N
i = 0
c = 1
check = []
visited = [0]*N
flag = False
while c<=K:
    if visited[i] == 1:
        flag = True
        break
    else:
        check.append(i)
        visited[i] = 1
        i = A[i]
        c += 1
if flag==True:
    X = check[check.index(i):]
    print(1+X[(K-check.index(i))%len(X)])  
else: 
    print(i+1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [i-1 for i in A]

check = [0]*N
i = 0
c = 0
check = []
visited = [0]*N
flag = False
while c<=K:
    if visited[i] == 1:
        flag = True
        break
    else:
        check.append(i)
        visited[i] = 1
        i = A[i]
        c += 1
if flag==True:
    X = check[check.index(i):]
    print(1+X[(K-check.index(i))%(len(check)-check.index(i)))  
else: 
    print(i+1)
Problem p02691 (python)

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))

L = [i+j for i, j in enumerate(A)]
R = [i-j for i, j in enumerate(A)]

l = collections.Counter(L)
r = collections.Counter(R)

ans = 0
for i in l.keys():
    ans += l[i]*r[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int, input().split()))

L = [i+j for i, j in enumerate(A)]
R = [i-j for i, j in enumerate(A)]

l = collections.Counter(L)
r = collections.Counter(R)

for i in l.keys():
    ans += l[i]*r[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int, input().split()))

L = [i+j for i, j in enumerate(A)]
R = [i-j for i, j in enumerate(A)]

l = collections.Counter(L)
r = collections.Counter(L)

for i in l.keys():
    ans += l[i]*r[i]

print(ans)
Problem p02708 (python)

Fixed submission:
N, K = map(int, input().split())

ans, saidai, saisyo = 0, 0, 0
for i in range(1, N+2):
    saisyo += i-1
    saidai += N-i+1
    if i >= K:
        ans += (saidai - saisyo + 1)
    
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

ans = 0
for i in range(1, N+2):
    saisyo += i-1
    saidai += N-i+1
    if i >= K:
        ans += (saidai - saisyo + 1)
    
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

for i in range(1, N+2):
    saisyo += i-1
    saidai += N-i+1
    if i >= K:
        ans += (saidai - saisyo + 1)
    
print(ans%(10**9+7))
Problem p02713 (python)

Fixed submission:
import math

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        x = math.gcd(i, j)
        for k in range(1, K+1):
            ans += math.gcd(x, k)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        x = math.gcd(i, j)
        for k in range(1, K+1):
            count += math.gcd(x, k)

print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())

P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
        
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

A=P[:X]+Q[:Y]+R

A.sort(reverse=True)

print(sum(A[:X+Y]))

Buggy submission (verdict: Runtime Error):
N, Y, A, B, C = map(int, input().split())

P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
        
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

A=P[:X]+Q[:Y]+R

A.sort(reverse=True)

print(A[X+Y])
Problem p02732 (python)

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))

gokei = 0
counter = collections.Counter(A)
for i in counter.values():
    gokei += i * (i - 1) // 2

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    d = counter[z]
    if ans[z] == 0:
        e = gokei - (d * (d - 1) // 2 - (d-1) * (d - 2) // 2)
        ans.append(e)
        print(e)
    else:
        print(ans[z])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))

B=sorted(set(A))
sa = []
gokei = 0
for i in range(len(B)):
    x = A.count(B[i])
    if x == 1:
        continue
    elif x ==2:
        gokei += 1
        sa.append(1)
    else:
        z = math.factorial(x)//(math.factorial(x-2)*math.factorial(2))
        gokei += z
        sa.append(z-z*(x-2)//x)

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    if ans[z] == 0:
        e = gokei - sa[B.index(z)]
        ans.append(e)
        print(e)
    else:
        print(ans[z])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))

B=sorted(set(A))
sa = []
gokei = 0
for i in range(len(B)):
    x = A.count(B[i])
    if x == 1:
        continue
    elif x ==2:
        gokei += 1
        sa.append(1)
    else:
        y = x-1
        z = math.factorial(x)//(math.factorial(x-2)*math.factorial(2))
        gokei += z
        sa.append(z-math.factorial(y)//(math.factorial(y-2)*math.factorial(2)))

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    if ans[z] == 0:
        e = gokei - sa[B.index(z)]
        ans.append(e)
        print(e)
    else:
        print(ans[z])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))

B=sorted(set(A))
sa = []
gokei = 0
for i in range(len(B)):
    x = A.count(B[i])
    if x == 1:
        continue
    elif x ==2:
        gokei += 1
        sa.append(1)
    else:
        y = x-1
        z = math.factorial(x)//math.factorial(x-2)//math.factorial(2)
        gokei += z
        sa.append(z-math.factorial(y)//math.factorial(y-2)//math.factorial(2))

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    if ans[z] == 0:
        e = gokei - sa[B.index(z)]
        ans.append(e)
        print(e)
    else:
        print(ans[z])
Problem p02756 (python)

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
x = 1
l=[]
for i in range(Q):
    a, *b = input().split()
    if a == "1":
        x *= -1
    elif a == "2":
        c, d = b
        if (c == "2" and x == -1) or  (c == "1" and x == 1):
            S.appendleft(d)
        else:
            S.append(d)
if x == -1:
    S.reverse()
print(*S, sep="")

Buggy submission (verdict: Runtime Error):
from collections import deque
S = deque(input())
Q = int(input())
x = 1
l=[]
for i in range(Q):
    l=[]
    l = list(input().split())
    if l[0] == "1":
        x *= -1
    elif l[0] == "2":
        if (l[1] == "2" and x == -1) or  (l[1] == "1" and x == 1):
            S.appendleft(l[2])
        else:
            S.append(l[2])
if x == -1:
    S = S[::-1]
print(*S, sep="")

Buggy submission (verdict: Runtime Error):
from collections import deque
S = deque(input())
Q = int(input())
x = 1
l=[]
for i in range(Q):
    l=[]
    l = list(input().split())
    if l[0] == "1":
        x *= -1
    elif l[0] == "2":
        if (l[1] == "2" and x == -1) or  (l[1] == "1" and x == 1):
            S.appendleft(l[2])
        else:
            S.append(l[2])
if x == -1:
    S = S[::-1]
print(*S, sep="")

Buggy submission (verdict: Runtime Error):
xxfrom collections import deque
S = deque(input())
Q = int(input())
x = 1
l=[]
for i in range(Q):
    l=[]
    l = list(input().split())
    if l[0] == "1":
        x *= -1
    elif l[0] == "2":
        if (l[1] == "2" and x == -1) or  (l[1] == "1" and x == 1):
            S.appendleft(0, l[2])
        else:
            S.append(l[2])
if x == -1:
    S = S[::-1]
print(*S, sep="")

Buggy submission (verdict: Runtime Error):
S = list(input())
Q = int(input())
x = 1
l=[]
for i in range(Q):
    l = list(input().split())
    if l[0] == "1":
        x *= -1
    elif l[0] == "2":
        if (l[1] == "2" and x == -1) or  (l[1] == "1" and x == 1):
            S.insert(0, d)
        else:
            S.append(d)
if x == -1:
    S = S[::-1]
print(*S, sep="")

Buggy submission (verdict: Runtime Error):
S = list(input())
Q = int(input())
x = 1
for i in range(Q):
    a, *b = input().split()
    if a == "1":
        x *= -1
    elif a == "2":
        c, d = b
        if (c == "2" and x == -1) or  (c == "1" and x == 1):
            S.appendleft(d)
        else:
            S.append(d)
if x == -1:
    S = S[::-1]
print(*S, sep="")

Buggy submission (verdict: Runtime Error):
S = list(input())
Q = int(input())
x = 1
for i in range(Q):
    a, *b = input().split()
    if a == "1":
        x *= -1
    elif a == "2":
        c, d = b
        if (c == "2" and x == -1) or  (c == "1" and x == 1):
            S.appendleft(d)
        else:
            S.append(d)
if x == -1:
    S = S[::-1]
print(*S, sep="")
Problem p02760 (python)

Fixed submission:
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(input())
B=set(B)
if set(A[0]) <= B or set(A[1]) <= B or set(A[2]) <= B or {A[0][0], A[1][0], A[2][0]} <= B or\
{A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B \
or {A[0][0], A[1][1], A[2][2]} <= B or {A[0][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(input())
B=set(B)
if set(A[0]) <= B or set(A[1]) <= B or set(A[2]) <= B or {A[0][0], A[1][0], A[2][0]} <= B or\
{A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B \
or {A[0][0], A[1][1], A[2][2]} <= B or {A[0][2], A[1][1], A[2][0]} <= setB:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(input())
B=set(B)
if {A[0]} <= B or {A[1]} <= B or {A[2]} <= B or {A[0][0], A[1][0], A[2][0]} <= B or\
 {A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B or {A[0][0], A[1][1], A[2][2]} <= B or {A[2][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = set()
for i in range(N):
    B.append(input())
if {A[0]} <= B or {A[1]} <= B or {A[2]} <= B or {A[0][0], A[1][0], A[2][0]} <= B or {A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B or {A[0][0], A[1][1], A[2][2]} <= B or {A[2][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = set()
for i in range(N):
    B.append(input())
if {A[0]} <= B or {A[1]} <= B or {A[2]} <= B or {A[0][0], A[1][0], A[2][0]} <= B or {A[0][1], A[1][1], A[2][1]} <= B or \
{A[0][2], A[1][2], A[2][2]} <= B or {A[0][0], A[1][1], A[2][2]} <= B or {A[2][2], A[1][1], A[2][0]} <= B:
print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = set()
for i in range(N):
    B.append(input())
if {A[0]} <= B or {A[1]} <= B or {A[2]} <= B or {A[0][0], A[1][0], A[2][0]} <= B, {A[0][1], A[1][1], A[2][1]} <= B or //
{A[0][2], A[1][2], A[2][2]} <= B or {A[0][0], A[1][1], A[2][2]} <= B or {A[2][2], A[1][1], A[2][0]} <= B:
print("Yes")
else:
    print("No")
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
A=[]
for j in range(M):
    s, c = map(int, input().split())
    A.append([s-1, str(c)])
if N == 1:
    b = 0
elif N == 2:
    b= 10
else:
    b = 100
ans=[]
for i in range(b, 1000):
    a = 0
    for j in range(M):
        x=str(i)
        if len(x) < N:
            break 
        if A[j][1] == x[A[j][0]]:
            a += 1
    if a == M:
        ans.append(i)
if ans == []:
    print(-1)
else:
    print(min(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0]*N
for i in range(M):
    s, c = map(int, input().split())
    d = a[s-1]
    if s == 1 and c == 0:
        print("-1")
        break
    if d != 0:
        a[s-1] = min(c, d)
    else:
        a[s-1] = c
if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
else:
    if a[0] == 0:
        a[1] = 1
        print(*a, sep="") 
    else:
        print(*a, sep="")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0]*N
for i in range(M):
    s, c = map(int, input().split())
    d = a[s-1]
    if s == 1 and c == 0:
        print("-1")
        break
    if d != 0:
        a[s-1] = min(c, d)
    else:
        a[s-1] = c
if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
else:
    if a[0] == 0:
        a[1] == 1
        print(*a, sep="") 
    else:
        print(*a, sep="")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0]*N
for i in range(M):
    s, c = map(int, input().split())
    if a[s-1] =! 0:
        a[s-1] = min(c, a[s-1])
if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
else:
    if a[0] != 0:
        print(*a, sep="") 
    else:
        print("-1")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0]*M
for i in range(M):
    s, c = map(int, input().split())
    a[s-1] = c
if a[0] == 0:
    print("-1")
else:
    print(*a, sep="")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0]*M
for i in range(M):
    s, c = map(int, input().split())
    a[s-1] = c
if a[0] == 0:
    print("-1")
else:
    print(*a, sep="")
Problem p02772 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = True
for i in A:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            continue
        else:
            ans = False
print("APPROVED" if ans==True else "DENIED")

Buggy submission (verdict: Runtime Error):
ans = True
for i in A:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            continue
        else:
            ans = False
print("APPROVED" if ans==True else "DENIED")
Problem p02791 (python)

Fixed submission:
N = int(input())
list=list(map(int, input().split()))
count=0
m=list[0]
for i in list:
    if m >= i:
        count+=1
    m = min(m, i)
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
list=list(input().split() for j in range(N))
count=0
m=list[0]
for i in list:
    a=i
    if m >= a:
        count+=1
    m = a
print(count)
Problem p02801 (python)

Fixed submission:
C=str(input())
abc=['a', 'b', 'c', 'd' , 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(abc[abc.index(C)+1])

Buggy submission (verdict: Runtime Error):
C=str(input())
abc=['a', 'b', 'c', 'd' , 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(abc[abc.index(C)+1)])
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
P=0
AC = [0]*(N+1)
WA = [0]*(N+1)
for i in range(M):
    p, s =input().split()
    if s == "AC":
        AC[int(p)] = 1
    else:
        if AC[int(p)] == 1:
            continue
        else:
            WA[int(p)] += 1
for i in range(N+1):
    if AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
P=[]
S=[]
for i range(M):
  p, s = map(int, input().split())
  count('WA')
  count('AC')
  P.append(p)
  S.append(s)
  if i in range(M):
    index=P.index(i+1)
    if S[index]=='WA':
      WA+=1
    else:
      AC=1
      if AC!=0:
        WA=0
      return break
print(AC, WA)
Problem p02803 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())

G = []
for i in range(H):
    G.append(list(input()))


move = [[0, 1], [0, -1], [-1, 0], [1, 0]]
saidai = 0
for sy in range(H):
    for sx in range(W):
        if G[sy][sx] == ".":
            queue = deque([[sy, sx]])
            visited = [[-1]*W for i in range(H)]
            visited[sy][sx] = 0
            while queue:
                y, x = queue.popleft()
                for i in move:
                    iy, ix = i[0], i[1]
                    if 0<=iy+y<H and 0<=ix+x<W and G[iy+y][ix+x] =="." and visited[iy+y][ix+x] == -1:
                        visited[iy+y][ix+x] = visited[y][x] + 1
                        queue.append([iy+y, ix+x])
        
            for i in range(H):
                for j in range(W):
                        saidai = max(saidai, visited[i][j])
            queue = []
            visited = [[0]*W for i in range(H)]
print(saidai)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())

G = []
for i in range(H):
    G.append(list(input()))


move = [[0, 1], [0, -1], [0, 1], [1, 0]]
saidai = 0
for sy in range(H):
    for sx in range(W):
        if G[sy][sx] == "#":
            break
        queue = deque([[sy, sx]])
        G[sy][sx] = 0
        visited = [[0]*W for i in range(H)]
        while queue:
            y, x = queue.popleft()
            for i in move:
                iy, ix = i[0], i[1]
                if 0<=iy+y<H and 0<=ix+x<W and G[iy+y][ix+x] =="." and visited[iy+y][ix+x] == 0:
                    visited[iy+y][ix+x] = 1
                    G[iy+y][ix+x] = G[y][x] + 1
                    queue.append([iy+y, ix+x])
 
        for i in range(H):
            for j in range(W):
                if G[i][j] == "#":
                    continue
                else:
                    saidai = max(saidai, G[i][j])

print(saidai)
Problem p02837 (python)

Fixed submission:
N = int(input())

X = [[-1]*N for i in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        b, c = map(int, input().split())
        X[i][b-1] = c
ans = 0
for i in range(2**N):
    Y = [0]*(N)
    for j in range(N):
        if ((i >> j) & 1):
            Y[j] = 1
    flag = True
    for j in range(N):
        if Y[j] == 1:
            for k in range(N):
                if X[j][k] == -1:
                    continue
                if X[j][k] != Y[k]:
                    flag = False
    if flag:
        ans = max(ans, sum(Y))

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())

X = [[[-1]*N] for i in range(N)]
for i in range(N):
    a = int(input())
    for i in range(a):
        b, c = map(int, input().split())
        X[i][b-1] = c
ans = 0
for i in range(2**N):
    Y = [0]*(N)
    for j in range(N):
        if ((i >> j) & 1):
            Y[j] = 1
    for j in range(N):
        if Y[j] == 1:
            for k in range(N):
                if X[j][k] == -1:
                    continue
                if X[j][k] != Y[j]:
                    Y[j] = 0
    ans = max(ans, sum(Y))

print(ans)
Problem p02838 (python)

Fixed submission:
import numpy as np
 
data = int(input())
array = np.fromiter(map(int, input().split()), np.int64)
 
result = 0
for bit in range(60):
    array01 = int((array & 1).sum())
    result = (result + array01 * (data - array01) * (1 << bit)) % 1000000007
    array >>= 1
print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
mod = 10**9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   
    n_1 = np.count_nonzero((A >> n)&1)   
    n_0 = N - num_1                       
    ans += ((2 ** n)*n_1*n_0) % mod

print(ans%mod)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
mod = 10**9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   
    n_1 = np.count_nonzero((A >> n)&1)   
    n_0 = N - num_1                       
    ans += ((2 ** n)*n_1*n_0) % mod

print(ans%mod)
Problem p02850 (python)

Fixed submission:
from queue import deque

N = int(input())

A = []
B = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    A.append([a, b])
    
for i, j in A:
    B[i-1].append(j-1)

q = deque([0])
color = [-1]*N
ans = {}
saidai = 0
while q:
    nord = q.popleft()
    c = 0
    for i, v in enumerate(B[nord]):
        if color[nord] == i:
            c += 1
        color[v] = c + i 
        ans[(nord, v)] = c + i
        q.append(v)
        saidai = max(saidai,i+c+1)

print(saidai)

for i, j in A:
    print(1+ans[(i-1, j-1)])

Buggy submission (verdict: Runtime Error):
from queue import deque

N = int(input())

A = []
B = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    A.append([a, b])
    B[a-1].append(b-1)

X = max(len(i) for i in B)

print(X)

q = deque([0])
color = [[-1]*N]
ans = {}
while q:
    nord = q.popleft()
    c = 0
    for i, v in enumerate(B[nord]):
        if color[v] == i:
            c += 1
        color[i] = c + i 
        ans[(nord, i)] = c + i
        q.append(v)

for i, j in B:
    print(ans[(i-1, j-1)]+1)
Problem p02882 (python)

Fixed submission:
import math

a, b, x = map(int, input().split())

if x >= a**2*b/2:
    print(math.degrees(math.atan(2*(a**2*b-x)/a**3)))

else:
    print(math.degrees(math.atan(b**2*a/(2*x))))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

if x >= a**2*b/2:
    print(math.degrees(math.atan(2*(a**2*b-x)/a**3)))

else:
    print(math.degrees(math.atan(a**2*b/(2*x)))
Problem p02886 (python)

Fixed submission:
import itertools

N = int(input())
D = list(map(int, input().split()))
S = list(itertools.accumulate(D))

ans = 0
for i in range(N-1):
    ans += D[i]*(S[-1]-S[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
import collections

N = int(input())
D = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += reduce(mul, D)
    queue.popleft()
print(ans)
Problem p02888 (python)

Fixed submission:
import bisect

N = int(input())

A = list(map(int, input().split()))

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(A, A[a]+A[b])-b-1

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N = int(input())

A = list(map(int, input().split()))

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(A, A[a]+A[b])-j-1

print(ans)

Buggy submission (verdict: Runtime Error):
N = input()

A = list(map(int, input().split()))

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            if A[c] < (A[a] + A[b]):
                ans += 1
            else:
                break

print(ans)

Buggy submission (verdict: Runtime Error):
N = input()

A = list(map(int, input().split()))

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            if A[c] < (A[a] + A[b]):
                ans += 1
                print(a, b, c)
            else:
                break

print(ans)