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



Sample input:
5 3
50 100 80 120 80


Sample output:
210

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(P[:K]))

Submission status: Accepted

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

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

print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
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)

Submission status: Accepted

Solution code:
n, k,  =map(int, input().split())
cost = 0
price = list(map(int, input().split()))
        
price.sort()
del price[k:]
for p in price:
        cost += p

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(sum)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
p = map(int,input().split())
newlist = sorted(p, reverse=False)
ans_list=[]
for i in range(1,K+1):
    ans_list.append(newlist[i-1])
print(sum(ans_list))

Submission status: Accepted

Solution code:
import itertools
import sys
from typing import Callable, List, NoReturn


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

if __name__ == "__main__":
    slove()

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()

cheap = l[:k]

print(sum(cheap))

Submission status: Accepted

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

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

total = 0

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

P.sort()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
# print(n)
# print(k)
x = list(map(int, input().split()))
# print(x)

# print(sorted(x))
sort_x = sorted(x)

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 21:05:17 2020

@author: naoki
"""

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

Submission status: Accepted

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

Submission status: Accepted

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

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

total = 0

after = sorted(fruits)

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



print(total)

Submission status: Accepted

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

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

print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

B.sort()
num = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

m.sort()

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

print(sum)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(p[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

new_A = A[0:K]

print(sum(new_A))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# yenintを小さい順に並び変える
yensort = []
small = 1
while small <= 1000:
    for i in yenint:
        if i == small:
            yensort.append(i)
    small += 1

# 小さい方からk個の和を出す
count = 0
for j in range(0, k):
    count += yensort[j]
print(count)

Submission status: Accepted

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

P.sort()

print(sum(P[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()
ans = 0

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input_list = sys.stdin.readlines()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

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


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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

res=sum(p[:k])

print(res)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

p.sort()

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

print(ans)

Submission status: Accepted

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


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

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, K = map(int, input().split())
L = list(map(int, input().split()))

L.sort()

l = L[0:K]

print(sum(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print (m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(sumz)

Submission status: Accepted

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

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

low = sorted(p)

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(S)

Submission status: Accepted

Solution code:
import sys
#果物の種類Nと，購入数K
N, K = map(int, input().split())

#果物値段A
A = list(map(int, input().split()))
A = sorted(A, reverse = False)
#print(N, K)
#print(A)
ans=0
#C = 0
#i = 0
ans = (A[:K])
#print(ans)
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from functools import reduce 

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(data[:k]))

Submission status: Accepted

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

p.sort()
ans = 0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

p.sort()

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

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

p.sort()

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

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

q=sorted(p)

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

print(sum(li))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

li.sort()
i = 0
sum = 0

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

print(sum)

Submission status: Accepted

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

List.sort()

print(sum(List[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

shukei_def()

print(shukei)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import exit
# import copy
# import numpy as np
# from collections import deque

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

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

Submission status: Accepted

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

P.sort()

print(sum(P[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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


p_sort=sorted(p_in)

sum=0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(prices[:K]))