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):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
print(sum(l[:k]))

Solution (Python):
import numpy as np

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

p.sort()

print(np.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()
 
temp = 0
for i in p[:k] :
  temp += i
print(temp)

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

p.sort()
s = 0
for i in p[:k]:
  s += i
print(s)

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

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

a=sorted(a)

print(sum(a[:k]))

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

Solution (Python):
a,b = map(int,input().split())
price = [int(s) for s in input().split()]
pric = sorted(price)
sum = 0
for i in range(b):
    sum += int(pric[i])
print(sum)

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())
p = sorted(list(map(int, input().split())))
print(sum(p[: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):
a,b = map(int, input().split()) 
cost = sorted(map(int, input().split())) 

ans = 0

for i in range(0, b):
  ans = ans + cost[i]

print(ans)

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

Solution (Python):


def solve():
    N, K = list(map(int, input().split()))
    Ps = list(map(int, input().split()))
    Ps.sort()
    ans = sum(Ps[0:K])
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):

"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

tmp = input()

N,K = tmp.split()
que = input()

try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]


"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

que = sorted(que)



x = [que[i] for i in range(K)]
min_val = np.sum(x)

print(min_val)

Solution (Python):
from sys import stdin

N,K = (int(x) for x in stdin.readline().rstrip().split())

plist = [int (x) for x in stdin.readline().rstrip().split()]

plist.sort()

print(sum(plist[:K]))

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
p = sorted(LI())
print(sum(p[:K]))

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

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):
def main():
    n,k=map(int,input().split())
    pp=sorted(map(int,input().split()))
    print(sum(pp[:k]))
main()

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

print(sum(kudamono[:k]))

Solution (Python):
import sys

input_data = []
input_pointer = 0

output_data = []

def input_scan():
    global input_data
    input_data = sys.stdin.readlines()
    input_data = [x[:-1] for x in input_data]

def next_line():
    global input_pointer
    global input_data
    if input_pointer < len(input_data):
        input_pointer += 1
        return input_data[input_pointer - 1]
    else:
        return ""

def append_output(string):
    global output_data
    output_data.append(string)

def print_output():
    global output_data
    output_data.append("")
    sys.stdout.write("\n".join(output_data))









input_scan()
[n, k] = [int(x) for x in next_line().split(" ")]
fruits = sorted([int(x) for x in next_line().split(" ")])
print(sum(fruits[:k]))

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

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

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

Solution (Python):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


n,k=MAP()
a=sorted(LI())
print(sum(a[:k]))

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

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

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

for i in range(len(b)):
    b[i] = int(b[i])
    
b.sort()
c = 0


for i in range(a[1]):
    c = c + b[i]

print(c)

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

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 = [int(x) for x in input().split()];
p.sort();
sum = 0;
for i in range(0,K) :
    sum = sum + p[i];
print(sum);

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())
price = list(map(int, input().split()))
amount = 0
sortPrice = sorted(price)

for i in range(K):
    amount = amount + sortPrice[i]

print(amount)

Solution (Python):
a = input().split(' ')
n, k = a
n, k = int(n), int(k)
ps = input().split(' ')
pf = []
for i in ps:
    t = int(i)
    pf.append(t)
pf = sorted(pf)
c = []
s = 0

for i in range(k):
    for j in range(n):
        if j in c:
            continue
        c.append(j)
        s += pf[j]
        break

print(s)

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

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

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    p = na()
    p.sort()
    print(sum(p[:k]))

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from functools import reduce

def main(n, k, p):
    """ main
    """
    p.sort()
    return sum(p[0:k])

if __name__ == "__main__":
    N, K = map(int, sys.stdin.readline().split(" "))
    P = list(map(int, sys.stdin.readline().split(" ")))

    print(main(N, K, P))

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

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

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())
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())))

ans = sum(p[:K])
print(ans)

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

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

l.sort()
total = 0
for a in range(K):
  total += l[a]

print(total)

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

if __name__ == '__main__':
	main()

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

l.sort()

print(sum(l[:K]))

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

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

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

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))


def resolve():
    n,k = mi()
    p = mi()

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

if __name__ == "__main__":
    resolve()

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

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

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

s= sum(p[:k])
print(s)

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())
a = list(map(int, input().split()))
a.sort()
print(sum(a[:K]))

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

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):
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

print(sum(A[:K]))

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,m = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
ar.sort()
print(sum(ar[0:m]))

Solution (Python):
n,k = map(int,input().split())
arr = list(map(int,input().split()))
arr = sorted(arr)
print(sum(arr[: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=list(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()))

p.sort()

print(sum(p[:k]))

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

value = 0
for i in range(K):
  value += min(A)
  A.remove(min(A))
print(value)

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()))
PS = sorted(P)
ans=0

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

print (ans)

Solution (Python):









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

Solution (Python):
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    
    n, k = [int(x) for x in raw_input().split()]
    
    arr = [int(x) for x in raw_input().split()]
    
    arr.sort()
    
    ans = sum(arr[0:k])
    
    print(ans)
        
    

main()

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

ans=0
if n!=1:
    for i in range(k):
        min=p[i]
        for j in range(i+1,n):
            if min>p[j]:
                min=p[j]
                p[j]=p[i]
                p[i]=min
        ans+=min
else:
    ans=p[0]
print(ans)

Solution (Python):


import io
import sys
import math

def solve(n,k,p_lst):
    pp_lst = sorted(p_lst)
    return sum(pp_lst[0:k])

def main():
    n,k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    
    ans = str(solve(n,k,p_lst))
    print(ans)

    return ans
        

_DEB = 0   

_INPUT = """\
5 4
50 100 80 120 80
"""
_EXPECTED = """\
210
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")


if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Solution (Python):

import sys
input = lambda: sys.stdin.readline().strip()
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
print(sum(sorted(a)[:k]))

Solution (Python):
list1=(input().split())
list2=(input().split())
list3=[]
sum=0
for i in range(len(list2)):
  list3.append(int(list2[i]))
  list3.sort()
for j in range(int(list1[1])):
  sum=sum+list3[j]
print(sum)

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


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()
x=0
a=0
for x in range(k):
    a+=p[x]
    x+=1
print(a)

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

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

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

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

Solution (Python):
import numpy as np

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

p = np.sort(np.array(p))
print(sum(p[:K]))

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

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

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

Solution (Python):
nsel = int(input().split()[1])
fruits = [int(fr) for fr in input().split()]
print(sum(sorted(fruits)[:nsel]))

Solution (Python):
K =  int(input().split()[1])
p = [int(n) for n in input().split()]
p.sort()
answer = 0
for i in range(K):
  answer += p[i]
print(answer)

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

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

Solution (Python):
import sys
import math
import collections

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


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


def get(s):
    return str(s % 9) + '9' * (s // 9)

if __name__ == '__main__':
    

    
    t = 1

    for ti in range(1, t + 1):
        n, k = int_input()
        A = int_input()

        A.sort()

        print(sum(A[:k]))

Solution (Python):
n, k = 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 = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
s = sum(a[:k])
print (s)

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()
print(sum(A[:k]))

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

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

    print(sum)


if __name__ == "__main__":
    main()

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
A = sorted(readInts())
print(sum(A[: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 = [int(e) for e in input().split()]
nums = [int(f) for f in input().split()]

nums.sort()

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

Solution (Python):
K = int(input().split(" ")[1])
p = [int(i) for i in input().split(" ")]
p.sort()
sum = 0
for i in range(K):
  sum += int(p[i])
print(sum)

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

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

Solution (Python):
N_K_var = input().split()
price_list_var = input().split()

N_K = [int(s) for s in N_K_var]
price_list = [int(s) for s in price_list_var]

price_sorted = sorted(price_list)
price = 0
for i in range(N_K[1]):
    price += price_sorted[i]

print(price)

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

Solution (Python):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n,k = mi()
    p = li()
    p.sort()
    ans = 0
    for i in range(k):
        ans+=p[i]
    print(ans)


main()

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

count = 0
for i in range(int(K)):
    count += A[i]
print(count)

Solution (Python):
import sys

data = sys.stdin

conversion_data = []
for l in data:
    conversion_data.append([int(i) for i in l.split()])
    

N = conversion_data[0][0]
K = conversion_data[0][1]
conversion_data[1].sort()
price_list = conversion_data[1]

print(sum(price_list[:K]))

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

p=sorted(p)
sum=0

for i in range(k):
    sum+=p[i]
print("{}".format(sum))

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

print(ans)

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()))
sum = 0

p.sort()
for x in range(k):
  sum += p[x]
  
print(sum)

Solution (Python):
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
n,k = ma()
P = list(ma())
P.sort()
print(sum(P[0:k]))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, k = map(int, input().split())
p = [int(x) for x in input().split()]

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

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

new_p = sorted(prices)
sum = 0
for i in range(k):
    sum += new_p[i]

print(sum)

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

p.sort()

print(sum(p[:k]))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    P.sort()

    print(sum(P[:K]))





if __name__ == '__main__':
    main()

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

y = sum(sorted(l)[:int(K)])

print(y)

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

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 = list(map(int,input().split()))
p_list.sort()
print(sum(p_list[:K]))

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

Solution (Python):









import sys

def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]

OutV = lambda x: print(*x, sep='\n')

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)


N, K = iInM()
P = iInLH()

P.sort()

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

print(ans)

Solution (Python):
from sys import stdin
A=stdin.readline().split()
N=int(A[0])
K=int(A[1])
B=list(map(int,stdin.readline().split()))
B.sort()
sum=0

for k in range(0,K):
  sum+=B[k]
 
print(sum)

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, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

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

Solution (Python):
n,k=map(int,input().split())
p=sorted(list(map(int,input().split())))
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()))
p.sort()

import numpy as np
ans = np.sum(p[:K])
print(ans)

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

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

Solution (Python):
N, K = [int(i) for i in input().split()]
p = sorted([int(i) for i in input().split()])
print(sum(p[: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 = ans + p[i]
print(ans)

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0
result = []
while count < a[1]:
  result.append(min(b))
  b.remove(min(b))
  count += 1
  
print(sum(result))

Solution (Python):
load = input().split(" ")
N = int(load[0])
K = int(load[1])

price = input().split(" ")
for i in range(len(price)):
  price[i] = int(price[i])

price.sort()

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

Solution (Python):
import sys

n, k = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [int(x) for x in sys.stdin.readline().strip().split(" ")]

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

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

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

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

Solution (Python):
li = input().split(' ')
N = int(li[0])
K = int(li[1])
li = input().split(' ')
li2 = []

for item in li:
  li2.append(int(item))
  
li2.sort()

print(sum(li2[:K]))

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

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

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

Solution (Python):
n ,k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = sorted(p)
total = 0
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()
print(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())

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

a = 0

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

print(a)

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

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

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

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

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    p=LI()
    p.sort()
    ans=sum(p[:K])
    print(ans)

main()

Solution (Python):



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


p_nums = sorted(p_nums)
num_tmp = p_nums[:K]
ans = sum(num_tmp)


print(ans)

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()))
p1 = sorted(p)
print(sum(p1[:K]))

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

Solution (Python):
from queue import LifoQueue


def print_sol(c, sol):
    print('Case 


def rd_int():
    return int(input())


def rd_str():
    return input()


def rd_str_lst():
    return input().split(' ')


def sp_str_lst():
    return list(input())


def rd_int_lst():
    return [int(i) for i in rd_str_lst()]


def sp_int_lst():
    return [int(i) for i in sp_str_lst()]


def dfs(g, i, v):
    """
    recursive post order dfs
    Args:
        g: array of graph nodes
        i: node to traverse
        v: visited array

    Returns: a post order dfs of graph g
    """
    v[i] = True
    for j in g[i]:
        if not v[j]:
            dfs(g, j, v)

    print(i)


def dfs_iter(g, i, n):
    v = [False] * n
    stack = LifoQueue()
    stack.put(i)
    while stack.not_empty:
        u = stack.get()
        v[u] = True
        print(u)
        for i in g[u]:
            if not v[i]:
                stack.put(i)


def main():
    n, k = rd_int_lst()
    p = rd_int_lst()
    p.sort()

    print(sum(p[:k]))


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n, k  = [int(num) for num in input().strip().split(' ')]
prices = [ int(num) for num in input().strip().split(' ')]
prices.sort()
ans = 0

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

print(ans)

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

Solution (Python):
import sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()
    print(sum(P[:k]))
resolve()

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

prices = sorted(prices)


print(sum(prices[:K]))

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

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())

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

print(sum(p[:K]))

Solution (Python):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
def p(a):print(" ".join(list(map(str,a))))
from collections import Counter

n,k=MAP()
a=sorted(LI())
print(sum(a[:k]))

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

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

Solution (Python):
arr = list(map(int, input().split()))
N = arr[0]
K = arr[1]

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

p.sort()
sum = 0

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

print(sum)

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

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

Solution (Python):
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = sorted([int(_) for _ in stdin.readline().rstrip().split()])
print(sum(P[:K]))

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

if __name__ == '__main__':
    main()

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()
print(sum(p[:k]))