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

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

Buggy submission (verdict: Runtime Error):
V=list(map(int,input().split()))
V0=Counter(V[::2]).most_common()
V1=Counter(V[1::2]).most_common()
ans=0
if V0[0][0]==V1[0][0]:
  if len(V0)==1 and len(V1)==1:
    print(N//2)
    exit()
  elif len(V0)!=1 and len(V1)!=1:
    if V0[1][0]>=V1[1][0]:
      V0[0],V0[1]=V0[1],V0[0]
    else:
      V1[0],V1[1]=V1[1],V1[0]
  elif len(V0)>len(V1):
     V0[0],V0[1]=V0[1],V0[0]
  else:
    V1[0],V1[1]=V1[1],V1[0]
for i in range(1,len(V0)):
  ans+=V0[i][1]
for i in range(1,len(V1)):
  ans+=V1[i][1]
print(ans)
Problem p03293 (python)

Fixed submission:
from collections import deque
S=deque(input())
T=deque(input())
for i in range(len(T)):
  if S==T:
    print("Yes")
    exit()
  t=T.pop()
  T.appendleft(t)
print("No")

Buggy submission (verdict: Runtime Error):
import collections deque
S=deque(input())
T=deque(input())
for i in range(len(T)):
  if S==T:
    print("Yes")
    exit()
  t=T.popleft()
  T.appendleft(t)
print("No")
Problem p03399 (python)

Fixed submission:
A=min([int(input()) for i in range(2)])
print(A+min([int(input()) for i in range(2)]))

Buggy submission (verdict: Runtime Error):
A=min([int(input()) for i in range(2)])
print(A+min([int(input()) for i in range(2)])
Problem p03424 (python)

Fixed submission:
n=int(input())
A=sorted(list(input().split()))
if A[-1]=="Y":
  print("Four")
else:
  print("Three")

Buggy submission (verdict: Runtime Error):
n=int(input())
print("Four" if sum(["Y" if in input().split() for i in range(n)])!=0 else "Three")
Problem p03486 (python)

Fixed submission:
s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
print("Yes" if sorted(input())<sorted(input(),reversed=True) else "No")
Problem p03495 (python)

Fixed submission:
from collections import Counter
m,k=map(int,input().split())
A=list(map(int,input().split()))
d=Counter(A)
l=d.most_common()[::-1]
ans=0
i=0
while len(d)>k:
  ans+=l[i][1]
  del d[l[i][0]]
  i+=1
print(ans)

Buggy submission (verdict: Runtime Error):
m,k=map(int,input().split())
A=list(map(int,input().split()))
d=Counter(A)
l=d.most_common()[::-1]
s=set(A)
ans=0
i=0
while len(s)>k:
  ans+=l[i][1]
  del d[l[i]]
  s=len(d)
  i+=1
print(ans)
Problem p03545 (python)

Fixed submission:
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c+d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b-c+d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b+c-d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c+d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c-d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a+b-c-d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c-d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()

Buggy submission (verdict: Runtime Error):
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
  print(a+"+"+b+"+"+c+"+"+d+"="+7)
  exit()
if a-b+c+d==7:
  print(a+"-"+b+"+"+c+"+"+d+"="+7)
  exit()
if a+b-c+d==7:
  print(a+"+"+b+"-"+c+"+"+d+"="+7)
  exit()
if a+b+c-d==7:
  print(a+"+"+b+"+"+c+"-"+d+"="+7)
  exit()
if a-b-c+d==7:
  print(a+"-"+b+"-"+c+"+"+d+"="+7)
  exit()
if a-b+c-d==7:
  print(a+"-"+b+"+"+c+"-"+d+"="+7)
  exit()
if a+b-c-d==7:
  print(a+"+"+b+"-"+c+"-"+d+"="+7)
  exit()
if a-b-c-d==7:
  print(a+"-"+b+"-"+c+"-"+d+"="+7)
  exit()
Problem p03556 (python)

Fixed submission:
N=int(input())
for i in range(N):
  if (i**2)>N:
    break
print(max((i-1)**2,1))

Buggy submission (verdict: Runtime Error):
N=int(input())
for i in range(N):
  if (i**2)>N:
    break:
print(max((i-1)**2,1))
Problem p03607 (python)

Fixed submission:
N=int(input())
s=set()
for i in range(N):
  a=int(input())
  if a in s:
    s.remove(a)
  else:
    s.add(a)
print(len(s))

Buggy submission (verdict: Runtime Error):
N=int(input())
s=set()
for i in range(N):
  s^=｛input()｝
print(len(s))

Buggy submission (verdict: Runtime Error):
N=int(input())
s=set()
for i in range(N):
  a=set(int(input()))
  s^=a
print(len(a))
Problem p03624 (python)

Fixed submission:
s=set(list(input()))
a=set([chr(i+97) for i in range(26)])
a-=s
print(sorted(list(a))[0] if len(a)!=0 else "None")

Buggy submission (verdict: Runtime Error):
s=input()
a=[chr(i) for i in range(ord("a"),ord("z")+1) if i not in s]
print("None" if len(a)==0 else a[0])
Problem p03672 (python)

Fixed submission:
S=input()
for i in range(len(S)-1):
  S=S[:-1]
  N=len(S)//2
  if S==S[:N]*2:
    print(N*2)
    exit()
print(1)

Buggy submission (verdict: Runtime Error):
S=input()
for i in range(N-1):
  S=S[:-1]
  N=len(S)//2
  if S==S[:N]*2:
    print(N*2)
    exit()
print(1)
Problem p03673 (python)

Fixed submission:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
for i in range(N):
  if i%2==0:
    r.append(A[i])
  else:
    l.append(A[i])
if N%2==0:
  print(*(list(reversed(l))+r))
else:
  print(*(list(reversed(r))+l))

Buggy submission (verdict: Runtime Error):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=deque()
for i in range(N):
  if i%2==0:
    l.append(A[i])
  else:
    l.appendleft(A[i])
print(*l if N%2==0 else *list(revrsed(l)))

Buggy submission (verdict: Runtime Error):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i])
  B=reversed(B)
print("".join(B))
Problem p03738 (python)

Fixed submission:
a=int(input())
b=int(input())
print("GREATER" if a>b else "LESS" if a<b else "EQUAL")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print("GREATER", if a>b else "LESS" if a<b else "EQUAL")
Problem p03760 (python)

Fixed submission:
O=input()
E=input()
R=O[:len(E)]
print(*[r+e for r,e in zip(R,E)],sep="",end="")
if len(O)!=len(E):
  print(O[-1])

Buggy submission (verdict: Runtime Error):
O=input()
E=input()
R=[:len(E)]
print(*[e+r for e,r in zip(E,R)],sep="",end="")
if len(O)!=len(E):
  print(O[-1])
Problem p03761 (python)

Fixed submission:
from collections import Counter
N=int(input())
d={chr(i):100 for i in range(ord("a"),ord("z")+1)}
for i in range(N):
  A={chr(i):0 for i in range(ord("a"),ord("z")+1)}
  A.update(Counter(list(input())))
  for i in A:
    if d[i]>A[i]:
      d[i]=A[i]
for i in d:
  if d[i]==100:
    d[i]=0
ans=""
key=sorted(d.keys())
for i in key:
  ans+=i*d[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
d={chr(i):100 for i in range(ord("a"),ord("z")+1)}
for i in range(N):
  A=Counter(list(input()))
  for i in A:
    if d[i]>A[i]:
      d[i]=A[i]
for i in d:
  if d[i]==100:
    d[i]=0
ans=""
for i in d:
  ans=d*d[i]+ans
print(ans)
Problem p03796 (python)

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
print(math.factorial(int(input()))%(10**9+7)
Problem p04012 (python)

Fixed submission:
from collections import Counter
s=input()
d=Counter(s)
da=[i for i in d if d[i]%2==0]
if len(da)==len(set(s)):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import Counter
s=input()
d=Conter(s)
da=[i for i in d if d[i]%2==0]
if len(da)==len(set(s)):
  print("Yes")
else:
  print("No")
Problem p04030 (python)

Fixed submission:
from collections import deque
s=deque(input())
A=deque()
for i in range(len(s)):
  a=s.popleft()
  if a=="B":
    if len(A)>0:
      A.pop()
  else:
    A.append(a)
print("".join(A))

Buggy submission (verdict: Runtime Error):
from collections import deque
s=deque(input())
A=deque()
for i in range(len(s)):
  a=s.popleft()
  if a=="B":
    A.pop()
  else:
    A.append(a)
print("".join(A))
Problem p02718 (python)

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

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

As.sort(reverse=True)

al = sum(As)

ans = 'No' if al/(4*M)>As[M-1] else 'Yes'
print(ans)

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

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

As.sort(reverse=True)

al = sum(As)

ans = 'No' if al/(4*M)>As[M] else 'Yes'
print(ans)
Problem p02755 (python)

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

AA = A*100//8 + 1 if A*100%8!=0 else A*100//8
AF = (A+1)*100//8 + 1 if (A+1)*100%8!=0 else (A+1)*100//8
BB = B*10
AAA = [i for i in range(AA,AF)]
BBB = [i for i in range(BB,(B+1)*10)]
AB_list = list(set(AAA)&set(BBB))

ans = min(AB_list) if AB_list and (12<min(AB_list)<=1000) else -1
print(ans)

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

AA = A*100//8
AF = (A+1)*100//8 + 1 if (A+1)*100%8!=0 else (A+1)*100//8
BB = B*10
AAA = [i for i in range(AA,AF]
BBB = [i for i in range(BB,(B+1)*10)]
AB_list = list(set(AAA)&set(BBB))

ans = min(AB_list) if AB_list and (12<min(AB_list)<=1000) else -1
print(ans)
Problem p02801 (python)

Fixed submission:
al = input()

b = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'
b = b.split()

idx = b.index(al)
ans = b[idx+1]

print(ans)

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

INF = float('inf')

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

point_list = []
for i in range(w*h):
    point_list.append([w*h]*w*h)
maze = []

Q = deque([])


for i in range(h):
    tmp = list(input())
    maze.append(tmp)

for s_y in range(h):
    for s_x in range(w):
        if maze[s_y][s_x] == "#":
            continue
        check = []
        Q.append((s_y,s_x))
        check.append((s_y,s_x))
        point_list[s_x+s_y*w][s_x+s_y*w] = 0
        while Q:
            y, x = Q.popleft()
            if y == 0:
                pass
            elif maze[y-1][x]=="#":
                pass
            else:
                point_list[s_x+s_y*w][x+(y-1)*w] = min(point_list[s_x+s_y*w][x+(y-1)*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y-1,x) in check:
                    pass
                else:
                    check.append((y-1,x))
                    Q.append((y-1,x))
                    

            if y == h-1 :
                pass
            elif maze[y+1][x]=="#":
                pass
            else:
                point_list[s_x+s_y*w][x+(y+1)*w] = min(point_list[s_x+s_y*w][x+(y+1)*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y+1,x) in check:
                    pass
                else:
                    check.append((y+1,x))
                    Q.append((y+1,x))
                    

            if x==0:
                pass
            elif maze[y][x-1]=="#":
                pass
            else:
                point_list[s_x+s_y*w][(x-1)+y*w] = min(point_list[s_x+s_y*w][(x-1)+y*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y,x-1) in check:
                    pass
                else:
                    check.append((y,x-1))
                    Q.append((y,x-1))
                    

            if x==w-1:
                pass
            elif maze[y][x+1]=="#":
                pass
            else:
                point_list[s_x+s_y*w][(x+1)+y*w] = min(point_list[s_x+s_y*w][(x+1)+y*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y,x+1) in check:
                    pass
                else:
                    check.append((y,x+1))
                    Q.append((y,x+1))
                    
max_list = []
for i in range(w*h):
    tmp = set(point_list[i])
    if min(tmp)==w*h:
        continue
    if w*h in tmp:
        tmp.remove(w*h)
    max_list.append(max(tmp))

ans = max(max_list)
print(ans)
Problem p02818 (python)

Fixed submission:
ta_c,ao_c,num = map(int,input().split())

if num <= ta_c:
    print(ta_c-num,ao_c)
elif ta_c < num <= ta_c + ao_c:
    ao_c = ta_c+ao_c - num
    ta_c = 0
    print(ta_c,ao_c)
else:
    ta_c, ao_c = 0,0
    print(ta_c,ao_c)

Buggy submission (verdict: Runtime Error):
ta_c,ao_c,num = map(int,input().split())

if num <= ta_c:
    print(ta_o-num,ao_c):
elif ta_c < num <= ta_c + ao_c:
    ao_c = ta_c+ao_c - num
    ta_c = 0
    print(ta_c,ao_c)
else;
    ta_c, ao_c = 0,0
    print(ta_c,ao_c)

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

ta_c,ao_c,num = map(int,input().split())

for _ in [0]*num:
    if ta_c > 0:
        ta_c -=1
    elif ao_c >0:
        ao_c -=1

print(ta_c,ao_c)
Problem p02646 (python)

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


if A < B:
    A_sum = A + (V * T)
    B_sum = B + (W * T)
    if A_sum >= B_sum:
        print('YES')
    else:
        print('NO')

else:
    A_sum = A - (V * T)
    B_sum = B - (W * T)
    if A_sum <= B_sum:
        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())

A_sum = A + V * T
B_sum = B + W * T

if B > A:
    if A_sum >= B_sum:
        print('YES')
    else:
        print('NO')

else:
    if A_sum <= B_sum
        print('YES')
    else:
        print('NO')
Problem p02664 (python)

Fixed submission:
T = list(map(str, input()))
count = 0
ans = []




for i in range(0, len(T)):
    if T[i] == '?':
        ans.append('D')
    else:
        ans.append(T[i])


ans_ans = ''.join(ans);

print(ans_ans)

Buggy submission (verdict: Runtime Error):
T = list(map(str, input()))
count = 0
ans = []

if T[0] == '?':
    T.pop(0)
    if T[1] == 'D' or T[1] == '?':
        ans.append('P')
        T.insert(0, 'P')
    else:
        ans.append('D')
        T.insert(0, 'D')
else:
    ans.append(T[0])

for i in range(1, len(T)):
    if T[i] == '?':
        if ans[i - 1] == 'D':
            if len(T) % 2 == 0:
                ans.append('P')
            else:
                ans.append('D')
        else:
            ans.append('D')
    else:
        ans.append(T[i])

ans_ans = ''.join(ans);

print(ans_ans)

Buggy submission (verdict: Runtime Error):
T = list(map(str, input()))
count = 0
ans = []

if T[0] == '?':
    T.pop(0)
    if T[1] == 'D' or T[1] == '?':
        ans.append('P')
        T.insert(0, 'P')
    else:
        ans.append('D')
        T.insert(0, 'D')
else:
    ans.append(T[0])

for i in range(1, len(T)):
    if T[i] == '?':
        if ans[i - 1] == 'D':
            if len(T) % 2 == 0:
                ans.append('P')
            else:
                ans.append('D')
        else:
            ans.append('D')
    else:
        ans.append(T[i])


for i in range (0, len(ans) - 1):
    if ans[i] == 'P' and ans[i + 1] == 'D':
        count += 1
    if ans[i] == 'D':
        count += 1
if ans[len(ans) - 1] == 'D':
    count += 1



print(str(count))
Problem p02743 (python)

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

d = c - a - b
 
if d > 0 and 4 * a * b < pow(d, 2):
    print('Yes')
else:
    print('No')

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

d = c - a - b
 
if d > 0 and 4 * a * b < d * d
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

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

d = c - a - b
 
if d > 0 and 4 * a * b > d * d
    print('Yes')
else:
    print('No')
Problem p03370 (python)

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

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
m = []
count = N
X_new = X

for i in range(0, N):
	m.append(input())

print(N + (X - sum(m)) // min(m))
Problem p02705 (python)

Fixed submission:
from math import pi
r = int(input())
print(2*r*pi)

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int W[N];
    for(int i=0;i<N;i++)W[i] = 0;
    for(int i=0;i<N-1;i++){
        int A;
        cin >> A;
        W[A-1] += 1;
    }
    for(int i=0;i<N;i++){
        cout << W[i] << '\n';
    }
    return 0;
}
Problem p02709 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
N = int(input())
A = list(map(int, input().split()))
acts = [(x, i) for i, x in enumerate(A)]
acts.sort()
dp = [[-1]*N for _ in range(N)]
 
def solve(l, r):
    if r < l:
        return 0
    if dp[l][r] >= 0:
        return dp[l][r]
    k = r - l
    act, init_pos = acts[k]
    gain_l = act * abs(l - init_pos)
    gain_r = act * abs(r - init_pos)
    res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))
    return res
 
print(solve(0, N-1))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
acts = [(x, i) for i, x in enumerate(A)]
acts.sort()
dp = [[-1]*N for _ in range(N)]

def solve(l, r):
    if r < l:
        return 0
    if dp[l][r] >= 0:
        return dp[l][r]
    k = r - l
    act, init_pos = acts[k]
    gain_l = act * abs(l - init_pos)
    gain_r = act * abs(r - init_pos)
    res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))
    return res

print(solve(0, N-1))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
acts = [(x, i) for i, x in enumerate(A)]
acts.sort()
print(acts)
dp = [[-1]*N for _ in range(N)]

def solve(l, r):
    if r < l:
        return 0
    if dp[l][r] >= 0:
        return dp[l][r]
    k = r - l
    act, init_pos = acts[k]
    gain_l = act * abs(l - init_pos)
    gain_r = act * abs(r - init_pos)
    res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))
    return res

print(solve(0, N-1))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a= list(map(int,input().split()))
score=np.array(a)
b=np.sort(score)
c=b[-1::-1]
#print(c)
x=np.argsort(a)
y=x[-1::-1]
#print(y)

#c:score、y:index
cand=list(range(N))

count=0
for i in range(N):
    if (y[i]-cand[0])>(cand[-1]-y[i]):
        count+=c[i]*abs(y[i]-cand[0])
        cand.pop(0)
    elif (y[i]-cand[0])<(cand[-1]-y[i]):
        count+=c[i]*abs(cand[-1]-y[i])
        cand.pop(-1)
    else:
        if y[i+1]>y[i]:
            count+=c[i]*abs(y[i]-cand[0])
            cand.pop(0)
        else:
            count+=c[i]*abs(cand[-1]-y[i])
            cand.pop(-1) 

print(count)
Problem p02885 (python)

Fixed submission:
s=list(map(int,input().split()))
if s[0]-2*s[1]<0:
  print(0)
else:
  print(s[0]-2*s[1])

Buggy submission (verdict: Runtime Error):
n=input()
if n[0]-2*n[1]<0:
  print(0)
else:
  print(n[0]-2*n[1])

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
if s[1]-2*s[2]<0:
  print(0)
else:
  print(s[1]-2*s[2])

Buggy submission (verdict: Runtime Error):
s=input().split()
if s[1]-2*s[2]<0:
  print(0)
else:
  print(s[1]-2*s[2])
Problem p02887 (python)

Fixed submission:
n=int(input())
s=input()
sum=1
i=1
str=s[0]
while i<=n-1:
  if str == s[i]:
    i+=1
  else:
    str=s[i]
    sum+=1
    i+=1
    
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input().split())
sum=0
i=1
str=s[0]
while i<=n-1:
  if str == s[i]:
    continue
  else:
    str=s[i]
    sum+=1
print(sum)
Problem p02657 (python)

Fixed submission:
def resolve():
    N, M = [int(i) for i in input().split()]
    print(N*M)


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, M = [int(i) for i in input().split()]
    print(A*B)


resolve()
Problem p02678 (python)

Fixed submission:
def resolve():
    N, M = [int(i) for i in input().split()]
    path = [[] for _ in range(N)]
    for _ in range(M):
        A, B = [int(i) for i in input().split()]
        path[A - 1].append(B - 1)
        path[B - 1].append(A - 1)
    visited = [-1] * N
    que = [0]
    visited[0] = 0

    while que:
        v = que.pop(0)
        for nv in path[v]:
            if visited[nv] != -1:
                continue
            visited[nv] = v + 1
            que.append(nv)

    if -1 in visited:
        print("No")
    else:
        print("Yes")
        for i in range(N - 1):
            print(visited[i + 1])


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, M = [int(i) for i in input().split()]
    path = [[] for _ in range(N)]
    for _ in range(M):
        A, B = [int(i) for i in input().split()]
        path[A - 1].append(B - 1)
        path[B - 1].append(A - 1)
    visited = [-1] * N
    que = [0]
    visited[0] = 0

    while que:
        v = que.pop(0)
        print(v, path[v], file=sys.stderr)
        for nv in path[v]:
            if visited[nv] != -1:
                continue
            print(nv, visited[v] + 1, file=sys.stderr)
            visited[nv] = v + 1
            que.append(nv)

    if -1 in visited:
        print("No")
    else:
        print("Yes")
        for i in range(N - 1):
            print(visited[i + 1])


resolve()
Problem p02683 (python)

Fixed submission:
import unittest
from io import StringIO
import sys


def resolve():
    n, m, x = [int(i) for i in input().split()]
    cc = []
    aa = []
    for comb in range(n):
        c, *a = [int(comb) for comb in input().split()]
        cc.append(c)
        aa.append(a)

    ans = float('inf')
    for comb in range(2**n):
        sum = 0
        xx = [0] * m
        for i in range(n):
            if (comb >> i) & 1:
                sum += cc[i]
                for j in range(m):
                    xx[j] += aa[i][j]
        for tx in xx:
            if tx < x:
                break
        else:
            ans = min(ans, sum)

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3 10
60 2 2 4
70 8 7 9
50 2 3 9"""
        output = """120"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 10
100 3 1 4
100 1 5 9
100 2 6 5"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2"""
        output = """1067"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

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

n, m, x = map(int, input().split())
calist = []
for i in range(n):
    ca = list(map(int, input().split()))
    calist.append(ca)

# print(n, m, x, calist)

# check
for j in range(m):
    sum = 0
    for i in range(n):
        sum += calist[i][j + 1]
    if sum < x:
        print(-1)
        exit()

calist = np.array(calist)
dp = float('inf')

for comb in range(1, m + 1):
    sc = itertools.combinations(calist, comb)
    sum = 0
    a = np.array([0 for _ in range(m)])
    for ca in sc:
        sum += ca[0]
        a += ca[1:]
    if False not in (a > x) and sum < dp:
        dp = sum

print(dp)