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())
p = [int(x) for x 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())
ps   = sorted(map(int, input().split()))

print(sum(ps[:k]))

Solution (Python):
def run(n, k, num_array):
    '''
    '''
    print(sum([i for i in sorted(num_array)[:k]]))

if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    num_array = list(map(int, input().split()))

    run(n, k, num_array)

Solution (Python):
N, K = list(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()
add=0
for i in range(k):
    add+=p[i]
print(add)

Solution (Python):
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    k = kwargs["k"]
    P = kwargs["P"]
    P = sorted(P)
    res = sum(P[:k])
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"], kwargs["k"] = [int(i) for i in cin]
    cin = input().split()
    kwargs["P"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

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

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

Solution (Python):
import sys
from io import StringIO
import unittest
import os


sys.setrecursionlimit(999999999)



def resolve(test_def_name=""):
    
    
    
    
    
    

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

    p_s.sort()

    print(sum(p_s[0:k]))




class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5 3
50 100 80 120 80"""
        output = """210"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """1 1
1000"""
        output = """1000"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

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

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

p.sort()

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

print(cost)

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

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

P.sort()

ans=sum(P[:K])

print(ans)

Solution (Python):
X = list(map(lambda x:int(x), input().split()))
n = X[0]
k = X[1]
p = list(map(lambda x:int(x), input().split()))

p.sort()

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

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

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

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

print(sum(p[:K]))

Solution (Python):

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

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

print(sum(l[0:b]))

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

print(sum(l[0:k]))

Solution (Python):

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

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

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

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

list.sort()

print(sum(list[:k]))

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

Solution (Python):

import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')


REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

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

        p.sort()

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

        print(str(result))

solver = Solver(REL_PATH)
solver.exec_resolve()

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

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

ans = 0
for i in range(k):
    min_i = min(p_li)
    p_li.remove(min_i)
    ans += min_i

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

print(sum(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

N,K = map(int,sys.stdin.readline().split())

a = tuple(map(int,sys.stdin.readline().split())) 
print(sum(sorted(a)[:K]))

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

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

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

print(result)

Solution (Python):
def main():
    n, k = [int(v) for v in input().split()]
    p = sorted([int(v) for v in input().split()])
    q = sum(p[:k])
    print(q)

main()

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


p_list = sorted(p_list)

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

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

p.sort()
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):
data = input().rstrip().split(" ")
data2 = input().rstrip().split(" ")
price = []
for i in data2:
    price.append(int(i))
price.sort()
ans = 0
for i in range(int(data[1])):
    ans += price[i]
print(ans)

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

Solution (Python):
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  
    to_index = lambda x: int(x) - 1  
    print_list_in_2D = lambda x: print(*x, sep="\n")  

    
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

    def MII_split(): return map(int, input().split())

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

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

    
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    N, K = MII_split()
    ps = LII_split()

    import numpy as np
    ps_array = np.array(ps)
    indicies = np.argsort(ps_array)
    print(sum([ps[i] for i in indicies[:K]]))
    
resolve()

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())
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())
li = list(map(int, input().split()))
li.sort()
ans = 0
for i in range(k):
    ans += li[i]
print(ans)

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

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

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

print(price_sum)

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

Solution (Python):
from collections import deque

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

    p.sort()

    q = deque(p)

    ans = 0
    for _ in range(K):
        ans += q.popleft()

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

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

print(ans)

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

Solution (Python):










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


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



p.sort()

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

print(sum)

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

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

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

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

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

print(sum(arr[: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+=p[i]
print(s)

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

p2 = sorted(p)

print(sum(p2[:k]))

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

print(sum(p_list[:k]))

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

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

print(total)

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

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

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

print(ans)

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

given_list_sort = sorted(given_list)
temp_sum = 0
for i in range(K):
    temp_sum += given_list_sort[i]

print(temp_sum)

Solution (Python):
N,K=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort()
print(sum(lst[: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()))
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(k):
  ans = ans + a[i]
print(ans)

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P.sort()
    print(sum(P[:K]))


main()

Solution (Python):

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

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

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

print(sum(p_list[:K]))

Solution (Python):
n, k = map(int, 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 += p[i]

print(ans)

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

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

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

Solution (Python):
N,K = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
ans = 0
for i in range(K):
    ans = ans + x[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)

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())
lst = list(map(int, input().split()))
lst.sort()
total = 0
for i in range(K):
    total += lst[i]
print(total)

Solution (Python):
import heapq
n,k=map(int,input().split())
p=list(map(int, input().split()))
heapq.heapify(p)
ans=0
for _ in range(k):
    tmp=heapq.heappop(p)
    ans+=tmp
print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n,k = nm()
p = nl()
p = sorted(p)
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()
cost = 0
for i in range(K):
    cost += p[i]
print(cost)

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

Solution (Python):

def q2():
    n, k = [int(i) for i in input().split(" ")]
    p = [int(i) for i in input().split(" ")]
    p.sort()

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


q2()

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(n) for n in input().split()]
P = [int(n) for n in input().split()]
P.sort()

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

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

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

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

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

print(sum(a[:m]))

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

lp.sort()

print(sum(lp[:nk[1]]))

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

print(sum(p[:K]))

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    
    
    
    n, k = map(int, input().split())
    
    
    
    P = list(map(int, input().split()))
    
    

    P.sort()
    cnt=0

    for i in range(k):
        cnt += P[i]

    print(cnt)


resolve()

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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






N, K = getNM()
P = getList()
P.sort()
P = P[:K]
print(sum(P))

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

p.sort()

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

Solution (Python):

from sys import stdin
input = stdin.readline
import numpy as np

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

p.sort()

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

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

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

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

p.sort()

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

print(sum)

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



def main():
    N, K = [int(i) for i in input().strip().split()]
    prices = sorted([int(i) for i in input().strip().split()])

    return sum(prices[:K])


if __name__ == "__main__":
    print(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]))

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

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

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

if __name__=='__main__':
    main()

Solution (Python):
N, K = map(int, input().rstrip().rsplit())
prices = sorted(list(map(int, input().rstrip().rsplit())))

print(sum(prices[:K]))

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

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

print(sum(p_list[:K]))

Solution (Python):
import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate 
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache 

def main():
    n,k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

NK=np.array(input().split(" "),dtype=np.int64)
N=NK[0]
K=NK[1]

p=np.array(input().split(" "),dtype=np.int64)

sorted_p=np.sort(p)

L=sorted_p[:K]

print(sum(L))

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().strip().split())

P = list(map(int, sys.stdin.readline().strip().split()))

P.sort()

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

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

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

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

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

Solution (Python):

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

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 = [int(e) for e in input().split()]
    P = [int(e) for e in input().split()]

    P.sort()

    print(sum(P[:k]))


if __name__ == '__main__':
    main()

Solution (Python):
import math

n, k = map(int, input().split(" "))
pL = sorted(list(map(int, input().split(" "))))

print(sum(pL[:k]))

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

Solution (Python):
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(x) for x in input().split()]
l = [int(x) for x in input().split()]
l.sort()
ans = 0
for i in range(K):
    ans += l[i]
print(ans)

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

li.sort()
total = 0
for i in range(k):
  total += li[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, M = map(int, input().split())
*A, = map(int, input().split())

INF = 1<<30
dp = [[INF]*(N) for _ in [0]*(M+1)]
dp[0][0] = 0
dp[1][0] = A[0]

for i, a in enumerate(A):
    if i == 0:
        continue
    for k in range(M+1):
        dp[k][i] = min(dp[k][i-1], dp[k-1][i-1]+a)

print(min(dp[M]))

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

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

S = 0
for i in range(K):
    S += prices[i]
print(S)

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

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

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

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

p.sort()

count = 0
ans = 0

for i in p:
    count += 1
    if count == k+1:
        break
    ans += i

print(ans)

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

data.sort()
out = 0
for i in range(k):
    out += data[i]
print(out)

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

Solution (Python):
n, k = map(int, input().split())
listP = list(map(int, input().split()))
listP.sort()
mon = 0
count = 0
for p in listP:
    if count < k:
        count+=1
        mon+=p
    if count >= k:
        break
print(mon)

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

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

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

    return ans


print(solve())

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

    p.sort()

    for i in range(k):
        sum += p[i]
    print(sum)
if __name__ == "__main__":
    main()

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

Solution (Python):
import sys



if(__name__ == "__main__"):

    NK= input().strip().split()
    N = int( NK[0] )
    K = int( NK[1] )
    prices = [0] * N
    prices_str = input().strip().split()
    for i in range(N):
        prices[i] = int(prices_str[i])
    prices.sort()
    sum = 0
    for j in range(K):
        sum += prices[j]
    print(sum)

Solution (Python):
def main():
    import sys
    
    
    N, K = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    P.sort()
    print(sum(P[0: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()
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 = sum(p[0:k])
print(ans)

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

P.sort()
result = 0
for i in range(K):
    result = result + P[i]
print(result)

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

p_list.sort()

ans = 0
for i in range(k):
  ans += p_list[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())
a = list(map(int,input().split()))

a = sorted(a)
ans = sum(a[:k])
print(ans)

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

resolve()

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

if __name__ == '__main__':
    resolve()

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

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

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

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

li.sort()

print(sum(li[:k]))

Solution (Python):
N, K = map(int, input().split())
p = [j for j in 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(sorted(map(int, input().split())))

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

l.sort()

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