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

Fixed submission:
N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(str, input().split()))
  a=int(a)
  if not list_Flag[a-1] == 1:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    elif b=='AC':
      list_Flag[a-1]=1
penalty = [0] * N
for p in range(N):
    penalty[p]=list_WA[p]*list_Flag[p]
PE=sum(penalty)
AC=sum(list_Flag)
print(AC,PE)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt', 'r')
sys.stdin = f

N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(str, input().split()))
  a=int(a)
  if list_Flag[a-1] == 1:
      pass
  else:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    elif b=='AC':
      list_Flag[a-1]=1
    else:
      pass
WA=sum(list_WA)
AC=sum(list_Flag)
ans=[AC,WA]
print(' '.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(int, input().split()))
  if list_Flag[a-1] == 1:
	pass
  else:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    elif b=='AC':
      list_Flag[a-1]=1
    else:
      pass
WA=sum(list_WA)
AC=sum(list_Flag)
print(AC,WA)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
list_WA = [0]*N
list_Flag = [0]*N
for i in range(M):
  a, b = list(map(int, input().split()))
  if list_Flag[a-1] == 1:
	pass
  else:
    if b=='WA':
      list_WA[a-1]+=1
    elif b=='AC':
      list_Flag[a-1]=1
    else:
      pass
WA=sum(list_WA)
AC=sum(list_Flag)
ans=[AC,WA]
print(*ans)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split())) #問題数(リストサイズ）と提出数（ループ回数）を受ける
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(int, input().split()))
  if list_Flag[a-1] == 1:
	pass
  else:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    else:
      list_Flag[a-1]=list_Flag[a-1]+1
WA=sum(list_WA)
AC=sum(list_Flag)
ans=[AC,WA]
print(' '.join(map(str, ans)))
Problem p02628 (python)

Fixed submission:
N, K = map(int, input().split())
p = [int(x) for x in input().split()]
p.sort()

price = 0
if N > 0:
    for j in range(K):
        price += p[j]
print(price)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = []
for i in range(N):
    p.append(int(input()))
p.sort()

price = 0
if N > 0:
    for j in range(3):
        price += p[j]
print(price)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = []
for i in range(N):
    p.append(int(input()))
p.sort()

price = 0
for j in range(3):
    price += p[j]
print(price)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = []
for i in range(N):
    p.append(int(input()))
p.sort()

price = 0
for i in range(3):
    price += p[i]
print(price)
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
s = []
sort = []
for i in range(n):
    # print(i)
    s.append(input())
s.sort()
print(''.join(s))

Buggy submission (verdict: Runtime Error):
l, n = map(int, input().split())
s = []
sort = []
for i in range(n):
    s.append(input())
s.sort()
print(''.join(s))
Problem p02612 (python)

Fixed submission:
N = int(input())
mod = N%1000
if mod == 0:
  print(0)
else:
  print(1000-(N%1000))

Buggy submission (verdict: Runtime Error):
N = int(input())
result = [0,0,0,0]
for n in range(N):
    S = input()
    if S == "AC":
        result[0] += 1
    elif S == "WA":
        result[1] += 1
    elif S == "TLE":
        result[2] += 1
    else:
        result[3] += 1
name = ["AC","WA","TLE","RE"]
for res,nam in zip(result,name):
    print("%s x %d"%(nam,res))
Problem p02639 (python)

Fixed submission:
vs = list(map(int,input().split()))
for i in range(len(vs)):
    if vs[i] == 0:
        print(i+1)

Buggy submission (verdict: Runtime Error):
vs = map(int,input().split())
for i in range(len(vs)):
    if vs[i] == 0:
        print(i)

Buggy submission (verdict: Runtime Error):
as= inst(input().split())
for a in as:
    if a ==0:
       return(a)
Problem p02675 (python)

Fixed submission:
N = input()
last = int(N[-1])

if last ==3:
  print("bon")
elif last in [0,1,6,8]:
  print("pon")
else:
  print("hon")

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

last = N[-1]

if last == "2":
  ans = "hon"
elif last == "4":
  ans = "hon"
elif last == "5":
 ans = "hon"
elif last =="7":
 ans = "hon"
elif last == "9"
  ans = "hon"
elif last == "0":
  ans = "pon"
elif last == "1":
  ans = "pon"
elif last == "6":
  ans = "pon"
elif last == "8":
  ans = "pon"
else:
  ans = "bon"

print(ans)
Problem p02677 (python)

Fixed submission:
import numpy as np

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

th_a = 30*H + 0.5 * M
th_b = 6*M

theta = th_a -th_b

if theta <= 0:
  theta = -theta
if theta >= 180:
  theta = 360 - theta

if theta == 0:
  if A >= B:
    print(A-B)
  else:
    print(B-A)

elif theta == 180:
  print(A+B)

else:
  print(np.sqrt(A**2 + B**2 - 2*A*B*np.cos(theta*np.pi/180)))

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

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

th_a = 30*H
th_b = 6*M

theta = th_a -th_b

if theta <= 0:
  theta = -theta

if theta == 0:
  if A >= B:
    print(A-B)
  else:
    print(B-A)

elif theta == 180:
  print(A+B)

else:
  print(np.sqrt(A**2 + B**2 - 2*A*B*cos(theta)))

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

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

th_a = 30*H
th_b = 6*M

theta = th_a -th_b

if theta == 0:
  if A >= B:
    print(A-B)
  else:
    print(B-A)

elif theta == 180:
  print(A+B)

else:
  print(np.sqrt(A**2 + B**2 - 2*A*B*cos(theta)))
Problem p02612 (python)

Fixed submission:
n = int(input())
for i in range(10):
  pay = 1000 * (i+1)
  change = 0
  if pay >= n:
    change = pay - n
    break
print(change)

Buggy submission (verdict: Runtime Error):
n = input()
change = n[1:]
change = int(change)
print(change)
Problem p02646 (python)

Fixed submission:
def main():
  a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True

  if v - w < 0: 
    ans  = False
  elif (v - w) * t >= abs(a - b):
    ans = True
  else:
    ans = False
      
  if ans:
    print("YES")
  else:
    print("NO")            


main()

Buggy submission (verdict: Runtime Error):
def main():
  a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True

  a_can_plus = min(a + v * t, 10 ** 8)
  a_can_minus = max(a - v * t, -10 ** 8)
  b_can_plus = min(b + w * t, 10 ** 8)
  b_can_minus = max(b - w * t, -10 ** 8)
  # print(a_can_plus)
  # print(a_can_minus)
  # print(b_can_plus)
  # print(b_can_minus)

  if v - w < 0: 
    ans  = False
  elif (v - w) * t >= abs(a - b):
    ans = True
  elif a > b:
        if b_can_minus < a_can_minus:
      ans = False
    else:
      ans = True  
  elif a < b:
    if a_can_plus < b_can_plus:
      ans = False
    else:
      ans = True
      
  if ans:
    print("YES")
  else:
    print("NO")            


main()

Buggy submission (verdict: Runtime Error):
def main():
      a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True

  a_can_plus = min(a + v * t, 10 ** 8)
  a_can_minus = max(a - v * t, -10 ** 8)
  b_can_plus = min(b + w * t, 10 ** 8)
  b_can_minus = max(b - w * t, -10 ** 8)

  if v - w < 0: 
    ans  = False
  elif a > b:
    if b_can_minus < a_can_minus:
      ans = False
    else:
      ans = True  
  elif a < b:
    if a_can_plus < b_can_plus:
      ans = False
    else:
      ans = True
      
  if ans:
    print("YES")
  else:
    print("NO")            


main()

Buggy submission (verdict: Runtime Error):
def main():
      a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True
  vect = v - w
  if vect <= 0:
    ans = False
  else:
    if vect * t > abs(a - b):
      ans = True
    else:
      if (a + w * t > 10 ** 9 and b + v * t > 10 ** 9 and b > a):
        ans = True
      elif (a - w * t < -10 ** 9 and b - v * t < 10 ** 9 and b < a):
        ans = True
      else:
        ans = False
  if ans:
    print("YES")
  else:
    print("NO")   
            

main()

Buggy submission (verdict: Runtime Error):
def main():
      a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True
  vect = v - w
  if vect <= 0:
    ans = False
  else:
    if vect * t > abs(a - b):
      ans = True
    else:
      if (a + w * t > 10 ** 9 and b + v * t > 10 ** 9 and b > a):
        ans = True
      elif (a - w * t < -10 ** 9 and b - v * t < 10 ** 9 and b < a):
        ans = True
      else:
        ans = False
  if ans:
    print("YES")
  else:
    print("NO")   
            


main()
Problem p02658 (python)

Fixed submission:
def main():
  n = int(input())
  li = list(map(int,input().split()))
  li.sort()
  ans = 1
  for i in range(n):
    ans *= li[i]
    if ans > (10 ** 18):
      print(-1)
      exit()
  print(ans)


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import math

def main():
  a, b = input().split()
  a = int(a)
  b = float(b)
  c = int(b)
  d = (b - c) * 100
  ans_a = a * c
  ans_b = (a * d) // 100
  ans = math.floor(ans_b) + ans_a
  print(ans)
 
 
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  n = int(input())
  ans = 0
  for i in range(n):
    ans *= int(input())
  if ans >= 10 ** 18:
    print(-1)
  else:
    print(ans)


if __name__ == '__main__':
  main()
Problem p02866 (python)

Fixed submission:
import collections

n = int(input())
li = list(map(int,input().split()))
 
ans = 1
ans_li = collections.Counter(li)

if not li[0] == 0:
    print(0)
    exit()

if not ans_li[0] == 1:
    print(0)
    exit()

for i in range(max(ans_li)+1):
    ans *= ans_li[i] ** ans_li[i+1]
    if ans_li[i] == 0:
        print(0)
        exit()
 
print(ans % 998244353)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
 
ans = 1
ans_li = [0 for i in range(max(li))]
count = 0
 
for i in range(n):
    ans_li[li[i]] += 1
 
if not ans_li[0] == 1:
    print(0)
    exit()

for i in range(1,n-1):
    ans *= ans_li[i] ** ans_li[i+1]
 
for i in range(n-1):
    if ans_li[i] == 0 and (not ans_li[i+1] == 0):
        print(0)
        exit()
 
print(ans % 998244353)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
 
ans = 1
ans_li = [0 for i in range(max(li))]
count = 0
 
for i in range(n):
    ans_li[li[i]] += 1
 
if not ans_li[0] == 1:
    print(0)
    exit()

for i in range(1,n-1):
    ans *= ans_li[i] ** ans_li[i+1]
 
for i in range(n-1):
    if ans_li[i] == 0 and (not ans_li[i+1] == 0):
        print(0)
        exit()
 
print(ans % 998244353)
Problem p02900 (python)

Fixed submission:
import math
import fractions

x, y = map(int,input().split())

gcd = fractions.gcd(x,y)

size = int(math.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(math.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    if num > int(math.sqrt(num)):
        table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

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

x, y = map(int,input().split())

gcd = np.gcd(x,y)

size = int(np.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(np.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

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

x, y = map(int,input().split())

gcd = np.gcd(x,y)

size = int(np.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(np.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

Buggy submission (verdict: Runtime Error):
import math

x, y = map(int,input().split())

gcd = math.gcd(x,y)

size = int(math.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(math.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)
Problem p02910 (python)

Fixed submission:
x = input()
count = 0
for i in range(len(x)):
  if i % 2 == 0:
    if x[i] == "R" or x[i] == "U" or x[i] == "D":
      count += 1
    else:
      print("No")
      break
  if i % 2 == 1:
    if x[i] == "L" or x[i] == "U" or x[i] == "D":
      count += 1
    else:
      print("No")
      break
if count == len(x):
  print("Yes")

Buggy submission (verdict: Runtime Error):
x = input()
count = 0
for i in range(len(x)):
  if i % 2 == 0:
    if x[i] == "R" || x[i] == "U" || x[i] == "D":
      count += 1
    else:
      print("No")
      break
  if i % 2 == 1:
    if x[i] == "L" || x[i] == "U" || x[i] == "D":
      count += 1
    else:
      print("No")
      break
if count == len(x):
  print("Yes")
Problem p02983 (python)

Fixed submission:
l, r = map(int,input().split())

li = []

if r - l > 2018:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i + 1,r + 1):
            li.append((i * j) % 2019)
    ans = min(li)

print(ans)

Buggy submission (verdict: Runtime Error):
l, r = map(int,input().split())

l_mod = l % 2019
r_mod = r % 2019
li = []

if r - l > 2018:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i + 1,r + 1):
            li.append((i * j) % 2019)

ans = min(li)

print(ans)
Problem p02995 (python)

Fixed submission:
import fractions

a, b, c, d = map(int,input().split())

e = c * d // fractions.gcd(c,d)
c_count = b // c - a // c
if a % c == 0:
    c_count += 1
d_count = b // d - a // d
if a % d == 0:
    d_count += 1
e_count = b // e - a // e
if a % e == 0:
    e_count += 1

ans = b - a + 1 - (c_count + d_count - e_count)

print(ans)

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

a, b, c, d = map(int,input().split())

e = c * d // np.gcd(c,d)
c_count = b // c - a // c
if a % c == 0:
    c_count += 1
d_count = b // d - a // d
if a % d == 0:
    d_count += 1
e_count = b // e - a // e
if a % e == 0:
    e_count += 1

ans = b - a + 1 - (c_count + d_count - e_count)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int,input().split())

e = c * d // math.gcd(c,d)
c_count = b // c - a // c
if a % c == 0:
    c_count += 1
d_count = b // d - a // d
if a % d == 0:
    d_count += 1
e_count = b // e - a // e
if a % e == 0:
    e_count += 1

ans = b - a + 1 - (c_count + d_count - e_count)

print(ans)
Problem p02706 (python)

Fixed submission:
mn = input().split()
mn = [int(x) for x in mn]
n = mn[0]
m = mn[1]
a = input().split()
a  = [int(x) for x in a]


total = sum(a)
if n-total <0:
    print('-1')
else:
    print(n-total)

Buggy submission (verdict: Runtime Error):
mn = input().split()
mn = [int(x) for x in mn]
n = mn[0]
m = mn[1]
a = input().split()
a  = [int(x) for x in a]


total = sum(a)
if n-total <0:
    print('-1')
else:
    prtin(n-total)

Buggy submission (verdict: Runtime Error):
mn = input().split()
mn = [int(x) for x in mn]
n = mn[0]
m = mn[1]
a = input().split()
a  = [int(x) for x in a]


total = sum(a)
if n-total <0:
    print(-1)
else:
    prtin(n-total)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()
a = []
for i in range(n):
    if s[i] == 'R' :
         a.append(0)
    if s[i] == 'G' :
         a.append(1)
    if s[i] == 'B' :
         a.append(2)
cnt = [0,0,0]
for i in range(n):
    cnt[a[i]] +=1
ans = 1

for i in range(3):
    ans *= cnt[i]
# print(a)
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)
        if k<n:
            if a[i] != a[j] and  a[i] != a[k]and a[k] != a[j]:
                # print(i,j,k,a[i],a[j],a[k])
                ans -=1



# print(cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
total = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if s[i] != s[j] and  s[i] != s[k] and s[j] != s[k]:
                if j!= (k+i)/2:
                    # if j<3:
                        # print(i,j,k)
                    total += 1
print(total)
Problem p02719 (python)

Fixed submission:

NK = input().split()
N = int(NK[0])
K = int(NK[1])

# N = 1000000000
# K = 1

def func(N,K):
    prev = N 

    while(1):
        N = abs(N-K)
        if prev<=N:
            return prev
        prev = N


def fun(N,K):
    N = (N % K) 
    return N  

S=fun(N,K)
T = func(S,K)
# print('S',S)
# print('T',T)
print(T)

Buggy submission (verdict: Runtime Error):
NK = input().split()
N = int(NK[0])
K = int(NK[1]

def function(N,K):
    pre =N
    if N > K*10:
        return 0



    while(1):    
        # print('N',N)
        N = abs(N-K)
        if pre == N:
            return pre

        if pre< N:
            return pre
        pre = N 

print(function(N,K))
Problem p02741 (python)

Fixed submission:
A  = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


K  = input()
k = int(K)

print(A[k-1])

Buggy submission (verdict: Runtime Error):
A  = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


K  = input()
k = int(K)

print(A[k+1])
Problem p02760 (python)

Fixed submission:
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]

N = input()
N = int(N)



B  = [] 
for i in range(N):
    inp  =input()
    inp = int(inp)
    B.append(inp)


# arr = [[0]*3]*3
# print(arr)
# for i in range(3):
#     arr[0][i]= first_line[i]
#     print(arr)
# print(arr)
# for i in range(3):
#     arr[1][i]= second_line[i]
# for i in range(3):
#     arr[2][i]= third_line[i]

arr = []
arr.append(first_line)
arr.append(second_line)
arr.append(third_line)
carr = [[False for i in range(3)] for j in range(3)]

for b in B:
    for i in range(3):
        for j  in range(3):
            if b == arr[i][j]:
                carr[i][j] = True

def yoko(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[i][j] != True:
                flag = 1
        if flag == 0 :
            return True    
    return False


def tate(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[j][i] != True:
                flag = 1
                break
        if flag == 0:

            return  True
    
    return False

def naname (carr):
    flag2 = 0
    flag1 = 0
    for i in range(3):
        if carr[i][i] != True:
            flag1 = 1

        if carr[i][3-i-1] != True:
            flag2 = 1;
    if flag1==0 or flag2 ==0:
        return True
    else:
        return False

def checker(carr):
    # print(tate(carr))
    # print(yoko(carr))
    # print(naname(carr))
    
    if not tate(carr)  and not yoko(carr) and not naname(carr):
        return 'No'
    else:
        return 'Yes' 
print(checker(carr))

Buggy submission (verdict: Runtime Error):
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]

N = input()
N = int(N)



B = []
for i in range(N):
    inp  =input()
    inp = int(inp)
    B.append(inp)



for i in range(3):
    arr[0][i]= first_line[i]
for i in range(3):
    arr[0][i]= second_line[i]
for i in range(3):
    arr[0][i]= third_line[i]

carr = [[False]*3]*3
for b in B:
    for i in range(3):
        for j  in range(3):
            if b == arr[i][j]:
                carr[i][j] = True


def yoko(carr):
    for i in range(3):
        for j in range(3):
            if carr[i][j] != True:
                break
        return  True
    
    return False


def tate(carr):
    for i in range(3):
        for j in range(3):
            if carr[j][i] != True:
                break
        return  True
    
    return False

def naname (carr):
    for i in range(3):
        if carr[i] != True:
            for j in range(3):
                if carr[3-j-1] != True:
                    return False
            return True    
    return True


def checker(carr):
    if not tate  and not yoko and not naname:
        return 'No'
    else:
        return 'Yes' 



print(checker(carr))
Problem p02658 (python)

Fixed submission:
n = int(input())

l = list(map(int, input().split()))
l.sort()

if l[0] == 0:
  print(0)
  exit()
res = 1

for i in l:
  res *= i
  if res > 10 **18:
    print(-1)
    exit()
print(res)

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

l = list(map(int, input().split())).sort()

if l[0] == 0:
  print(0)
  exit()
res = 1

for i in l:
  res *= i
  if res > 10 **18:
    print(res)
    exit()
  print(res)
Problem p02678 (python)

Fixed submission:
from collections import deque

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

grid = [[] for _ in range(n + 1)]

ans = [0] * n
visited = [False] * n
visited[0] = True

for _ in range(m):
  s, t = map(int, input().split())
  grid[s].append(t)
  grid[t].append(s)

queue = deque([1])

while queue:
  node = queue.popleft()
  for i in grid[node]:
    if visited[i - 1]:
      continue
    visited[i - 1] = True
    ans[i - 1] = node
    queue.append(i)

print('Yes')
for i in ans[1:]:
  print(i)

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

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

grid = [[] for _ in range(n + 1)]

ans = [0] * n
visited = [False] * n
visited[0] = True

for _ in range(n):
  s, t = map(int, input().split())
  grid[s].append(t)
  grid[t].append(s)

queue = deque([1])

while queue:
  node = queue.popleft()
  for i in grid[node]:
    if visited[i - 1]:
      continue
    visited[i - 1] = True
    ans[i - 1] = node
    queue.append(i)

print('Yes')
for i in ans[1:]:
  print(i)
Problem p02741 (python)

Fixed submission:
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(l[k - 1])

Buggy submission (verdict: Runtime Error):
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(l[k])
Problem p02830 (python)

Fixed submission:
n = int(input())

a = input().split()

res = ""
for i in range(n):
  res += a[0][i]
  res += a[1][i]
print(res)

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

a = input()
b = input()

res = ""
for i in range(n):
  res += a[i]
  res += b[i]
print(res)
Problem p02615 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
# print(A)
ans = A[0]
if N >= 3:
    a = (N - 2) // 2
    b = (N - 2)  % 2
# print(a)
# print(b)
    if b == 0:
        for i in range(a):
            ans += (A[i+1] * 2)
    else:
        for i in range(a):
            ans += (A[i+1] * 2)
        ans += A[a+1]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
# print(A)
ans = A[0]
if N >= 3:
    a = (N - 2) // 2
    b = (N - 2)  % 2
# print(a)
# print(b)
if b == 0:
    for i in range(a):
        ans += (A[i+1] * 2)
else:
    for i in range(a):
        ans += (A[i+1] * 2)
    ans += A[a+1]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
print(A)
ans = A[0]
if N >= 3:
    a = (N - 2) // 2
    b = (N - 2)  % 2
print(a)
print(b)
if b == 0:
    for i in range(a):
        ans += (A[i+1] * 2)
else:
    for i in range(a):
        ans += (A[i+1] * 2)
    ans += A[a+1]
print(ans)