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 sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


if __name__ == '__main__':
    solve()

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

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

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


new_fluit = sorted(fluit)

sum_fluit = sum(new_fluit[:k])
print(sum_fluit)

Solution (Python):




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

num_list.sort()

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

print(ans)

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

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

  P.sort()

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


if __name__ == "__main__":
  main()

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

Solution (Python):
a, b = [int(x) for x in input().split()]
cs = [int(x) for x in input().split()]
cs.sort()

print(sum(cs[:b]))

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

mix = []
a = 0

while a < k:
    mix.append(min(fruits))
    fruits.remove(min(fruits))
    a += 1

print(sum(mix))

Solution (Python):
n,k=map(int, input().split())
l=sorted(list(map(int,input().split())))
ans=0
if k == 1:
    print(l[0])
else:
    print(sum(l[0:k]))

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

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

print(total)

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

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

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

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

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

Solution (Python):
number = input().split()
num = input().split()
num_int = [int(n) for n in num]
number_int = [int(a) for a in number]
num_int.sort()
m = 0
for i in range(number_int[1]):
    m += num_int[i]
print(m)

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

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

data = list(int(i) for i in input().split())
s =data.sort()
res = 0
for i in range(k):
    res += int(data[i])
print(res)

Solution (Python):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def to_char(a):
    return chr(a + ord("a"))

def main():
    N, K = read_values()
    P = read_list()
    P.sort()
    print(sum(P[:K]))


if __name__ == "__main__":
    main()

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

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()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    l = nl()
    print(sum(sorted(l)[:k]))
    return

solve()

Solution (Python):
import sys
from numba import njit
from numba import prange

import re

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def solver(N,K,Pn):
    Pn.sort()

    s = 0
    for i,p in enumerate(Pn):
        s = s + p
        if i == K - 1:
            break

    print(s)

def main():
    N,K = LI()
    Pn = LI()
    
    solver(N,K,Pn)

if __name__ == '__main__':
    main()

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

p = input()
lists = []
for i in range(N):
  lists.append(int(p.split(" ")[i]))

lists.sort()

price = 0
for j in range(K):
  price += lists[j]
  
print(price)

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

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

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

Solution (Python):
import numpy as np

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

ans = 0

for c1 in range (k):
    ans = ans + ( np.min(p) )
    p.remove(np.min(p))

print(ans)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=0
for i in range(k):
  s+=min(p)
  p.remove(min (p))
print(s)

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

q = sorted(p)
SUM = 0

a = 0

for a in range(0, k):
    SUM += q[a]


print(SUM)

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

sum = 0
min_index = 0

for i in range(k):
    min_index = price_list.index(min(price_list))
    sum += price_list.pop(min_index)

print(sum)

Solution (Python):
n,k = [int(x) for x in input().split()]
fs = [int(x) for x in input().split()]
fs_s = sorted(fs)

price = 0

for i in range(k):
      price += fs_s[i]

print(price)

Solution (Python):
import sys

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

sum = 0
for i, price in enumerate(p):
    sum += price
    if i >= k-1:
        break

print(sum)

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

X = P[0]
for i in range(K-1):
    X = X + P[i+1]
    
print(X)

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 = input().split(' ')
n = int(n)
k = int(k)
p = input().split(' ')
s =  [int(i) for i in p]
total =0
for _ in range(k):
  total += s.pop(s.index(min(s)))
print(total)

Solution (Python):
input_data = [input().split() for l in range(2)]

total_num = int(input_data[0][0])
select_num = int(input_data[0][1])

price_list = []
for price in input_data[1]:
  price_list.append(int(price))

min_price = 0
for p in sorted(price_list)[:select_num]:
  min_price += p

print(min_price)

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()))
p1 = sorted(p)
ans = p1[0:k]
a = 0
print(sum(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())
l = list(map(int, input().split()))
s = 0
l.sort()
for i in range(k):
  s += l[i]
print(s)

Solution (Python):
n,k = map(int, input().split())
P = [*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())
plist = list(map(int,input().split()))

sorted = sorted(plist)

output = 0
for i in range(k):
  output += sorted[i] 
  
print(output)

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

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.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[0:k])

print(ans)

Solution (Python):

max_, request = map(int, input().split())
amounts = list(map(int, input().split()))
amounts.sort()
print(sum(amounts[:request]))

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

S = 0
cou = 0
p.sort()

for i in p:
    cou += 1
    S += i
    if cou >= K:
        break
    
print(S)

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

Solution (Python):


def find_min(lst):
    tmp = lst[0]
    idx = 0
    for i, item in enumerate(lst):
        if item < tmp:
            tmp = item
            idx = i

    return idx


def main():
    n, k = map(int, input().split())
    price = list(map(int, input().split()))

    price_sum = 0

    for i in range(k):
        idx = find_min(price)
        price_sum = price_sum + price.pop(idx)

    print(price_sum)

if __name__ == '__main__':
    main()

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


def solve(N, K, p):
    p.sort(reverse=True)

    sum = 0
    for _ in range(K):
        sum += p.pop()

    return sum


if __name__ == "__main__":
    main()

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
count = 0
p = sorted(p)
for i in p:
  ans += i
  count += 1
  if count == k:
    break
print(ans)

Solution (Python):
import numpy as np
n,k=map(int,input().split())
p=np.array(list(map(int,input().split())))
sp=np.sort(p)
sum=0
for i in range(k):
    sum+=sp[i]
print(sum)

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

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

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

Solution (Python):
n,k=(int(x) for x in input().split())
p = [int(a) for a in input().split()]
p.sort()
ans = 0
for t in range(k):
  ans += p[t]

print(ans)

Solution (Python):
NK = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
N = NK[0]
K = NK[1]
p.sort()
mix = 0
for i in range(K):
    mix += p[i]
print(mix)

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

Solution (Python):
def main():
    _, k = [int(v) for v in input().split(' ')]
    lst_p = [int(v) for v in input().split(' ')]
    lst_p.sort()
    ans = sum(lst_p[:k])
    print(ans)


if __name__ == '__main__':
    main()

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

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

p.sort(reverse = False)

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

print(sam)

Solution (Python):
s = [input() for i in range(2)] 
li1 = list(map(int, s[0].split()))
li2 = list(map(int, s[1].split()))
N = li1[0]
K = li1[1]

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

Solution (Python):
import sys
import math as mt
input=sys.stdin.buffer.readline  

t=1
for __ in range(t):
    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())
P = list(map(int, input().split()))
P.sort()

print(sum(P[:K]))

Solution (Python):
def resolve():
    N, K = list(map(int, input().split()))
    p_list = list(map(int, input().split()))
    sorted_p_list = sorted(p_list)
    target_fruits = sorted_p_list[0:K]
    print(sum(target_fruits))

resolve()

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

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

Solution (Python):


l_1 = input()
l_2 = input()

a, b = l_1.split()
prices = list(map(int, l_2.split()))
prices.sort()

r = 0
for i in range(int(b)):
    r += prices[i]

print(r)

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

Solution (Python):
n,k = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
print(sum(li[0: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):
init = input().split()
N = int(init[0])
K = int(init[1])
 
prices = list(map(int, input().split()))
prices.sort()
 
sum = 0
for i, ele in enumerate(prices):
  if i >= K:
    break
  else:
  	sum = sum + ele
print(sum)

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

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

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

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

re = 0

l.sort()

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

print(re)

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

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

split = input().split()
pList = [int(i) for i in split]
list.sort(pList)
score = 0
for i in range(k):
    score += pList[i]
print(score)

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




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

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

Solution (Python):
n, k = list(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()

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

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

print(s)

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

a.sort()

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

print(cnt)

Solution (Python):
s = input().split()
intN = int(s[0])
intK = int(s[1])

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


inList.sort()



idx = 0
intCnt = 0

for wInt in inList:
    if (idx < intK) :
        intCnt += wInt
        
        
    idx += 1

print(intCnt)

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

print(ans)

Solution (Python):
N, K = map(int, input().split())
A = input().split()
L = [int(b.strip()) for b in A] 
la = sorted(L)[:K]
print(sum(la))

Solution (Python):
from sys import stdin, stdout
for _ in range(1):
    n,k=map(int, stdin.readline().split())
    a=sorted(map(int, stdin.readline().split()))
    print(sum(a[: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())
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 = list(map(int, input().split()))
    P = list(map(int, input().split()))
    result = solve(N, K, P)
    print(result)


def solve(N, K, P) -> int:
    sorted_p = sorted(P)
    return sum(sorted_p[:K])


if __name__ == '__main__':
    main()

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

new = sorted(p)
num = 0
for i in range(K):
  num += new[i]
print(num)

Solution (Python):
temparr = input()
temparr = temparr.split()
n = int(temparr[0])
items = int(temparr[1])
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
arr = sorted(arr)
total = 0 
items -= 1 
for i,j in enumerate(arr):
    total += j
    if i == items:
        break
print(total)

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

fruit_prices.sort()

min_price = 0

for i in range(K):
  min_price += fruit_prices[i]

print(min_price)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[0]*n
r=0
for i in range(n):
    t=0
    for j in range(n):
        if p[i]>p[j]:
            t+=1
    q[t]=p[i]
for i in range(n):
    if q[i]==0:
        q[i]=q[i-1]
for i in range(k):
    r+=q[i]
print(r)

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

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

main()

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

p.sort()
p_sum = 0

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

print(p_sum)

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

li=sorted(li)
Li=li[0:K]
print(sum(Li))

Solution (Python):
syurui,num = map(int,input().split())
hako = []
ans = 0

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

for i in range(num):
    ans = ans + b[i]
print(ans)

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

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

newH = sorted(H)
print(sum(newH[0:K]))

Solution (Python):
n, k = list(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()
print(sum(p[0: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=p[:]
i=0
t=0
L=[]
while i < k:
    d=p[0]
    for e in p:
        if e < d:
            d=e
    L.append(d)
    p.remove(d)
    i+=1
for e2 in L:
    t+=e2
print(t)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
m = sorted(p)
total = 0
for i in range(0,k):
  total += m[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):
a, b = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
check = lst[:b]
print(sum(check))

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

Solution (Python):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

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

for i in p[:k]:
  total += 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()))
for ind in range(len(P)-1):
		iSm = ind
		for i in range(ind, len(P)):
			if P[iSm]>P[i]:
				iSm = i
		P[ind], P[iSm] = P[iSm], P[ind]
ans = 0
for j in range(K):
	ans += P[j]
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())
lsp = list(map(int,input().split()))
lsp.sort()
cost = 0
for i in range(K):
    cost += lsp[i]
print(cost)

Solution (Python):
a=[]
b=[]
z=[]
def insertion_sort():
    for i in range(len(a)-1):
        j=i+1
        while i >=0:
            if a[j]<a[i]:
                a[i],a[j]=a[j],a[i]
                i-=1
                j-=1
            else:
                break
                
n, k= map(int, input().split())
p=map(int, input().split())
for i in p:
    a.append(i)
insertion_sort()

for i in range(k):
    z.append(i)
        
for i in z:
    b.append(a[i])

print(sum(b))

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

Solution (Python):
import numpy as np
s = list(map(int,input().split()))
n=s[0]
k=s[1]
s = list(map(int, input().split()))
s.sort()
s=np.array(s[0:k])
print(np.sum(s))

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

p.sort()

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

print(S)

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

Solution (Python):
x,y = map(int,input().split())
num_list = list(map(int, input().split()))
All=0
num_list.sort()
for i in range(y):
    All += min(num_list)
    num_list.pop(0)
print(All)

Solution (Python):
a=input().split(' ')
b=0
d=0
c=input().split(' ')
a[0]=int(a[0])
a[1]=int(a[1])
while b<a[0]:
    c[b]=int(c[b])
    b=b+1
c.sort()
b=0
while a[1]>b:
    d=d+c[b]
    b=b+1
print(d)

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

Solution (Python):
i, s = 0, 0
n , k = map(int,input().split())
p = list(map(int,input().split()))
while(i<k):
    i += 1;    m = min(p)
    s += (m)
    p.remove(m)
else:
    print(s)

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

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

ans = 0

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

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

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

total = []

for i in range(K):
    total.append(min(p))
    p.remove(min(p))

print(sum(total))

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

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

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

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

low_prices = sorted(prices)

total = sum(low_prices[:k])

print(total)

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

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

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

    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))

    A_list.sort()
    
    ans = 0
    for i in range(0,K) :
        ans = ans + A_list[i]

    print(ans)

if __name__ == '__main__':
    main()

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

list.sort()
A = 0

for j in range(K) :
    A = list[j] + A

print(A)

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

N = nk[0]
K = nk[1]

prices.sort()
print(sum(prices[0:K]))

Solution (Python):
from collections import deque
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
P = deque(P)
res = 0
for k in range(K):
    A = min(P)
    P.popleft()
    res += A
print(res)

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

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

L = sorted(L)

count = 0

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

print(count)

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

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

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n, k = rli()
    lp = rli()
    lp.sort()
    print(sum(lp[:k]))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


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

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from math import gcd


N, K = read_ints()
p = read_ints()
p.sort()

print(sum(p[:K]))

Solution (Python):
n, k = map(int, input().split())
ps = sorted(
    map(int, input().split())
)
tot = 0
for i, p in enumerate(ps, 1):
    if i > k:
        break
    tot += p

print(tot)

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

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

price.sort()

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

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

p_list.sort()
p_k = p_list[:K]
print(sum(p_k))

Solution (Python):
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
prices = [int(x) for x in stdin.readline().rstrip().split()]
prices.sort()
sum  = 0
for i in range(K):
  sum += prices[i]
print(sum)

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

Solution (Python):


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

P.sort()
total = sum(P[:K])

print(total)

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

Solution (Python):
n,k = map(int,input().split())
fruit = list(map(int, input().strip().split()))
fruitR = sorted(fruit)
p=0

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

print(p)

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



p.sort()


answer = sum(p[:K])

print(answer)

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

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

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