qyliang/CodeNanoFix huggingface dataset:
Buggy code:

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = 0
sumB = 0
sumAB = 0

for i in range(n):
    sumA += A[i]
    sumB += B[i]

for i in range(n):
    if A[i] < B[i]:
        sumAB += int((b[i] - a[i]) / 2 + 0.5)

if sumAB <= sumB - sumA:
    print("Yes")
else:
    print("No")


Fixed code:

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = 0
sumB = 0
sumAB = 0

for i in range(n):
    sumA += A[i]
    sumB += B[i]

for i in range(n):
    if A[i] < B[i]:
        sumAB += int((B[i] - A[i]) / 2 + 0.5)

if sumAB <= sumB - sumA:
    print("Yes")
else:
    print("No")
Buggy code:
#
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

#
op = sum(B) - sum(A)
if op<0:
    print('No')

#
a = 0
b = 0
e = 0
for i in range(N):
    if A[i]==B[i]:
        e += 1
    elif A[i]>B[i]:
        a += 1
    else:
        b += 1

#
if max(a,b)<=op:
    print('Yes')
else:
    print('No')


Fixed code:
#
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

#
#op = sum(B) - sum(A)
#if op<0:
#    print('No')

#
a = 0
b = 0
e = 0
for i in range(N):
    if A[i]==B[i]:
        e += 1
    elif A[i]>B[i]:
        b += A[i] - B[i]
    else:
        a += (B[i] - A[i])//2

#
if b<=a:
    print('Yes')
else:
    print('No')
Buggy code:
n = int(input())
numbersA = input().split()
numbersB = input().split()
diff = []
plusTotal = 0
minousTotal = 0

for i in range(0,n):
	diff.append((int(numbersB[i]) - int(numbersA[i])))
	if diff[i] < 0:
		minousTotal += diff[i]
	else:
		plusTotal += diff[i] // 2


print(plusTotal)

if plusTotal >= abs(minousTotal):
	print("Yes")
else:
	print("No")

Fixed code:
n = int(input())
numbersA = input().split()
numbersB = input().split()
diff = []
plusTotal = 0
minousTotal = 0

for i in range(0,n):
	diff.append((int(numbersB[i]) - int(numbersA[i])))
	if diff[i] < 0:
		minousTotal += diff[i]
	else:
		plusTotal += diff[i] // 2



if plusTotal >= abs(minousTotal):
	print("Yes")
else:
	print("No")
Buggy code:
def after_exp():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    count = sum(b) - sum(a)
    mina = 0
    minb = 0

    for i in range(N):
        if a[i] > b[i]:
            minb += a[i] - b[i]
        else:
            mina += (b[i] - a[i] // 2)
    if a == b: return print('Yes')
    if count < 0: return print('No')
    if minb > mina:
        return print('No')
    else:
        return print('Yes')


# main()
after_exp()

Fixed code:
def after_exp():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    count = sum(b) - sum(a)
    if count < 0: return print('No')
    if a == b: return print('Yes')

    Amove = 0
    Bmove = 0
    for i in range(N):
        if a[i] > b[i]:
            Amove += a[i] - b[i]
        else:
            Bmove += (b[i] - a[i]) //2

    if Amove > Bmove:
        return print('No')
    else:
        return print('Yes')


# main()
after_exp()
Buggy code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
    if B[i] >= A[i]:
        a += (B[i] - A[i] + 1) // 2
        b += (B[i] - A[i]) % 2
    else:
        b += A[i] - bytes[i]
print('Yes' if a >= b else 'No')


Fixed code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
    if B[i] >= A[i]:
        a += (B[i] - A[i] + 1) // 2
        b += (B[i] - A[i]) % 2
    else:
        b += A[i] - B[i]
print('Yes' if a >= b else 'No')
Buggy code:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

suma = sumb = num = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] < B[i]:
        num += ceil((B[i] - A[i]) / 2)

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if num > sumb - suma:
            print("No")
        else:
            print("Yes")


Fixed code:
from math import ceil

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

suma = sumb = num = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] < B[i]:
        num += ceil((B[i] - A[i]) / 2)

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if num > sumb - suma:
            print("No")
        else:
            print("Yes")
Buggy code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p=0
for i in range(n):
    if a[i]<b[i]:
        p+=(b[i]-a[i])
    elif b[i]<a[i]:
        p-=(a[i]-b[i])
if p>=0:
    print('Yes')
else:
    print('No')
    


Fixed code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p, q = 0, 0
for i in range(n):
    if a[i] > b[i]:
        p += a[i] - b[i]
    elif a[i] < b[i]:
        q += (b[i] - a[i]) // 2

if p <= q:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
plus=0;minus=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
    elif c > 0:
        plus+=c

print("Yes" if minus +1 >= plus*2 else "No")


Fixed code:
N = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
plus=0;minus=0;co=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
        if c%2==1:
            co+=1
    elif c > 0:
        plus+=c

print("Yes" if minus >= plus*2+co else "No")
Buggy code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    d = sum(B) - sum(A)

    if d < 0:
        print('No')
        return

    C = [a - b for a, b in zip(A, B)]
    m = sum((x for x in C if x < 0))

    print(d, m)

    if abs(m) > d * 2:
        print('No')
        return

    assert d * 2 + sum((x for x in C if x > 0)) + m == d
    print('Yes')


main()


Fixed code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    d = sum(B) - sum(A)

    if d < 0:
        print('No')
        return

    C = [a - b for a, b in zip(A, B)]
    m = sum(((abs(x) + 1) // 2 for x in C if x < 0))

    # print(d, m)

    if abs(m) > d:
        print('No')
        return

    # assert d * 2 + sum((x for x in C if x > 0)) + m == d
    print('Yes')


main()
Buggy code:
import numpy as np


def a():
    x, y = map(int, input().split())


def b():
    n = int(input())
    a = np.asarray(list(map(int, input().split())))
    b = np.asarray(list(map(int, input().split())))
    x = b.sum() - a.sum()
    d = b - a
    a_req = 0
    b_req = 0
    for i in d:
        if i <= 0:
            b_req += i // -1
        else:
            a_req += i // 2 + i % 2
            b_req += i % 2
    print(x, a_req, b_req)
    # total require
    if (a_req >= b_req and (0 < a_req + (a_req - b_req) == x)) or (a_req == 0 and b_req == 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    b()


Fixed code:
import numpy as np


def a():
    x, y = map(int, input().split())


def b():
    n = int(input())
    a = np.asarray(list(map(int, input().split())))
    b = np.asarray(list(map(int, input().split())))
    x = b.sum() - a.sum()
    d = b - a
    a_req = 0
    b_req = 0
    for i in d:
        if i <= 0:
            b_req += i // -1
        else:
            a_req += i // 2 + i % 2
            b_req += i % 2
    # total require
    if (a_req >= b_req and (0 < a_req + (a_req - b_req) == x)) or (a_req == 0 and b_req == 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    b()
Buggy code:
import numpy as np
N = int(input())
a = []
b = []

a = np.array([int(num) for num in input().split(" ")])
b = np.array([int(num) for num in input().split(" ")])

flag = False
M = sum(b) - sum(a)

a_count = 0
b_count = 0
c = b - a
for i in range(N):
    if c[i] < 0:
        b_count -= c[i]
    if c[i] > 0:
        count = c[i] % 2
        a_count += count
        b_count += count
        a_count += c[i] // 2
b_count += M - a_count

if a_count == b_count:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Fixed code:
import numpy as np
N = int(input())
a = []
b = []

a = np.array([int(num) for num in input().split(" ")])
b = np.array([int(num) for num in input().split(" ")])

flag = False
M = sum(b) - sum(a)

a_count = 0
b_count = 0
c = b - a
for i in range(N):
    if c[i] < 0:
        b_count -= c[i]
    if c[i] > 0:
        count = c[i] % 2
        a_count += count
        b_count += count
        a_count += c[i] // 2
        
if M - b_count == (M - a_count) * 2:
        flag = True
if a_count > M or b_count > M:
    flag = False
if flag:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [B[i]-A[i] for i in range(N)]

P = sum(filter(lambda x: x<0, C))
M = list(filter(lambda x: x>1, C))
M = list(map(lambda x: x%2, M))
M = sum(M)
if abs(M) <= abs(P):
    print("Yes")
else:
    print("No")





Fixed code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [B[i]-A[i] for i in range(N)]

P = sum(filter(lambda x: x<0, C))
M = list(filter(lambda x: x>1, C))
M = list(map(lambda x: x//2, M))

M = sum(M)
if abs(M) >= abs(P):
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
st = input().split()
a = [int(i) for i in input().split()]
A = sum(a)
b = [int(i) for i in input().split()]
B = sum(b)
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")


Fixed code:
N = int(input())
st = input().split()
a = [0 for i in range(N)]
A = 0
for i in range(N):
    a[i] = int(st[i])
    A += a[i]
st = input().split()
b = [0 for i in range(N)]
B = 0
for i in range(N):
    b[i] = int(st[i])
    B += b[i]
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")
Buggy code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
if K >= N:
  print(0)
else:
  H.sort
  print(sum(H[0:N-K])

Fixed code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
if K >= N:
  print(0)
else:
  H.sort()
  print(sum(H[0:N-K]))
Buggy code:
# coding: utf-8
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if n =< k:
    print(n)
else:
    print(sum(h[0: n - k]) + k)


Fixed code:
# coding: utf-8
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if n <= k:
    print(0)
else:
    print(sum(h[0: n - k]))
Buggy code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
if h == 0:
  print(sum(h))
elif h >= n:
  print(0)
else:
  h.sort()
  print(sum(h[:n-k]))


Fixed code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
if k == 0:
  print(sum(h))
elif k >= n:
  print(0)
else:
  h.sort()
  print(sum(h[:n-k]))
Buggy code:
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    h = sorted(h)

    if n <= k:
        print(0)
    else:
        print(sum(h[:-k]))


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    h = sorted(h)

    if n <= k:
        print(0)
    else:
        amari = n - k
        print(sum(h[:amari]))


if __name__ == '__main__':
    main()
Buggy code:
n,k=map(int,input().split())
hlist = list(map(int,input().split()))

hlist.sort(reverse=True)
print(hlist)

if n<k:
    k = n
for i in range(0,k):
    hlist[i] = 0

print(sum(hlist))

Fixed code:
n,k=map(int,input().split())
hlist = list(map(int,input().split()))

hlist.sort(reverse=True)

if n<k:
    k = n
for i in range(0,k):
    hlist[i] = 0

print(sum(hlist))
Buggy code:
N,K=map(int,input().split())
H=list(map(int,input().split())
print(N)
print(K)
s=0
if N<=K:
  print(0)
else:
  for i in range(H-N)
    s+=H[i]
  print(s)

Fixed code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
I=sorted(H)
s=0
if N<=K:
  print(0)
else:
  for i in range(N-K):
    s+=I[i]
  print(s)
Buggy code:
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:N])
print(sum_a)

Fixed code:
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:])
print(sum_a)
Buggy code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
if k>=n:
  print(k)
else:
  print(k+sum(h[:n-k]))

Fixed code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
if k>=n:
  print(0)
else:
  print(sum(h[:n-k]))
Buggy code:
import math

N, K = map(int,input().split())
H = list(map(int,input().split()))

if N <= K:
  print(0)
elif K == 0:
  print(sum(H))
else:
  H.sort()
  h = H[:-K]
  print(h)
  print(sum(h))


Fixed code:
import math

N, K = map(int,input().split())
H = list(map(int,input().split()))

if N <= K:
  print(0)
elif K == 0:
  print(sum(H))
else:
  H.sort()
  h = H[:-K]
  print(sum(h))
Buggy code:
n, k = map(int, input().split())
H = list(map(int, input().split()))
H = list(reversed(sorted(H)))
if k >= n:
    print(0)
else:
    print(sum(H[:k]))

Fixed code:
n, k = map(int, input().split())
H = list(map(int, input().split()))
H = list(reversed(sorted(H)))
if k >= n:
    print(0)
else:
    print(sum(H[k:]))
Buggy code:
import sys

n, k, *h = map(int, sys.stdin.read().split())

def main():
    print(sum(sorted(h)[:n-k]))

if __name__ ==  '__main__':
    main()

Fixed code:
import sys

n, k, *h = map(int, sys.stdin.read().split())

def main():
    print(sum(sorted(h)[:max(0, n-k)]))

if __name__ ==  '__main__':
    main()
Buggy code:
i = list(map(int, input().split()))
j= list(map(int, input().split()))
x=sorted(j, reverse=True)
z=0

if i[1]>=len(j):
  print(0)
else:
  for a in range(i[0],len(x)):
    z+=x[a]
  print(z)

Fixed code:
i = list(map(int, input().split()))
j= list(map(int, input().split()))
x=sorted(j, reverse=True)
z=0
 
if i[1]>=len(j):
  print(0)
else:
  for a in range(i[1],len(x)):
    z+=x[a]
  print(z)
Buggy code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse==True):
ans = 0
for i in range(k,n):
  ans += h[i]
print(ans)

Fixed code:
n, k = map(int, input().split())
h = list(map(int,input().split()))
ans = 0

h = sorted(h,reverse=True)

for i in range(k,n):
    ans += h[i]

print(ans)
Buggy code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverce=True):
ans = 0
if(k>=n):
  ans = 0
else:
  for i in range(k,n):
    ans += h[i]
print(ans)


Fixed code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
ans = 0
if(k>=n):
  ans = 0
else:
  for i in range(k,n):
    ans += h[i]
print(ans)
Buggy code:
import math

n,k=map(int,input().split())
enemys = list(map(int,input().split()))

enemys.sort(reverse=True)
count = 0
for e in enemys:
  if(k > 0):
    count += 1
    k -= 1
  else:
    count += e

print(count)



Fixed code:
import math

n,k=map(int,input().split())
enemys = list(map(int,input().split()))

enemys.sort(reverse=True)
count = 0
for e in enemys:
  if(k > 0):
    k -= 1
  else:
    count += e

print(count)
Buggy code:
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort
if N >= K:
  for i in range(K):
    A.pop()
  print(A)
else:
  print("0")



Fixed code:
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
if N > K:
  for i in range(K):
    A.pop()
  print(sum(A))
else:
  print("0")
Buggy code:
n,k,*h=map(int,open(0).read().split())
print(sum(sorted(h)[:n-k]))

Fixed code:
n,k,*h=map(int,open(0).read().split())
print(sum(sorted(h)[:n-min(n,k)]))
Buggy code:
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)
print(list_hp)

if K < N:
    sum = 0
    for i in range(N-K):
        sum = sum + list_hp[i]
    print(sum)
else:
    print(0)

Fixed code:
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)

if K < N:
    sum = 0
    for i in range(N-K):
        sum = sum + list_hp[i]
    print(sum)
else:
    print(0)
Buggy code:
s = []
for i in range(2):
    s.append(input().split())
n = int(s[0][0])
k = int(s[0][1])
answer = 0
hs = s[1]
print(hs)
h = [int(a) for a in hs]
print(h)
h.sort()
print(h)
h.reverse()
if(k<n):
    for i in range(k,n):
        answer = answer + h[i]
print(answer)

Fixed code:
s = []
for i in range(2):
    s.append(input().split())
n = int(s[0][0])
k = int(s[0][1])
answer = 0
hs = s[1]
h = [int(a) for a in hs]
h.sort()
h.reverse()
if(k<n):
    for i in range(k,n):
        answer = answer + h[i]
print(answer)
Buggy code:
n, k = map(int, input().split())
li = sorted(list(map(int, input().split())))
print(sum(li[:(n-k)]))


Fixed code:
n, k = map(int, input().split())
li = sorted(list(map(int, input().split())))
print(sum(li[:(max(n-k, 0))]))
Buggy code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
print(sum(sorted(h)[:-k]))

Fixed code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
print(sum(sorted(h)[:max(0, n - k)]))
Buggy code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())))
if N<=K:
  print('0')
else:
  print(sum(H[N-K:]))



Fixed code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())))
if (N<=K):
   print('0')
else:
   print(sum(H[:N-K]))
Buggy code:
n,k=map(int,input().split())
a=list(map(int,input().split()))

if n<=k:
  print(k)
  
else:
  a=sorted(a)
  b=n-k
  ans=0
  for x in range(n-k):
    ans+=a[x]
    
  print(ans+k)

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

if n<=k:
  print(0)
  
else:
  a=sorted(a)
  b=n-k
  ans=0
  for x in range(n-k):
    ans+=a[x]
    
  print(ans)
Buggy code:
N, K = map(int, input().split())
life = list(map(int, input().split()))

Nlife = sorted(life, reverse=True)


if K >= 1:
  del Nlife[:K-1]
  

answer = sum(Nlife)

print(answer)

Fixed code:
N, K = map(int, input().split())
life = list(map(int, input().split()))

Nlife = sorted(life, reverse=True)


if K >= 1:
  del Nlife[:K]
  

answer = sum(Nlife)

print(answer)
Buggy code:
H, K = int(input().split())
array = list(map(int, input().split()))
A = sorted(array, reverse=True)
del A[0:K-1]
print(sum(A))

Fixed code:
H, K = map(int, input().split())
array = list(map(int, input().split()))
A = sorted(array, reverse=True)
del A[0:K]
print(sum(A))
Buggy code:
N, K = map(int, input().split())
H = list(map(int,input().split()))
if K == 0:
    print(sum(H))
if K >= N:
    print(0)
else:
    print(sum(H[:-K]))

Fixed code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
print(sum(H[:-K]) if K > 0 else sum(H))
Buggy code:
import sys
n,k=map(int,input().split())
h=list(map(int,input().split()))

if n<=k:
  print(0)
  sys.exit()

hi=sorted(h)
print(sum(hi[:-k]))


Fixed code:
import sys
n,k=map(int,input().split())
h=list(map(int,input().split()))

if n<=k:
  print(0)
  sys.exit()

hi=sorted(h)
if k:
  print(sum(hi[:-k]))
else:
  print(sum(hi))
Buggy code:
N, K = map(int,input().split())
Hi = list(map(int,input().split()))
Hi.sort(reverse=True)
print(Hi)
del Hi[:K]
print(Hi)
min_count = sum(Hi)
print(min_count)

Fixed code:
N, K = map(int,input().split())
Hi = list(map(int,input().split()))
Hi.sort(reverse=True)
del Hi[:K]
min_count = sum(Hi)
print(min_count)
Buggy code:
N, K = list(map(int,input().split()))
k = K - 1
H = list(map(int,input().split()))
Hs = sorted(H,reverse = True)
for i in range(0,K):
  Hs[i] = 0
print(sum(Hs))

Fixed code:
N, K = list(map(int,input().split()))
k = K - 1
H = list(map(int,input().split()))
Hs = sorted(H,reverse = True)
if K <= N:
  for i in range(0,K):
    Hs[i] = 0
  print(sum(Hs))
if K > N:
  print(0)
Buggy code:
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])[::-1]
print(sum(H[N:]))


Fixed code:
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])[::-1]
print(sum(H[K:]))
Buggy code:
n,k=map(int,input().split())
m = list(map(int,input().split()))
m.sort(reverse=True)
print(k+sum(m[k:]))


Fixed code:
n,k=map(int,input().split())
m = list(map(int,input().split()))
m.sort(reverse=True)
print(sum(m[k:]))
Buggy code:
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort()

attack = 0
for i, hp in enumurate(reversed(hp_list)):
  if i < k:
    continue
  attack += hp
print(attack)

Fixed code:
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort()

attack = 0
for i, hp in enumerate(reversed(hp_list)):
  if i < k:
    continue
  attack += hp
print(attack)
Buggy code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N:
	print(0)
b=sorted(a)
c=0
for i in range(N-K):
	c+=b[i]
print(c)

Fixed code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N:
	print(0)
else:
	b=sorted(a)
	c=0
	for i in range(N-K):
		c+=b[i]
	print(c)
Buggy code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
if(k==0):
  print(sum(l))
else:
  l=sorted(l)
  l=l[k:]
  print(sum(l))

Fixed code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
if(k==0):
  print(sum(l))
else:
  l=sorted(l,reverse=True)
  l=l[k:]
  print(sum(l))
Buggy code:
n, k = (int(x) for x in input().split())
H = list(map(int, input().split()))
if k != 0:
    H.sort()
    del H[:k]
print(sum(H))

Fixed code:
n, k = (int(x) for x in input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
if k != 0:
    H.sort(reverse=True)
    del H[:k]
print(sum(H))
Buggy code:
N,K = map(int,input().split())
H = list(map(int,input().split()))

sort = sorted(H, reverse = True)
print(sort)

ans = 0
for i in range(N):
    if i+1 > K:
        ans += sort[i]
    
print(ans)

Fixed code:
N,K = map(int,input().split())
H = list(map(int,input().split()))

sort = sorted(H, reverse = True)
ans = 0
for i in range(N):
    if i+1 > K:
        ans += sort[i]
    
print(ans)
Buggy code:
n,k=map(int,input().split())
a=list(int(x) for x in input().split())
a.sort(reverse = True)
s=0
if k <= n:
	print(0)
else:
		s = sum(a[:n-k])
		print(s)

Fixed code:
n,k=map(int,input().split())
a=list(int(x) for x in input().split())
a.sort()
s=0
if n <= k:
	print(0)
else:
		s = sum(a[:n-k])
		print(s)
Buggy code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()

cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
    else:
        cnt += H[i]

print(cnt)

Fixed code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

H = sorted(H)[::-1]

cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
    else:
        cnt += H[i]

print(cnt)
Buggy code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
c.sort()
d=sum(c)
e=0
if a<=b:
  print(0)
else:
  for i in range(b):
    e=e+c[-i]
  print(d-e)

Fixed code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
c.sort()
d=sum(c)
e=0
if a<=b:
  print(0)
else:
  for i in range(1,b+1):
    e=e+c[-i]
  print(d-e)
Buggy code:
H, K = map(int, input().split())
hp = list(map(input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))


Fixed code:
H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))