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

Fixed submission:
S=input()
S=S.replace('7','8',1)

print(S)

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

a=[]
for i in range(N+1):
    for j in range(N-i+1):
        if 1000*i+5000*j+10000*(N-i-j)==Y:
            a.append(str(N-i-j))
            a.append(str(j))
            a.append(str(i))
    if len(a)!=0:
        break


if len(a)!=0:
    print(a[0]+' '+a[1]+' '+a[2])
else:
    print('-1 -1 -1')

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

a=[]
for i in range(N+1):
    for j in range(N-i+1):
        if 1000*i+5000*j+10000*(N-i-j)==Y:
            a.append(str(N-i-j))
            a.append(str(j))
            a.append(str(i))
    if len(a)!=0:
        break


if len(a)!=0:
    print(a[0]+' '+a[1]+' '+a[2])
else:
    print('-1 -1 -1')
Problem p02641 (python)

Fixed submission:
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)


	for x in range(diff+2):
		if X-x not in p:
			print(X-x)
			break
		if X+x not in p:
			print(X+x)
			break

Buggy submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)

	for x in range(0,diff+1):
		if X-x not in p
			print(X-x)
			break
		if X+x not in p
			print(X+x)
			break

Buggy submission (verdict: Runtime Error):
X,N = map(int,input().split())
p = list(map(int,input().split()))
ans = []
p.sort()

diff_1 = abs(X-p[-1])
diff_2 = abs(X-p[1])
diff = max(diff_1,diff_2)

for x in range(1,diff+1):
	if X+x not in p:
		ans.append(X+x)
		
	if X-x not in p:
		ans.append(X-x)

ans.sort()
print(ans[1])
Problem p02645 (python)

Fixed submission:
S = input()

print(S[:3])

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
	if A + (V*T) >= B + (W*T):
		print("YES")
	else:
		print("NO")
else:
	if A - (V*T) <= B - (W*T):
		print("YES")
	else:
		print("NO")

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
	if A + (V*T) >= B + (W*T):
		print("YES")
	else:
		print("NO")
else:
	if A - (V*T) <= B - (W*T):
		print("YES")
	else:
		print("NO")
Problem p02646 (python)

Fixed submission:
A,V = map(int,input().split())
B,W = map(int,input().split())

T = int(input())

dist = abs(A-B)
diff = V-W
if dist > diff * T:
	print("NO")
else:
	print("YES")

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
dist = abs(A-B)
diff = V-W
if dist > diff * T:
	print("NO")
else:
	print("YES")
Problem p02675 (python)

Fixed submission:
N = input()

if int(N[-1]) == 2 or int(N[-1]) == 4 or int(N[-1]) == 5 or int(N[-1]) == 7 or int(N[-1]) == 9:
	print("hon")
elif int(N[-1]) == 0 or int(N[-1]) == 1 or int(N[-1]) == 6 or int(N[-1]) == 8:
	print("pon")
else:
	print("bon")

Buggy submission (verdict: Runtime Error):
import math

INF = 10 ** 9
A,B,H,M = map(int,input().split())

rad_H = (360*H/12) + (0.5 * M)
rad_M = 360*M/60
diff = abs(rad_H-rad_M)

if diff > 180:
	diff = diff - 180

temp = (A ** 2) + (B ** 2) -(2*A*B*math.cos(math.radians(diff))) 
ans = math.sqrt(temp)

print(ans)
Problem p02713 (python)

Fixed submission:
import math
K = int(input())

sum = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		temp = math.gcd(i,j)
		for m in range(1,K+1):
			sum = sum + math.gcd(temp,m)

print(sum)

Buggy submission (verdict: Runtime Error):
import math
K = int(input())

sum = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		temp = math.gcd(i,j)
		for m in range(1,K+1):
			sum = sum + math.gcv(temp,m)

print(sum)
Problem p03101 (python)

Fixed submission:
H,W = map(int, input().split())
h,w = map(int, input().split())

total = H* W
ans = total - (H*w + W*h - h*w) 
print (ans)

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

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


sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j]
		sum += B[j]
	sum += C
	if sum > 0:
		count += 1

print(sum)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = []
for i in range(N):
	X.append(list(map(int, input().split())))

#Sorted by first element
X.sort(key=lambda x:x[0])
i = 0
total = 0
ans = 0

while i <= N-1:
	total += X[i][1]
	ans += X[i][0] * X[i][1]
	if total > M:
		ans -= X[i][0] * (total-M)
		break
	i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	temp1, temp2 = map(int, input().split())
	#temp1 = 1
	#temp2 = 1
	l1.append(temp1)
	l2.append(temp2)

while True:
	min_index = l1.index(min(l1))
	ans += (min(l1) * l2[min_index])
	rest -= l2[min_index]
	if rest <= 0:
		break
	l1.pop(min_index)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
l1 = []
l2 = []
ans = 0
rest = M
for i in (N+1):
	l1[i],l2[i]  = map(int, input().split())

while true:
	min_index = l1.index(min(l1))
	ans += (min(l1) * l2[min_index])
	rest -= l2[min_index]
	if rest == 0:
		break
	l1.pop(min_index)

print(ans)
Problem p03102 (python)

Fixed submission:
# ファイルをオープンする
#test_data = open("test.txt", "r")

# 行ごとにすべて読み込んでリストデータにする
#line = test_data.readline()


#N, M, C = map(int, line.split())
N, M, C = map(int, input().split())
B = []
A = []

#line = test_data.readline()


#B = [int(b) for b in line.split()]
B = [int(b) for b in input().split()]
for i in range(N):
	A.append(list(map(int, input().split())))
	#line = test_data.readline()
	#A.append(list(map(int, line.split())))

sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j] * B[j]
	sum += C
	if sum > 0:
		count += 1

print(count)

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

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


sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j]
		sum += B[j]
	sum += C
	if sum > 0:
		count += 1

print(sum)

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

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


sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j]
		sum += B[j]
	sum += C
	if sum > 0:
		count += 1

print(count)

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

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


sum = 0
count + 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j]
		sum += B[j]
	sum += C
	if sum > 0:
		count += 1

print(sum)
Problem p03103 (python)

Fixed submission:
N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = []
for i in range(N):
	X.append(list(map(int, input().split())))

#Sorted by first element
X.sort(key=lambda x:x[0])
i = 0
total = 0
ans = 0

while i <= N-1:
	num += X[i][1]
	ans += X[i][0] * X[i][1]
	if num > M:
		ans -= X[i][0] * (num-M)
		break
	i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	temp1, temp2 = map(int, input().split())
	#temp1 = 1
	#temp2 = 1
	l1.append(temp1)
	l2.append(temp2)

while True:
	min_index = l1.index(min(l1))
	if rest >= l2[min_index]:
		ans += (min(l1) * l2[min_index])
		rest -= l2[min_index]
	else:
		ans += (min(l1) * rest)
		break
	l1.pop(min_index)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	temp1, temp2 = map(int, input().split())
	#temp1 = 1
	#temp2 = 1
	l1.append(temp1)
	l2.append(temp2)

while True:
	min_index = l1.index(min(l1))
	if(rest >= l2[min_index]):
		ans += (min(l1) * l2[min_index])
		rest -= l2[min_index]
	else :
		ans += (min(l1) * rest)
		break
	l1.pop(min_index)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	temp1, temp2 = map(int, input().split())
	#temp1 = 1
	#temp2 = 1
	l1.append(temp1)
	l2.append(temp2)

while True:
	min_index = l1.index(min(l1))
	if(rest >= l2[min_index])
		ans += (min(l1) * l2[min_index])
		rest -= l2[min_index]
	else :
		ans += (min(l1) * rest)
		break
	l1.pop(min_index)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	temp1, temp2 = map(int, input().split())
	#l1[i],l2[i]  = map(int, input().split())
	l1.append(temp1)
	l2.append(temp2)

while true:
	min_index = l1.index(min(l1))
	ans += (min(l1) * l2[min_index])
	rest -= l2[min_index]
	if rest <= 0:
		break
	l1.pop(min_index)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#N = 1
#M = 1
l1 = []
l2 = []
ans = 0
rest = M
for i in range(N):
	l1[i],l2[i]  = map(int, input().split())
	#l1[0],l2[0] = 3,1

while true:
	min_index = l1.index(min(l1))
	ans += (min(l1) * l2[min_index])
	rest -= l2[min_index]
	if rest <= 0:
		break
	l1.pop(min_index)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
l1 = []
l2 = []
ans = 0
rest = M
for i in N+1:
	l1[i],l2[i]  = map(int, input().split())

while true:
	min_index = l1.index(min(l1))
	ans += min(l1) * l2[min_index]
	rest -= l2[min_index]
	if rest == 0:
		break
	l1.pop(min_index)

print(ans)
Problem p03105 (python)

Fixed submission:
A,B,C = map(int,input().split())
#A,B,C = 2,1,3
ans = B//A

if ans > C:
	ans = C

print(ans)

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

if A > B:
	tmp = B
	B = A
	A = tmp

count = 0
ans = 0

for i in range(1,A+1):
	if A % i == 0 and B % i == 0
		count += 1
		if count == K:
			ans = i
			break

print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C = int(input().split())
ans = B//A

if ans > C:
	ans = C

print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C = int(input().split())
ans = int(B/A)

if ans > C:
	ans = C

print(ans)
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())
#A, B, K = 12, 8, 2


if A > B:
	tmp = B
	B = A
	A = tmp
	#print(A,B)

d = []

for i in range(1,A+1):
	if A % i == 0 and B % i == 0:
		d.append(i)

d.reverse()
print(d[K-1])

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

if A > B:
	tmp = B
	B = A
	A = tmp

count = 0
ans = 0

for i in range(1,A+1):
	if A % i == 1 and B & i ==1
		count += 1
		if count == K:
			ans = i
			break

print(ans)
Problem p03110 (python)

Fixed submission:
# ファイルをオープンする
#test_data = open("test.txt", "r")

# 行ごとにすべて読み込んでリストデータにする
#line = test_data.readline()


N = int(input())
#N = int(line)
sum = 0
for i in range(N):
	x, u = input().split()
	#line = test_data.readline()
	#x, u = line.split()
	if u == "BTC":
		sum += float(x) * 380000
	else:
		sum += float(x)

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
	x, u = input().split()
	if u = "BTC":
		sum += int(x) * 380000
	else:
		sum += int(x)

print(sum)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

if N == 0:
    print(X)
    exit()

if X not in p:
    print(X)    
else:
    i = 1
    while p[p.index(X)] + i in p:
        i += 1
    up = p[p.index(X)] + i
    
    i = 1
    while p[p.index(X)] - i in p:
        i += 1
    down = p[p.index(X)] - i

    if abs(down-X) <= abs(up-X):
        print(down)
    else:
        print(up)

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

if N == 0:
    print(X)
    exit()

i = 0
if X not in p:
    r = bisect_left(p, X)
    l = r-1
    if abs(p[l]-X) <= abs(p[r]-X):
        print(p[l])
    else:
        print(p[r])
else:
    i = 1
    while p[p.index(X)] + i in p:
        i += 1
    up = p[p.index(X)] + i
    
    i = 1
    while p[p.index(X)] - i in p:
        i += 1
    down = p[p.index(X)] - i

    if abs(down-X) <= abs(up-X):
        print(down)
    else:
        print(up)
Problem p02642 (python)

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

M = 10**6 + 1
cnt = [0]*M

for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for i in range(M)[a::a]:
        cnt[i] += 1

ans = 0
for a in A:
    if cnt[a] == 1:
        ans += 1

print(ans)

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

M = 10**6 + 1
flag = [True]*M

for a in A:
    if flag[a+a] == False:
        continue
    for i in range(M)[a+a::a]:
        flag[i] = False

ans = 0
for a in A:
    if flag[a] == True:
        ans += 1

print(ans)

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

if len(A) == 1:
    print(0)
    exit()

ans = 0
for i in range(N-1):
    flag = True
    for j in range(i+1, N):
        if A[i] % A[j] == 0:
            flag = False
            break
    if flag:
        ans += 1

print(ans+1)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S + T[-1] == T:
  print("Yes")
else:
  print("No")

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

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

row = [i for i in range(1, N+1)]
ans = float("INF")
for i in range(1, N):
  for v in combinations(row, i):
    q = deque(v)
    cost = 0
    Asum = [0]*M
    while q:
      a = q.popleft() - 1
      cost += CA[a][0]
      for j in range(M):
        Asum[j] += CA[a][j+1]
    flag = True
    for m in range(M):
      if Asum[m] < X:
        flag = False
    if flag:
      ans = min(ans, cost)
if ans == float("INF"):
  print(-1)
else:
  print(ans)
Problem p02780 (python)

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

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

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

def dice_sum(i):
  if i == 1:
    return 1
  else:
    return i + dice_sum(i-1)

ans = 0
for i in range(N-K+1):
  sum, num, ave = 0, 0, 0
  for k in range(K):
    sum = dice_sum(p[i+k])
    num = p[i+k]
    ave += sum/num
  ans = max(ans, ave)

print(ans)

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

def dice_sum(i):
  if i == 1:
    return 1
  else:
    return i + dice_sum(i-1)

ans = 0
for i in range(N-K+1):
  sum, num, ave = 0, 0, 0
  for k in range(K):
    sum = dice_sum(p[i+k])
    num = p[i+k]
    ave += sum/num
  ans = max(ans, ave)

print(ans)
Problem p02806 (python)

Fixed submission:
N = int(input())
s, t = [0]*N, [0]*N
for i in range(N):
  s[i], t[i] = input().split()
X = input()

ans = 0
flag = False
for i in range(N):
  if flag:
    ans += int(t[i])
  if s[i] == X:
    flag = True

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = [0]*N, [0]*N
for i in range(N):
  S[i], T[i] = input().split()
X = input()

print(sum(T[S.index(X)+1:]))

Buggy submission (verdict: Runtime Error):
N = int(input())
s, t = [0]*N, [0]*N
for i in range(N):
  s[i], t[i] = map(int, input().split())
X = input()

ans = 0
flag = False
for i in range(N):
  if flag:
    ans += t[i]
  if s[i] == X:
    flag = True

print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
s, t = [0]*N, [0]*N
for i in range(N):
  s[i], t[i] = map(int, input().split())
X = input()

ans = 0
flag = False
for i in range(N):
  if flag:
    ans += t[i]
  if s[i] == X:
    flag = True

print(ans)
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
if 500*K >= X:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
if 500*K >= X:
  print("Yes")
elif:
  print("No")
Problem p02882 (python)

Fixed submission:
from math import *
a, b, x = map(int, input().split())
if a*a*b == x:
    theta = 0
elif a*a*b > 2*x:
    theta = degrees(pi/2 - atan(2*x/(a*pow(b,2))))
else:
    theta = degrees(pi/2 - atan(pow(a,3)/(2*(pow(a,2)*b - x))))
print(theta)

Buggy submission (verdict: Runtime Error):
from math import *
a, b, x = map(int, input().split())
if a*a*b >= 2*x:
  theta = degrees(pi/2 - atan(2*x/(a*pow(b,2))))
else:
  theta = degrees(pi/2 - atan(pow(a,3)/(2*(pow(a,2)*b - x))))    
print(theta)
Problem p02922 (python)

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

socket = 1
cnt = 0
while True:
  if B == 1:
    print(0)
    exit()
  else:
    socket = socket + A - 1
    cnt += 1
    if socket >= B:
      print(cnt)
      exit()

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

if B - A <= 0:
  print(0)
else:
  cnt = 0
  B -= 1
  while B - (A - 1) >= 0:
    B = B - (A - 1)
    cnt += 1
print(cnt)
Problem p02936 (python)

Fixed submission:
#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

n, q = map(int, input().split())

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)

points = [0]*N
for i in range(Q):
  p, x = map(int, input().split())
  points[p-1] += x
  
def dfs(v, pv):
  global points
  for nv in G[v]:
    if nv != pv:
      points[nv] += points[v]
      dfs(nv, v)

dfs(0, 0)
print(*points)
Problem p02969 (python)

Fixed submission:
print(3*int(input())**2)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
N, M, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
index = bisect_left(A, X)
print(min(len(A[:index]), len(A[index:])))
Problem p02993 (python)

Fixed submission:
S = input()
for i in range(1, 4):
  if S[i] == S[i-1]:
    print("Bad")
    exit()
print("Good")

Buggy submission (verdict: Runtime Error):
S = int(input())
for i in range(1, 4):
  if A[i] == A[i-1]:
    print("Bad")
    exit()
print("Good")
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 9))

N = int(input())
G = [[] for _ in range(N)]

def dfs(v, dist):
  for nv, e_dist in G[v]:
    if ans[nv] == -1:
      ans[nv] = (dist + e_dist) % 2
      dfs(nv, dist + e_dist)

for i in range(N-1):
  u, v, w = map(int, input().split())
  G[u-1].append([v-1, w])
  G[v-1].append([u-1, w])

ans = [-1] * N
dfs(0, 0)

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
N = int(input())
G = [[] for _ in range(N)]

def dfs(v, dist):
  for nv, e_dist in G[v]:
    if ans[nv] == -1:
      ans[nv] = (dist + e_dist) % 2
      dfs(nv, dist + e_dist)

for i in range(N-1):
  u, v, w = map(int, input().split())
  G[u-1].append([v-1, w])
  G[v-1].append([u-1, w])

ans = [-1] * N
dfs(0, 0)

print(*ans, sep="\n")
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())
t = S[K-1]
ans = ""
for s in S:
  if s == t:
    ans += s
  else:
    ans += "*"
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
K = int(input())
t = S[K+1]
ans = ""
for s in S:
  if s == t:
    ans += s
  else:
    ans += "*"
print(ans)
Problem p03078 (python)

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

AB = []
for i in range(X):
  for j in range(Y):
    AB.append(A[i] + B[j])
AB.sort(reverse=True)

ans = []
for i in range(min(K, len(AB))):
  for j in range(Z):
    ans.append(AB[i] + C[j])
ans.sort(reverse=True)

for i in range(K):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = [0]*X*Y
i = 0
for a in A:
    for b in B:
        AB[i] = a + b
        i += 1
AB.sort(reverse=True)

ans = [0]*min(K, len(AB)*Z)
i, j = 0, 0
for i in range(min(K, len(AB))):
    for c in C:
        ans[j] = AB[i] + c
        j += 1
ans.sort(reverse=True)

for i in range(K):
    print(ans[i])
Problem p03109 (python)

Fixed submission:
y, m, d = map(int, input().split("/"))
if y * 365 + m * 30 + d > 2019 * 365 + 4 * 30 + 30:
  print("TBD")
else:
  print("Heisei")

Buggy submission (verdict: Runtime Error):
y, m, d = input().split("/")
if y * 365 + m * 12 + d > 2019 * 365 + 4 * 12 + 30:
  print("TBD")
else:
  print("Heisei")
Problem p03361 (python)

Fixed submission:
H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
for i in range(H):
  for j in range(W):
    up = down = left = right = "."
    if S[i][j] == "#":
      if i-1 >= 0:
        up = S[i-1][j]
      if j-1 >= 0:
        left = S[i][j-1]
      if i+1 <= H-1:
        down = S[i+1][j]
      if j+1 <= W-1:
        right = S[i][j+1]
      if up == down == left == right == ".":
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
S = [list(input()) for _ in range(W)]
for i in range(H):
  for j in range(W):
    up = down = left = right = "#"
    if S[i][j] == "#":
      if i-1 >= 0:
        up = S[i-1][j]
      if j-1 >= 0:
        left = S[i][j-1]
      if i+1 <= H-1:
        down = S[i+1][j]
      if j+1 <= W-1:
        right = S[i][j+1]
      if up == down == left == right == ".":
        print("No")
        exit()
print("Yes")
Problem p03370 (python)

Fixed submission:
N, X = map(int, input().split())
m = [int(input()) for _ in range(N)]
print(N + (X - sum(m)) // min(m))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
m = [int(input()) for _ in range(N)]
print(N + (X - m) // min(m))
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
    if 500*i + 100*j + 50*k == X:
      cnt += 1
print(cnt)