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

Fixed submission:
N, A, B = map(int, input().split())
print(sum(i for i in range(1, N+1) if A <= sum(map(int, str(i))) <= B))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split)
List = []
for i in range(1, N+1):
  f1 = i // 100
  f2 = (i - 100 * f1) // 10
  f3 = (i - 100 * f1 - 10 * f2) 
  s1 = f1 + f2 + f3
  List.append(s1)
for i in List:
  if not A <= i <= B:
    List.remove(i)
s2 = sum(List)
print(s2)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split)
List = []
for i in range(1, N+1):
  f1 = i // 100
  f2 = (i - 100 * f1) // 10
  f3 = (i - 100 * f1 - 10 * f2) 
  s1 = f1 + f2 + f3
  List.append(s1)
for i in List:
  if not A <= i <= B:
    List.del[i]
s2 = sum(List)
print(s2)
Problem p02641 (python)

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

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break

Buggy submission (verdict: Runtime Error):
from bisect import bisect
from bisect import insort
 
X,N=list(map(int,input().split()))
if N != 0:
	p=list(map(int,input().split()))
 
	not_list=[]
	for i in range(1,101):
		if i not in p and i != X:
			not_list.append(i)
 
	a=bisect(not_list,X)
	insort(not_list,X)
 
	ans1=not_list[a]-not_list[a-1]
	ans2=not_list[a+1]-not_list[a]
 
	if ans1 < ans2:
		print(not_list[a-1])
	elif ans1 == ans2:
		print(not_list[a-1])
	else:
		print(not_list[a+1])
            
else:
	print(X)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
from bisect import insort

X,N=list(map(int,input().split()))
if N != 0:
	p=list(map(int,input().split()))

	not_list=[]
	for i in range(1,101):
		if i not in p:
			not_list.append(i)

		a=bisect(not_list,X)
		insort(not_list,X)

		ans1=not_list[a]-not_list[a-1]
		ans2=not_list[a+1]-not_list[a]

		if ans1 < ans2:
			print(not_list[a-1])
		elif ans1 == ans2:
			print(not_list[a-1])
		else:
			print(not_list[a+1])
            
else:
	print(X)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
from bisect import insort

X,N=list(map(int,input().split()))
if N != 0:
	p=list(map(int,input().split()))

	not_list=[]
	for i in range(1,101):
		if i not in p:
			not_list.append(i)

		a=bisect(not_list,X)
		insort(not_list,X)

		ans1=not_list[a]-not_list[a-1]
		ans2=not_list[a+1]-not_list[a]

		if ans1 < ans2:
			print(not_list[a-1])
		elif ans1 == ans2:
			print(not_list[a-1])
		else:
			print(not_list[a+1])
            
else:
	print(X)
Problem p02700 (python)

Fixed submission:
a,b,c,d=list(map(int,input().split()))
 
while True:
	c-=b
	if c<=0:
		print("Yes")
		break
	a-=d
	if a<=0:
		print("No")
		break

Buggy submission (verdict: Runtime Error):
a,b,c,d=list(map(int,input().split()))
 
while True:
	c-=b
    if c<=0:
		print("Yes")
		break
    a-=d
	if a<=0:
		print("No")
		break
Problem p02718 (python)

Fixed submission:
from fractions import Fraction
n,m=map(int,input().split())
a=list(map(int,input().split()))

cnt=0

for i in a:
	if (sum(a))*(Fraction(1,4*m))<=i:
		cnt+=1
		if cnt==m:
			print("Yes")
            
if cnt<m:
	print("No")

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split())
a=list(map(int,input().split()))
 
cnt=0
 
for i in a:
	if (s/(4*m))<=i:
		cnt+=1
		if cnt==m:
			print("Yes")
            
if cnt<m:
	print("No")
Problem p02724 (python)

Fixed submission:
n=int(input())
 
if n!=0:
	ans1=n//500
	sub=n-(ans1*500)
	ans2=sub//5
 
	print((ans1*1000)+(ans2*5))
 
else:
	print(0)

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

if n!=0:
	ans1=n//500
	sub=n-(ans1*500)
	ans2=sub//5

	print((ans1*1000)+(ans2*5))

else:
	print(0)
Problem p02730 (python)

Fixed submission:
s = input()
n = len(s)
sl = s[:n//2]
sr = s[n//2+1:]
if sl == sr and sr ==  sr[::-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
n=s
 
if s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n]==reversed(s[((n+3)//2)-1:n]):
print("Yes")
 
else:
	print("No")

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

if s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n] and reversed(s[((n+3)//2)-1:n]):
print("Yes")

else:
	print("No")
Problem p02755 (python)

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

for i in range(2000):
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        exit()
print(-1)

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

e=0
t=0

for i in range(1,100):
	if a<=i*0.08<a+1:
		e=i
	if b<=i*0.1<b+1:
		t=i
	if e==t:
		print(e)
        
print(-1)
Problem p02767 (python)

Fixed submission:
from numpy import average
from decimal import Decimal, ROUND_HALF_UP

n=int(input())
x=list(map(int,input().split()))

p=Decimal(str(average(x))).quantize(Decimal('0'),rounding=ROUND_HALF_UP)

ans=0
for i in x:
	ans+=((i-p)**2)

print(ans)

Buggy submission (verdict: Runtime Error):
from numpy import average

n=int(input())
x=list(map(int,input().split()))

p=int(average(x))

ans=0
for i in range(x):
	ans+=((i-p)**2)

print(ans)
Problem p02802 (python)

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
wa=0
ac=0
check = [0]*n
for _ in range(m):
	a, b = input().split()
	i = int(a)
	if check[i]==0:
		if b == "WA":
			wa+=1
		elif b == "AC":
			ac+=1
			check[i]=1
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
wa=0
ac=0
check = [0]*n
for _ in range(m):
	a, b = input().split()
    i = int(a)
	if check[i]==0:
		if b == "WA":
			wa+=1
		elif b == "AC":
			ac+=1
			check[i]=1
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
wa=0
ac=0
check = [0]*n
for _ in range(m):
	a, b = input().split()
	if check[int(a)]==0:
		if b == "WA":
			wa+=1
		elif b == "AC":
			ac+=1
			check[int(a)]=1
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
wa=0
ac=0
check = [0]*n
for _ in range(m):
	a, b = input().split()
	if check[int(a)]==0:
		if b == "WA":
			wa+=1
		elif b == "AC":
			ac+=1
			check[int(a)]=1
print(ac,wa)
Problem p02952 (python)

Fixed submission:
n=int(input())
 
r=0
 
for i in range(1,n+1):
	if len(str(i))%2==1:
		r+=1
print(r)

Buggy submission (verdict: Runtime Error):
n=int(input())
 
r=0
 
for i in range(1,n+1)
	if len(str(i))%2==1:
    	r+=1
print(r)

Buggy submission (verdict: Runtime Error):
n=int(ibput())
 
r=0
 
for i in range(1,n+1):
	if len(str(i))%2==1:
		r+=1
print(r)

Buggy submission (verdict: Runtime Error):
n=int(ibput())
 
r=0
 
for i in range(1,n+1):
	if len(str(i))%2==1:
    	r+=1
print(r)

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

r=0

for i in range(1,n+1)
	if len(str(i))%2==1:
    	r+=1
print(r)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
 
ans=[]
 
for i in range(1,min(a,b)+1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[-k])

Buggy submission (verdict: Runtime Error):
a,b,k=list(map(int,input().split()))
 
ans=[]
 
for i in range(1,min(a,b)+1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[k+1])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
 
ans=[]
 
for i in range(1,min(a,b)+1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[k+1])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
 
ans=[]
 
for i in range(1,min(a,b)+1):
	if a%i==0 and b%i==0:
		ans.append[i]
print(ans[k+1])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
 
cnt=0
 
for i in range(1,max(a,b)):
	ans=0
	if a%i==0 and b%i==0:
		ans+=i
		cnt+=1
	if cnt==k:
		break
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
 
cnt=0
 
for i in range(1,min(a,b)):
	ans=0
	if a%i==0 and b%i==0:
		ans+=i
		cnt+=1
	if cnt==k:
		break
print(ans)

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

ans=0
cnt=0

for i in range(1,max(a,b)+1)
	if a%i==0 and b%i==0:
		ans+=i
		cnt+=1
	if cnt==k:
		print(ans)
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
l=0
for i in s:
    if i=="1":
        l+=1
    else:
        break
print("1" if k<=l else s[l])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=="1":
	print(int(s[1]))
else:
	print(int(s[0]))

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=="1":
	print(int(s[1])
else:
	print(int(s[0]))
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
if a*b%2==0:
	print("Even")
else:
	print("Odd")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b%2==0:
	print("Even")
else:
	pritn("Odd")
Problem p03493 (python)

Fixed submission:
n=input()
print(n.count("1"))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(n.count(1))
Problem p02576 (python)

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

if N % X:
	print((N // X + 1) * T)
else:
	print(N // X * T)

Buggy submission (verdict: Runtime Error):
N, X, T = input().split()

if N / X:
	print(N / X * T)
else:
	print((N / X + 1) * T)
Problem p02811 (python)

Fixed submission:
k, x = input().split()

if int(x) <= int(k)*500:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input()
k = input()

X = int(x)
K = int(k)

if X <= K*500:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input()
k = input()

if int(x) <= int(k)*500:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input()
k = input()

if x <= k*500:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input()
k = input()

if x <= k*500:
    print("Yes")
else:
    print("No")
Problem p02885 (python)

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

answer = a - 2 * b

if (answer < 0):
  print(0)
else:
  print(answer)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()

if B > A/2:
  print(0)
else:
  print(A-2*B)
Problem p02886 (python)

Fixed submission:
N = int(input())
d = [int(x) for x in input().split()]

f = sum(d)
s = 0

for i in d:
  s += i * (f-i)
print(s//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = [int(x) for x in input().split()]
f = sum(d)
s = 0

for i in f:
  s += i * (f-i)

print(s//2)

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

answer = 0

for x in N:
  for y in N-1:
    w = d[x]*d[y]/2
    answer += w

print(answer)
Problem p02887 (python)

Fixed submission:
N = int(input())
c = [str(x) for x in input()]

a = N
for i in range(N-1):
  if c[i]==c[i+1]:
    a -= 1
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
c = [int(x) for x in input().split()]

a = N

for i in N - 2:
  if c[i]==c[i+1]:
    a -= 1

print(a)
Problem p02888 (python)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(N-2):
  j = i + 1
  k = N - 1
  while j < k:
    if l[i] < l[j] + l[k]:
      ans += k - j
      j += 1
    else:
      k -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
 
ans = 0
 
for i in range(n-2):
  j = i + 1
  k = n - 1
  while j < k:
    if l[i] < l[j] + l[k]:
    	ans += k - j
    	j += 1
  	else:
  		k -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)

ans = 0

for i in range(n-2):
  j = i + 1
  k = n - 1
  if l[i] < l[j] + l[k]:
    ans += k - j
    j += 1
  else:
    k -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [int(x) for x in input().split()]

L = sorted(l,reverse=True)
a = 0

for x in range(0,N-3):
  for y in range(x+1,N-2):
	for i in range(y+1,N-1):
	  if L[i] > L[x] - L[y]:
		a += 1
print(a)
Problem p02899 (python)

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

ans=[0]*n

for i, x in enumerate(a):
  ans[x-1] = str(i+1)
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = []
for index, i in enumerate(a):
  A[i -1] = index + 1
print(' '.join(A))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = []
for index, i in enumerate(a):
  A[i] = index + 1
print(A)
Problem p02909 (python)

Fixed submission:
now = input()
weather = ["Sunny","Cloudy","Rainy"]
print(weather[(weather.index(now)+1) % 3])

Buggy submission (verdict: Runtime Error):
now = input()
weather = ["Sunny","Cloudy","Rainy"]
print(weather[weather.index(now)+1 % 3])
Problem p02945 (python)

Fixed submission:
a, b= map (int, input().split())
plus = a + b
m = a - b
x = a * b
print(max(plus,m,x))

Buggy submission (verdict: Runtime Error):
a, b=map(int, input().split())
puls = a + b
m = a - b
x = a * b
print(max(plus,m,x))

Buggy submission (verdict: Runtime Error):
a, b=map(int, input().split())
int puls = a + b
int m = a - b
int x = a * b
print(max(plus,m,x))

Buggy submission (verdict: Runtime Error):
input int=a, int=b
int puls = a + b
int m = a - b
int x = a * b
print(max(plus,m,x))
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = sum(1 for i in range(n-2) if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
int count = 0
p[] = map(int,input(),split())
for (i=0; i < n-2; i++){
  if p[i] < p[i+1] < p[i+2]: count ++;}
print(count)
Problem p02999 (python)

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

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
ans = 1

for i in range(N):
    D += L[i]
    if D <= X:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
ans = 1

for i in range(n):
  d += l[i]
  if d < x:
    ans += 1
  else:
    break
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
ans = 1

for i in range(n):
  d += l[i]
  if d < x:
    ans ++;
  else:
    break
    
print(ans)

Buggy submission (verdict: Runtime Error):
a, x = int(input().split())
print("0" if x < a else "10")
Problem p03000 (python)

Fixed submission:
N, X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = 0
ans = 1

for i in range(N):
    D += L[i]
    if D <= X:
        ans += 1

print(ans)

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

int d = 0;
for i in range(n):
  if d < x:
    d += l[i]
  else:
    break
    
print(i)
Problem p03813 (python)

Fixed submission:
n = int(input())
print("ABC" if 0 <= n < 1200 else "ARC")

Buggy submission (verdict: Runtime Error):
print("ABC" if int input() < 1200 else "ARC")
Problem p03998 (python)

Fixed submission:
A = list(input())
B = list(input())
C = list(input())

n = A.pop(0)
while True:
  if n == 'a':
    if A == []:
      print('A')
      break
    n = A.pop(0)
  elif n == 'b':
    if B == []:
      print('B')
      break
    n = B.pop(0)
  else:
    if C == []:
      print('C')
      break
    n = C.pop(0)

Buggy submission (verdict: Runtime Error):
n = A.pop(0)
while True:
  if n == 'a':
    if A == []:
      print('A')
      break
    n = A.pop(0)
  elif n == 'b':
    if B == []:
      print('B')
      break
    n = B.pop(0)
  else:
    if C == []:
      print('C')
      break
    n = C.pop(0)
Problem p04030 (python)

Fixed submission:
s = input()
ans = ''
for x in s:
  if x != 'B':
    ans += x
  elif x == 'B' and x != '':
    ans = ans[:-1]
  else:
    continue
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = ''
a_s = s[::-1]
b = 0
for index, x in enumerate(a_s):
  if x == 'B':
    b += 1
  elif b == 0:
	ans.append(x)
  else:
    b -= 1
print(ans[::-1])
Problem p04043 (python)

Fixed submission:
a, b, c = map(int, input().split())
if (a==b == 5 and c ==7) or (a==c == 5 and b ==7) or (c== b == 5 and a ==7):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = map(int, input().split())
return (s[0] == s[1] == 5 and s[2] == 7 or s[2] == s[1] == 5 and s[0] == 7 or s[0] == s[2] == 5 and s[1] == 7)

Buggy submission (verdict: Runtime Error):
s = map(int, input().split())
return (s[0] == s[1] == 5 and s[2] == 7 or s[2] == s[1] == 5 and s[0] == 7 s[0] == s[2] == 5 and s[1] == 7)
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
k = [input() for x in range(n)]
print(''.join(sorted(k)))

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = []
for i in range(n):
  S[i] = input()
ans = ''.jion(sorted(S))
print(ans)

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = []
for i in n:
  S[i] = input()
ans = ''.jion(sorted(S))
print(ans)
Problem p02730 (python)

Fixed submission:
S = str(input())
N = len(S)
num = (N-1)/2
num1 = (N+2)/2
if(S[:int(num)]==S[int(num1):]):
    print("Yes")
else:
    print("No")

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

a = list(combinations(range(N), 2))
b = list(combinations(range(M), 2))
print(len(a)+len(b))
Problem p02765 (python)

Fixed submission:
n,r= map(int,input().split())
if n >= 10:
    print(r)
else:
    r  = r + 100*(10-n)
    print(r)

Buggy submission (verdict: Runtime Error):
inp = input().split(" ")
N = int(inp[0])
R = int(inp[1])
if N >= 10:
    iner_r = R
else:
    iner_r  = R + 100*(10-N)
return iner_r
Problem p02607 (python)

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy

def main():
    n, *a = map(int, read().split())
    if n == 1:
        if a[0] % 2 == 1:
            print(1)
        else:
            print(0)
        sys.exit()
    r = 0
    for i1 in range(0,n,2):
        r += a[i1] % 2 == 1
    print(r)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, *a = map(int, read().split())
    r = 0
    for i1, ae in enumerate(a):
        if (i1+1)&1 and ae&1:
            r += 1
    print(r)

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

Fixed submission:
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = a[0]
    for i1 in range(1, n):
        if r > largenum:
            print(-1)
            sys.exit()
        else:
            r *= a[i1]
    print(r)

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

Fixed submission:
from copy import deepcopy
def main():
    global flags, edges
    n, m = map(int, input().split())

    flags = {e:[n+1, n+1] for e in range(1, n + 1)}
    flags[1][1] = 0
    edges = {e:set() for e in range(1, n + 1)}
    edge_list = []
    for _ in range(m):
        a, b = map(int, input().split())
        edges[a].add(b)
        edges[b].add(a)
        edge_list.append((a, b))

    distance = 1
    node_next = list(edges[1])
    node_next_next = []
    while node_next:
        for next in node_next:
            if flags[next][1] > distance:
                flags[next][1] = distance
                node_next_next += edges[next]
        node_next = deepcopy(node_next_next)
        node_next_next = []
        distance += 1
    for edge in edge_list:
        e1 = edge[0]
        e2 = edge[1]
        if flags[e1][1] == flags[e2][1]:
            pass
        elif flags[e1][1] > flags[e2][1]:
            flags[e1][0] = min(flags[e1][0], e2)
        else:
            flags[e2][0] = min(flags[e2][0], e1)
    result = [flags[f][1] < (n + 1) for f in flags if f > 1]
    if not all(result):
        print('No')
    else:
        print('Yes')
        for i1 in range(2, n + 1):
            print(flags[i1][0])
            
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

flags = {}
edges = {}

def dfs(next, before, distance):
    global flags, edges
    if next == 1:
        return
    elif flags[next][1] < distance:
        return
    else:
        flags[next][0] = before
        flags[next][1] = distance
        nexts_tmp = edges[next]
        for n in nexts_tmp:
            dfs(n, next, distance + 1)

def main():
    global flags, edges
    n, m = map(int, input().split())
    flags = {e:[0, n+1] for e in range(1, n + 1)}
    edges = {e:set() for e in range(1, n + 1)}
    for _ in range(m):
        a, b = map(int, input().split())
        edges[a].add(b)
        edges[b].add(a)

    next_from1 = edges[1]
    for n1 in next_from1:
        dfs(n1,1,1)
    result = [flags[f][1] < (n + 1) for f in flags if f > 1]
    if not all(result):
        print('No')
    else:
        print('Yes')
        for i1 in range(2, n + 1):
            print(flags[i1][0])


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

Fixed submission:

from itertools import combinations
from copy import deepcopy
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(list(map(int, input().split())))
    books_pattern = []
    books_num = [i for i in range(n)]
    for i1 in range(1, n + 1):
        books_pattern += list(combinations(books_num, i1))
    skill_set = []

    for ebp in books_pattern:
        skill_pattern = [0] * (m + 1)
        for ebpe in ebp:
            book_e = books[ebpe]
            for i2 in range(m + 1):
                skill_pattern[i2] += book_e[i2]
        skill_set.append(skill_pattern)

    skill_set_ok = []
    for ess in skill_set:
        tess = deepcopy(ess[1:])
        tessc = [i for i in tess if i >= x]
        if len(tessc) == m:
            skill_set_ok.append(ess[0])
    if len(skill_set_ok) > 0:
        print(min(skill_set_ok))
    else:
        print(-1)





if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    books_pattern = product((0, 1), repeat=n)
    for each_pattern in books_pattern:
        books_set = [0] * (m + 1)
        for i in each_pattern:
            if i:
                for i2 in range(m + 1):
                    books_set[i2] += books[i][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)

if __name__ == '__main__':
    main()