Problem:
 Score : 200 points    Problem Statement A shop sells N kinds of fruits, Fruit 1, \ldots, N , at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)  Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.      Constraints  1 \leq K \leq N \leq 1000  1 \leq p_i \leq 1000  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  p_1  p_2  \ldots  p_N       Output Print an integer representing the minimum possible total price of fruits.        Sample Input 1 5 3
50 100 80 120 80      Sample Output 1 210  This shop sells Fruit 1 , 2 , 3 , 4 , and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.  The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1 , 3 , and 5 .       Sample Input 2 1 1
1000      Sample Output 2 1000

Solution (Python):
import itertools
import sys
from typing import Callable, List, NoReturn


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline
    n, k = map(int, readline().rstrip().split())  
    p: List[int] = [int(_) for _ in readline().rstrip().split()]
    p.sort()
    print(sum(p[:k]))


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int,input().split())
l = sorted(list(map(int,input().split())))
 


print(sum(l[:k]))

Solution (Python):
n,k,*p=map(int,open(0).read().split())
print(sum(sorted(p)[:k]))

Solution (Python):
n, k = input().split(" ")
n = int(n)
k = int(k)
p = input().split(" ")
p = list(map(int, p))

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

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
S = 0
 
for i in range(K):
  S = S + p[i]
  
print(S)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
total = 0
list.sort(p)
for i in range(k):
    total += p[i]
print(total)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
ps=sorted(p)
print(sum(ps[:k]))

Solution (Python):
import sys
input = sys.stdin.readline

def slove():
    n, k = map(int,input().split())
    p = map(int,input().split())
    p = sorted(p)
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)

if __name__ == "__main__":
    slove()

Solution (Python):
numberOfFruit, chosenFruit = map(int, input().split())
priceRange = list(map(int, input().split()))
sortedPriceRange = sorted(priceRange)
print(sum(sortedPriceRange[:chosenFruit]))

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))

l.sort()

cheap = l[:k]

print(sum(cheap))

Solution (Python):
N,K = map(int,input().split())

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

total = 0

p.sort()

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

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()

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

Solution (Python):
n , k= map(int, input().split())
p = list(map(int, input().split()))


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

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
s=0
l.sort()
x=l[:m]
print(sum(x))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
print(sum(sorted(p)[:K]))

Solution (Python):
a = list(map(int,input().split()))
n = a[0]
k = a[1]
m = list(map(int,input().split()))
m.sort()
sum = 0
i = 0
while(i<k):
  sum += m[i]
  i += 1
print(sum)

Solution (Python):
n, k= map(int,input().split())
lista= [int (x) for x in input().split()]
soma=0
novalist= sorted(lista)
for x in range(k):
    soma+= novalist[x]
print(soma)

Solution (Python):
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)

Solution (Python):
n, k, = map(int, input().split())
p = list(map(int, input().split()))

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

print("{}".format(ret))

Solution (Python):
n, k = map(int, input().split())


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



sort_x = sorted(x)

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

print(sum)

Solution (Python):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

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

Solution (Python):
x,y = map(int,input().split())
li= list(map(int,input().split()))
li.sort()
ans=0
for i in range(y):
  ans+=li[i]
print(ans)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):

"""
Created on Sun Jun 21 21:05:17 2020

@author: naoki
"""

N,K = map(int,input().split())
p = list(map(int,input().split())) 
p.sort()
count = 0 
for i in range(K):
    count += p[i]
print(count)

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
ppp=sorted(p)
buy=[]
for i in range(K):
    buy.append(ppp[i])
print(sum(buy))

Solution (Python):
a, b = input().split()
x = int(a)
y = int(b)

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

total = 0

after = sorted(fruits)

for i in range(y):
    total += after[0]
    after.pop(0)



print(total)

Solution (Python):
n, k = map(int, input().split())
p = sorted(map(int, input().split()))

i = 0
x = 0
while i < k:
    x = x + p[i]
    i += 1

print(x)

Solution (Python):
n,k = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()

ln = l[:k]
print(sum(ln))

Solution (Python):
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)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
cost=0
for t in range(k):
    cost+=p[t]
print(cost)

Solution (Python):
a, b = map(int, input().split())
l = list(map(int, input().split()))
ld = sorted(l)[:b]
sumld = sum(ld)
print(sumld)

Solution (Python):
N,K = (int(x) for x in input().split())
P   = [int(x) for x in input().split()]
print(sum(sorted(P)[:K]))

Solution (Python):
nk = input().split()
n = int(nk[0])
k = int(nk[1])
A = [int(x) for x in input().split()]
A.sort()
ans = 0
for i in range(k):
    ans +=A[i]
print(ans)

Solution (Python):
k = list(map(int, input().split()))
m = list(map(int, input().split()))
sum = 0

m.sort()

for i in range(k[1]):
    sum += m[i]

print(sum)

Solution (Python):
N, K = map(int, input().split())
p = list(int(x) for x in input().split())

sum = 0
p.sort()
for k in range(K):
  sum +=p[k]

print(sum)

Solution (Python):
N,K=map(int,input().split())
price=list(map(int,input().split()))
xprice=sorted(price,reverse=False)
yprice=xprice[:K]
print(sum(yprice))

Solution (Python):
N, K = map(int, input().split())

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

print(sum(p[:K]))

Solution (Python):
N, K = map(int, input().split())
p = [int(i) for i in input().split()]
ans = 0
p.sort()
for x in p[:K]:
    ans += x
print(ans)

Solution (Python):
n,k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[:k]))

Solution (Python):
import heapq
N,K= map(int,input().split())
p = list(map(int, input().split()))

num=heapq.nsmallest(K,p)
print(sum(num))

Solution (Python):
n,m=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
a.sort()
print(sum(a[:m]))

Solution (Python):
n,k = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
sum = 0

p.sort()

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

print(sum)

Solution (Python):
a,b=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
print(sum(l[:b]))

Solution (Python):
n, k = input().split()
lists = list(input().split())
for i in range(int(n)):
    lists[i] = int(lists[i])
lists.sort()
sum_fruit = 0
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists.pop(0))
print(str(sum_fruit))

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

new_A = A[0:K]

print(sum(new_A))

Solution (Python):
n,k = map(int, input().split())
line = sorted(list(map(int,input().split())))
print(sum(line[:k]))

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
n, k = map(int, input().split())
yenstr = input().split()

yenint = []
for y in yenstr:
    yenint.append(int(y))


yensort = []
small = 1
while small <= 1000:
    for i in yenint:
        if i == small:
            yensort.append(i)
    small += 1


count = 0
for j in range(0, k):
    count += yensort[j]
print(count)

Solution (Python):
N, K = (int(i) for i in input().split())  
P = list(map(int, input().split()))

P.sort()

print(sum(P[:K]))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
B=0
C=0
p.sort()
N=N-5
for i in range(0,K):
    B=B+p[i]
    i=i+1
    
print(B)

Solution (Python):
N, K = map(int, (input().split()))
list1 = list(map(int, input().split()))
list1.sort()
to_sum = list1[0:K]
print(sum(to_sum))

Solution (Python):
n,k=map(int, input().split()) 
a = list(map(int, input().split()))
b=sorted(a)
c=0
for i in range(k):
   c+=b[i]
print(c)

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

Solution (Python):
N,K=map(int,input().split())
a=map(int,input().split())
ans = sorted(a)
answer = ans[:K]
aaa = sum(answer)
print(aaa)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
sum = 0

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

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

Solution (Python):
N, K = map(int, input().split())
p = list(map(int,input().split()))

p.sort()
ans = 0

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

Solution (Python):
N , K =map(int,input().split())
p=list(map(int,input().split()))
ans=0
p.sort()
for i in range(K):
    ans+=p[i]
print(ans)

Solution (Python):
x = input().split()
for i in range(len(x)):
  x[i] = int(x[i])
list = input().split()
for i in range(x[0]):
  list[i] = int(list[i])
list.sort()
sum = 0
for i in range(x[1]):
  sum += list[i]
print(sum)

Solution (Python):
import sys

input_list = sys.stdin.readlines()

count = 1
get_count = 0
get_value_count = 0
output = 0
for i in input_list:
  get_values = i.split()
  if count == 1:
    get_value_count = int(get_values[0])
    get_count = int(get_values[1])
  else:
    if get_value_count == 1:
      output = get_values[0]
    else:
      new_list = sorted(get_values, key=int)
      count_value = 1
      for c in new_list:
        if count_value > get_count:
          break
        else:
          output = output + int(c)
        count_value = count_value + 1
  count = count + 1
print(str(output))

Solution (Python):
x,y = map(int, input().split())
list=[int(i) for i in input().split()]
list.sort()
count=0
for i in range(y):
    count=count+list[i]
print(count)

Solution (Python):
def main():
  N, K = map(int, input().split())
  p = list(map(int, input().split()))
  p.sort()
  print(sum(p[:K]))
  
if __name__ == "__main__":
  main()

Solution (Python):




import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
sys.setrecursionlimit(10 ** 8)


def 関数(n, k, lipi):
    lipi.sort()
    boy = len(lipi)
    boy = min(k, boy)

    somme = 0
    for i in range(boy):
        somme += lipi[i]
    return somme

def çözmek():
    N, K = map(int, input().split())
    
    liste_pi = list(map(int, input().split()))
    
    res = []
    res.append(関数(N, K, liste_pi))
    print(*res)

if __name__ == "__main__":
    çözmek()

Solution (Python):
n,k=map(int,input().split())
p=[]
a,*b=map(int,input().split())
p.append(a)
for i in range(len(b)):
    p.append(b[i])
p.sort()
y=0
for i in range(k):
    y=y+p[i]
print(y)

Solution (Python):
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)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))

p.sort()

res=sum(p[:k])

print(res)

Solution (Python):
def main():
    n, k = list(map(int, input().split()))
    p_list = list(map(int, input().split()))
    
    p_list.sort()
    total_money = 0
    for i in range(k):
        total_money += p_list[i]
    
    print(total_money)

if __name__ == '__main__':
    main()

Solution (Python):
N,K=map(int,input().split())
ans=0
p=list(map(int,input().split()))

p.sort()

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

print(ans)

Solution (Python):
number,buy= (int(x) for x in input().split())


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

total = 0

for i in range(buy):
    total = total + min(price)
    price.remove(min(price))

print(total)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
print(sum(P[:K]))

Solution (Python):
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
tmp = [0]*k
for i in range(k):
    tmp[i] = min(p)
    p.remove(tmp[i])
print(sum(tmp))

Solution (Python):
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
arr.sort()
print(sum(arr[:k]))

Solution (Python):
import heapq
N,K = map(int,input().split())
p = list(map(int,input().split()))
print(sum(heapq.nsmallest(K,p)))

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))

P.sort()

print(sum(P[:K]))

Solution (Python):
N , K = map(int, input().split())
l = list(map(int, input().split()))
ll = sorted(l)
res = 0
if N == K :
    res = sum(ll)
elif K==1 : 
    res = ll[0]
else:
    for i in range (K):
        res += ll[i]
print(res)

Solution (Python):
N, K = map(int, input().split())

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

ans = 0
for i in range(K):
  ans += sL[i]
  
print(ans)

Solution (Python):

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

L.sort()

l = L[0:K]

print(sum(l))

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
price=0

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

Solution (Python):
N , K = map(int, input().split())
l = list(map(int, input().split()))
ll = sorted(l)
res = 0
if N == K :
    res = sum(ll)
elif K==1 : 
    res = ll[0]
else:
    for i in range (K):
        res += ll[i]
print(res)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

i = 0
price = 0
while i < k:
  price += p[i]
  i += 1
 
print(price)

Solution (Python):
n,k =map(int, input().split())
line = list(map(int, input().split()))

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

Solution (Python):
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort()
print(sum(P[:K]))

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

Solution (Python):
import itertools
N,K = map(int,input().split())
P = list(map(int,input().split()))
Sigma = sorted(P,reverse = False)
print(sum(Sigma[:K]))

Solution (Python):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

p_list = sorted(p_list)
print(sum(p_list[:k]))

Solution (Python):
n, k = map(int,input().split())
price = list(map(int, input().split()))
a = sorted(price)
total = 0
for i in range(k):
    total +=a[i]
print(total)

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
sort_p=sorted(p)
i=0
m=0
while K!=i:
    m=m+sort_p[i]
    i=i+1

print (m)

Solution (Python):
N, K = map(int, input().split())
price = list(map(int,input().split()))
total = 0
for i in range(K):
  min_prices = min(price)
  total += min_prices
  price.remove(min(price))
print(total)

Solution (Python):

n,k = map(int,input().split())
p = list(map(int,input().split()))
p = sorted(p)
print(sum(p[:k]))

Solution (Python):
N,K=map(int, input().split())
P=sorted(map(int, input().split()))
sum=0
for i in range(K):
  sum+=P[i]
print(sum)

Solution (Python):
N, K = map(int, input().split())

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

sumz = 0
for i in range(K):
    sumz += fruit[i]

print(sumz)

Solution (Python):
n,k = map(int,input().split())

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

low = sorted(p)

ans = 0

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

print(ans)

Solution (Python):
n, m =map(int,input().split())
s = list(map(int,input().split()))
ans = 0
s.sort()
for _ in range(m):
  ans += s[_]
print(ans)

Solution (Python):
A = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
N = A[0]
K = A[1]
S = 0
L = []
if N == K:
    for i in range(N):
        S += P[i]
else:
    P.sort()
    for i in range(K):
        S += P[i]

print(S)

Solution (Python):
import sys

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


A = list(map(int, input().split()))
A = sorted(A, reverse = False)


ans=0


ans = (A[:K])

print(sum(ans))

Solution (Python):

N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
r = 0
for i in range(K):
    r = r+p[i]
print(r)

Solution (Python):
n, k = map(int, input().split())
price_arr = list(map(int, input().split()))
price_arr.sort()
value = 0
for i in range(k):
    value += price_arr[i]
print(value)

Solution (Python):
K, N = map(int, input().split())

P_in = input().split()
price = []

for i in P_in:
    price.append(int(i))
    
P_sort = sorted(price)
print(sum(P_sort[:N]))

Solution (Python):
from functools import reduce 

N,K = [int(x) for x in input().split()]
P = sorted([int(x) for x in input().split()])
print(reduce(lambda x,y:x+y,P[0:K]))

Solution (Python):
ans=0
X=[]
N,K=map(int, input().split())
P=[int(_) for _ in input().split()]
P.sort()
print(sum(P[0:K]))

Solution (Python):
num = list(map(int,input().split()))
prices = list(map(int,input().split()))
prices.sort()
ans =0
for i in range(num[1]):
  ans +=prices[i]
print(ans)

Solution (Python):
a,b= map(int, input().split())
p=map(int, input().split())
X=sorted(p)[:b]
print(sum(X))

Solution (Python):
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)

Solution (Python):
N, K = map(int, input().split())
prices = [int(i) for i in input().split()]
prices.sort()
print(sum(prices[:K]))

Solution (Python):
t=1
while t:
	t-=1
	n,m=(map(int,input().split()))
	l=list(map(int,input().split()))
	l.sort()
	i=0
	sumi=0
	while(i<m):
		sumi+=l[i]	
		i+=1
	print(sumi)

Solution (Python):
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)

Solution (Python):
[n,k] = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]
data.sort()

print(sum(data[:k]))

Solution (Python):
n,k=map(int,input().split())
print(sum(sorted(map(int,input().split()))[:k]))

Solution (Python):
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)

Solution (Python):
N, K = map(int,input().split())
p = list(map(int,input().split()))

list.sort(p)
total = 0
for i in range(K):
	total += p[i]
print(total)

Solution (Python):



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


if __name__ == "__main__":
    main()

Solution (Python):
N, K = map(int, input().split())

"1 2 3 4 5を配列に"
p = list(map(int, input().split()))

p.sort()

count = 0
for i in range(K):
  count += p[i]

print(count)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
N,K = map(int, input().split())
L=range(N)
L=map(int, input().split())
l=sorted(L)
del l[K:]
J=sum(l)
print(J)

Solution (Python):
N,K=map(int,input().split())
L=list(map(int, input().split()))
L.sort()
print(sum(L[0:K]))

Solution (Python):
N, K = map(int, input().split())
fruits = sorted(list(map(int, input().split())))
pay = 0
for i in range(K):
    pay += fruits[i]
print(pay)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
res = 0
for num in range(k):
  res += p[num]

print(res)

Solution (Python):
N, K = map(int, input().split())

"1 2 3 4 5を配列に"
p = list(map(int, input().split()))

p.sort()

count = 0
for i in range(K):
  count += p[i]

print(count)

Solution (Python):



def main():
    N, K = map(int,input().split())
    p = list(map(int,input().split()))
    p.sort()
    print(sum(p[:K]))


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
p_list =  sorted(list(map(int, input().split())))
print( sum(p_list[0:k]) )

Solution (Python):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a_sort = sorted(a)
sum = 0
for num in range(k):
  sum =sum+ a_sort[num]
print("{}".format(sum))

Solution (Python):
N,K = map(int, input().split())
P   = list(map(int,input().split()))
ans = 0

newP = sorted(P)
for i in range(0,K):
    ans += newP[i]

print(ans)

Solution (Python):
a, b = map(int, input().split())
c = input().rstrip().split()
d = sorted ([int(s) for s in c])

sum = 0
for i in range (b):
    sum = sum + d[i]

print(sum)

Solution (Python):
N,K = map(int,input().split())
L=list(map(int,input().split()))
S=0
for i in range (K):
  S+=min(L)
  L.remove(min(L))
print(S)

Solution (Python):
nk=list(map(int,input().split()))
p=list(map(int,input().split()))

q=sorted(p)

li=[]
for i in range(int(nk[1])):
  li.append(q.pop(0))

print(sum(li))

Solution (Python):
N,K=map(int,input().split())
p=list(input().split())
sum=0
for i in range(K):
    q=sorted(p,key=int)
    sum += int(q[i])
print(sum)

Solution (Python):
N, K = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum(p[:K]))

Solution (Python):
fruit = map(int, input().split())
price = map(int, input().split())
list1=[]
list2=[]
for i in price:
    list1.append(i)
for j in fruit:
    list2.append(j)
sot=sorted(list1)
result=0
for x in range(0,list2[1]):
    result+= sot[x]
print(result)

Solution (Python):
from functools import reduce

N, K = [int(x) for x in input().split()]
p = sorted([int(x) for x in input().split()])
print(reduce(lambda x, y: x + y, p[0:K]))

Solution (Python):
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)

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

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

print(s)

Solution (Python):
N, K = map(int,input().split())
li = list(map(int, input().split()))

li.sort()
i = 0
sum = 0

while i <= K-1:
    n =li[i]
    sum += n
    i += 1

print(sum)

Solution (Python):
N,K = map(int,input().split())
List = list(map(int,input().split()))

List.sort()

print(sum(List[:K]))

Solution (Python):
print((lambda a,p:sum(sorted(p)[:a[1]]))(list(map(int,input().split())),list(map(int,input().split()))))

Solution (Python):
N,K=map(int, input().split())
p=list(map(int, input().split()))
p.sort()
count = 0
for i in range(K):
  count+=p[i]
print(count)

Solution (Python):
k_n = list(map(int, input().split()))
p = list(map(int, input().split()))
p = sorted(p, reverse=False)
sum = 0
for i in range(k_n[1]):
    sum += p[i]
print(sum)

Solution (Python):
N,K=map(int,input().split(' '))
Num=list(map(int,input().split(' ')))
l=list()
for i in range(K):
  min_Num=min(Num)
  l.append(min_Num)
  Num.remove(min_Num)
sum_Num=sum(l)
print(sum_Num)

Solution (Python):
n,k = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
sum = 0
for j in range(k):
  sum = sum + li[j]
print(sum)

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

Solution (Python):
n, k = map(int, input().split())
p = input()
x = p.split()
l = [int(s) for s in x]
shukei = 0

def shukei_def():
    global shukei
    if n == len(l):
        for i in range(k):
            shukei += min(l)
            l.remove(min(l))
        else:
            return

shukei_def()

print(shukei)

Solution (Python):
N,K = map(int,input().split())
p_list = list(map(int, input().split()))

new_p_list = sorted(p_list)[:K]
sum = 0
for p in new_p_list:
    sum = sum + p
print(sum)

Solution (Python):
n,k = map(int, input().split())
lst = sorted(list(map(int, input().split())))

res = sum(lst[:k])
print(res)

Solution (Python):
from sys import exit




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

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

Solution (Python):
N, K, *P = map(int, open(0).read().split())

P.sort()

print(sum(P[:K]))

Solution (Python):
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()

sum=0
for n in range (K):
    sum+=p[n]
print(sum)

Solution (Python):
N,K=input().strip().split()
N,K=[int(N),int(K)]

p=input().strip().split()

p_in=[int(s) for s in p]


p_sort=sorted(p_in)

sum=0

for i in range(0,K,1):
    sum=sum+p_sort[i]

print(sum)

Solution (Python):
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
sum=0
p.sort()
for i in range(K):
  sum+=p[i]
print(sum)

Solution (Python):
N,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
print(sum(L[:K]))

Solution (Python):
N, K = [int(x) for x in input().split()]
prices = sorted([int(x) for x in input().split()])

print(sum(prices[:K]))

Solution (Python):
n,k = map(int,input().split())
if n==1:
    print(int(input()))
else:
    total = 0
    lis = list(map(int,input().split()))
    lis.sort()
    for i in range(k):
        total += lis[i]
    print(total)

Solution (Python):
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)

Solution (Python):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

result = 0

for _ in range(k):
  min_p = min(p)
  index = p.index(min_p)
  p.pop(index)
  result += min_p

print(result)

Solution (Python):
import numpy as np
n,k = map(int,input(). split ())
a = list(map(int, input().split()))

la = sorted(a)
ans = 0
for i in range(k):
    ans += la[i]

print(ans)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))

P.sort()

print(sum(P[0:K]))

Solution (Python):
n,k = map(int,input().split())
lisP= list(map(int,input().split()))
lisP.sort()
print(sum(lisP[:k]))

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
l = sorted(p)
print(sum(l[:k]))

Solution (Python):
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)

Solution (Python):
n,k,*p=map(int,open(0).read().split())
p.sort()
print(sum(p[:k]))

Solution (Python):
N, K = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum(p[:K]))

Solution (Python):
n,k = map(int, input().split())
a = list(map(int, input().split())) 
a.sort(reverse=False)
ans = 0

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

print(ans)

Solution (Python):
import numpy as np
import math
import collections
import bisect


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    p = sorted(p)
    print(sum(p[:K]))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import itertools

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    p = LI()
    ps = sorted(p)
    ans = 0

    for i in range(K):
        ans += ps[i]

    print(ans)
    
    



if __name__ == "__main__":
	main()

Solution (Python):
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)

Solution (Python):
N,K=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
ans=0
n=0
for n in range(K):
    ans+=A.pop(0)
print(ans)

Solution (Python):
N, K = map(int, input().split())
prices = sorted(list(map(int, input().split())))
sum = 0
for i in range(0,K) :
    sum = sum + prices[i]

print(sum)

Solution (Python):
x, n = map(int, input().split())
d = []
d= list(map(int, input().split()))


d.sort()
a = 0
for i in range(n):
    a = a + d[i]
print(a)

Solution (Python):
n, k = map(int, input().split())

p = [int(i) for i in input().split()]
sp = sorted(p)
l = []
for i in range(k):
    l.append(sp[i])
print(sum(l))

Solution (Python):
import itertools
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

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

Solution (Python):
n,k = map(int,input().split())
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)
 
new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)

Solution (Python):
N,K = map(int,input().split())
import sys
if N==1:
    print(input())
    sys.exit()
list = input().split()
MIN = 1001
SUM = 0
for j in range(0,K):
  for i in list:
    if MIN > int(i):
      MIN = int(i)
  list.remove(str(MIN))
  SUM += MIN
  MIN = 1001
print(SUM)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int,input().split()))

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

Solution (Python):


kind = input().split()
kind_int = [int(l) for l in kind]

price = input().split()
price_int = [int(l) for l in price]
price_int.sort()

price_int_2 = price_int[0:kind_int[1]]
print(sum(price_int_2))

Solution (Python):
k = 0
a = input().split(" ")
b = input().split(" ")
g = int(a[0])
f = int(a[1])
i = 0
d = []
while i < g :
    d.append(int(b[i]))
    i = i + 1
x = sorted(d)
i = 0
while i < f :
    k = k + x[i]
    i = i + 1
print(k)

Solution (Python):
n,k = map(int,input().split())
prices = list(map(int,input().split()))
prices.sort()
sum1=0
for i in range(k):
	sum1+=prices[i]
print(sum1)

Solution (Python):
a, b =map(int,input().split())
c = list(map(int,input().split()))
c.sort()
print(sum(c[:b]))

Solution (Python):
a = list(map(int, input().split()))
v = list(map(int, input().split()))
v.sort()
r = 0
for i in range(0, a[1]):
    r += v[i]
print(r)

Solution (Python):
n,k = (int(a) for a in input().split())
p = sorted(list(map(int,input().split())))
print(sum(p[:k]))

Solution (Python):
a = input().split()
b = input().split()

a = [int(x) for x in a]
b = [int(x) for x in b]

a = a[1]
b.sort()

output = sum(b[0:a])
print(output)

Solution (Python):
N, K = map(int,input().split())
p = list(map(int,input().split()))
ans = sorted(p)
print(sum(ans[0:K]))

Solution (Python):
a = []
a = input().split()
N = int(a[0])
K = int(a[1])
p = []
p = input().split()
p = [int(i) for i in p]




p.sort()


total = 0

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

print(total)

Solution (Python):
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)

Solution (Python):
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)