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

Fixed submission:
#137 +-x
A = list(map(int,input().split()))
print(max(A[0]+A[1], A[0]-A[1], A[0]*A[1]))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print(max(A+B, A-B, A*B))
Problem p02946 (python)

Fixed submission:
K,X=map(int,input().split())
for i in range(max(-1000000,X-K+1),min(1000000,X+K-1)+1):
    print(i)

Buggy submission (verdict: Runtime Error):
K,X=map(int,input().split());print(for i in range(min(-1000000,X-K+1),max(1000000,X+K-1)))
Problem p02957 (python)

Fixed submission:
#135  Harmony
A,B = map(int, input().split())
print((A+B)//2 if (A+B)%2 == 0 else 'IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
print((A+B)/2 if (A+B)%2 == 0)
Problem p02958 (python)

Fixed submission:
N=int(input())
p=list(map(int,input().split()))
q=[i for i in range(1,N+1)]
c=0
for i in range(N):
    if p[i]!=q[i]:
        c+=1
print('YES' if c==0 or c==2 else 'NO')

Buggy submission (verdict: Runtime Error):
#135 0 or 1 Swap
N=int(input())
P=map(int,input().split())
c=0
for i in range(1,N):
    if P[i-1]>P[i]:
        c+=1
print('YES' if c==0 or c==2 else 'NO')
Problem p02981 (python)

Fixed submission:
#133 T or T
N,A,B = map(int,input().split())
print(min(N*A,B))

Buggy submission (verdict: Runtime Error):
N,D=map(int,input().split())
c=0
X=[[0]*D]*N
for l in range(N):
    X[l]=list(map(int,input().split()))
for i in range(N-1):
    l=0
    for j in range(i+1,N):
        for k in range(D):
            l+=(X[i][k]-X[j][k])**2
        if pow(l,0.5).is_integer() == True:
            c+=1
print(c)

Buggy submission (verdict: Runtime Error):
print(min(int(input())*int(input()),int(input())))
Problem p02993 (python)

Fixed submission:
S=list(input())
c=0
for i in range(3):
    if S[i]==S[i+1]:
        c+=1
print('Bad' if c>0 else 'Good')

Buggy submission (verdict: Runtime Error):
A = input()
print('Bad' if A[0] == A[1] or A[1] == A[2] or A[2] == A[3] or A[3] == A[4]  else 'Good')

Buggy submission (verdict: Runtime Error):
A =input()
print('Bad' if A[0] == A[1] | A[1] == A[2] | A[2] == A[3] | A[3] == A[4]  else 'Good')

Buggy submission (verdict: Runtime Error):
A = inout()
print('Bad' if A[i] == A[i+1] for i in range(4) else 'Good')
Problem p03160 (python)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
 
dp = [0]*N
dp[1] = abs(H[0] - H[1])
for i in range(2,N):
    dp[i] = min(dp[i-2] + abs(H[i-2]-H[i]), dp[i-1] + abs(H[i-1]-H[i]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
def dp(i):
    if i>=n-1:
        return 0
    elif i==n-2:
        return dp(i+1)+abs(h[i]-h[i+1])
    else:
        return min(dp(i+1)+abs(h[i]-h[i+1]),dp(i+2)+abs(h[i]-h[i+2]))
print(dp(0))
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
 
res = [abs(T-h*0.006-A) for h in H]
print(res.index(min(res))+1)

Buggy submission (verdict: Runtime Error):
#Palace
N,T,A,*H = map(int,open(0).read().split())
A = [A]*N
for i in range (N):
    H[i] = abs((T-H[i]*0.006)-A[i])
print(H.index(min(H)+1)+1)

Buggy submission (verdict: Runtime Error):
#Palace
N,T,A,*H = map(int,open(0).read().split())
A = [A]*N
for i in range (N):
    H[i] = abs((T-H[i]*0.006)-A[i])
print(H.index(min(H)+1)+1)

Buggy submission (verdict: Runtime Error):
#Palace
N,T,A,*H = map(int,open(0).read().split())
A = [A]*N
for i in range (N):
    H[i] = abs((T-H[i]*0.006)-A[i])
print(H.index(min(H)+1)+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))
meanx = (T - A)/0.006
H = H - meanx
print(index(min(H)))
Problem p03285 (python)

Fixed submission:
n = int(input())
print("Yes" if [1 for a in range(n//7+1) for b in range(n//4+1) if a*7+b*4 == n] else "No")

Buggy submission (verdict: Runtime Error):
#Cakes and Donuts
n = int(input())
print('Yes' if[1 for a in range(n//7+1) for b in range(n//4+1) if a*7+b*4=n] else 'No')
Problem p03290 (python)

Fixed submission:
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Buggy submission (verdict: Runtime Error):
d,g=map(int,input().split())
pc=[list(map(int,input().split()) for i in range(d)]
def dfs(i,s,count,r):
    global ans
    if i==d:
        if s<g:
            e=max(r)
            n=min(pc[e-1][0],-(-(g-s)//(n*100)))
            count+=n
            s+=n*e*100
        if s>=g:
            ans=min(ans,count)
    else:
        dfs(i+1,s,r)
        dfs(i+1,s+(i+1)*100*pc[i][0]+pc[i][1],pc[i][0],r-{i+1})
ans=float('inf')
dfs(0,0,0,set(range(1,d+1)))
print(ans)

Buggy submission (verdict: Runtime Error):
#All Green フク
d,g=map(int,input().split())
pc=[list(map(int,input()).split()) for i in range(d)]
def dfs(i,s,count,r):
    global ans
    if i==d:
        if s<g:
            e=max(r)
            n=min(pc[e-1][0],-(-(g-s)//(n*100)))
            count+=n
            s+=n*e*100
        if s>=g:
            ans=min(ans,count)
    else:
        dfs(i+1,s,r)
        dfs(i+1,s+(i+1)*100*pc[i][0]+pc[i][1],pc[i][0],r-{i+1})
ans=float('inf')
dfs(0,0,0,set(range(1,d+1)))
print(ans)

Buggy submission (verdict: Runtime Error):
d,g=map(int,input().split())
a=[list(map(int,input().split()) for i in range(d))]

def f(i,s,count,nokori):
    global ans
    if s<g:
        b=max(nokori)
        n=min(pc[use-1],-(-(g-s)//(b*100)))
        count+=n
        s+=n*b*100
    if s>=g:
        ans=min(ans,count)
    else:
        f(i+1,s,count,nokori)
        f(i+1,s+a[i][0]*100*(i+1)+a[i][0],count+a[i][0],nokori-{i+1})
        
ans=float('inf')
f(0,0,0,set(range(1,d+1)))
print(ans)
Problem p03433 (python)

Fixed submission:
X = int(input())
A = int(input())
if X % 500 <= A:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
X = int(input())
A = int(input())
if X % 500 <= A:
	print('Yes')
eise:
	print('No')
Problem p03469 (python)

Fixed submission:
S = input()
print('2018' + S[4:])

Buggy submission (verdict: Runtime Error):
S = input()
S[0] = '2'
S[1] = '0'
S[2] = '1'
S[3] = '8'
print(for i in S)
Problem p03485 (python)

Fixed submission:
a,b=map(int,input().split())
print((1+a+b)//2)

Buggy submission (verdict: Runtime Error):
#Two Anagrams
s = list(input()).sorted
t = list(input()).sorted
if s < t:
    print('Yes')
else:
    print('No')
Problem p03486 (python)

Fixed submission:
s = list(input())
s.sort()

t = list(input())
t.sort(reverse=True)

if s < t:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
s = input().sorted
t = input().sorted
if s < t:
    print('Yes')
else:
    print('No')
Problem p03493 (python)

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

Buggy submission (verdict: Runtime Error):
#Shift only
N = int(input())
A = list(map(int,input().split()))
count = [0]*N
for a in range(N):
    count_local = 0
    while A[a]%2 == 0:
        A[a] = A[a]/2
        count_local += 1
        if count_local >= count[a]:
            count[a] = count_local

print(min(count))

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int,input().split()))
count = 0
for a in A:
    count_local = 0
    while a%2 == 0:
        a = a/2
        count_local += 1
        if count_local <= count:
            count = count_local

print(count)
Problem p03545 (python)

Fixed submission:
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))


s = input()

dfs(0, s[0], int(s[0]))

Buggy submission (verdict: Runtime Error):
a=input()
def dfs(i,s,l):
    if i==3:
        if s==7:
            print(l+'=7')
    else:
        dfs(i+1,s+int(a[i+1]),l+'+'+a[i+1])
        dfs(i+1,s-int(a[i+1]),l+'-'+a[i+1])

dfs(dfs(0,int(a[0]),a[0]))

Buggy submission (verdict: Runtime Error):
def f(i,s,t):
    if i==3:
        if s==7:
            print(t + '=7')
            exit()
    
    else:
        f(i+1,t+'-'+a[i+1],s-int(a[i+1]))
        f(i+1,t+'+'+a[i+1],s+int(a[i+1]))

a=input()
f(0,int(a[0]),a[0])

Buggy submission (verdict: Runtime Error):
def f(i,s,t):
    if i==3:
        if s==7:
            print(t + '=7')
            exit()
    
    else:
        f(i+1,t+'-'+a[i+1],s-int(a[i+1]))
        f(i+1,t+'+'+a[i+1],s+int(a[i+1]))

a=input()
f(0,a[0],int(a[0]))
Problem p03636 (python)

Fixed submission:
S = input()
print(S[0] + str(len(S)-2) + S[len(S)-1])

Buggy submission (verdict: Runtime Error):
s = list(input())
print(s[0] + (s.count - 2) + s[-1])

Buggy submission (verdict: Runtime Error):
S = input()
print(S[0] + string(len(S)-2) + S[len(S)-1])
Problem p03693 (python)

Fixed submission:
r, g, b = map(int,input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
r,g,b = map(int,input().split())
if (100*a + 10*g + b)%4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
r,g,b = map(int,input().split())
if ((100*a + 10*g + b)%4 == 0):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
r, g, b = map(int,input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
	print(YES)
else:
	print(NO)

Buggy submission (verdict: Runtime Error):
r, g, b = int(input().split())
total = r*100 + g*10 + b
if total % 4 == 0:
	print(YES)
else:
	print(NO)
Problem p03999 (python)

Fixed submission:
s=input()
n=len(s)

def f(i,t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return f(i+1,t+s[i+1]) + f(i+1,t+'+'+s[i+1]) #sumの値を足してる

print(f(0,s[0]))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
def dfs(i,x):
    if i==n-1:
        return sum(list(int,x.split('+')))
    return dfs(i+1,x+s[i+1])+dfs(i+1,x+'+'+s[i+1])
print(dfs(0,s[0]))

Buggy submission (verdict: Runtime Error):
print(dfs(0,s[0]))

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

def f(i,t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return f(i+1,f+s[i+1]) + f(i+1,f+'+'+s[i+1])

print(f(0,s[0]))
Problem p02678 (python)

Fixed submission:
# import numpy as np
# import copy
from collections import defaultdict
import queue


q = queue.Queue()

n, m = map(int, input().split())
graph = defaultdict(list)
for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)


# l = np.array(l)
# lc = copy.deepcopy(l)
li = [-1 for _ in range(n)]
li[0] = 1

def search(x):
#     if sum(l[x]) == 0:
#         q.queue = False
#         return
    
#     ind_lis = np.where(lc[x] == 1)[0]
#     ind_lis = [e for e in ind_lis if li[e] == -1]
#     print(li)
#     print(lc[x])
    for e in graph[x]:
#         print(e)
        if li[e-1] != -1:
            continue
        li[e-1] = x
#         print('q', i+1)
        q.put(e)
x = 1
search(x)
while q.queue:
    search(q.get())

if li[1:].count(-1) == 0:
    print('Yes')
    for e in li[1:]:
        print(e)
else:
    print('No')

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


q = queue.Queue()

n, m = map(int, input().split())
l = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    l[a-1][b-1] = 1
    l[b-1][a-1] = 1


# l = np.array(l)
# lc = copy.deepcopy(l)
li = [-1 for _ in range(n)]

def search(x):
    if sum(lc[x]) == 0:
        q.queue = False
        return
    
#     ind_lis = np.where(lc[x] == 1)[0]
#     ind_lis = [e for e in ind_lis if li[e] == -1]
#     print(li)
#     print(lc[x])
    for i,e in enumerate(l[x]):
#         print(i,e)
        if li[i] != -1 or e == 0:
            continue
        li[i] = x
#         print('q', i+1)
        q.put(i)
x = 0
search(x)
while q.queue:
    search(q.get())

if li[1:].count(-1) == 0:
    print('Yes')
    for e in li[1:]:
        print(e+1)
else:
    print('No')

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


q = queue.Queue()

n, m = map(int, input().split())
l = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    l[a-1][b-1] = 1
    l[b-1][a-1] = 1


l = np.array(l)
lc = copy.deepcopy(l)
li = [-1 for _ in range(n)]

def search(x):
    if sum(lc[x]) == 0:
        q.queue = False
        return
    
#     ind_lis = np.where(lc[x] == 1)[0]
#     ind_lis = [e for e in ind_lis if li[e] == -1]
#     print(li)
#     print(lc[x])
    for i,e in enumerate(lc[x]):
#         print(i,e)
        if li[i] != -1 or e == 0:
            continue
        li[i] = x
#         print('q', i+1)
        q.put(i)
x = 0
search(x)
while q.queue:
    search(q.get())

if li[1:].count(-1) == 0:
    print('Yes')
    for e in li[1:]:
        print(e+1)
else:
    print('No')
Problem p02683 (python)

Fixed submission:
import numpy as np
n, m, x = map(int, input().split())
l = []
for i in range(n):
    l += [list(map(int, input().split()))]

a = 1 <<(n )
r = []
for i in range(a):
    li = np.array([0 for _ in range(m +1)])
    for j in range(n):
        if i & (1 << j):
            li += l[j]
#     print(li)
    for k in range(1,m +1):
        if li[k] < x:
            break
        if k == m:
            r +=[li[0]]
        
if len(r) == 0:
    print('-1')
else:
    print(min(r))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, m, x = map(int, input().split())
l = []
for i in range(n):
    l += [list(map(int, input().split()))]

a = 1 <<(n )
r = []
for i in range(a):
    li = np.array([0, 0, 0,0])
    for j in range(n):
        if i & (1 << j):
            li += l[j]

    if li[1] >= x and li[2] >= x and li[3] >= x:
        r += [li[0]]
        
if len(r) == 0:
    print('-1')
else:
    print(min(r))
Problem p02687 (python)

Fixed submission:
s = input()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
if s == 'ABC':
    print('ARC')
else:
    print('ABC')
Problem p03565 (python)

Fixed submission:
import copy
import sys

s = input()
t = input()
li = list('abcdefghijklmnopqrstuvwxyz')
r = []
for i in range(len(s)-len(t)+1):
    ss = list(s)
#     print(i)
    lo = [1 if ((s[i + j] == t[j]) or (s[i + j] == '?')) else 0 for j in range(len(t))]
#     print(lo)
    if all(lo):
        ss[i:i+ len(t)] = t
        rs = ''.join(ss)
        rs = rs.replace('?','a')
        r += [rs]

if len(r) == 0:
    print('UNRESTORABLE')
    sys.exit()
r = sorted(r)
print(r[0])

Buggy submission (verdict: Runtime Error):
import copy
import sys
li = list('abcdefghijklmnopqrstuvwxyz')
r = []
for i in range(len(s)-len(t)+1):
    ss = list(s)
    print(i)
    lo = [1 if ((s[i + j] == t[j]) or (s[i + j] == '?')) else 0 for j in range(len(t))]
    print(lo)
    if all(lo):
        ss[i:i+ len(t)] = t
        rs = ''.join(ss)
        rs = rs.replace('?','a')
        r += [rs]

if len(r) == 0:
    print('UNRESTORABLE')
    sys.exit()
r = sorted(r)
print(r[0])
Problem p02717 (python)

Fixed submission:
x, y, z = (int(i) for i in input().split())
a,b = y,x
a,c = z,a
print(a,b,c," ")

Buggy submission (verdict: Runtime Error):
x, y, z = (int(i) for i in input().split())
a,b = y,x
a,c = c,a
print(a,b,c," ")
Problem p02730 (python)

Fixed submission:
s = input()
N = len(s)
t = s[::-1]
a = s[0:int((N-1)/2)]
b = a[::-1]
if s == t and a == b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import sys

s = input()
N = len(s)
j = int((N-1)/2)
i = 0
while i!=j:
  if s[i] == s[j]:
    print("YES")
  else:
    print("No")
    sys.exit()
  i = i+1
  j = j-1
p = int((N+3)/2 -1)
q = N
while p!=q:
  if s[p] == s[q]:
    pass
  else:
    print("No")
    sys.exit()
  p = p+1
  q = q-1

a = 0
while a != N:
  if s[a] == s[N]:
    pass
  else:
    print("No")
    sys.exit()
  a = a+1
  N = N-1
if a >= (N-1)/2:
  print("Yes")
Problem p02952 (python)

Fixed submission:
N = input()
n = int(N)
l = len(N)

if l == 1:
  print(n)
elif l == 2:
  print(9)
elif l == 3:
  print(n-90)
elif l == 4:
  print(909)
elif l == 5:
  print(n-9090)
else:
  print(90909)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = len(N)
if l == 1:
  print(N)
elif l == 2:
  print(9)
elif l == 3:
  print(N-90)
elif l == 4:
  print(909)
elif l == 5:
  print(N-9090)
else:
  print(90909)
Problem p02957 (python)

Fixed submission:
A, B = (int(x) for x in input().split())
K = 0
K = (A+B)/2
if K == int(K):
  print((A+B)//2)
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
A, B = (int(x) for x in input().split())
K = 0
K = (A+B)/2
if K == int(K):
  print((A+B)//2)
else:
  print(IMPOSSIBLE)
Problem p03000 (python)

Fixed submission:
N,X = (int(x) for x in input().split())
L = [int(x) for x in input().split()]
s = 0
i = 0
while (s <= X):
  if i >= N:
    print(N+1)
    quit()
  else:
    s = s + L[i]
    i = i + 1
print(i)

Buggy submission (verdict: Runtime Error):
N,X = (int(x) for x in input().split())
L = [int(x) for x in input().split()]
s = 0
i = 0
while (s <= X):
  if i > N:
    print(N)
    quit()
  else:
    s = s + L[i]
    i = i + 1
print(i)
Problem p03031 (python)

Fixed submission:
N,M = (int(x) for x in input().split())
a = [0]*N  
k = []
ans = 0
for i in range(M):
  k = [int(x) for x in input().split()]
  for j in range(k[0]): #kよりつながっている電球を一個ずつ見てる
    s = k[j+1]-1
#    print(i,j,s,a[s],a)
    a[s] = a[s] | (1<<i)
#   print(i,j,s,a[s],a)
    #二進数でi桁目が１のとき、スイッチsとi番目の電球がつながっている?
p = [int(x) for x in input().split()]
P = 0
for i in range(M):
  P |= p[i] << i
for s in range(1<<N):
  t = 0
  for i in range(N):
    if ((s>>i) & 1):
      t ^= a[i]
  if (t == P):
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())
a = [0]*N  
k = []
ans = 0
for i in range(M):
  k = [int(x) for x in input().split()]
  for j in range(k[0]): #kよりつながっている電球を一個ずつ見てる
    s = k[j+1]-1
#    print(i,j,s,a[s],a)
    a[s] = a[s] | (1<<i) #aは各スイッチがつながっている電球の情報を保持
#   左端はMとつながっているかどうかを表す。
    #a[0]＝10100はスイッチ０が電球4と電球2とつながっていることを表している。
p = [int(x) for x in input().split()]
P = 0
for i in range(M):
  P |= p[i] << i　
  #Pはpの情報を全て持っている二進数。例えば、P＝10011は電球４、１、０が
  # on になっているスイッチの個数を2で割った余りが１の時点灯するを表す
  #左端がMは統一されている
for s in range(1<<N):　　#1<<N は2**nと同じ
  t = 0
  for i in range(N):
    if ((s>>i) & 1):　#スイッチオンだったら
      t ^= a[i]		
      #これはXORを使って、スイッチがonになっているスイッチの個数を２で割ったあまりを表している
  if (t == P):	#もし、t＝＝Pなら、当てはまっているので、ans++する。
    ans += 1
print(ans)
Problem p03076 (python)

Fixed submission:
import sys
a = list(sys.stdin.read().split())
t = list(zip(*[[int(n[:-1] or 0), int(n[-1])] for n in a]))
print((sum(t[0]) + len((u := sorted(filter(lambda n: n > 0, t[1])))[:0:-1])) * 10 + (u and u[0] or 0))

Buggy submission (verdict: Runtime Error):
import sys
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]
t = list(zip(*t))
ans = (sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u)
print(ans)

Buggy submission (verdict: Runtime Error):
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]

t = list(zip(*t))

ans = (sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u)
print(ans)

Buggy submission (verdict: Runtime Error):
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]
print((sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u))
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)[-X:]
q = sorted(q)[-Y:]
pq = p + q
pq.sort()
r.sort()
N = X + Y
cnt = 0

from collections import deque
pq = deque(pq)
r = deque(r)

pq_max = pq.pop()
r_max = r.pop()
emp = deque()

for _ in range(N):
    if pq_max >= r_max:
        cnt += pq_max
        if pq == emp:
            pq_max = 0
        else:
            pq_max = pq.pop()
    else:
        cnt += r_max
        if r == emp:
            r_max = 0
        else:
            r_max = r.pop()

print(cnt)

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

goukei = X + Y
delicious = 0
red = 0
green = 0


def max_pop(p):
    pidx = p.index(max(p))
    maxp = p.pop(pidx)
    return maxp


maxp = max_pop(p)
maxq = max_pop(q)
maxr = max_pop(r)
maxdelis = [maxp, maxq, maxr]
for i in range(goukei):
    maxdeli = max(maxdelis)
    idx = maxdelis.index(max(maxdelis))
    delicious += maxdeli
    if idx == 0:
        red += 1
        if red == X:
            maxdelis[0] = 0
        else:
            maxdelis[0] = max_pop(p)
    elif idx == 1:
        green += 1
        if green == X:
            maxdelis[1] = 0
        else:
            maxdelis[1] = max_pop(q)
    else:
        maxdelis[2] = max_pop(r)

print(delicious)
Problem p02733 (python)

Fixed submission:
from itertools import product

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
S_T = [[int(s[w]) for s in S] for w in range(W)]
sumS = sum(map(sum, S_T))
ans = (H - 1) * (W - 1)

if sumS <= K:
    print(0)
else:
    for i in product([True, False], repeat=H-1):
        cnt = sum(i)
        if cnt >= ans:
            continue
        M = [[0]]
        for j, k in enumerate(i):
            if k:
                M.append([])
            M[-1].append(j+1)
        A = [0] * len(M)
        for s_t in S_T:
            for l, m in enumerate(M):
                A[l] += sum(s_t[i] for i in m)
            if any(a > K for a in A):
                cnt += 1
                if cnt >= ans:
                    break
                A = [sum(s_t[i] for i in m) for m in M]
                if any(a > K for a in A):
                    cnt = ans + 1
                    break
        ans = min(cnt, ans)
    print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import product
    
    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]
    S_T = [[int(s[w]) for s in S] for w in range(W)]
    sumS = sum(map(sum, S_T))
    ans = (H - 1) * (W - 1)
    
    if sumS <= K:
        print(0)
    else:
        for i in product([True, False], repeat=H-1):
            cnt = sum(i)
            if cnt >= ans:
                continue
            M = [[0]]
            for j, k in enumerate(i):
                if k:
                    M.append([])
                M[-1].append(j+1)
            A = [0] * len(M)
            for s_t in S_T:
                for l, m in enumerate(M):
                    A[l] += sum(s_t[i] for i in m)
                if any(a > K for a in A):
                    cnt += 1
                    if cnt >= ans:
                        break
                    A = [sum(s_t[i] for i in m) for m in M]
                    if any(a > K for a in A):
                        cnt = ans + 1
                        break
            ans = min(cnt, ans)
        print(ans)

if __name__ == '__main__'
    main()