Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(1:n+1):
  if i%3==0:
    continue
  elif i%5==0:
    continue
  else:
    s.append(i)
print(sum(s))

Fixed submission:
print('YNeos'[not ('7'in input())::2])

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(1:n+1):
  if a%3==0:
    continue
  elif a%5==0:
    continue
  else:
    s.append(i)
print(sum(s))

Fixed submission:
print('YNeos'[not ('7'in input())::2])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(1:n+1):
  if a%3==0:
    continue
  elif a%5==0:
    continue
  else
  	s.append(i)
print(sum(s))

Fixed submission:
n=int(input())
s=[]
for i in range(1,n+1):
  if i%3==0:
    continue
  elif i%5==0:
    continue
  else:
    s.append(i)
print(sum(s))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
def num(x):
  if x<2:
    return 0
  else:
    return int(x*(x-1)/2)
 print(num(n)+num(m))

Fixed submission:
n,m=map(int,input().split())
def num(x):
  if x<2:
    return 0
  else:
    return int(x*(x-1)/2)
print(num(n)+num(m))
Buggy python submission (verdict: Time Limit Exceeded):
n,*s=map(str,open(0).read().split())
mydict={}
for i in set(s):
    mydict[i]=1
for i in range(int(n)):
    mydict[s[i]]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
for i in sorted([kv[0] for kv in mydict.items() if kv[1]==max(mydict.values())]):
    print(i)

Fixed submission:
n,*s=map(str,open(0).read().split())
mydict={}
for i in set(s):
    mydict[i]=1
for i in s:
    mydict[i]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
v_max=max(mydict.values())
for i in sorted([kv[0] for kv in mydict.items() if kv[1]==v_max]):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n,*s=map(str,open(0).read().split())
mydict={}
for i in range(int(n)):
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
for j in sorted([kv[0] for kv in mydict.items() if kv[1]==max(mydict.values())]):
    print(j)

Fixed submission:
n,*s=map(str,open(0).read().split())
mydict={}
for i in set(s):
    mydict[i]=1
for i in s:
    mydict[i]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
v_max=max(mydict.values())
for i in sorted([kv[0] for kv in mydict.items() if kv[1]==v_max]):
    print(i)
Buggy python submission (verdict: Runtime Error):
h,a=mp(int,input().split());print(h//a+1 if h%a!=0 else h//a)

Fixed submission:
h,a=map(int,input().split());print(h//a+1 if h%a!=0 else h//a)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input(),split());print(str(min(a,b))*max(a,b))

Fixed submission:
a,b=map(int,input().split());print(str(min(a,b))*max(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
n,*p=map(int,open(0).read().split())
c=0
for i in range(n):
    if p[i]<=min(p[:i+1]):
        c+=1
print(c)

Fixed submission:
n,*p=map(int,open(0).read().split())
c=0
min_p=p[0]
for i in range(n):
    min_p=min(min_p,p[i])
    if p[i]<=min_p:
        c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input());print(1/2 if n%2=0 else (n//2+1)/n)

Fixed submission:
n=int(input());print(1/2 if n%2==0 else (n//2+1)/n)
Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
for i in range(n):
    print(a.index(i+1)+1,end=' ')

Fixed submission:
n,*a=map(int,open(0).read().split())
b=[0]*n
for i in range(n):
    b[a[i]-1]=str(i+1)
print(' '.join(b))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q,*a=map(int,open(0).read().split())
points=[k]*n
for i in range(q):
    for j in range(n):
        if a[i]-1!=j:
            points[j]-=1
for i in range(n):
    print('NYoe s'[points[i]>0::2])

Fixed submission:
n,k,q,*a=map(int,open(0).read().split())
import numpy as np
points=np.full(n,k)

for i in range(q):
    points-=1
    points[a[i]-1]+=1

for i in range(n):
    print('NYoe s'[points[i]>0::2])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
i=1
while a+(i-1)*(a-1)<b:
    i+=1
print(i)

Fixed submission:
s=input()
t=input()
a=0
for i in range(3):
  if s[i]==t[i]:
    a+=1
print(a)

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
a=0
for i in range(3)
  if s[i]==t[i]:
    a+=1
print(a)

Fixed submission:
s=input()
t=input()
a=0
for i in range(3):
  if s[i]==t[i]:
    a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input());print('IMPOSSIBLE' if (b-a)%2!=0 else int((a+b)/2))

Fixed submission:
a,b=map(int,input().split());print('IMPOSSIBLE' if (b-a)%2!=0 else int((a+b)/2))
Buggy python submission (verdict: Runtime Error):
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(s[0])==2::2])

Fixed submission:
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(list(s)[0])==2::2])
Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input().split());print(b*(c//a))

Fixed submission:
a,b,t=map(int,input().split());print(b*(t//a))
Buggy python submission (verdict: Runtime Error):
t,x=map(int,input().spllit());print(t/x)

Fixed submission:
t,x=map(int,input().split());print(t/x)

Buggy python submission (verdict: Runtime Error):
t,x=map(int,input().spllit());pirnt(t/x)

Fixed submission:
t,x=map(int,input().split());print(t/x)
Buggy python submission (verdict: Runtime Error):
n,l=map(int,open(0).read().split())
sum_n=sum(l)
for i in range(n):
	if 2*l[i]>=sum_n
		print('No')
		import sys
		sys.exit()
print('Yes')

Fixed submission:
n,*l=map(int,open(0).read().split())
sum_n=sum(l)
for i in range(n):
	if 2*l[i]>=sum_n:
		print('No')
		import sys
		sys.exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
n,l=map(int,open(0).read().split())
sum_n=sum(l)
for i in range(n):
  if 2*l[i]>=sum_n
  	print('No')
    import sys
    sys.exit()
print('Yes')

Fixed submission:
n,*l=map(int,open(0).read().split())
sum_n=sum(l)
for i in range(n):
	if 2*l[i]>=sum_n:
		print('No')
		import sys
		sys.exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
m=input()
def s(x):
  if x=='1':
    return '9'
  else:
    return '1'
print(s(m[0])+s(m[1])+s(m[2])

Fixed submission:
m=input()
def s(x):
  if x=='1':
    return '9'
  else:
    return '1'
print(s(m[0])+s(m[1])+s(m[2]))

Buggy python submission (verdict: Runtime Error):
m=input()
def s(x):
  if x=='1':
  	return '9'
  else:
    return '1'
print(s(m[0])+s(m[1])+s(m[2])

Fixed submission:
m=input()
def s(x):
  if x=='1':
    return '9'
  else:
    return '1'
print(s(m[0])+s(m[1])+s(m[2]))

Buggy python submission (verdict: Runtime Error):
m=input()
def s(x):
  if x=='1'
  	return '9'
  else:
    return '1'
print(s(m[0])+s(m[1])+s(m[2])

Fixed submission:
m=input()
def s(x):
  if x=='1':
    return '9'
  else:
    return '1'
print(s(m[0])+s(m[1])+s(m[2]))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c),abs(a-b)+abs(c-a),abs(c-b)+abs(a-c),abs(a-c)+abs(b-a),abc(b-c)+abs(a-b)))

Fixed submission:
a,b,c=map(int,input().split())
print(min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c),abs(a-b)+abs(c-a),abs(c-b)+abs(a-c),abs(a-c)+abs(b-a),abs(b-c)+abs(a-b)))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print(max(a+b,a-b a*b))

Fixed submission:
a,b=map(int,input().split());print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input(),split())
print('NYoe s'[abs(a-c)<=d or (abs(b-a)<=d and abs(c-b)<=d)::2])

Fixed submission:
a,b,c,d=map(int,input().split())
print('NYoe s'[abs(a-c)<=d or (abs(b-a)<=d and abs(c-b)<=d)::2])
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
a.sort()
k = int(input())
print(a[0]+a[1]+a[2]*(2**k))

Fixed submission:
a,b=map(int,input().split())
print(a if a<=b else a-1)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split())).sort()
k = int(input())
print(a[0]+a[1]+a[2]*(2**k))

Fixed submission:
a = list(map(int,input().split()))
a.sort()
k = int(input())
print(a[0]+a[1]+a[2]*(2**k))
Buggy python submission (verdict: Runtime Error):
n,*s=map(int,open(0).read().split())
print('TFhoruere'[len(set(s))==4::2])

Fixed submission:
_,*s=map(str,open(0).read().split())
print('TFhoruere'[len(set(s))==4::2])
Buggy python submission (verdict: Runtime Error):
x,y=input().split()
if ord(x)<ord(y):
  print('<')
elif prd(x)>ord(y):
  print('>')
else:
  print('=')

Fixed submission:
x,y=input().split()
if ord(x)<ord(y):
  print('<')
elif ord(x)>ord(y):
  print('>')
else:
  print('=')
Buggy python submission (verdict: Runtime Error):
r,g=map(int,input().split());print(g*2-r)

Fixed submission:
r,g=map(int,open(0).read().split());print(g*2-r)
Buggy python submission (verdict: Runtime Error):
a,b=mpa(int,input().split())
print('Possible' if (a%3==0 or b%3==0 or a+b%3==0) else 'Impossible')

Fixed submission:
a,b=map(int,input().split())
print('Possible' if (a%3==0 or b%3==0 or (a+b)%3==0) else 'Impossible')

Buggy python submission (verdict: Runtime Error):
print('Possible' if sum(map(int, input()))%3==0 else 'Impossible')

Fixed submission:
a,b=map(int,input().split())
print('Possible' if (a%3==0 or b%3==0 or (a+b)%3==0) else 'Impossible')

Buggy python submission (verdict: Runtime Error):
print('Possible' if sum(list(map(int, input())))%3==0 else 'Impossible')

Fixed submission:
a,b=map(int,input().split())
print('Possible' if (a%3==0 or b%3==0 or (a+b)%3==0) else 'Impossible')
Buggy python submission (verdict: Runtime Error):
a,b,c=map(str,input().split());print((a[0]+b[0]+v[0]).upper())

Fixed submission:
a,b,c=map(str,input().split());print((a[0]+b[0]+c[0]).upper())
Buggy python submission (verdict: Runtime Error):
a,b=map(str,input().split());print('DH'[a==b::2]

Fixed submission:
a,b=map(str,input().split());print('DH'[a==b::2])
Buggy python submission (verdict: Runtime Error):
p=[2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b=map(int,input().split())
print('ABloibc e'[p.index(a)<p.idex(b)::2] if a!=b else 'Draw') 

Fixed submission:
p=[2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b=map(int,input().split())
print('ABloibc e'[p.index(a)<p.index(b)::2] if a!=b else 'Draw')
Buggy python submission (verdict: Runtime Error):
a=map(int,input().split())
a.sort()
print('YNeos'[a[2]!=a[0]+a[1]::2])

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print('YNeos'[a[2]!=a[0]+a[1]::2])
Buggy python submission (verdict: Runtime Error):
R,G,B,K=map(int,input().split())



for _ in range (K) :
    if R < G :
        pass
    else:
        G*=2
        continue

    if G < B :
        pass
    else:
        B*=2
        continue
    
if R < G < B :
    print('Yes')
else :
    print('No')


Fixed submission:
R,G,B=map(int,input().split())
K=int(input())
for _ in range (K) :
    if R < G :
        pass
    else:
        G*=2
        continue

    if G < B :
        pass
    else:
        B*=2
        continue
    
if R < G < B :
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
n,k= map(int , input().split())

p=list(map(int,input().split()))
p.sort()
ans =0
for i in range(k):
	ans+= p[i]
print(ans)

Fixed submission:
a = input()
 
if a == a.upper():
	print('A')
else:
	print('a')
Buggy python submission (verdict: Runtime Error):
a=int(input())
p=int(input())
print(int((3*a+p)/2))

Fixed submission:
L = list(map(int,input().split()))
print((int(L[0]*3+L[1])//2))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a+b)%2 == 0:
	print((a+b)//2)
else:
  	print(IMPOSSIBLE)

Fixed submission:
a, b = map(int, input().split())
if (a+b)%2 == 0:
	print((a+b)//2)
else:
  	print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
if l>=0:
	print(int(n**2/2+l*n-n/2-l))
if l<0 and n-1<l:
  	print(int(n**2/2+l*n-n/2))
else:
  	print(int((n**2/2)+l*n-n/2-l-n+1))

Fixed submission:
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
	print('Bad')
else:
  	print('Good')

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
if l>=0:
	print(n**2/2+l*n-n/2-l)
if l<0 and n-1<l:
  	print(n**2/2+l*n-n/2)
else:
  	print((n**2/2)+l*n-n/2-l-n+1)

Fixed submission:
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
	print('Bad')
else:
  	print('Good')
Buggy python submission (verdict: Runtime Error):
r,d,x = map(int, input().split())
result=[]
result.append(x)
for i in range(10):
	x=r*x-d
	result.append(x)
for i in result[1:11]:
	print(int(i))

Fixed submission:
a, b = map(int, input().split())
if a>=13:
  print(int(b))
elif 6<=a<=12:
  print(int(b/2))
else:
  print(int(0))

Buggy python submission (verdict: Runtime Error):
r,d,x = map(int, input().split())
result=[]
result.append(x)
for i in range(10):
	x=r*x-d
	result.append(x)
for i in result[1:11]:
	print(str(i))

Fixed submission:
a, b = map(int, input().split())
if a>=13:
  print(int(b))
elif 6<=a<=12:
  print(int(b/2))
else:
  print(int(0))

Buggy python submission (verdict: Runtime Error):
r,d,x = map(int, input().split())
result=[]
result.append(x)
for i in range(10):
	x=r*x-d
	result.append(x)
for i in result[1:11]:
	print(i)

Fixed submission:
a, b = map(int, input().split())
if a>=13:
  print(int(b))
elif 6<=a<=12:
  print(int(b/2))
else:
  print(int(0))

Buggy python submission (verdict: Runtime Error):
r,d,x = map(int, input().split())
result=[]
result.append(x)
for i in range(10):
	x=r*x-d
	result.append(x)
for i in result[1:10]:
	print(i)

Fixed submission:
a, b = map(int, input().split())
if a>=13:
  print(int(b))
elif 6<=a<=12:
  print(int(b/2))
else:
  print(int(0))
Buggy python submission (verdict: Runtime Error):
g

Fixed submission:
n=int(input())
res=int((n%100)/5)
n -= 105*res
if n == 0 or n >= 100:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(sorted(map(int, input().split())))

result = 0
for a in range(N):
    for b in range(a+1, N):
        for c in range(b+1, N):
            if arr[c] >= arr[a]+arr[b]:
                break
            result += 1

print(result)


Fixed submission:
N = int(input())
arr = list(sorted(map(int, input().split())))

memo = [0]*1001
for x in range(1001):
    for i in arr:
        if i < x:
            memo[x] += 1

result = 0
for a in range(N):
    for b in range(a+1, N):
        aa = arr[a]
        bb = arr[b]
        if aa+bb > 1000:
            result += N-b-1
        else:
            result += memo[aa+bb]-b-1

print(result)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]

res = 0
prev = -1
for i in range(n):
  res += b[a[i]]
  if prev+1 == a[i]:
    res += c[prev]
  prev = a[i]

print(res)

Fixed submission:
n=int(input())
a=[0]+[int(i) for i in input().split()]
b=[0]+[int(i) for i in input().split()]
c=[0]+[int(i) for i in input().split()]
 
res = 0
prev = -1
for i in range(1, n+1):
    res += b[a[i]]
    if prev+1 == a[i]:
        res += c[prev]
    prev = a[i]

print(res)
Buggy python submission (verdict: Runtime Error):
d,t,s=map(int,input().split())
time=d/s
if time<=t:
    print("Yes")
else:
    primmt("No")


Fixed submission:
d,t,s=map(int,input().split())
time=d/s
if time<=t:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())
if t*s>=d:
    print("YES")
else:
    print("NO")

Fixed submission:
d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())
if t>=d/s:
    print("YES")
else:
    print("NO")

Fixed submission:
d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
d,t,s=map(int,input(.split())
if d/s<=t:
	print("YES")
else:
	print("NO")

Fixed submission:
d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())
if d/s<=t:
    print("YES")
else:
    print("NO")

Fixed submission:
d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())

if d/s<=t:
    print("YES")
else:
    print("NO")

Fixed submission:
d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
N=int(input()) 
D=int(input())
c=0
ans=0
while c<N:
    x=int(input()) 
    y=int(input()) 
    if x*x+y*y<=D*D:
        ans+=1
    c+=1
print(ans)

Fixed submission:
import math
N,D=map(int,input().split())
c=0
ans=0
while c<N:
    x,y=map(int,input().split()) 
    if x*x+y*y<=D*D:
        ans+=1
    c+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input()) 
D=int(input())
P=[]
c=0
ans=0
while c<N:
    x=int(input()) 
    y=int(input())
    z=x**2+y**2
    z=z**(1/2)
    if z<=D:
        ans+=1
    c+=1
print(ans)

Fixed submission:
import math
N,D=map(int,input().split())
c=0
ans=0
while c<N:
    x,y=map(int,input().split()) 
    if x*x+y*y<=D*D:
        ans+=1
    c+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    	break
	while b[j] > K - a[i]:
    		j -= 1
	ans = max(ans, i + j)
print(ans)



Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    		break
	while b[j] > K - a[i]:
    		j -= 1
	ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans=0
j=M
for i in range(N + 1): 
	if a[i]>K:
    	break
	while b[j] > K - a[i]:
    	j -= 1
	ans = max(ans, i + j)
print(ans)


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    		break
	while b[j] > K - a[i]:
    		j -= 1
	ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    	break
while b[j] > K - a[i]:
    j -= 1
ans = max(ans, i + j)
print(ans)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    		break
	while b[j] > K - a[i]:
    		j -= 1
	ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N, M = map(int, input().split())

cards = list(map(int, input().split()))
cards.sort()
ops = []
for i in range(M):
    B, C = map(int, input().split())
    ops.append({"B": B, "C": C})
ops.sort(key=lambda o: o["C"], reverse=True)
#print(cards)
#print(ops)

left = 0
for op in ops:
    length = bisect.bisect_left(cards, op["C"], lo=left) - left
    #print(length)
    # fill left..idx
    for i in range(op["B"]):
        if i < length:
            cards[left + i] = op["C"]
    left += min(length, op["B"])
#print(cards)
ans = 0
for val in cards:
    ans += val
print(ans)


Fixed submission:
import bisect

N, M = map(int, input().split())

cards = list(map(int, input().split()))
cards.sort()
ops = []
for i in range(M):
    B, C = map(int, input().split())
    ops.append({"B": B, "C": C})
ops.sort(key=lambda o: o["C"], reverse=True)
#print(cards)
#print(ops)

left = 0
for op in ops:
    length = bisect.bisect_left(cards, op["C"], lo=left) - left
    #print(length)
    # fill left..idx
    for i in range(min(length, op["B"])):
        cards[left + i] = op["C"]
    left += min(length, op["B"])
#print(cards)
ans = 0
for val in cards:
    ans += val
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
nlist = []
for i in range(N):
    nlist.append([])
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    w = (w % 2 == 1)
    nlist[u].append([v, w])
    nlist[v].append([u, w])

color = [-1] * N
def fill(n, val):
    if color[n] != -1:
        return
    color[n] = val
    for nei in nlist[n]:
        fill(nei[0], (val + nei[1]) % 2)
fill(0, 0)

for c in color:
    print(c)


Fixed submission:
N = int(input())
nlist = []
for i in range(N):
    nlist.append([])
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    w = (w % 2 == 1)
    nlist[u].append([v, w])
    nlist[v].append([u, w])

color = [-1] * N
color[0] = 0
nextlist = [0]
while nextlist:
    tmp = []
    for proc in nextlist:
        for n in nlist[proc]:
            if color[n[0]] != -1:
                continue
            color[n[0]] = (color[proc] + n[1]) % 2
            tmp.append(n[0])
    nextlist = tmp

for c in color:
    print(c)