Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    b, c = map(int, input().split())
    A.extend([c]*b)
A.sort(reverse=True)
ans = A[:N]
print(sum(ans))

Fixed submission:
import heapq
q = []
N, M = map(int, input().split())
A = (map(int, input().split()))
for a in A:
    heapq.heappush(q, a)

lst = []   
for i in range(M):
    lst.append(list(map(int, input().split())))
lst = sorted(lst, key = lambda x: -x[1])
for i, j in lst:
    for _ in range(i):
        v = heapq.heappop(q)
        if v < j:
            heapq.heappush(q, j)
        else:
            heapq.heappush(q, v)
            break
print(sum(q))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    b, c = map(int, input().split())
    A.extend([c]*b)
A.sort(reverse=True)
ans = A[:N]
print(sum(ans))

Fixed submission:
import heapq
q = []
N, M = map(int, input().split())
A = (map(int, input().split()))
for a in A:
    heapq.heappush(q, a)

lst = []   
for i in range(M):
    lst.append(list(map(int, input().split())))
lst = sorted(lst, key = lambda x: -x[1])
for i, j in lst:
    for _ in range(i):
        v = heapq.heappop(q)
        if v < j:
            heapq.heappush(q, j)
        else:
            heapq.heappush(q, v)
            break
print(sum(q))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
q = []
for i in A:
    heapq.heappush(q, i)
for i in range(M):
    b, c = map(int, input().split())
    for j in range(b):
        v = heapq.heappop(q)
        if v >= c:
            heapq.heappush(q, v)
        else:
            heapq.heappush(q, c)
print(sum(q))

Fixed submission:
import heapq
q = []
N, M = map(int, input().split())
A = (map(int, input().split()))
for a in A:
    heapq.heappush(q, a)

lst = []   
for i in range(M):
    lst.append(list(map(int, input().split())))
lst = sorted(lst, key = lambda x: -x[1])
for i, j in lst:
    for _ in range(i):
        v = heapq.heappop(q)
        if v < j:
            heapq.heappush(q, j)
        else:
            heapq.heappush(q, v)
            break
print(sum(q))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = list(input())
if 0 < 10*a + b <= 12 and 0 < c*10 + d <= 12:
    print('AMBIGUOUS')
elif 10*a + b >= 12 and 0 < c*10 + d <= 12:
    print('YYMM')
elif 0 < 10*a + b <= 12 and c*10 + d >= 12:
    print('MMYY')
else:
    print('NA')

Fixed submission:
a, b, c, d = list(input())
a = int(a)
b = int(b)
c = int(c)
d = int(d)
if 0 < 10*a + b <= 12 and 0 < c*10 + d <= 12:
    print('AMBIGUOUS')
elif (10*a + b >= 12 or a + b == 0) and 0 < c*10 + d <= 12:
    print('YYMM')
elif 0 < 10*a + b <= 12 and (c*10 + d >= 12 or c + d == 0):
    print('MMYY')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
N = int(input())
Tree = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    Tree[u-1].append([v-1, w])
    Tree[v-1].append([u-1, w])

ans = [-1]*N

def dfs(node, dist):
    for next_node, size in Tree[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((dist+size)%2)
            dfs(next_node, dist+size)
dfs(0, 0)
print(*ans, sep='\n')

Fixed submission:
import sys
sys.setrecursionlimit(20000000)

N = int(input())
Tree = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    Tree[u-1].append([v-1, w])
    Tree[v-1].append([u-1, w])

ans = [-1]*N

def dfs(node, dist):
    for next_node, size in Tree[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((dist+size)%2)
            dfs(next_node, dist+size)
dfs(0, 0)
print(*ans, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
 
N = int(input())
lst = list(map(int,input().split()))

L = [0]
R = [0]
for i in range(N):
    L.append(fractions.gcd(L[i], lst[i]))
    R.insert(0, fractions.gcd(R[0], lst[N-1-i]))
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(L[i], R[i+1]))
print(ans)

Fixed submission:
import fractions
from functools import reduce
 
N = int(input())
lst = list(map(int,input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = fractions.gcd(L[i], lst[i])
    R[N-i-1] = fractions.gcd(R[N-i], lst[N-i-1])
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(L[i], R[i+1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = list(input())
l = len(S)
X = []
cnt0 = 0
cnt1 = 0
for i in S:
    if i == '0':
        if cnt1 != 0:
            X.append(cnt1)
            cnt1 = 0
            cnt0 += 1
        else:
            cnt0 += 1
    else:
        if cnt0 != 0:
            X.append(cnt0)
            cnt0 = 0
            cnt1 += 1
        else:
            cnt1 += 1
if cnt1 != 0:
    X.append(cnt1)
elif cnt0 != 0:
    X.append(cnt0)
ans = []
if S[0] == '1': #Xの奇数は1
    sum0 = sum(X[0:2*K+1])
    ans.append(sum0)
    i = 0
    if 2*K+1 >= len(X):
        ans = sum(X)
    else:
        while 2*K+i+1 < len(X):
            ans.append(ans[i] + X[2*K+i+1] - X[i])
            i += 1
else:
    sum0 = sum(X[0:2*K])
    ans.append(sum0)
    i = 0
    while 2*K+i < len(X):
        ans.append(ans[i] + X[2*K+i] - X[i])
        i += 1
print(max(ans))

Fixed submission:
A,B=map(int,input().split())
s=0
if A > B:
    s=A+(A-1)
elif A < B:
    s=B+(B-1)
else:
    s=A+B
print(s)

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
cnt = 1
for i in range(1, N):
    if i == 1:
        if H[0] <= H[1]:
            cnt += 1
    else:
        elif max(H[:i-1]) <= H[i]:
            cnt += 1
print(cnt)

Fixed submission:
A,B=map(int,input().split())
s=0
if A > B:
    s=A+(A-1)
elif A < B:
    s=B+(B-1)
else:
    s=A+B
print(s)

Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
cnt=1
before=H[0]
for i in range(1,N):
    if before <= H[i]:
        cnt+=1
    before=max(before,H[i])
print(cnt)
            
        

Fixed submission:
A,B=map(int,input().split())
s=0
if A > B:
    s=A+(A-1)
elif A < B:
    s=B+(B-1)
else:
    s=A+B
print(s)

Buggy python submission (verdict: Runtime Error):
N=int(input())
cnt=1
H=list(map(int,input().split()))
for i in range(N):
    for j in range(i):
        if j-1 > 0:
            if H[i] >= H[j-1]:
                cnt+=1
print(cnt)
            

Fixed submission:
A,B=map(int,input().split())
s=0
if A > B:
    s=A+(A-1)
elif A < B:
    s=B+(B-1)
else:
    s=A+B
print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
cnt = 1
for i in range(1, N):
    if i == 1:
        if H[0] <= H[1]:
            cnt += 1
    else:
        elif max(H[:i-1]) <= H[i]:
            cnt += 1
print(cnt)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
cnt=1
before=H[0]
for i in range(1,N):
    if before <= H[i]:
        cnt+=1
    before=max(before,H[i])
print(cnt)
Buggy python submission (verdict: Runtime Error):
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Fixed submission:
S=input()
a=["0","1"]
count=0
n=len(S)
for i in range(n):
    if S[i] == a[i%2]:
        count+=1
print(min(count,n-count))

Buggy python submission (verdict: Runtime Error):
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans1[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Fixed submission:
S=input()
a=["0","1"]
count=0
n=len(S)
for i in range(n):
    if S[i] == a[i%2]:
        count+=1
print(min(count,n-count))
Buggy python submission (verdict: Runtime Error):
a=input(int)
b=input(int)
c=input(int)
d=input(int)
e=input(int)
k=input(int)
if (e-a) < k :
  print("Yay!")
else:
  print(":(")

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if ( e - a ) <= k :
  print("Yay!")
else:
  print(":(")

Buggy python submission (verdict: Runtime Error):
a=input(int)
b=input(int)
c=input(int)
d=input(int)
e=input(int)
k=input(int)
if (a-e) < k :
  print("Yay!")
else:
  print(":(")

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if ( e - a ) <= k :
  print("Yay!")
else:
  print(":(")

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,k=map(int,input().split())
if (a-e) < k :
  print("Yay!")
else:
  print(":(")

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if ( e - a ) <= k :
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            cnt += 1
    print(cnt)

Fixed submission:
b=input()

if  b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
elif b == "C":
    print("G")
else:
    print("")

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n):
    if s[i] == 'A':
        a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            if s[i+1] == 'C':
                cnt += 1
    print(cnt)

Fixed submission:
b=input()

if  b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
elif b == "C":
    print("G")
else:
    print("")

Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split()) 
S=str(input())
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Fixed submission:
b=input()

if  b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
elif b == "C":
    print("G")
else:
    print("")
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            cnt += 1
    print(cnt)

Fixed submission:
N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n):
    if s[i] == 'A':
        a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            if s[i+1] == 'C':
                cnt += 1
    print(cnt)

Fixed submission:
N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = list(input())

for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if s[i] == 'A':
            if s[i+1] == 'C':
                cnt += 1
    print(cnt)

Fixed submission:
N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split()) 
S=sinput()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Fixed submission:
N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split()) 
S=str(input())
for _ in range(Q): 
    x,y = map(int, input().split()) 
    s=S[x-1:y]
    n=s.count('AC')
    print(n)
    

Fixed submission:
N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    X=0
    for j in range(M):
        X += A[i][j]*B[j]
    X=X+C
    if  0 < X:
        ans += 1
print(ans)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
B=(H-h)*(W-w)
print(B)

Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    X=0
    for j in range(M):
        X+=(A[i][j]*B[j])
    X=X+C
    if  0 < X:
        ans = ans+1
print(ans)
    


Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
B=(H-h)*(W-w)
print(B)
Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[j])
    X=X+C
    if  0 < X:
        ans = ans+1
print(ans)
    

Fixed submission:
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split()))for i in range(n)]
cnt=0
for i in range(n):
    total=0
    for j in range(m):
        total+=B[j]*A[i][j]
    total+=c
    if 0<total:
        cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[j])
    X=X+C
    if  0 < X:
        ans = ans+1
    else:
        ans = ans
print(ans)

Fixed submission:
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split()))for i in range(n)]
cnt=0
for i in range(n):
    total=0
    for j in range(m):
        total+=B[j]*A[i][j]
    total+=c
    if 0<total:
        cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[j])+C
    if  0 < X:
        ans = ans+1
    else:
        ans = ans
print(ans)
    


Fixed submission:
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split()))for i in range(n)]
cnt=0
for i in range(n):
    total=0
    for j in range(m):
        total+=B[j]*A[i][j]
    total+=c
    if 0<total:
        cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[i])+C
    if  0 < X:
        ans = ans+1
    else:
        ans = ans
print(ans)

Fixed submission:
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split()))for i in range(n)]
cnt=0
for i in range(n):
    total=0
    for j in range(m):
        total+=B[j]*A[i][j]
    total+=c
    if 0<total:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])

Fixed submission:
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a+1):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])
Buggy python submission (verdict: Runtime Error):
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x, y):
    return find(x) == find(y)

#初期化
n, m = map(int, input().split())
par = [0]*n
for i in range(n):
    par[i] = i　#まず全ての値を根に置く
rank = [1]*n #深さ
size = [1]*n #根iにおけるグループサイズ

edge = [tuple(map(int, input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
    edge[i] = (edge[i][0]-1, edge[i][1]-1)

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        rs.append(size[fi]*size[se])
        unite(fi, se)
ass = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)


Fixed submission:
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x, y):
    return find(x) == find(y)

#初期化
n, m = map(int, input().split())
par = [0]*n
for i in range(n):
    par[i] = i #まず全ての値を根に置く
rank = [1]*n #深さ
size = [1]*n #根iにおけるグループサイズ

edge = [tuple(map(int, input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
    edge[i] = (edge[i][0]-1, edge[i][1]-1)

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi, se)
ass = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(rest0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(C-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(rest0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

dp = [-1] * (N+1)
need = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp[0] = 0

for i in range(N+1):
    for j in A:
        if i + need[j] > N:
            continue
        dp[i+need[j]] = max(dp[i+need[j]], dp[i]*10+j])
print(dp[N])

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

dp = [-1] * (N+1)
need = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp[0] = 0

for i in range(N+1):
    for j in A:
        if i + need[j] > N:
            continue
        dp[i+need[j]] = max(dp[i+need[j]], dp[i]*10+j)
print(dp[N])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
lst2 = []
for i in range(1, M):
    lst2.append(lst[i] - lst[i-1])
lst2.sort()
print(sum(lst2[0:(M-N)]))


Fixed submission:
t, x = map(int, input().split())
print(t/x)
Buggy python submission (verdict: Runtime Error):
from heapq import heappop, heappush, heapify
n, k = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst = sorted(lst, reverse=True, key=lambda x:x[1])
q = []
v = set()
cnt = 0
for t, d in lst[:k]:
    cnt += d
    if t in v:
        heappush(q, d)
    else:
        v.add(t)
cnt += len(v)**2
ans = cnt
for t, d in lst[k:]:
    if t not in v and len(q)!=0:
        x = heappop(q)
        cnt += d + 2*len(v) + 1 - x
        ans = max(ans, cnt)
print(ans)

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