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

Fixed submission:
n, a, b = map(int,input().split())

ans = a*(n//(a+b))+ min(a,n%(a+b))
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int,input().split())

sum = ""
k = (n//(a+b)+1)
blue = "b"*a
red = "r"*b
sum = (blue + red) * k
ans = sum[:n].count("b")
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int,input().split())

sum = ""
k = (n//(a+b)+1)
for i in range(k):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    print(ans)
    exit()
    

print(sum.count("b"))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int,input().split())

sum = ""
for i in range(10**18):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    print(ans)
    exit()
    

print(sum.count("b"))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int,input().split())

sum = ""
for i in range(10**100):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    break
    
print(ans)
Problem p02989 (python)

Fixed submission:
n= int(input())
d = list(map(int,input().split()))
d.sort()
x=int(n/2)
if d[x] == d[x-1]:
  print(0)
else:
  y = d[x] - d[x-1]
  print(y)

Buggy submission (verdict: Runtime Error):
n= int(input())
d = list(map(int,input().split()))
d.sort()
x=int(n/2)
if d[x] == d[x-1]:
  print(0)
else:
  y = d[x] - d[x-1]

print(y)

Buggy submission (verdict: Runtime Error):
n= int(input())
d = list(map(int,input().split()))
d.sort()
x=int(len(d)/2)
if d[x] == d[x-1]:
  print(0)
else:
  y = d[x] - d[x-1]

print(y)
Problem p02550 (python)

Fixed submission:
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))


def solve():
    N, X, M = it()
    if N == 1:
        return X % M
    value = defaultdict(int)
    history = defaultdict(int)
    cur = 0
    cnt = 0
    for i in range(N):
        if X in history:
            break
        value[X] = cur
        history[X] = i
        cnt += 1
        cur += X
        X = X * X % M
    period = i - history[X]
    cur += (N - cnt) // period * (cur - value[X])
    for i in range((N - cnt) % period):
        cur += X
        X = X * X % M
    return cur

if __name__ == '__main__':
    print(solve())

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))


def solve():
    N, X, M = it()
    value = defaultdict(int)
    history = defaultdict(int)
    cur = 0
    cnt = 0
    for i in range(N):
        if X in history:
            break
        value[X] = cur
        history[X] = i
        cnt += 1
        cur += X
        X = X * X % M
    period = i - history[X]
    cur += (N - cnt) // period * (cur - value[X])
    for i in range((N - cnt) % period):
        cur += X
        X = X * X % M
    return cur

if __name__ == '__main__':
    print(solve())
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a < 3200:
  print("red")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
a = input()
s = input()
if a < 3200:
  print("red")
else:
  print(s)
Problem p02935 (python)

Fixed submission:
n = int(input())
v = input().split()

v = list(map(lambda x: int(x), v))
for i in range(n-1):
  v.sort()
  v.append((v.pop(0)+v.pop(0))/2)
print(v[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
v = input().split()

v = map(lambda x: int(x), v)
for i in range(n-1):
  v.sort()
  v.append((v.pop()+v.pop())/2)
print(v[0])
Problem p02594 (python)

Fixed submission:
X = input()
ans = 'Yes' if int(X) >= 30 else 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
X = input()
ans = 'Yes' if X >= 30 else 'No'
print(ans)
Problem p02622 (python)

Fixed submission:
s = input()
t = input()
cnt = 0
for i, p in enumerate(s):
  if p != t[i]:
    cnt += 1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
cnt = 0
for i, p in enumerate(range(s)):
  if p != t[i]:
    cnt += 1
    
print(cnt)
Problem p02623 (python)

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 a[i] + b[j] > k:
    j -= 1
  ans = max(ans, i+j)

print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = input().split()
a = input().split()
b = input().split()

n = int(n)
m = int(m)
k = int(k)
a = list(map(int, a))
b = list(map(int, b))

ans = 0
temp_a = {}
temp_b = {}

for i_a in range(n+1):
  if sum(a[0:i_a]) > k:
    break
  temp_a[i_a] = sum(a[0:i_a])
for i_b in range(m+1):
  if sum(b[0:i_b]) > k:
    break
  temp_b[i_b] = sum(b[0:i_b])
  
temp_a = sorted(temp_a.items(), key=lambda x:x[1], reverse=True)
temp_b = sorted(temp_b.items(), key=lambda x:x[1], reverse=True)
ans = {}

if len(item_a) > len(item_b):
  item_a, item_b = item_b, item_a

for item_a in temp_a:
  for item_b in temp_b:
    if item_a[1] + item_b[1] > k:
      continue
    else:
      ans[len(ans)] = item_a[0] + item_b[0]
      break

ans = max(ans.values())
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = input().split()
a = input().split()
b = input().split()

n = int(n)
m = int(m)
k = int(k)
a = list(map(int, a))
b = list(map(int, b))

a.extend(b).sort()
add = 0

for item in a:
  if add >= k:
    break
  add += item
  
print(add)

Buggy submission (verdict: Runtime Error):
n, m, k = input().split()
a = input().split()
b = input().split()

n = int(n)
m = int(m)
k = int(k)
a = list(map(int, a))
b = list(map(int, b))

a = a.extend(b).sort()
add = 0

for item in a:
  if add >= k:
    break
  add += item
  
print(add)
Problem p02831 (python)

Fixed submission:
import fractions
A, B = map(int, input().split())
tmp = fractions.gcd(A,B)
print((A*B)//tmp)

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(A,B))
Problem p02984 (python)

Fixed submission:
import numpy as np

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

ans = []

ans.append(str(sum(W) - 2 * sum([W[i] for i in range(N) if i % 2 == 1])))

for i in range(1, N):
    ans.append(str( 2*W[i-1] - int(ans[i-1])))

print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

tmp = [[0 for i in range(N)] for i in range(N)]
for i in range(N):
    tmp[i][i] = 1
    tmp[i][(i+1)%N] = 1

A = np.matrix(tmp)
Y = np.matrix(W).T

ans = np.linalg.solve(A, Y)*2

tmp = []
for a in ans:
    tmp.append(str(int(a)))

print(" ".join(tmp))
Problem p02629 (python)

Fixed submission:
def xxx(n):
    alpha = "abcdefghijklmnopqrstuvwxyz"
    ans = ""
    i = 1

    while True:
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans = alpha[n%26] + ans
                n //= 26
            return ans
        else:
            n -= 26 ** i
            i += 1


N = int(input())
print(xxx(N))

Buggy submission (verdict: Runtime Error):
def xxx(n):
    ans = ""
    i = 1

    while True:
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans = char(ord("a") + n%26) + ans
                n //= 26
            return ans
        else:
            n -= 26 ** i
            i += 1


N = int(input())
print(xxx(N))

Buggy submission (verdict: Runtime Error):
def xxx(n):
    alpha = "abcdefghijklmnopqrstuvwxyz"
    ans = ""
    i = 0

    while True:
        if n <= 26 ** i:
            n -= 1
            while N > 0:
                ans = alpha[N%26-1] + ans
                N //= 26
            return ans
        else:
            n -= 26 ** i

            
N = int(input())
print(xxx(N))
Problem p02766 (python)

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

ans = 0
while True:
    N //= K
    ans += 1
    if N == 0:
        break

print(ans)

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

ans = 0
while True:
    N = N // K
    ans += 1
    if N == 0:
        break

print(ans)

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

ans = 0
while True:
    N //= K
    ans += 1
    if N == 0:
        break

print(ans)
Problem p02793 (python)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
sum_A = 0
for i in range(N):
    lcm_ = lcm(lcm_, A[i])
    sum_A += 1 / A[i]

ans = lcm_ * sum_A % mod

print(int(ans % mod))
Problem p02912 (python)

Fixed submission:
import heapq

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

for i in range(len(A)):
    A[i] *= -1

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print(-sum(A))

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

A = sorted(A)[::-1]
a = 0
for i in range(M):
    A[a] = A[a] // 2
    if a > 0:
        if A[a-1] > A[a]:
            a -= 1
    if a+1 <= len(A)-1:
        if A[a] < A[a+1]:
            a += 1
            if A[a] < A[a+1]:
                a += 1
        if a+2 <= len(A)-1:
            if A[a] in [A[a+1], A[a+1]+1]:
                if A[a] < A[a+2]:
                    a += 2

print(sum(A))

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

A = sorted(A)[::-1]
a = 0
for i in range(M):
    A[a] = A[a] // 2
    if a > 0:
        if A[a-1] > A[a]:
            a -= 1
    if a+1 <= len(A)-1:
        if A[a] < A[a+1]:
            a += 1
            if A[a] < A[a+1]:
                a += 1
        if a+2 <= len(A)-1:
            if A[a] in [A[a], A[a]+1]:
                if A[a] < A[a+2]:
                    a += 2

print(sum(A))
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
a = 9999999
for i in range(N):
    ans += B[A[i]-1]
    if A[i] == a + 1:
        ans += C[a-1]
    a = A[i]

print(ans)

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

ans = 0
a = 9999999
for i in range(N):
    ans += B[A[i]]
    if A[i] == a + 1:
        ans += C[a]
    a = A[i]

print(ans)
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
A = [[1,int(a)] for a in input().split()]
BC = A + [list(map(int,input().split())) for _ in range(M)]

BC.sort(key=lambda x:x[1], reverse=True)

i = 0
ans = 0
for B,C in BC:
    if i + B <= N:
        ans += B*C
        i += B
    else:
        ans += (N - i) * C
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = [[1,int(a)] for a in input.split()]
BC = A + [list(map(int,input().split())) for _ in range(M)]

BC.sort(key=lambda x:x[1], reverse=True)

i = 0
ans = 0
for B,C in BC:
    if i + B <= N:
        ans += B*C
    else:
        ans += (N - i) * C

print(ans)

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

card = A.copy()
for i in range(M):
    B,C = map(int, input().split())
    card += [C]*B

card.sort(reverse=True)
print(sum(card[:len(A)]))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

card = A.copy()
for B,C in BC:
    card += [C]*B

card.sort()
print(sum(card[:range(A)]))
Problem p03107 (python)

Fixed submission:
s = input()
ans = min(s.count("0"), s.count("1")) * 2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s2 = s
while "01" in s2 or "10"in s2::
    if "01" in s2:
        s2 = s2.replace("01", "")
    elif "10" in s2:
        s2 = s2.replace("10", "")

print(len(s) - len(s2))
Problem p03127 (python)

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ans = A[0]
for i in range(N):
    ans = gcd(ans, A[i])

print(ans)

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ans = A[0]
for i in range(n):
    ans = gcd(ans, A[i])

print(ans)

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

ans = A[0]
for i in range(n):
    ans = gcd(ans, A[i])

    print(ans)
Problem p03207 (python)

Fixed submission:
n = int(input())
p = [int(input()) for i in range(n)]

price = sum(p) - max(p) / 2
print(int(price))

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for i in range(n)]

price = sum(p) - max(p) / 2
print(int(price)
Problem p03242 (python)

Fixed submission:
n = input()

print(n.translate(str.maketrans({"1":"9", "9":"1"})))

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

print(n.translate(str.maketrans({"1":"9", "9":"1"}))
Problem p03631 (python)

Fixed submission:
n = input()
print("Yes" if n == n[::-1] else "No")

Buggy submission (verdict: Runtime Error):
n=input()
print("Yes" if n=n[::-1] else "No")
Problem p03804 (python)

Fixed submission:
import sys

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[k]:
                break
        else:
            print("Yes")
            sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[y+k]:
                break
        else:
            print("Yes")
            sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[y+k]:
                break
        else:
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[y]:
                break
        else:
            print("Yes")
            exit()
print("No")
Problem p02851 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*a, = map(int, input().split())

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
for i in range(len(s)):
    s[i] = (s[i] - i)%k

from collections import defaultdict
cnt = defaultdict(int)

left = 0
right = k-1
if right > n:
    right = n

for i in range(right+1):
    cnt[s[i]] += 1

ans = 0
while left < right:
    ans += cnt[s[left]]-1
    if right == n:
        cnt[s[left]] -= 1
        left += 1
    else:
        cnt[s[left]] -= 1 
        left += 1
        right += 1
        cnt[s[right]] += 1 

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*a, = map(int, input().split())

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
for i in range(len(s)):
    s[i] = (s[i] - i)%k

cnt = [0]*k
left = 0
right = k-1
if right > n:
    right = n

for i in range(right+1):
    cnt[s[i]] += 1

ans = 0
while left < right:
    ans += cnt[s[left]]-1
    if right == n:
        cnt[s[left]] -= 1
        left += 1
    else:
        cnt[s[left]] -= 1 
        left += 1
        right += 1
        cnt[s[right]] += 1 

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*a, = map(int, input().split())

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
for i in range(len(s)):
    s[i] = (s[i] - i)%k

cnt = [0]*k
left = 0
right = k-1
if right >= n:
    right = n-1

for i in range(right+1):
    cnt[s[i]] += 1

ans = 0
while left < right:
    ans += cnt[s[left]]-1
    if right == n:
        cnt[s[left]] -= 1
        left += 1
    else:
        cnt[s[left]] -= 1 
        left += 1
        right += 1
        cnt[s[right]] += 1 

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*a, = map(int, input().split())

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
for i in range(len(s)):
    s[i] = (s[i] - i)%k

cnt = [0]*k
left = 0
right = k-1
if right >= n:
    right = n-1

for i in range(right+1):
    cnt[s[i]] += 1

ans = 0
while left < right:
    ans += cnt[s[left]]-1
    if right == n:
        cnt[s[left]] -= 1
        left += 1
    else:
        cnt[s[left]] -= 1 
        left += 1
        right += 1
        cnt[s[right]] += 1 

print(ans)
Problem p02873 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

s = input()[:-1]

cnts = []

tmp = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        tmp += 1
    else:
        if s[i] == '>':
            tmp *= -1
        cnts.append(tmp)
        tmp = 1

if s[-1] == '>':
    tmp *= -1
cnts.append(tmp)

idx = 0
a = [0] * (len(s)+1)

for i in range(len(cnts)):
    if i != 0 and cnts[i-1] > 0 and cnts[i] < 0 and a[idx-1] >=  abs(cnts[i]):
        a[idx] = a[idx-1] + 1

    for j in range(abs(cnts[i])):
        if a[idx] != 0:
            idx += 1
            continue
        if cnts[i] > 0:
            a[idx] = j
        else:
            a[idx] = abs(cnts[i]) - j
        idx += 1
if s[-1] == '<':
    a[-1] = a[-2] + 1

# print(*cnts)
# print(*a)
print(sum(a))
# for i in range(len(s)):
#     print(a[i],s[i],end='')
# print(a[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

s = input()[:-1]

cnts = []

tmp = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        tmp += 1
    else:
        if s[i] == '>':
            tmp *= -1
        cnts.append(tmp)
        tmp = 1

if s[i] == '>':
    tmp *= -1
cnts.append(tmp)

idx = 0
a = [0] * (len(s)+1)
for i in range(len(cnts)):
    base = 0
    if i != 0 and cnts[i-1] > 0 and cnts[i] < 0 and a[idx-1] >= abs(cnts[i]):
        base = a[idx-1] - abs(cnts[i])
    for j in range(abs(cnts[i])):
        if cnts[i] > 0:
            a[idx] = j
        else:
            a[idx] = abs(cnts[i]) - j + base
        idx += 1
# print(*cnts)
# print(*a)
print(sum(a))
# for i in range(len(s)):
#     print(a[i],s[i],end='')
# print(a[-1])
Problem p02912 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
*a, = map(int, input().split())

ans = []
for i in range(n):
    heapq.heappush(ans, -a[i])

for i in range(m):
    temp = -heapq.heappop(ans)
    heapq.heappush(ans, -(temp//2))

print(-sum(ans))

Buggy submission (verdict: Runtime Error):
import bisect
import numpy as np

n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()

    left = 0
    right = n-2
    mid = 0
    while left < right:
        mid = (left + right) // 2
        if a[mid] > temp:
            right = mid - 1
            if right == left:
                a.insert(right+1, temp)
        elif a[mid] < temp:
            left = mid + 1
            if right == left:
                a.insert(right, temp)
        else:
            a.insert(right, temp)
            break
    
    
print(sum(a))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
import sys
 
sys.setrecursionlimit(200000000)
 
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
 
l = [[] for i in range(n+1)]
for pi in ab:  
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
 
def dfs(graph, start, oya):
    if start != 1:
        graph[start].remove(oya)
    if len(graph[start]) == 0:
        return
    else:
        for i in graph[start]:
            dfs(graph, i, start)
 
dfs(l, 1, 1)
 
def dfs_2(graph, start, ans, x):
    ans[start] += x
    if len(graph[start]) == 0:
        return
    else:
        for i in graph[start]:
            dfs_2(graph, i, ans, x)
 
ans = [0 for i in range(n+1)]
for p, x in px:
    dfs_2(l, p, ans, x)
        
for i in range(1, n+1):
    print(ans[i], end=' ')
print()
Problem p02987 (python)

Fixed submission:
s = input()

for i in range(4):
    cnt = s.count(s[i])
    if(cnt != 2):
        print('No')
        break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, n-k+2):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))
Problem p02989 (python)

Fixed submission:
n = int(input())
*d, = map(int, input().split())

d.sort()

print(d[n//2] - d[n//2-1])

Buggy submission (verdict: Runtime Error):
import math
from operator import mul
from functools import reduce

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)