qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))

H.soat(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)

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

H.sort(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)
Buggy code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

if len(a)<=m:
  print(0)
else:
  a=a[:-m]
  print(sum(a))


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

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

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

H.sort()

print(sum(H[:max(N-K, 0)]))
Buggy code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
ans=0
H.sort()
for i in range(N):
    if i>=N-K:
        ans+=1
    else:
        ans+=H[i]
print(ans)

Fixed code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
ans=0
H.sort()
for i in range(N):
    if i>=N-K:
        ans+=0
    else:
        ans+=H[i]
print(ans)
Buggy code:
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)
  print(sum(H[:-K]))

Fixed code:
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 = sorted(H)
  print(sum(H[:-K]))
Buggy code:
def main():
  N, K = map(int, input().split())
  
  H = sorted(list(map(int, input().split())), reverse=True)
 
  n =  sum(H)
  
  if K == 0:
    print(n)
  else:
    for i in range(K):
      n -= H[i]
    print(n)
    
  return 0

if __name__ == "__main__":
  main()

Fixed code:
def main():
  N, K = map(int, input().split())
  
  H = sorted(list(map(int, input().split())), reverse=True)
 
  n = sum(H)
  
  if K == 0:
    print(n)
  elif N > K:
    for i in range(K):
      n -= H[i]
    print(n)
  else:
    print(0)
    
  return 0
 
if __name__ == "__main__":
  main()
Buggy code:
n, k = (int(z) for z in input().split())
a = [int(z) for z in input().split()]
a.sort()
sm = 0
for i in range(k,n):
  sm += a[i]
print(sm)

Fixed code:
n, k = (int(z) for z in input().split())
a = [int(z) for z in input().split()]
a.sort()
sm = 0
for i in range(n - k):
  sm += a[i]
print(sm)
Buggy code:
N,K  =  map(int,input().split())
li = sorted(list(map(int,input().split())),reverse=True)
del(li[:K])
sum(li)

Fixed code:
N,K  =  map(int,input().split())
li = sorted(list(map(int,input().split())),reverse=True)
del(li[:K])
print(sum(li))
Buggy code:
n,k = map(int,input().split())
arr = list(map(int,input().split()))

arr = sorted(arr)
arr[:min(n,k)] = [0]*min(n,k)

print(sum(arr)) 

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

arr = sorted(arr,reverse=True)
arr[:min(n,k)] = [0]*min(n,k)

print(sum(arr))
Buggy code:
#n = int(input())
n,k = map(int,input().split())
h_L = list(map(int,input().split()))

h_L.sort(reverse=True)
#print(h_L)
if k ==0:
    print(sum(h_L))
else:
    print(sum(h_L[k+1:]))

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

h_L.sort(reverse=True)
#print(h_L)
if k ==0:
    print(sum(h_L))
else:
    print(sum(h_L[k:]))
Buggy code:
n,k=map(int,input().split())
h=list(map(int,input().split()))

h.sort(reverse=True)

for i in range(k):
  h[i]=0

sum_=0
for hh in range(h):
  sum_+=hh
print(sum_)

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

h.sort(reverse=True)

if k>n:
  k=n

for i in range(k):
  h[i]=0

sum_=0
for hh in h:
  sum_+=hh
print(sum_)
Buggy code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if k>=n:
    print(0)
else:
    s_h=sorted(h)
    print(sum(s_h[:-k]))

Fixed code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if k>=n:
    print(0)
else:
    s_h=sorted(h)[::-1]
    print(sum(s_h[k:]))
Buggy code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])
Hs = input().split()
Hs = [int(h) for h in Hs]

import numpy as np
Hs = np.array(Hs)
Hs = np.sort(Hs, kind="quick_sort")
s = np.sum(Hs[0:-K])
print(s)

Fixed code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])
Hs = input().split()
Hs = [int(h) for h in Hs]

import numpy as np
Hs = np.array(Hs)
Hs = np.sort(Hs, kind="quick_sort")
if K > 0:
  s = np.sum(Hs[0:-K]) if N > K else 0
else:
  s = np.sum(Hs)
print(s)
Buggy code:
n, k = list(map(int, input().split(' ')))
h_arr = list(map(int, input().split(' '))).sorted(reverse=True)

if n <= k:
  print('0')
else:
  print(sum(h_arr[k:]))

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

Fixed code:
N,K = map(int,input().split())
if N<=K :
    print(0)
else :
    H = list(map(int,input().split()))
    H.sort()
    if 0<K :
        del H[-K:]
    print(sum(H))
Buggy code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
if n<=k :
    print(0)
else :
    sm = 0
    for i in range(n-k):
        sm += l[i]
    pritn(sm)

Fixed code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if n<=k :
    print(0)
else :
    sm = 0
    for i in range(n-k):
        sm += l[i]
    print(sm)
Buggy code:
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)[k-1:]
print(sum(a))

Fixed code:
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)[k:]
print(sum(a))
Buggy code:
enemmyCountN,killerTimeK = map(int,input().split())
enemyHp = input().split()

enemyHp.sort()
print(enemyHp)
resultEnemyCount = enemmyCountN - killerTimeK
countNormal = 0


for i in range(resultEnemyCount):
    countNormal += int(enemyHp[i])

print(countNormal)

Fixed code:
enemmyCountN,killerTimeK = map(int,input().split())
enemyHp = input().split()

intEnemyHp = [int(i) for i in enemyHp]
intEnemyHp.sort()

resultEnemyCount = enemmyCountN - killerTimeK
countNormal = 0

if killerTimeK >= enemmyCountN:
    print(0)

else:
    for i in range(resultEnemyCount):
        countNormal += intEnemyHp[i]
    print(countNormal)
Buggy code:
n, k = map(int, input().split())
h = list(map(int, input().split()))

h = sorted(h)
H = h[k:]
sum_ = sum(H)
print(sum_)

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

h = sorted(h, reverse=True)
H = h[k:]
sum_ = sum(H)
print(sum_)
Buggy code:
n, k = map(int, input().split())

if k >= n:
  print(n)
  exit(0)

h = sorted(map(int, input().split()))
print(sum(h[0:n-k]) + k)


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

if k >= n:
  print(0)
  exit(0)

h = sorted(map(int, input().split()))
print(sum(h[0:n-k]))
Buggy code:
N, K=map(int, input().split())
List=sorted(list(map(int,input().split())))
a = 0
for i in range(N - k):
  a = a + List[i]
print(a)

Fixed code:
N, K=map(int, input().split())
List=sorted(list(map(int,input().split())))
a = 0
for i in range(N - K):
  a = a + List[i]
print(a)
Buggy code:
n,k,*a=map(int,open(0).read().split())
a.sort()
a+=[0]
print(sum(a[:~k])+k)

Fixed code:
n,k,*a=map(int,open(0).read().split())
a.sort()
a+=[0]
print(sum(a[:~k]))
Buggy code:
N, K = map(int,input().split(' '))
H_ls = list(map(int, input().split(' ')))
H_ls.sort()
print(sum(H_ls[K:]))

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

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

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

if K == 0:
  print(sum(H))
elif K < N:
  H.sort()
  print(sum(H[:-K]))
else:
  print(0)
Buggy code:
s = input().split()
N = int(s[0])
K = int(s[1])

H = input().split()

H_s = sorted(H, reverse=True)
H_s[:N] = 0

print(sum(H_s))


Fixed code:
s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))
Buggy code:
N, K = map(int, input().split(" "))
H = sorted(list(map(int, input().split(" "))))


if len(H) <= K:
  print(0)
else:
  c = sum(H[:-K])
  print(c)

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

if N <= K:
  print(0)
else:
  if K == 0:
    c = sum(H)
  else:
    c = sum(H[:-K])
  print(c)
Buggy code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
if K>=N:
  print(ans)
else:
  H = H.sort(reverse=True)
  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
if K>=N:
  print(ans)
else:
  H.sort(reverse=True)
  for i in range(K, N):
    ans += H[i]
  print(ans)
Buggy code:
def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main(

Fixed code:
def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main()
Buggy code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
ans = sum(H[:len(H) - K])

print(ans if N > K else N)

Fixed code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
ans = sum(H[:len(H) - K])

print(ans if N > K else 0)
Buggy code:
n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h,reverse=True)
if n>=k:
	for i in range(k):
		H[i]=0
print(sum(H))
else: 
	print(0)

Fixed code:
n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h,reverse=True)
if n>=k:
 for i in range(k):
  H[i]=0
 print(sum(H))
else: 
 print(0)
Buggy code:
n, k = map(int,input().split())
ls = list(map(int,input().split()))

ls = sorted(ls)

if len(ls)<k+1:
  print(0)
else:
  print(sum(ls[:-k]))


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

ls = sorted(ls)


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

Fixed code:
N,K = list(map(int,input().split()))
H = sorted(list(map(int,input().split())))
s = H[0]
if K >= len(H):
    s = 0
else:
    for i in range(1,len(H)-K):
        s += H[i]
print(s)
Buggy code:
N, K = [int(i) for i in input().split()]
H = sorted([int(i) for i in input().split()])

if K < N and  K != 0:
    print(sum(H[: -K]))
else:
    print(sum(H))

Fixed code:
N, K = [int(i) for i in input().split()]
H = sorted([int(i) for i in input().split()])

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

if len(h) <= k:
	print(len(h))

else:
	h.sort(reverse = True)

	for i in range(0, k):
		h[i] = 0

	print(sum(h) + k)

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

if len(h) <= k:
	print(0)

else:
	h.sort(reverse = True)

	for i in range(0, k):
		h[i] = 0

	print(sum(h))
Buggy code:
a,b = map(int, input().split())
box = list(map(int, input().split()))
box.sort()
ans = sum(box[b:])
print(ans)

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

Fixed code:
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
if k >= n:
    print(0)
elif k == 0:
    print(sum(h))
else:
    h.sort()
    ans = 0
    for i in h[: - k]:
        ans += i
    print(ans)
Buggy code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

H=sorted(H, reverse=True)
print(H)
print(sum(H[K:]))

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

H=sorted(H, reverse=True)

print(sum(H[K:]))
Buggy code:
import math

def main():
  N, K = map(int, input().split())
  H = list(map(int, input().split()))
  
  if K >= N:
    print(0)
    return
  
  ans = 0
  l = sorted(H, reverse=True)
  
  del l[:K]
  print(l)
  
  ans += sum(l)
  
  print(ans)
  
  
main()

Fixed code:
import math

def main():
  N, K = map(int, input().split())
  H = list(map(int, input().split()))
  
  if K >= N:
    print(0)
    return
  
  #ans = 0
  l = sorted(H, reverse=True)
  
  # del l[:K]
  # print(l)
  
  # ans += sum(l)
  
  print(sum(l[K:]))
  #print(ans)
  
  
main()
Buggy code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
print(sum(h[:n-k]))

Fixed code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
print(sum(h[:max(0,n-k)]))
Buggy code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse = True)
for i in range(k):
	h[i] = 0
print(sum(h))

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

def solve():
    if n <= k:
        return 0
    s = sum(h)
    h = sorted(h, reverse=True)
    for i in range(k):
        print(h[i])
        s -= h[i]
    return s

print(solve())

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

def solve():
    global n, k, h
    if n <= k:
        return 0
    s = sum(h)
    h = sorted(h, reverse=True)
    for i in range(k):
        s -= h[i]
    return s

print(solve())
Buggy code:
n , k = map(int, input().split())
hp = list(map(int, input().split()))

sum_hp = 0

print(hp)
hp.sort()
print(hp)

for i in range(k):
    if(len(hp)> 0):
        hp.pop()

print(hp)

for j in hp:
    sum_hp = sum_hp + int(j)

print(str(sum_hp))

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

sum_hp = 0


hp.sort()


for i in range(k):
    if(len(hp)> 0):
        hp.pop()



for j in hp:
    sum_hp = sum_hp + int(j)

print(str(sum_hp))
Buggy code:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
h.sort(reverse=True)
  
if(len(h) <= k):
	print("0")
else:
	print(sum(h,k))

Fixed code:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
h.sort(reverse=True)
  
if(len(h) <= k):
	print("0")
else:
	print(sum(h[k:]))
Buggy code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    h = LI()
    if n <= k:
        print(0)
        return
    h.sort()
    ans = sum(h[:-k])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Fixed code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    h = LI()
    if n <= k:
        print(0)
        return
    h.sort()
    ans = sum(h[:n-k])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()
Buggy code:
kazu1 = list(map(int, input().split()))
kazu2 = list(map(int, input().split()))
n = 0
kazu2.sort(reverse=True)

kazu2[0:kazu1[1]-1] = 0

n += sum(kazu2)

print(n)

Fixed code:
kazu1 = list(map(int, input().split()))
kazu2 = list(map(int, input().split()))
n = 0
kazu2.sort(reverse=True)

kazu2[:kazu1[1]] = [0]

n += sum(kazu2)

print(n)
Buggy code:
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
H.sort()
Ans = 0
for x in (0,K):
    H.pop()
for x in range(0,N):
    Ans = H[x]+Ans
print(Ans)

Fixed code:
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
#print(H)
H.sort()
#print(H)
Ans = 0
for x in range(0,min(K,N)):
#    print(x)
    H.pop()
#print(H)
for x in H:
    Ans = x+Ans
print(Ans)
Buggy code:
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
ans=0
if k>=n:
    ans=n
else:
    list_new=l[0:n-k]
    ans=sum(list_new)
print(ans)


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

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

h.reverse

h = h[k:]

print(sum(h))

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

h.sort(reverse=True)

h = h[k:]

print(sum(h))
Buggy code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
if N>K:
  H.sort()
  del H[N-K+1:]
  print(sum(H))
else:
  print(0)

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

if K < N:
    H_sorted = sorted(H)
    print(sum(H_sorted[:-K]))
else:
    print(0)

Fixed code:
N,K = map(int, input().split())
H = sorted(list(map(int, input().split())))
if K == 0:
  print(sum(H))
else:
  print(sum(H[:-K]))
Buggy code:
def main():
	N,K = map(int,input().split())
	H = [int(h) for h in input().split()]
	H = sorted(H,reverse=True)
	for i in range(K):
		H[i] = 0
	print(sum(H))
if __name__ == '__main__':
	main()

Fixed code:
def main():
	N,K = map(int,input().split())
	H = [int(h) for h in input().split()]
	H = sorted(H,reverse=True)
	for i in range(min(K,N)):
		H[i] = 0
	print(sum(H))
if __name__ == '__main__':
	main()
Buggy code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())))
if len(H) < 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 len(H) < K:
    print(0)
else:
    print(sum(H[:N-K]))
Buggy code:
n,k=map(int,input().split())
if(n<=k):
  print(0)
  exit()

H=list(map(int,input().split()))
H.sort()
print(sum(H[:k]))

Fixed code:
n,k=map(int,input().split())
if(n<=k):
  print(0)
  exit()

H=list(map(int,input().split()))
H.sort()
print(sum(H[:n-k]))
Buggy code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print(0)
  exit()

h.sort()
print(sum(h[:-k]))

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

h.sort()

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

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

h = list(map(int,input().split()))
h.sort(reverse=True)

m = 0
hit = 0
if k >= n :
  m = n
else:
  for i in range(k,n):
    hit += h[i]
  
  m = k + hit
  
print(m)

Fixed code:
N = list(map(int,input().rstrip().split()))
n = N[0]
k = N[1]

h = list(map(int,input().split()))
h.sort(reverse=True)

m = 0
hit = 0
if k >= n :
  m = 0
else:
  for i in range(k,n):
    hit += h[i]
  
  m = hit
print(m)
Buggy code:
n,k=int(input()).split()
h=list(map(int,input().split(' ')))
h.sort()
if(k!=0):
  print(sum(h[:-k]))
else:
  print(sum(h))

Fixed code:
n,k=list(map(int,input().strip().split(' ')))
h=list(map(int,input().strip().split(' ')))
h.sort()
if(k!=0): print(sum(h[:-k]))
else: print(sum(h))
Buggy code:
data = input().split()
 
n = int(data[0])
k = int(data[1])

hpstr = input().split()
hp = []

for i in range(n):
  hp.append(int(hpstr[i]))

hp.sort()

print(hp)

ans = 0
for i in range(n - k):
  ans += hp[i]
 
print(ans)


Fixed code:
data = input().split()
 
n = int(data[0])
k = int(data[1])
 
hpstr = input().split()
hp = []
 
for i in range(n):
  hp.append(int(hpstr[i]))
 
hp.sort()
 
ans = 0
for i in range(n - k):
  ans += hp[i]
 
print(ans)
Buggy code:
H, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

ans = 0

for i in range( N - K ):
  ans += A[i]
  
print(ans)

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

A.sort()

ans = 0

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

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

H.sort(reverse=True)

if N <= K:
  print(0)
else:
  del l[0:K]
  print(sum(H))

Fixed code:
N,K = map(int, input().split())
H = list(map(int, input().split()))
 
H.sort(reverse=True)
 
if N <= K:
  print(0)
else:
  del H[0:K]
  print(sum(H))
Buggy code:
import math


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

data = list(map(int,input().split()))

data.sort()

total = sum( data[0:N-K] )

print(total)


Fixed code:
import math


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

K = min(N,K)


data = list(map(int,input().split()))

data.sort()

total = sum( data[0:N-K] )


print(total)
Buggy code:
N, K = map(int, input().split())
Hs = map(int,input().split())
print(sum(sorted(Hs, reverse=True)[K::])

Fixed code:
N, K = map(int, input().split())
Hs = map(int,input().split())
print(sum(sorted(Hs, reverse=True)[K::]))
Buggy code:
n,k=map(int,input().split())
s=list(map(int,input().split()))

if n<=k:
  print(0)
else:
  s.sort()
  print(sum(s[:-k]))

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

if n<=k:
  print(0)
elif k==0:
  print(sum(s))
else:
  s.sort()
  print(sum(s[0:-k]))
Buggy code:
N, K = map(int, input().split())
Hlist = list(map(int, input().split()))
Hlist.sort(reverse=True)
'''
print(Hlist)
'''
if K == 0:
  print(sum(Hlist))
elif K == 1:
  del Hlist[0]
  print(Hlist)
  print(sum(Hlist))
else:
  del Hlist[0:K-1]
  print(Hlist)
  print(sum(Hlist))

Fixed code:
N, K = map(int, input().split())
Hlist = list(map(int, input().split()))
Hlist.sort(reverse=True)
if K == 0:
  print(sum(Hlist))
else:
  Hlist[0:K] = []
  print(sum(Hlist))
'''
elif K == 1:
  del Hlist[0]
  print(sum(Hlist))
elif K == 2:
  del Hlist[0]
  del Hlist[0]
  print(sum(Hlist))
else:
  del Hlist[0:K-1]
  print(sum(Hlist))
'''