qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = sorted(LI())
    if n <= m:
        return m

    return sum(a[:n-m])


print(main())





Fixed code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = sorted(LI())
    if n <= m:
        return 0

    return sum(a[:n-m])


print(main())
Buggy code:
import sys

sys.setrecursionlimit(200000)

def dfs(i, special):
    if (i > N - 1):
        return 0
    if (special > 0):
        return dfs(i + 1, special - 1)
    if MONSTERS[i] <= 1:
        return 1 + dfs(i + 1, special)
    else:
        MONSTERS[i] -= 1
        return 1 + dfs(i, special)

N, K = map(int, input().split())
MONSTERS = map(int, input().split())
MONSTERS = list(reversed(sorted(MONSTERS)))
print(dfs(0, K))


Fixed code:
import sys

sys.setrecursionlimit(1000000000)

def dfs(i, special):
    if (i > N - 1):
        return 0
    if (special > 0):
        return dfs(i + 1, special - 1)
    else:
        return  MONSTERS[i] + dfs(i + 1, special)       

N, K = map(int, input().split())
MONSTERS = map(int, input().split())
MONSTERS = list(reversed(sorted(MONSTERS)))
print(dfs(0, K))
Buggy code:
N,K = (int(x) for x in input().split())
H = list(map(int, input().split()))

sum = 0

H = sorted(H)

answer = 0

for i in H[:N-K]:
    answer += i

print(answer) 

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

sum = 0

H = sorted(H)

answer = 0

if N > K:
    for i in H[:N-K]:
        answer += i

print(answer)
Buggy code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = K
for i in range(K):
    H.pop()
ans += sum(H)
print(ans)

Fixed code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = 0
for i in range(min(K,N)):
    H.pop()
ans += sum(H)
print(ans)
Buggy code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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

Fixed code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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:
n,k = map(int, input().split())
a = list(map(int,input().split()))

list_a = sorted(a, reverse = True)

if k >= n:
    print(0)
else:
    attack = sum(list_a[(n - k - 1):])
    print(attack)

Fixed code:
n,k = map(int, input().split())
a = list(map(int,input().split()))
 
list_a = sorted(a, reverse = True)
 
if k >= n:
    print(0)
else:
    attack = sum(list_a[k:])
    print(attack)
Buggy code:
n,k = list(map(int,input().split()))

#print(n)
a = list(map(int, input().split()))

sum = 0
a.sort()
print(a)
for i in range(min(n,k)): a.pop()
#print(a)
for i in range(len(a)):
    sum += a[i]
print(sum)


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

#print(n)
a = list(map(int, input().split()))

sum = 0
a.sort()
#print(a)
for i in range(min(n,k)): a.pop()
#print(a)
for i in range(len(a)):
    sum += a[i]
print(sum)
Buggy code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

if N <= K:
	print(0)

H.sort()

res = 0
for i in range(N - K):
	res += H[i]
print(res)

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

H.sort()

for i in range(0,K):
    H.pop()

print(sum(H))

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

H.sort()

for i in range(0,K):
    if H:
      H.pop()

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

Fixed code:
N, K = map(int, input().split())
print(sum(sorted(map(int, input().split()), reverse=True)[K:]))
Buggy code:
n,k = map(int, input().split())
h = list(map(int, input().split()))
hsorted = sorted(h)
if k>=n:
    print(0)
else:
    print(sum(hsorted[k:n]))

Fixed code:
n,k = map(int, input().split())
h = list(map(int, input().split()))
hsorted = sorted(h, reverse=True)
if k>=n:
    print(0)
else:
    print(sum(hsorted[k:n]))
Buggy code:
A,B=map(int,input().split())
C=list(map(int,input().split()))
C.sort(reverse=True)
sum(C[B:])

Fixed code:
A,B=map(int,input().split())
C=list(map(int,input().split()))
C.sort(reverse=True)
print(sum(C[B:]))
Buggy code:
N,K= map(int,input().split())
H = list(map(int,input().split()))
H = sort(H)
s = 0
for i in range(N-K):
  s += H[i]
print(s+K)
  


Fixed code:
N,K= map(int,input().split())
H = list(map(int,input().split()))
H.sort()
s = 0
for i in range(N-K):
  s += H[i]
print(s)
Buggy code:
n,k=map(int,input().split(' '))
l=list(map(int, input().split(' ')))
l=sorted(l)

print(sum(l[:n-k]))

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

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

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

if K > len(H):
	print(0)
else:
	print(sum(H[:-K]))

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

if K >= int(N):
	print(0)
elif K == 0:
	print(sum(H))
else:
	print(sum(H[:-K]))
Buggy code:
import math

EnemyCount, slayeCount = map(int, input().split())
enemyHealths = list(map(int, input().split(" "))).sort()

if EnemyCount < slayeCount:
    slayeCount = EnemyCount

for _ in range(slayeCount):
    del enemyHealths[-1]

print(sum(enemyHealths))

Fixed code:
import math

EnemyCount, slayeCount = map(int, input().split())
enemyHealths = list(map(int, input().split(" ")))
enemyHealths.sort()

if EnemyCount < slayeCount:
    slayeCount = EnemyCount

for _ in range(slayeCount):
    del enemyHealths[-1]

print(sum(enemyHealths))
Buggy code:
n,k=map(int,input().split())
H=list(map(int,input().split()))

H.sort()
H.reverse()
print(H)
del H[:k]
a=sum(H)
print(a)

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

H.sort()
H.reverse()
del H[:k]
a=sum(H)
print(a)
Buggy code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))

b.sort(reverse=True)

if len(b) <= a[1]:
    print("0")
else :
    print(sum(b[:a[1]]))


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

if len(b) <= a[1]:
    print("0")
elif a[1]==0:
    print(sum(b))
else:
    b.sort(reverse=True)
    print(sum(b[a[1]:]))
Buggy code:
n,k = map(int,input().split())
h = list(map(input().split()))
h.sort()
ans = int(0)
for i in range(len(h) - k):
    ans += int(h[i])
print(ans)

Fixed code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
ans = int(0)
for i in range(len(h) - k):
    ans += int(h[i])
print(ans)
Buggy code:
n,k = map(int,input().split())
h = list(map(int,input().split()))

if n < k:
    print('0')

h.sort()
l = h[0:(n-k)]

print(sum(l))

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

if n < k:
    print('0')
else:
    h.sort()
    l = h[0:(n-k)]

    print(sum(l))
Buggy code:
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])
#print(H)

for i in range(K):
	H.pop((N-1)-i)

#print(H)

print(sum(H))

Fixed code:
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])
#print(H)

if N<K:
	K=N

for i in range(K):
	H.pop((N-1)-i)

#print(H)

print(sum(H))
Buggy code:
n,k=(int(i) for i in input().split())
h=[]
for i in input().split():
  h.append(int(i))
h.sort()
if k!=0:
	for i in range(k):
 	  h.pop(-1)
print(sum(h))

Fixed code:
n,k=(int(i) for i in input().split())
h=[]
for i in input().split():
  h.append(int(i))
h.sort()
if k!=0:
	for i in range(min(n,k)):
 	  h.pop(-1)
print(sum(h))
Buggy code:
N, K = map(int, input().split())
Hs = list(map(int, input().split()))
Hs.sort(reverse=True)
if K == 0:
  print(sum(Hs))
else:
  for i in range(K):
    Hs[i] = 0
  print(sum(Hs))

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

h = input().split()
h.sort(reverse=True)

print(sum(h[k:]))

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

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

print(sum(h[k:]))
Buggy code:
N, K = map(int, input().split())
H = map(int, input().split())

H.sort(reverse=True)

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(reverse=True)

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


Fixed code:
n, k = tuple(map(int, input().split(' ')))
hs = list(map(int, input().split(' ')))
if k>=n:
    print(0)
    exit()
hs = sorted(hs)
print(sum(hs[:n-k]))
Buggy code:
n,k=map(int,input().split())
hp=list(map(int,input().split()))
hp.sort(reverse=True)
print(sum(hp[-k:]))

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

if n < a:
  print(0)
  
aaa = list(map(int, input().strip().split()))

aaa = sorted(aaa, reverse=True)
h = 0
for i in range(a, n):
  h += aaa[i]
  
print(h)

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

if n <= a:
  print(0)
else:
  aaa = list(map(int, input().strip().split()))

  aaa = sorted(aaa, reverse=True)
  h = 0
  for i in range(a, n):
    h += aaa[i]

  print(h)
Buggy code:
monster_num,k = map(int,input().split(" "))
hp = list(map(int,input().split(" ")))
hp = sorted(hp, reverse = True)
print(hp)
total = 0
for i in hp:
    total += i
    
s = 0
for i in range(k):
    if s <= len(hp) - 1:
        total -= hp[s]
        s += 1

print(total)
    

Fixed code:
monster_num,k = map(int,input().split(" "))
hp = list(map(int,input().split(" ")))
hp = sorted(hp, reverse = True)

total = 0
for i in hp:
    total += i
    
s = 0
for i in range(k):
    if s <= len(hp) - 1:
        total -= hp[s]
        s += 1

print(total)
Buggy code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
if len(h) <= k:
    print(0)
else:
    for _ in range(k):
        h.pop()
    print(sum(h))

Fixed code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if len(h) <= k:
    print(0)
else:
    for _ in range(k):
        h.pop()
    print(sum(h))
Buggy code:
import sys


def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, K = InL()
H = InL().sort()

if K >= N:
    print(0)
    sys.exit()

print(sum(H[0:N-K]))


Fixed code:
import sys


def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, K = InL()
H = InL()
H.sort()

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

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

H.sort(reverse=True)

print(sum(H[k+1:]))

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


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

H.sort(reverse=True)

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

H.sort(reverse=True)
print(sum(H[K:]))

Fixed code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
list.sort(H,reverse=True)
print(sum(H[K:]))
Buggy code:
import numpy as np
n, k = map(int,input().split())
h = np.array(input().split(),dtype=int)

h.sort()
sum = 0
for i in range(k+1,n):
    sum += h[i]
print(sum)

Fixed code:
import numpy as np
n, k = map(int,input().split())
h = np.array(input().split(),dtype=int)

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


Fixed code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())),reverse=True)
if N<K: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, inoput().split))
sum = 0
h.sort()

if n < k:
  print(0)
else:
   for i in range(0, k):
    h[n-i-1] = 0
  
   for i in range(0, n):
    sum += h[i]
  print(sum)

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

if n <= k:
  print(0)
else:
   for i in range(0, k):
    h[n-i-1] = 0
  
   for i in range(0, n):
    sum += h[i]
   
   print(sum)
Buggy code:
inp = input().split()
n,k = map(int, inp)
nums = list(input().split())
nums_list = list(map(int, nums))
kill_en_hp = 0
if len(nums_list) < k:
    print(0)
else:
    nums_list.sort()
    nums_list_2 = nums_list[k:]
    print(sum(nums_list_2u))

Fixed code:
inp = input().split()
n,k = map(int, inp)
nums = list(input().split())
nums_list = list(map(int, nums))
kill_en_hp = 0
if len(nums_list) < k:
    print(0)
else:
    nums_list.sort(reverse=True)
    nums_list_2 = nums_list[k:]
    print(sum(nums_list_2))
Buggy code:
N, K = list(map(int, input().split()))
enemy = sorted(list(map(int, input().split())), reverse=True)

if K > len(enemy):
  print(0)
  

print(sum(enemy[K:]))

Fixed code:
N, K = list(map(int, input().split()))
enemy = sorted(list(map(int, input().split())), reverse=True)
 
if K >= N:
  print(0)
else:
  print(sum(enemy[K:]))
Buggy code:
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
l = len(li)
t = 0
if l > k:
  li.sort().reverse()
  t = sum(li[k:])
print(t)
  

Fixed code:
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
l = len(li)
t = 0
if l > k:
  li.sort()
  li.reverse()
  t = sum(li[k:])
print(t)
Buggy code:
n, k = map(int, input().split())
h = list(map(int, input().split()))

h_ = sorted(h)

for i in range(k):
    h_.pop()

s = [0]*(len(h_)+1)
for j in range(len(h_)):
    s[i+1] = s[i] + h_[i]

print(s[-1])

Fixed code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
 
h_ = sorted(h)
 
for i in range(k):
    if len(h_) > 0:
        h_.pop()
    
s = [0]*(len(h_)+1)
for j in range(len(h_)):
    s[j+1] = s[j] + h_[j]

print(s[-1])
Buggy code:
n,k=map(int,input().split())
h=list(map(int,input().split()))

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

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

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

if n<=k:
  print(0)
  exit()
if k==0:
  print(sum(h))
  exit()

h.sort()
h=h[:-k]
print(sum(h))
Buggy code:
N, K = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort(reverse=True)
ans = 0

if N <= K:
  print(N)
else:
  print(sum(lst[K:])+K)

Fixed code:
N, K = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort(reverse=True)
ans = 0

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

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

H.sort(reverse=True)

if N <= K:
    print(0)
    exit()


r_H = H[K:]


sum_H = 0
for hp in r_H:
    sum_H += hp

print(sum_H)
print(10**9)
print(2*10**14)

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

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

# print(H)
# print(f'N={N} K={K}')
if N <= K:
    print(0)
    exit()


H.sort(reverse=True)
# print(H)


r_H = H[K:]
# print(r_H)

# for hp in r_H:
#     sum_H += hp

print(sum(r_H))
# print(type(10**9))
# print(type(2*10**14))
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)
for i in range(min(n,k)):
    h[i] = 0
print(sum(h))
Buggy code:
n, k = map(int, input().split())
h = sorted(map(int, input().split()))
 
x = 0
print(h)
if n - k <= 0:
    print(0)
else:
    for i in range(n-k):
        x += h[i]
    print(x)

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

if n - k <= 0:
    print(0)
else:
    for i in range(n-k):
        x += h[i]
    print(x)
Buggy code:
N, K = map(int, input().split())
monsterList = [int(x) for x in input().split()]

atackTimes = 0

monsterList.sort()
if K == 0:
    for hp in monsterList[:-K]:
        atackTimes += hp
else:
    for hp in monsterList:
        atackTimes += hp

print(atackTimes)

Fixed code:
N, K = map(int, input().split())
monsterList = [int(x) for x in input().split()]

atackTimes = 0

monsterList.sort()
if K != 0:
    for hp in monsterList[:-K]:
        atackTimes += hp
else:
    for hp in monsterList:
        atackTimes += hp

print(atackTimes)
Buggy code:
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    if k >= n:
        return 0
    else:
        l = sorted(num)
        return sum(num[:-k])
print(main())


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

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

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

h.sort()

if k:
    print(sum(h[:-k]))
else:
    print(sum(h))
Buggy code:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t if len(t) > 1 else t[0]
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N,K = I()
A = I()
if N == K:
    print(0)
else:
    print(sum(sorted(A)[:N-K]))


Fixed code:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t 
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N,K = I()
A = I()
if K>N:
    K=N
if N == K:
    print(0)
else:
    print(sum(sorted(A)[:N-K]))
Buggy code:
# https://atcoder.jp/contests/abc153/tasks/abc153_c
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, k = map(int, input().split())
    hl = list(map(int, input().split()))
    hl.sort()
    hl = hl[:k]
    print(sum(hl))
    return 


if __name__ == '__main__':
    main()


Fixed code:
# https://atcoder.jp/contests/abc153/tasks/abc153_c
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, k = map(int, input().split())
    hl = list(map(int, input().split()))
    hl.sort()
    rest = max(0, n-k)
    hl = hl[:rest]
    print(sum(hl))
    return


if __name__ == '__main__':
    main()
Buggy code:
n, k = map(int, input().split())
if n <= k:
  print(0)
else:
  h = sorted(list(map(int, input().split())))
  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[:n-k]))
Buggy code:
n, k = map(int, input().split())
if n <= k:
  print(0)
  exit()
h = list(map(int, input().split())).sort()
print(sum(h[:-k]))

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

h = sorted(h)

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

Fixed code:
N, K = map(int,(input().split()))
H = list(map(int,(input().split())))
atk=0
H.sort(reverse=True)
del H[0:K]

atk=sum(H)
print(atk)
Buggy code:
def get_input_line():
    return list(map(int, input().split()))
n, k = get_input_line()
h_list = get_input_line()

print(sum(h_list[k:]))

Fixed code:
def get_input_line():
    return list(map(int, input().split()))
n, k = get_input_line()
h_list = get_input_line()
h_list.sort()
h_list.reverse()

print(sum(h_list[k:]))
Buggy code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
result = 0
if len(H) <= K:
    print(result)
else:
    H.sort()
    result = sum(H[0:N-K-1])
    print(result)

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