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

Fixed submission:
n = int(input())
if n == 2:
    a = int(input())
    b = int(input())
    print(a+b)
elif n == 1:
    print("Hello World")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
#n個に分けてあげなきゃいけない
#合計はmにならなきゃいけない。素数のときは1確定？
#10 123のとき12から試す。余りが０だといいけどこの場合は３余るこのときあまりは１〜１１
#結局この問題はmを素因数分解して２数の積で表現したときにn以上の数で表せるかって話なわけよ、
#約数っていうのはその数の二乗を境にペアになっているから小さい方で割れれば商が相方になっているというわけ
#できる限り平均的に分けてあげたほうがいいってことはわかる。
#大きい方から下って見つかって瞬間終わりにするほうが賢いかも
#候補のうち最大の数字は
i = int(m/n)
ans = 1
while i >= 1:
    if m % i == 0:
        if m / i >= n:
            ans = i
            break
    i = i-1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
#n個に分けてあげなきゃいけない
#できる限り平均的に分けてあげたほうがいいってことはわかる。
#大きい方から下って見つかって瞬間終わりにするほうが賢いかも
#候補のうち最大の数字は
i = int(m/n)
ans = 1
while n*i <= m:
    if m % i == 0 and m / i >= n:
        ans = i
        break
    i -= 1
print(ans)
Problem p02994 (python)

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

apples = []
zerochk = False
taste_sum = 0
for i in range(N):
    taste = L + i
    apples.append(taste)
    taste_sum += taste
    if taste == 0: zerochk = True


minval = 100

if zerochk:

    print('{}'.format(taste_sum))

elif L > 0:

    print('{}'.format(taste_sum - apples[0]))

else: # zerochk == True and L < 0

    for i in range(1, len(apples)):
        minval = min(minval, abs(apples[i]))

    ans = 0
    if taste_sum < 0:
        ans = abs(taste_sum) - abs(minval)
        ans *= -1
    else: # taste_sum >= 0
        ans = taste_sum - abs(minval)
    print('{}'.format(ans))

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

apple = []
zerochk = False
tastes = 0
for i in range(N):
    taste = L + i
    apple.append(taste)
    tastes += taste
    if taste == 0: zerochk = True

ans = 0
minval = 100

if zerochk:

    print('{}'.format(tastes))

else if L > 0:

    for i in range(1, len(tastes)):
        ans += tastes(i)
    
    print('{}'.format(ans))

else: # L < 0

    for i in range(1, len(tastes)):
        minval = min(minval, abs(tastes[i]))
        ans += tastes(i)

    print('{}'.format(ans) - minval)
Problem p02999 (python)

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

if X < A:
    print('{}'.format('0'))
else:
    print('{}'.format('10'))

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

if X < A:
    print('{}'.format('0'))
else:
    print('{}'.format('10'))
Problem p03047 (python)

Fixed submission:
N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if i + K - 1 <= N:
    ans += 1
  else:
    break

print('{}'.format(ans))

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

ans = 0
i = 0

while (i * R <= N):
  
  j = 0

  while (i * R + j * G <= N):

    tmp = N - (R * i) - (G * j)
    
    if tmp % B == 0 and tmp >= 0:
      ans += 1
      # print('{},{}'.format(i,j))
    j += 1
  
  i += 1

print('{0}'.format(ans))
Problem p03071 (python)

Fixed submission:
A, B = map(int, input().split())
ans = 0
for i in range(2):

  if A > 3 and A >= B:
    ans += A
    A -= 1
    continue

  if B > 3 and B > A:
    ans += B
    B -= 1
    continue
  
  if A == 3 and B == 3:
    ans += A

print(ans)

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

ans = 0
for i in range(len(H)):
  chkflg = True
  if i >= 1:
    for j in range(i): 
      if H[j] > H[i]:
        chkflg = False
        break

  if chkflg: ans += 1

print(ans)
Problem p02719 (python)

Fixed submission:
n,k = map(int,input().split())
if n > k:
    if k == 1:
        print(0)
    elif k == 2:
        print(n%2)
    else:
        mod = n%k
        if k/2 < mod:
            print(k - mod)
        else:
            print(mod)
elif n == k:
    print(0)
else:
    if 2*n > k:
        print(k-n)
    else:
        print(n)

Buggy submission (verdict: Runtime Error):
def main():
    n,k,c = map(int,input().split())
    s = list(input())
    s = list(map((lambda x: -1 if x=='o' else 0), s))
    r = s[::-1]
    ni = 0
    cnt = 0
    while(ni<n):
        if cnt>=k:
            break
        if s[ni] == -1:
            s[ni] = 1
            ni += c+1
            cnt += 1
        else:
            ni += 1
    ni = 0
    cnt = 0 
    while(ni<n):
        if cnt>=k:
            break
        if r[ni] == -1:
            r[ni] = 1
            ni += c+1
            cnt += 1
        else:
            ni += 1
    r = r[::-1]

    for i in range(n):
        if s[i] == 0:
            continue
        s_len = len([i for i in s[:i] if i==1])
        r_len = len([i for i in r[i+1:] if i==1])
        total = s_len+r_len
        # print(i)
        # print(s_len,r_len)
        if total < k:
            print(i+1)
if __name__ == '__main__':
    main()
Problem p02923 (python)

Fixed submission:
import sys
# sys.setrecursionlimit(1000000)
# N, Q = map(int, sys.stdin.readline().split())
# a_b = [list(map(int, sys.stdin.readline().split())) for _ in range(N-1)]
# p_x = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]
n = int(input())
h_l = list(map(int,input().split()))
c_l = [0 for _ in range(n)]
s = 0
# for i in range(n-1):
while s < n-1:
        for j in range(0,n-s-1):
                if h_l[s+j] >= h_l[s+1+j]:
                        c_l[s] += 1
                else:
                        break
        s = s+c_l[s]+1
        
# print(c_l)
print(max(c_l))

Buggy submission (verdict: Runtime Error):
import sys
a, b = map(int,input().split())
sum = a
count = 1
if b == 1:
        print(0)
else:
        for i in range(10000):
                if sum < b:
                        sum += (a-1)
                        count += 1
                else:
                        break
        print(count)
Problem p02947 (python)

Fixed submission:
import math
from collections import defaultdict

n = int(input())
# k,x = map(int,input().split())
s_l = []
for i in range(n):
        s = list(input())
        s.sort()
        s_l.append(''.join(s))

# for i in range(n):
#         s_l.append(''.join(sorted(s_i_l[i])))
#         # for x in sorted(s_l[i]):
#         #         a += x
#         # s_l[i] = a
cnt = 0

d = defaultdict(lambda: 0)
for s in s_l:
        d[s] += 1

for v in d.values():
        cnt += int(v*(v-1)/2)
print(cnt)

Buggy submission (verdict: Runtime Error):
import math

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

n = int(input())
# k,x = map(int,input().split())
s_l = []
for i in range(n):
        s_l.append(input())

for i in range(n):
        a = ''
        for x in sorted(s_l[i]):
                a += x
        s_l[i] = a

cnt = 0
# for i in range(n):
#         for j in range(1,n-i):
#                 if s_l[i] == s_l[i+j]:
#                         cnt += 1
set_s_l = set(s_l)
l = []
for val in set_s_l:
        l.append(s_l.count(val))
for i in l:
        cnt += c(i,2)
print(cnt)
Problem p02953 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
mx = a[0]
for i in range(1, n):
    if mx-a[i]>1:
        print("No")
        break
    mx = max(mx, a[i])
else: print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
import random
n = int(input())
h = list(map(int,input().split()))

mx = h[0]
for i in range(1, n):
        
        if mx > h[i]+1:
                print('No')
                break
        mx = max(mx,h[i+1])
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
import random
n = int(input())
h = list(map(int,input().split()))

mx = h[0]
for i in range(1, n):
        
        if mx > h[i]+1:
                print('NO')
                break
        mx = max(mx,h[i+1])
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
import random
n = int(input())
h = list(map(int,input().split()))

mx = h[0]
for i in range(1, n):
        
        if mx > h[i]+1:
                print('NO')
                break
        mx = max(mx,h[i+1])
else: print('Yes')
Problem p02995 (python)

Fixed submission:
from fractions import gcd

a, b, c, d = map(int,input().split())
cn_l, cn_r, cn_d = 0,0,0
l_list = []
r_list = []
if a%c == 0:
    start_l = a//c
else:
    start_l = a//c+1
# print('left')
cn_l = b//c+1 - start_l
# for i in range(start_l, b//c+1):
#     l_list.append(c*i)
#     cn_l += 1
if a%d == 0:
    start_r = a//d
else:
    start_r = a//d+1
# print('right')
cn_r = b//d+1 - start_r
# for i in range(start_r, b//d+1):
#     r_list.append(d*i)
#     cn_r += 1
# print(cn_l, cn_r)
# for val in l_list:
#     if val in r_list:
#         cn_d +=1
def lcm(x, y):
    return (x * y) // gcd(x, y)
lcm = lcm(c,d)
if a%lcm == 0:
    start_d = a//lcm
else:
    start_d = a//lcm+1
cn_d = b//lcm+1 - start_d
n = b-a+1
print(n-(cn_l+cn_r-cn_d))

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int,input().split())
cn_l, cn_r, cn_d = 0,0,0
l_list = []
r_list = []
if a%c == 0:
    start_l = a//c
else:
    start_l = a//c+1
# print('left')
cn_l = b//c+1 - start_l
# for i in range(start_l, b//c+1):
#     l_list.append(c*i)
#     cn_l += 1
if a%d == 0:
    start_r = a//d
else:
    start_r = a//d+1
# print('right')
cn_r = b//d+1 - start_r
# for i in range(start_r, b//d+1):
#     r_list.append(d*i)
#     cn_r += 1
# print(cn_l, cn_r)
# for val in l_list:
#     if val in r_list:
#         cn_d +=1
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
lcm = lcm(c,d)
if a%lcm == 0:
    start_d = a//lcm
else:
    start_d = a//lcm+1
cn_d = b//lcm+1 - start_d
n = b-a+1
print(n-(cn_l+cn_r-cn_d))

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int,input().split())
cn_l, cn_r, cn_d = 0,0,0
l_list = []
r_list = []
if a%c == 0:
    start_l = a//c
else:
    start_l = a//c+1
# print('left')
cn_l = b//c+1 - start_l
# for i in range(start_l, b//c+1):
#     l_list.append(c*i)
#     cn_l += 1
if a%d == 0:
    start_r = a//d
else:
    start_r = a//d+1
# print('right')
cn_r = b//d+1 - start_r
# for i in range(start_r, b//d+1):
#     r_list.append(d*i)
#     cn_r += 1
# print(cn_l, cn_r)
# for val in l_list:
#     if val in r_list:
#         cn_d +=1
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
lcm = lcm(c,d)
if a%lcm == 0:
    start_d = a//lcm
else:
    start_d = a//lcm+1
cn_d = b//lcm+1 - start_d
n = b-a+1
print(n-(cn_l+cn_r-cn_d))
Problem p02999 (python)

Fixed submission:
x, a = input().split()
if x < a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
w, h, x, y = input().split()
w, h, x, y = int(w), int(h), int(x), int(y)
if (x==0) or (y==0) or (x==w/2) or (y==h/2) or (x==w) or (y==h):
    if (x==w/2) and (y==h/2):
        print(w*h/2, 1)
    else:
        print(w*h/2, 0)
else:
    if (x < w/2) and (y < h/2):
        p = (h-y)/(w-x)
        x_pos = (p*x-y)/p
        print((w-x_pos)*h/2, 0)
    elif (x > w/2) and (y < h/2):
        p = (h-y)/-x
        x_pos = (p*x-y)/p
        print(x_pos*h/2, 0)
    elif (x < w/2) and (y > h/2):
        p = -y/(w-x)
        x_pos = (h-y+p*x)/p
        print((w-x_pos)*h/2, 0)
    elif (x > w/2) and (y > h/2):
        p = y/x
        x_pos = (h-y+p*x)/p
        print(x_pos*h/2, 0)
Problem p03071 (python)

Fixed submission:
ab = input().split()
ab[0] = int(ab[0])
ab[1] = int(ab[1])
coin = 0
for i in range(2):
  if ab[0] >= ab[1]:
    coin += ab[0]
    ab[0] = ab[0] - 1 
  else:
    coin += ab[1]
    ab[1] = ab[1] - 1 
print(coin)

Buggy submission (verdict: Runtime Error):
ab = input().split()
coin = 0
for i in range(2):
  if ab[0] >= ab[1]:
    coin += ab[0]
    ab[0] = ab[0] - 1 
  else:
    coin += ab[1]
    ab[1] = ab[1] - 1 
print(coin)

Buggy submission (verdict: Runtime Error):
ab = input().split()
coin = 0
for i in range(2):
  if ab[0] >= ab[1]:
    coin += ab[0]
    ab[0] = ab[0] - 1 
  else:
    coin += ab[1]
    ab[1] = ab[1] - 1 
print(coin)
Problem p03085 (python)

Fixed submission:
str = input()
if str == "A":
  print("T")
elif str == "T":
  print("A")
elif str == "C":
  print("G")
elif str == "G":
  print("C")

Buggy submission (verdict: Runtime Error):
str = input()
if str == "A":
  print(T)
elif str == "T":
  print(A)
elif str == "C":
  print(G)
elif str == "G":
  print(C)

Buggy submission (verdict: Runtime Error):
str = input()
if str = "A":
  print("T")
elif str = "T":
  print("A")
elif str = "C":
  print("G")
elif str = "G":
  print("C")

Buggy submission (verdict: Runtime Error):
str = input()
if str = "A":
  print(T)
elif str = "T":
  print(A)
elif str = "C":
  print(G)
elif str = "G":
  print(C)
Problem p03161 (python)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
# dp[2] = min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]))
# dp[3] = min((abs(h[3]-h[1])+dp[1]), abs(h[3]-h[2])+dp[2])
for i in range(2,n):
    ans = 10000000000000000000000000
    for j in range(1,k+1):
        if i-j >= 0:
            tmp = abs(h[i]-h[i-j])+dp[i-j]
            ans = min(ans,tmp)
    # dp[i] = min((abs(h[i]-h[i-2])+dp[i-2]), abs(h[i]-h[i-1])+dp[i-1])
    dp[i] = ans
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
# dp[2] = min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]))
# dp[3] = min((abs(h[3]-h[1])+dp[1]), abs(h[3]-h[2])+dp[2])
for i in range(2,n):
    m = 1000000
    for j in range(1,k+1):
        if i-j >= 0:
            tmp = abs(h[i]-h[i-j])+dp[i-j]
            if i == 3:
            m = min(m,tmp)
    # dp[i] = min((abs(h[i]-h[i-2])+dp[i-2]), abs(h[i]-h[i-1])+dp[i-1])
    dp[i] = m
print(dp[-1])
Problem p03436 (python)

Fixed submission:
H,W = map(int, input().split())
field = [list(input()) for _ in range(H)]
dy = [1,-1,0,0]
dx = [0,0,1,-1]


count = 0

# for i in range(H):
#     for j in range(W):
#         if field[i][j] == start:
#             sy, sx = i, j
#         elif field[i][j] == goal:
#             gy, gx = i, j
sy,sx = 0,0
gy,gx = H-1,W-1
seen = [[0 for i in range(W)] for j in range(H)]
queue = [[sy,sx]]
flag = False
while queue != []:
    h,w = queue.pop(0)
    before = seen[h][w]
    for i in range(4):
        nh = h + dy[i]
        nw = w + dx[i]
        if (nh == gy) and (nw == gx):
            count = before+1
            flag = True
        if (0<=nh<H) and (0<=nw<W):
            if field[nh][nw] != '#':
                if seen[nh][nw] == 0:
                    seen[nh][nw] = before+1
                    queue.append([nh,nw])
    if flag:
        break
whites = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == '.':
            whites += 1
if count != 0 :
    print(whites - count-1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
count = 0

# for i in range(H):
#     for j in range(W):
#         if field[i][j] == start:
#             sy, sx = i, j
#         elif field[i][j] == goal:
#             gy, gx = i, j
sy,sx = 0,0
gy,gx = H-1,W-1
seen = [[0 for i in range(W)] for j in range(H)]
queue = [[sy,sx]]
flag = False
while queue != []:
    h,w = queue.pop(0)
    before = seen[h][w]
    for i in range(4):
        nh = h + dy[i]
        nw = w + dx[i]
        if (nh == gy) and (nw == gx):
            count = before+1
            flag = True
        if (0<=nh<H) and (0<=nw<W):
            if field[nh][nw] != 'X':
                if seen[nh][nw] == 0:
                    seen[nh][nw] = before+1
                    queue.append([nh,nw])
    if flag:
        break
whites = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == '.':
            whites += 1
if count != 0 :
    print(whites - count-1)
else:
    print(-1)
Problem p02934 (python)

Fixed submission:
n = int(input())
a = list(map(float, input().split()))
s = 0.0
for i in range(n):
    a[i] = 1 / a[i]
    s += a[i]
s = 1 / s
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = [1 / a[i] for i int range(n)]
print(sum(s))
Problem p02947 (python)

Fixed submission:
n = int(input())
S = ["".join(list(sorted(input()))) for _ in range(n)]
d = {}
for i in S:
    d.setdefault(i, 0)
    d[i] += 1
ans = 0
for value in d.values():
    ans += value * (value - 1) / 2
print(int(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
S = ["".join(sorted(input())) for _ in range(n)]
d = []
for i in S:
  d.setdefault(i, 0)
  d[i] += 1
ans = 0
for value in d.values:
  ans = value * (value) / 2
print(ans)
Problem p02576 (python)

Fixed submission:
import math
n, x, t = map(int, input().split())

y = math.ceil(n / x) * t
print(int(y))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import Counter as C

h, w, m = map(int, input().split())

hs, ws = [], []
hw = []

for i in range(m):
    hi, w = map(int, input().split())
    hs.append(hi)
    ws.append(w)
    hw.append([hi, w])


ch = C(hs).most_common()
cw = C(ws).most_common()
anss = []
pre_ans = -float('inf')
mrow = ch[0][0]
mcow = cw[0][0]

for num1, num2 in zip(ch, cw):
    row, cow = num1[0], num2[0]
    if mrow > row and mcow > cow:
        break
    ans1 = hs.count(row)
    ans2 = ws.count(cow)
    ans = ans1 + ans2

    if [row, cow] in hw:
        ans -= 1

    anss.append(ans)


print(max(anss))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import Counter as C

h, w, m = map(int, input().split())

hs, ws = [], []
hw = []

for i in range(m):
    hi, w = map(int, input().split())
    hs.append(hi)
    ws.append(w)
    hw.append([hi, w])


ch = C(hs).most_common()
cw = C(ws).most_common()
anss = []
pre_ans = -float('inf')
mrow = ch[0][0]
mcow = cw[0][0]

for num1, num2 in zip(ch, cw):
    row, cow = num1[0], num2[0]
    if mrow > row and mcow > cow:
        break
    ans1 = hs.count(row)
    ans2 = ws.count(cow)
    ans = ans1 + ans2

    if [row, cow] in hw:
        ans -= 1

    anss.append(ans)

    if pre_ans >= ans:
        ans = pre_ans
    else:
        pre_ans = ans


print(max(anss))
Problem p02582 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s = input()

maxs = 0
ans = []
for a in s:
    if a == 'R':
        maxs += 1
    else:
        ans.append(maxs)
        maxs = 0


ans.append(maxs)
print(max(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
s = input()

maxs = 0
ans = []
for a in s:
    if a == 'R':
        maxs += 1
    else:
        ans.append(maxs)
        maxs = 0


print(max(ans))
Problem p02612 (python)

Fixed submission:
n = int(input())
if n % 1000 == 0:
    ans = 0
else:
    ans = 1000 - (n % 1000)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
h, w, k = map(int, input().split())
c = []
blacks = []
all_b = 0
ans = 0

for i in range(h):
    temp = input()
    temp_list = []
    for t in temp:
        temp_list.append(t)

    c.append(temp_list)
    blacks.append(c[i].count('#'))
    all_b += blacks[i]

c_t = np.array(c).T.tolist()

if all_b == k:
    ans += 1

for i in range(h):
    if k == all_b - blacks[i]:
        ans += 1

for i in range(w):
    if k == all_b - c_t[i].count('#'):
        ans += 1


for i in range(h):
    s = blacks[i]
    for j in range(i+1, h):
        if i != j:
            if k == all_b - s - blacks[j]:
                ans += 1


for i in range(w):
    temp = c_t[i].count('#')
    for j in range(i+1, w):
        if i != j:
            temp_2 = c_t[j].count('#')
            if k == all_b - temp - temp_2:
                ans += 1


for i in range(h):
    s = blacks[i]
    for j in range(w):
        counter_t = c_t[j].count('#')
        if k == all_b - counter_t - s + c[i][j].count('#'):
            ans += 1


print(ans)
Problem p02621 (python)

Fixed submission:
a = int(input())
ans = 0

for i in range(1, 4):
    ans += a ** i

print(ans)

Buggy submission (verdict: Runtime Error):


def main():
    n, m, k = map(int, input().split())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))
    ans = []
    time_sum = 0
    for i in range(n):
        for j in range(1, m):
            time_sum = sum(aa[:i]) + sum(bb[:j])
            if time_sum <= k:
                ans.append(i+j)

    if(len(ans) == 1):
        return ans[0]
    else:
        return max(ans)


if __name__ == '__main__':
    ans = main()
    print(ans)
Problem p02675 (python)

Fixed submission:
n = int(input())
ho = int(str(n)[-1])

if ho in [2, 4, 5, 7, 9]:
    print('hon')
elif ho in [0, 1, 6, 8]:
    print('pon')
else:
    print("bon")

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

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

g = [[] for _ in range(n)]  # 隣接リスト

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)


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


# 0からの各頂点の距離
d = bfs(0)
if len(d) != 0:
  print("Yes")
  for i in d[1:]:
    print(i)
else:
  print("No")
Problem p02687 (python)

Fixed submission:
s = input()

if s == "ABC":
    print("ARC")
else:
    print("ABC")

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

if s = "ABC":
    print("ARC")
else:
    print("ABC")
Problem p02706 (python)

Fixed submission:
# -*- coding: utf-8 -*-

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

ans = n - sum(a)

if ans < 0:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

ans = n - sum(a)

if ans < 0:
    return -1
else:
    return 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*i >= x:
    print("Yes")
else:
    print('No')
Problem p03361 (python)

Fixed submission:
from itertools import product

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
visited = []

def dfs(p):
    if s[p[0]][p[1]] == '.':  # p[0]gatate , p[1] gayoko
        return None

    temp = [1 if s[p[0]+y][p[1]+x] == '#' else 0 for (x, y) in [[1, 0], [0, 1], [0, -1], [-1, 0]] if 0 <= y+p[0] < h and 0 <= x+p[1] < w]
    if sum(temp) <= 0:
        print('No')
        exit(0)


for i in range(len(s)):
    for j in range(len(s[0])):
        dfs([i, j])
print('Yes')

Buggy submission (verdict: Runtime Error):
from itertools import product

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
visited = []

def dfs(p):
    if s[p[1]][p[0]] == '.':
        return None

    temp = [1 if s[p[0]+x][p[1]+y] == '#' else 0 for (y, x) in [[1, 0], [0, 1], [0, -1], [-1, 0]]
            if 0 <= x+p[0] < len(s[0]) and 0 <= y+p[1] < len(s)]
    if sum(temp) <= 0:
        print('No')
        exit(0)


for i in range(len(s)):
    for j in range(len(s[0])):
        dfs([j, i])
print('Yes')

Buggy submission (verdict: Runtime Error):
from itertools import product
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
visited = []

def dfs(p):
    if p in visited or s[p[0]][p[1]] == '.':
        return None

    temp = [1 if s[p[0]+x][p[1]+y] == '#' else 0 for (y, x) in [[1, 0], [0, 1], [0, -1], [-1, 0]]
            if 0 <= x+p[0] < len(s[0]) and 0 <= y+p[1] < len(s)]
    if sum(temp) <= 0:
        print('No')
        exit(0)


for i in range(len(s)):
    for j in range(len(s[0])):
        dfs([j, i])
print('Yes')

Buggy submission (verdict: Runtime Error):
from itertools import product
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
visited = []

def dfs(p):
    if p in visited or s[p[0]][p[1]] == '.':
        return None

    temp = [1 if s[p[0]+y][p[1]+x] == '#' else 0 for (y, x) in [[1, 0], [0, 1], [0, -1], [-1, 0]] if 0 <= y+p[0] < len(s) and 0 <= x+p[1] < len(s[0])]
    if sum(temp) <= 0:
        print('No')
        exit(0)


for i in range(len(s)):
    for j in range(len(s[0])):
        dfs([j, i])
print('Yes')