qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,K = map(int,input().split())
li = [int(i) for i in input().split()]
total = 0

for _ in range(K):
	total += min(li)
	li = li.remove(min(li))

print(total)

Fixed code:
N,K = map(int,input().split())
li = [int(i) for i in input().split()]
total = 0
 
for _ in range(K):
	total += min(li)
	li.remove(min(li))
 
print(total)
Buggy code:
n , x = map(int,input().split())
price_list = list(map(int,input().split()))
ld = sorted(price_list, reverse=True)
sum = 0
for i in range(x):
  sum += ld[i]
print(sum)

Fixed code:
n , x = map(int,input().split())
price_list = list(map(int,input().split()))
ld = sorted(price_list, reverse=False)
sum = 0
for i in range(x):
  sum += ld[i]
print(sum)
Buggy code:
N, K = map(int,input().split())
P = list(map(int,input().split()))
P_sorted = sorted(P)
print(P_sorted)
ans = 0
for i in range(K):
    ans += P_sorted[i]
print(ans)

Fixed code:
N, K = map(int,input().split())
P = list(map(int,input().split()))
P_sorted = sorted(P)
ans = 0
for i in range(K):
    ans += P_sorted[i]
print(ans)
Buggy code:
N, K = input().split()
P = list(map(int,input().split()))

P.sort()

total=0
for i in range(K):
  total=total+P[i]
 
print(total)



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

P.sort()
 
total=0

for i in range(int(K)):
    total=total+P[i]
 
print(total)
Buggy code:
N, K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ls = []
for i in range(K):
    ls.append(p[i])


Fixed code:
N, K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ls = []
for i in range(K):
    ls.append(p[i])
print(sum(ls))
Buggy code:
import heapq
N,K = map(int,input().split())
p = list(map(int,input().split()))
sum(heapq.nsmallest(K,p))

Fixed code:
import heapq
N,K = map(int,input().split())
p = list(map(int,input().split()))
print(sum(heapq.nsmallest(K,p)))
Buggy code:
N,K = map(int, input().split())
p = input().split()

p.sort()
print(sum(p[0:k]))


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

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

p = sorted(p)

print(sum(p[:N]))

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

p = sorted(p)

print(sum(p[:K]))
Buggy code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
list.sort(a)
sum(a[0:k])

Fixed code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
list.sort(a)
print(sum(a[0:k]))
Buggy code:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

S = sorted(A)
ans = 0
for i in range(K):
    ans += S[i]

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

S = sorted(A)
ans = 0
for i in range(K):
    ans += S[i]

print(ans)
Buggy code:
a=input()
b=a.split()
c=input()
d=c.split()
N=int(b[0])
K=int(b[1])
p=[]
for i in range(N):
    p.append(int(d[i]))
p.sort()
print(p)
ans=0
for i in range(K):
    ans=ans+p[i]
print(ans)

Fixed code:
a=input()
b=a.split()
c=input()
d=c.split()
N=int(b[0])
K=int(b[1])
p=[]
for i in range(len(d)):
    p.append(int(d[i]))
p.sort()
ans=0
for i in range(K):
    ans=ans+p[i]
print(ans)
Buggy code:
prices = []
total_fruits = 0
max_numb = 0

total_fruits, max_numb = input().split(' ')
tmp_prices = input().split(' ')
tmp_prices.sort()
ans = 0
for i in range(int(max_numb)):
  ans += int(tmp_prices[i])
  
print(ans)
  

Fixed code:
prices = []
total_fruits = 0
max_numb = 0

total_fruits, max_numb = input().split(' ')
tmp_prices = input().split(' ')
tmp_prices = [int(i) for i in tmp_prices]
tmp_prices.sort()
ans = 0
for i in range(int(max_numb)):
  ans += int(tmp_prices[i])
  
print(ans)
Buggy code:
N,K=input().split()
N=int(N)
K=int(K)
a=[]
a=[int(a) for a in input().split()]
a.sort()
print(sum(a[0:K-1])

Fixed code:
N,K=input().split()
N=int(N)
K=int(K)
a=[]
a=[int(a) for a in input().split()]
a.sort()
print(sum(a[0:K]))
Buggy code:
def main():
  n, k = map(int, input().split())
  p = sorted(list(input().split()))
  
  hui = 0
  
  for i in range(k):
    hui += int(p[i])
    
  print(hui)
  
main()

Fixed code:
def main():
  n, k = map(int, input().split())
  p = sorted(list(map(int, input().split())))
  
  hui = 0
  
  for i in range(k):
    hui += int(p[i])
    
  print(hui)
  
main()
Buggy code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
x = 0
for i in range(0, k):
    x = x + p[i]
print(p, x)

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

print(sum(sorted(p)[:n]))

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

print(sum(sorted(p)[:k]))
Buggy code:
n,k=map(int,input().split())
l=[int(_) for _ in input().split()]
l.sort()
sum=0
for i in range(k):
  sum+=l[k]
print(sum)

Fixed code:
n,k=map(int,input().split())
l=[int(_) for _ in input().split()]
l.sort()
 
ans=0
for i in range(k):
  ans+=l[i]
print(ans)
Buggy code:
N,K = map(int,input().split())
a = input().split()
a = [int(i) for i in a]
la = sorted(a)
sum(la[:K])

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

L_2=sorted(L)

L_3=L_2[0:k]
print(L_3)
print(sum(L_3))

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

L_2=sorted(L)

L_3=L_2[0:k]
print(sum(L_3))
Buggy code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
P = P.sort()
ans = 0
for i in range(k):
    ans += P[i]
print(ans)

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

p.sort()

ans = 0

for i in range(k):
  ans += p[i]
  
print(ans)
Buggy code:
N, K = map(int,input().split())
prices = input().split()

for i in range(len(prices)):
    prices[i] = int(prices[i])

pricesSum = 0
while K > 0:
    newFruit = min(prices) 
    index = prices.index(newFruit)
    prices.pop(index)
    pricesSum += newFruit
    K -= 1

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

for i in range(len(prices)):
    prices[i] = int(prices[i])

pricesSum = 0
while K > 0:
    newFruit = min(prices) 
    index = prices.index(newFruit)
    prices.pop(index)
    pricesSum += newFruit
    K -= 1
    
print(pricesSum)
Buggy code:
n,k = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort()
sum(arr[:k])

Fixed code:
n,k = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort()
print(sum(arr[:k]))
Buggy code:
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
for i in range(k) :
    s += p[i]
print(s)

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

p = sorted(p,reverse=True)
ans = 0
for i in range(k):
  ans += p[i]
print(ans)

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

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

Fixed code:
N, K = map(int, input().split()) 
A = list(map(int, input().split()))
A.sort()
print(sum(A[0:K]))
Buggy code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
print(c)
d=sorted(c)
ans=0
for i in range(0,b):
 ans+=d[i]
print(ans)

Fixed code:
a,b=map(int,input().split())
c=[]
c=map(int,input().split())
d=list(c)
d2=sorted(d)
ans=0
for i in range(b):
  ans+=d2[i]
print(ans)
Buggy code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=c.sort()
print(d)
ans=0
for i in range(0,b):
 ans+=d[i]

print(ans)

Fixed code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=sorted(c)
ans=0
for i in range(0,b):
 ans+=d[i]
print(ans)
Buggy code:
n,k=map(int,input().split())
p=map(int,input().split())

p=list(p)
p.sort()

a=0

for i in range(3):
    a+=p[i]

print(a)

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

p=list(p)
p.sort()

a=0

for i in range(k):
    a+=p[i]

print(a)
Buggy code:
n,k = map(int,input().split())
p = list(input().split())
p.sort()
print(sum(p[0:n]))

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

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

price_list.sort()

print(price_list)
print(sum(price_list[:k]))


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

price_list.sort()

print(sum(price_list[:k]))
Buggy code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=0
sort(p)
for i range k:
    s+=p[i]

print(s)

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

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

p.sort()

s=0

for i in range(k):
  s+=p[i]

print(s)
Buggy code:
n, k = tuple(map(int, input.split()))
l = list[map(int, input.split())]
s = sum(l.sort().[:k])
print(s)

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

Fixed code:
n,k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
ans=0
for i in ar:
  if(k==0):
    break
  ans+=i
  k-=1
print(ans)
Buggy code:
n, k = map(int, input().split())
nums = list(map(int, input().split()))

print(sum(sorted(nums))[:k])

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

print(sum(sorted(nums)[:k]))
Buggy code:
n, k = input().split()
sum(sorted([int(i) for i in input().split()])[:k])

Fixed code:
n, k = [int(i) for i in input().split()]
print(sum(sorted([int(i) for i in input().split()])[:k]))
Buggy code:
n, k = map(int, input().split())
p = [int(e) for e in input().split()]

p.sort

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

print(ans)

Fixed code:
n, k = map(int, input().split())
p = [int(e) for e in input().split()]

p.sort()

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

print(ans)
Buggy code:
n,k = map(int,input())
a = [int(i) for i in input().split()]
a.sort()
s = 0
for i in range(k):
  s += a[i]
print(s)

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

Fixed code:
a,b = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
print(sum(arr[:b]))
Buggy code:
N, K = map(int, input().split())
p = list(map(int, input().split()))

p.sort
total=0

for i in range(K):
    total += p[i]
    
print(total)

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

p.sort()
total=0

for i in range(K):
    total += p[i]
    
print(total)
Buggy code:
n, k = map(int, input().split())
price = list(map(int, input().split()))
price = sorted(price)
sum(price[:k])

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

sp = sorted(p)
print(sum(sp[:K]))


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

sp = sorted(p)
print(sum(sp[:K]))
Buggy code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
d=0
for i in range(b):
  d=d+c[i]
print(d)

Fixed code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
d=0
c.sort()
for i in range(b):
  d=d+c[i]
print(d)
Buggy code:
N, K = map(int, input().split())
A = sorted(map(int, input().split()))
print(A[:K])

Fixed code:
N, K = map(int, input().split())
A = sorted(map(int, input().split()))
print(sum(A[:K]))
Buggy code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
sorted(a)
print(sum(a[:k])

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

Fixed code:
n, k = map(int, input().split())
#pList = map(int, input().split())
split = input().split()
pList = [int(i) for i in split]
list.sort(pList)
score = 0
for i in range(k):
    score += pList[i]
print(score)
Buggy code:
i = list(map(int, input().split()))
s = list(map(int, input().split()))

out=0
s = sorted(s)
for i in range(3):
  out+=s[i]
print(out)

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

out=0
s = sorted(s)
for i in range(i[1]):
  out+=s[i]
print(out)
Buggy code:
def main():
	n, k = map(int, input().split())
	P = list(map(int, input().split()))
	sorted_p = sorted(P)
	ans = sum(sorted_p[:k])
	print(ans)
	return

if __name__ == "__main__":
	main(

Fixed code:
def main():
	n, k = map(int, input().split())
	P = list(map(int, input().split()))
	sorted_p = sorted(P)
	ans = sum(sorted_p[:k])
	print(ans)
	return

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

plist.sort()
ans = 0
for i in rangr(k):
    ans += plist[i]

print(ans)


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

plist.sort()
ans = 0
for i in range(k):
    ans += plist[i]

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

Fixed code:
N,K=map(int,input().split())
print(sum(sorted(list(map(int,input().split())))[:K]))
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:
n,k = list(map(int,input().split()))

p = lilst(map(int, input().split()))

p.sort()

print(sum(p[:k]))


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

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

p.sort()

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

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

print(sum(sorted(p)[:k])

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

p_s = sorted(p)

print(sum(p_s[:k]))
Buggy code:
l=map(int,open(0).read().split());print(sum(sorted(l[2:])[:l[1]]))

Fixed code:
l=list(map(int,open(0).read().split()));print(sum(sorted(l[2:])[:l[1]]))
Buggy code:
n,k=input().split();print(sum(sorted(int,input().split())[:int(k)]))

Fixed code:
n,k=input().split();print(sum(sorted(map(int,input().split()))[:int(k)]))
Buggy code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:2]))

Fixed code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))
Buggy code:
n, k = input().strip().split()
n, k = [int(n), int(k)]

p = list(map(int, input().strip().split()))

p.sort

print(f'{sum(p[0:k])}')

Fixed code:
n, k = input().strip().split()
n, k = [int(n), int(k)]

p = list(map(int, input().strip().split()))

p.sort()

print(f'{sum(p[0:k])}')
Buggy code:
inputs = [input() for i in range(2)]

N = inputs[0].split()[0]
K = inputs[0].split()[1]
p = [int(pn) for pn in inputs[1].split()]

ans = sum(p.sort()[0:K])
print(ans)

Fixed code:
inputs = [input() for i in range(2)]

N = int(inputs[0].split()[0])
K = int(inputs[0].split()[1])
p = [int(pn) for pn in inputs[1].split()]

ans = sum(sorted(p)[0:K])
print(ans)
Buggy code:
N, K = map(int,input().split())
s = list(map(int,input().split()))
s.sort()
print(sum(s[::K]))

Fixed code:
N, K = map(int,input().split())
s = list(map(int,input().split()))
s.sort()
print(sum(s[:K]))
Buggy code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
res = 0
i = 0
while(K):
	res += P[i]
	K -= 1
print(res)


Fixed code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
res = 0
i = 0
while(K):
    res += P[i]
    K -= 1
    i += 1
print(res)
Buggy code:
N,K = input().split()

P = [int(p) for p in input().split()]

P.sort()

for q in range(int(K)):
    X = X + int(q)

print(X)

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

P = [int(p) for p in input().split()]

P.sort()

X = 0

for q in range(int(K)):
    X = X + P[q]

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

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

p.sort()
c = 0
for i in range(k):
	c += p[i]

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

print(sum(sorted(p)[k:]))


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

print(sum(p[:k]))
Buggy code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p2=p.sort()
print(sum(p2[:k]))

Fixed code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p2=sorted(p)
print(sum(p2[:k]))
Buggy code:
N,K = map(int, input().split())
p=sorted(list(map(int,input().split())))
print(sum(p[0:2]))

Fixed code:
N,K = map(int, input().split())
p=sorted(list(map(int,input().split())))
print(sum(p[0:K]))
Buggy code:
n, k = list(map(int, input().split()))

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

prices = sorted(prices)

print(sum(prices[:k])

Fixed code:
n,k = map(int, input().split())
print(sum(sorted(list(map(int, input().split())))[:k]))
Buggy code:
A1, A2 = map(int, input().split())
B = list(map(int,input().split()))	

B.sort()
num = 0

for i in range(A2):
  num = B[i]

print(num)



Fixed code:
A1, A2 = map(int, input().split())
B = list(map(int,input().split()))	

B.sort()
num = 0

for i in range(A2):
  num = num + B[i]
  
print(num)
Buggy code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
xxx = sorted(A)
zzz = 0
for i in range(K):
    zzz += A[i]
print(zzz)

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

print(sum(l[:k]))

Fixed code:
n, k = map(int, input().split())
l = sorted([int(x) for x in input().split()])

print(sum(l[:k]))
Buggy code:
n, k = input().split()
list_in = list(map(int, input().split()))
print(list_in)
list_in.sort()

sum = 0
for i in range(int(k)):
    sum = sum + list_in[i]

print(sum)

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

sum = 0
for i in range(int(k)):
    sum = sum + list_in[i]

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

Fixed code:
N,K=map(int,input().split())
P=sorted(list(map(int,input().split())))
print(sum(P[:K]))
Buggy code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

print(sum(p[0:K])

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

print(sum(p[0:K]))
Buggy code:
n,k = map(int,input().split())
fruits = list(map(int,input().split()))
total = 0

for i in range(3) :
    x = min(fruits)
    total += x
    fruits.remove(x)
    
print(total)

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

for i in range(k) :
    x = min(fruits)
    total += x
    fruits.remove(x)
    
print(total)
Buggy code:
N, K = map(int, input().split(" "))
p = list(map(int, input().split(" ")))

sort(p)
print(sum(p[:K]))

         
           

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

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

p.sort()
print(sum(p[0:K]))
Buggy code:
N,K = map(int,input())
aa = list(map(int,input()))
aa.sort()
aaa = aa[:K]
print(sum(aaa))

Fixed code:
N,K = map(int,input().split())
aa = list(map(int,input().split()))
aa.sort()
aaa = aa[:K]
print(sum(aaa))
Buggy code:
n, k = map(int, input().split())
p = sorted(list(int, input().split()))

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

print(ans)

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

ans = 0
for i in range (k):
  ans += p[i]
print(ans)
Buggy code:
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
a = [int(i) for i in input().split()]
sorted(a)
sum = 0
for i in range(m):
  sum += a[i]
print(sum)


Fixed code:
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
a = [int(i) for i in input().split()]
a = sorted(a)
sum = 0
for i in range(m):
  sum += a[i]
print(sum)
Buggy code:
N, K = map(int, input().split())
p_list=sorted(list(map(int, input().split())))

print(p_list[:K])




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

print(sum(p_list[:K]))
Buggy code:
n, k = [int(j) for j in input().split(' ')]
p = input().split(' ')

p.sort()
sum = 0

for i in range(0,k):
  sum+=p[i]
  
print(sum)

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

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

p.sort()
print(sum(p[:K]))
Buggy code:
n,k = input().split(" ")

cost = input().split(" ")

cost.sort()

sum = 0
for i in range(int(k)):
  sum += int(cost[i])
print(sum)

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

cost = input().split(" ")
a = []
for i in cost:
  a.append(int(i))
a.sort()

sum = 0
for i in range(int(k)):
  sum += int(a[i])
print(sum)
Buggy code:
k,n = map(int, input().split())
prices = list(int, input().split()).sort()
total = sum(prices[:n])
print(total)


Fixed code:
k, n = map(int, input().split())
prices = list(map(int, input().split()))
prices.sort()
total = sum(prices[:n])
print(total)
Buggy code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
l1 = sorted(l, reverse= False)
sum = sum(l[0:3])
print(sum)

Fixed code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
l1 = sorted(l, reverse= False)
sum = sum(l1[0:k])
print(sum)
Buggy code:
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort()

n = 0
for i in range(b):
  n += i
  
print(n)

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

n = 0
for i in range(b):
  n += c[i]
  
print(n)
Buggy code:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum[:k])

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

p = sorted(p)

print(sum(p[:k]))
Buggy code:
N, K = int(input())
p = [int(i) for i in input().split()]
p_ascending = p.sort()
total = 0
for i in p_ascending[0,K]:
  total += i
  
print total
  

Fixed code:
N, K = map(int, input().split())
p = [int(i) for i in input().split()]
p.sort()
total = 0
for i in p[:int(K)]:
  total += i
  
print(total)
Buggy code:
n,k=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
print(sum(P[:5]))

Fixed code:
n,k=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
print(sum(P[:k]))
Buggy code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
print(sum(p[:k]))

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

print(sum(p[:k]))