qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
input = sys.stdin.readline

N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l = sorted(l, reverse=True)
print(sum(l[K]))

Fixed code:
import sys
input = sys.stdin.readline

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

ans = 0
for i in range(K):
	m = max(l)
	ans += m
	l[l.find(m)] = 0
print(ans)

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

ans = 0
for i in range(K):
	m = max(l)
	ans += m
	l[l.index(m)] = 0
print(ans)
Buggy code:
N,K = map(int,input().split())
L = sorted(list[map(int,input().split())], reverse=True)

print(sum(L[:K]))



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

L.sort(reverse=True)

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

L.sort()
print(sum(L[-3:]))


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

L.sort()
print(sum(L[-K:]))
Buggy code:
n, k = map(int, l.split())
l = list(map(int, l.split()))
l = sorted(l)
l = l[::-1]
print(sum(l[:k]))


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

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

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

tar = A[-K:]
tar_sum = sum(tar)
print(tar_sum)

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

A = list(map(int,input().split()))
A.sort()

tar = A[-K:]
tar_sum = sum(tar)
print(tar_sum)
Buggy code:
c, d = map(int, input().split())
ans = 0

a = [int(i) for i in input().split()]
a.sort()
print(a)

for i in range(d) :
    ans = ans + a[c-1-i]

print (ans)

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


Fixed code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
print(sum(sorted(l, reverse=True)[:k]))
Buggy code:
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())))
l = list(reversed(l))

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

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

print(sum(l[n-k:]))
Buggy code:
n, k = list(map(int, input().split()))
l=[int(x) for x in input().split()]
l.sort()
l.reverse()
print(sum(l[0:K]))


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

sum = 0
for i in range(K):
  sum += l[i]

  

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

sum = 0
for i in range(int(K)):
  sum += l[i]

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

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

L.sort()
L.reverse()
ans = 0
for i in range(0,n):
  ans += L[i]
  
print(ans)

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

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

L.sort()
L.reverse()
ans = 0
for i in range(0,k):
  ans += L[i]
  
print(ans)
Buggy code:
n = input().split('')[0]
k = input().split('')[1]

sticks = sorted(map(int,input().split('')),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)

Fixed code:
k = int(input().split()[1])
sticks = sorted(map(int,input().split()),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)
Buggy code:
k = input().split('')[1]
sticks = sorted(list(map(int,input().split(''))),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)

Fixed code:
k = int(input().split()[1])
sticks = sorted(list(map(int,input().split())),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

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

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


Fixed code:
n,k = map(int,input().split())
x = sorted(list(map(int,input().split())),reverse=True)
print(sum(x[:k]))
Buggy code:
n,k=map(int,input().split())
l=list(int(input()))
l.sort(reverse=True)
s=0
for i in range(k):
    s+=l[i]
print(l)

Fixed code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
s=0
for i in range(k):
    s+=l[i]
print(s)
Buggy code:
N, K = map(int,input().split(" "))
L = list(map(int,input().split(" ")))

L.sort(inverse = True)
length_of_snake = 0
for i in range(K):
  length_of_snake += L[i]

print(length_of_snake)

Fixed code:
N, K = map(int,input().split(" "))
L = list(map(int,input().split(" ")))
     
L.sort(reverse = True)
length_of_snake = 0
for i in range(K):
        length_of_snake += L[i]
     
print(length_of_snake)
Buggy code:
N, K = map(int, input().split())
Ls = map(int, input().split())

sorted_Ls = sorted(Ls, reverse=True)
length_sum = 0
for k in K:
    length_sum += sorted_Ls[k]
print(length_sum)

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

sorted_Ls = sorted(Ls, reverse=True)
length_sum = 0
for k in range(K):
    length_sum += sorted_Ls[k]
print(length_sum)
Buggy code:
N,K=map(int,input().split())
hebi=input().split()
hebi1=list(map(int,hebi))
hebi1.reverse()
ans=0
for i in range(K):
    ans+=hebi1[i]
print(ans)    
    

Fixed code:
N,K=map(int,input().split())
hebi=input().split()
hebi1=list(map(int,hebi))
hebi1.sort()
hebi1.reverse()
ans=0
for i in range(K):
    ans+=hebi1[i]
print(ans)
Buggy code:
N,K = map(int,input().split())
li = list(map(int,input().split()))
li.sort(reverse = True)
total = 0
for i in li[:K]
  total += i
  
print(total)

Fixed code:
N,K = map(int,input().split())
li = list(map(int,input().split()))
li.sort(reverse = True)
total = 0
for i in li[:K]:
  total += i
  
print(total)
Buggy code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
t=0
for i in range(k):
  t+=l[k-1-i]
print(t)

Fixed code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
t=0
for i in range(k):
  t+=l[n-1-i]
print(t)
Buggy code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-N:]))

Fixed code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-K:]))
Buggy code:
!/usr/bin
# -*- cording: "utf-8" -*-

a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse=true)
for i in range(b):
  x = x + c[i]
print(x)

Fixed code:
#!/usr/bin
# -*- cording: "utf-8" -*-
 
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse=True)
x = 0
for i in range(b):
  x = x + c[i]
print(x)
Buggy code:
N,K=map(int, input().split())
l=[int(x) for x in input().split()]

buf=sorted(l,reverse=True)
print(buf)
result=0

for i in range(K):
    result+=buf[i]

print(result)

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

buf=sorted(l,reverse=True)
result=0

for i in range(K):
    result+=buf[i]

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

Fixed code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(sum(sorted(a, reverse = True)[:k]))
Buggy code:
n,k=map(int,input().split())
l=[int(_) for _ in input().split()]
print(sum(l[-k:]))

Fixed code:
n,k=map(int,input().split())
l=sorted([int(_) for _ in input().split()])
print(sum(l[-k:]))
Buggy code:
n,k=map(int,input().split())
l=sorted(int(input().split()) ,reverse=True)
print(sum(l[:k]))

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

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

Fixed code:
n,k = map(int,input().split())
l = sorted(list(map(int,input().split())))[::-1]
print(sum(l[:k]))
Buggy code:
n,k = map(int, input().split()) 
L = list(map(int,input().split())) 

L.sort() 
L_len = len(L) 
print(sum(L[-L_len:]))

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

L.sort() 
L_len = len(L) 
print(sum(L[-k:]))
Buggy code:
N, K= list(map(int, input().split())) 
l = list(map(int, input().split()))

print(sum(sorted(l)[-K-1:]))

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

print(sum(sorted(l)[-K:]))
Buggy code:
N,K=map(int,input().split())
L=sorted(list(map(int,input().split())))
ans=sum(L[K:])
print(ans)


Fixed code:
N,K=map(int,input().split())
L=sorted(list(map(int,input().split())))
ans=sum(L[-K:])
print(ans)
Buggy code:
t,l=open(0);print(sorted(map(int,l.split()))[-int(t[2:])])

Fixed code:
t,l=open(0);print(sum(sorted(map(int,l.split()))[-int(t[2:]):]))
Buggy code:
N,K=map(int,input().split())

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

ans=0

for k in range(K):
  ans=ans+li[k]

  print(ans)


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

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

ans=0

for k in range(K):
  ans=ans+li[k]

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

l.sort(reversed=True)
print(sum(l[:k]))

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

print(sum(l[:k]))
Buggy code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))
    l_arr = list(map(int,_in[1].split(' ')))
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    l_arr.sort(reverse=True)
    cnt = l_arr[:K]
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Fixed code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))
    l_arr = list(map(int,_in[1].split(' ')))
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    l_arr.sort(reverse=True)
    cnt = sum(l_arr[:K])
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
Buggy code:
n, k = [int(num) for num in input().split()]
list = [int(num) for num in input().split()]
list.reverse()
print(sum(list[:k]))

Fixed code:
n, k = [int(num) for num in input().split()]
list = [int(num) for num in input().split()]

list.sort(reverse=True)
print(sum(list[:k]))
Buggy code:
n,k=map(int,input().split())
l=list(map(int,inout().split()))
print(sum(sorted(l)[:k][::-1]))

Fixed code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
print(sum(sorted(l)[::-1][:k]))
Buggy code:
n, k = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
print(sum(s[len(n) - k:]))

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


Fixed code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(m):
  ans+=l[i]
print(ans)
Buggy code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
print(a[:m])


Fixed code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
print(sum(a[:m]))
Buggy code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum[:K])

if __name__ == "__main__":
    main()


Fixed code:
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()
Buggy code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(k):
    ans += l[-i]
print(ans)


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

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

l.sort(reverse=True)

print(sum(l[:k]))
Buggy code:
nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
bars = [int(y) for y in input().split()]
bars.sort()
bars.reverse()
ans = 0
for i in range(k):
    ans += bars[i]
    print(ans)


Fixed code:
nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
bars = [int(y) for y in input().split()]
bars.sort()
bars.reverse()
ans = 0
for i in range(k):
    ans += bars[i]
print(ans)
Buggy code:
N,K=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(sum[:K])

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

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


Fixed code:
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[-K:]))
Buggy code:
# -*- coding: utf-8 -*-

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

a = sorted(L)

print(sum(L[-K:]))

Fixed code:
# -*- coding: utf-8 -*-
 
N, K = map(int, input().split())
L =list(map(int, input().split()))
 
a = sorted(L)
 
print(sum(a[-K:]))
Buggy code:
n, k = map(int, input())
print(sorted(map(int, input().split()), key = lambda x:-x)[0:k])

Fixed code:
n, k = map(int, input().split())
print(sum(sorted(map(int, input().split()), key = lambda x:-x)[0:k]))
Buggy code:
N,K=map(int,input().split())
l=list(map(int,input().split()))
print(sum(sorted(l, reverse=True)[0:3]))

Fixed code:
N,K=map(int,input().split())
l=list(map(int,input().split()))
print(sum(sorted(l, reverse=True)[0:K]))
Buggy code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split()))).reverse()
ans=0
for i in range K:
  ans+=A[i]
  
print(ans)

Fixed code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
A.reverse()
ans=0
for i in range(K):
  ans+=A[i]
  
print(ans)
Buggy code:
n, k = [int(e) for e in input().split()]
sticks_length = list(map(int, input().split()))
sticks_length.sort(reverse=True)
sum(sticks_length[:k:1])

Fixed code:
n, k = [int(e) for e in input().split()]
sticks_length = list(map(int, input().split()))
sticks_length.sort(reverse=True)
print(sum(sticks_length[:k:1]))
Buggy code:
N,K = map(int,input().split(' '))
L = sorted(map(int,input().split(' ')))
print(L[:-K])

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

Fixed code:
n, k = list(map(int, input().split()))
l = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(k):
  ans += l[i]
print(ans)
Buggy code:
N, K = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse = True)
print(L[:K])

Fixed code:
N, K = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse = True)
print(sum(L[:K]))
Buggy code:
# -*- coding: utf-8 -*-
import sys

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

l.sort()

X = range(K, -1, -1)

s = 0
for i in range(K, K-N+1, -1):
    s += l[i]

print(l, s, X)

Fixed code:
# -*- coding: utf-8 -*-
import sys

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

l.sort()
s = 0
for i in range(K):
    s += l[N-K+i]

print(s)
Buggy code:
K, N = map(int, input().split())
L = list(map(int, input().split())).sort(reverse=True)
print(sum(L[:K]))


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

Fixed code:
n, k = map(int, input().split())
lst = list(map(int, input().split()))
print(sum(sorted(lst)[::-1][:k]))
Buggy code:
N,K=map(int,input())
L=list(map(int,input().split()))
L.sort(reverse=True)
print(sum(L[:K]))

Fixed code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
print(sum(sorted(L, reverse=True)[:K]))
Buggy code:
n,k = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

array.sort()

sum = 0
for i in range(k):
  sum += array[-(i+1)]

Fixed code:
n,k = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

array.sort()

sum = 0
for i in range(k):
  sum += array[-(i+1)]

print(sum)
Buggy code:
N,K = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
print(sum(N[K-1:]))

Fixed code:
N,K = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
print(sum(l[-K:]))
Buggy code:
n,k=map(int,input().split())
l=sorted(map(int,input().split()))
print(sum(l[-1:-4:-1]))

Fixed code:
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l = sorted(l)[::-1]
print(sum(l[:k]))
Buggy code:
import sys

N, K = map(int, sys.stdin.readline())
L = sorted(list(map(int, sys.stdin.readline().split(" "))), reverse=True)
print(sum(L[0:K]))

Fixed code:
import sys
 
N, K = map(int, sys.stdin.readline().split(" "))
L = sorted(list(map(int, sys.stdin.readline().split(" "))), reverse=True)
print(sum(L[0:K]))
Buggy code:
n , k = map(int,input().split())
lis = list(map(int,input().split()))
lis = sorted(lis)
ans = 0
for i in range(k):
  ans += lis[i]
print(ans)

Fixed code:
n , k = map(int,input().split())
lis = list(map(int,input().split()))
lis = sorted(lis,reverse = True)
ans = 0
for i in range(k):
  ans += lis[i]
print(ans)
Buggy code:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l.sort(reversed = True)
print(sum(l[:K]))

Fixed code:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l.sort(reverse = True)
print(sum(l[:K]))
Buggy code:
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k,n):
    sum += l[i]

print(sum)

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

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

print(sum)
Buggy code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
lst = sorted(l, reverse=True)

print(sum(l[:k]))

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


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

Fixed code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
del l[:n-k]
print(sum(l))
Buggy code:
n, k = map(int, input().split())
l = list(map(int, input().split))
l.sort(revese = True)
sum_l=0
for i in range(0,k):
    sum_l+=l[i]

print(sum_l)

Fixed code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse = True)
sum_l=0
for i in range(0,k):
    sum_l+=l[i]

print(sum_l)
Buggy code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    num_list.sort(reverse=True)

    print(num_list[:2])

if __name__ == '__main__':
    main()


Fixed code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    num_list.sort(reverse=True)

    ans = 0
    
    for i in range(k):
        ans += num_list[i]

    print(ans)
    
if __name__ == '__main__':
    main()
Buggy code:
n,k = map(int, input().split())
l = map(int, input().split())
x = sorted(l)
print(sum(x[k:]))


Fixed code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
x = sorted(l)
print(sum(x[n-k:]))
Buggy code:
n,k=int(input().split())
l=list(map(int,input()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Fixed code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)
Buggy code:
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

sorted(L, reverse=True)
a = 0
for i in range(K):
    a += L[i]
print(a)


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

l = sorted(L, reverse=True)
a = 0
for i in range(K):
    a += l[i]
print(a)
Buggy code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l = list.sort(l,reverse = True)
c = 0

for i in range(l):
    c += l[i]

print(c)

Fixed code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
list.sort(l,reverse = True)
c = 0

for i in range(k):
    c = c + l[i]

print(c)