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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=list(map(int, input().split())) 
nedan=sorted(map(int, input().split()))#値段順に並べる
print(sum(nedan[0:b]))#リスト中の最小～指定された数まで足す

Submission status: Accepted

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

Submission status: Accepted

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

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

low_prices = sorted(prices)

total = sum(low_prices[:k])

print(total)

Submission status: Accepted

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

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

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

Submission status: Accepted

Solution code:
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))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


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
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


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

print(sum(p[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

price.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sorted(P)[: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]+ans
print(ans)

Submission status: Accepted

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

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()
# print(p)

answer = sum(p[:K])

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = list(map(int,input().split()))
p = list(map(int,input().split()))
N = i[0]
K = i[1]

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

print(t)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools
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:
INT_MAX=10**30+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[-1 for _ in range(n)]for _ in range(m)]
#=====================================================================
n,k=INPUT()
A=INPUT()
A.sort()
print(sum(A[0:k]))

Submission status: Accepted

Solution code:
N,K =(int(x) for x in 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:
i = list(map(int, input().split()))
i2 = list(map(int, input().split()))

n = i[0]
k = i[1]

i2.sort()

ans = 0
for x in i2[0:k]:
    ans = ans + x
print(ans)

Submission status: Accepted

Solution code:
import sys
L = []
for l in sys.stdin:
    L.append(l)
N, K = map(int, L[0].split())
p_N_list = list(map(int, L[1].split()))
p_N_list.sort()
sum = 0
for n in range(0, K):
  sum += p_N_list[n]
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
FruitVal,Fruit = map(int,input().split())
FList = list(map(int,input().split()))

addNum = 0

FList.sort()

for i in range(Fruit):
    addNum += FList[i]

print(addNum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
p = list(map(int, input().split()))
ans = 0
i = 0
while i<k:
    ans += min(p)
    p.remove(min(p))
    i+=1
print(ans)

Submission status: Accepted

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

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

#print (N,K)

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

#print (a)

#入力の取得成功

a.sort()

#print (a)

#安い順に並び替え成功

result = 0

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

print (result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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_sum + P[i]
print(P_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
li = list(map(int, input().split()))
li2 = sorted(list(map(int, input().split())))
re = 0
for i in range(li[1]):
    re += li2[i]
print(re)

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

Submission status: Accepted

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

B = sorted(P)
count = 0
for x in range(K):
    count = count + B[x]

print(count)

Submission status: Accepted

Solution code:
n,k=map(int,input('').split(' '))
p=input('')
p=p.split(' ')
for a in range(n):
    p[a]=int(p[a])

l=[]
for a in range(1001):
    l.append(0)

for a in range(n):
    l[p[a]]+=1

h=0
q=0
c=0
s=0
while c==0:
    if l[h]>0:
        l[h]-=1
        q+=h
        s+=1
    else:
        h+=1
    
    if s==k:
        c=1
    else:
        c=0

print(q)

Submission status: Accepted

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

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

li = []
for i in range(n):
    li.append(p[i-1])
        
li_int = sorted([int(n) for n in li])

li_ans = li_int[:k]

print(sum(li_ans))

Submission status: Accepted

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

Ans = sorted(P)[0:K:]
print(sum(Ans))

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = input().split()
p = sorted(map(int, input().split()))
print(sum(p[0:int(K)]))

Submission status: Accepted

Solution code:
import functools
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
cost=functools.reduce(lambda x,y:x+y,p[:k],0)
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:
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 0
c.sort()
for i in range(0,b):
  d = d + c[i]
print(d)

Submission status: Accepted

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

N = a[0]
K = a[1]

B = sorted(b)
C = B[:K]
print(sum(C))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = list(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()))
p.sort()
x = 0
for i in range(K):
    x += p[i]
print(x)

Submission status: Accepted

Solution code:
a = input().split()
n = int(a[0])
k = int(a[1])
p = [int(i) for i in input().split()]
p_sorted = sorted(p)
print(sum(p_sorted[0:k]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
lst1.sort()
print(sum(lst1[:k]))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(a) for a in input().split()]
ps = [int(a) for a in input().split()]

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = [int(e) for e in 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())
a=list(map(int,input().split()))
ans=0
for i in range(k):
  ans+=min(a)
  a.remove(min(a))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K =  list(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:
def A(x):
  if ord(x) - ord('a') >= 0:
    print('a')
  else:
    print('A')


def B(n, k, p_list):
  p_list = sorted(p_list)
  print(sum(p_list[:k]))


def main():
  # letter = input()
  # func(letter)
  # for x in ['A', 'Z', 'a', 'z']:
  #   func(x)

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


if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

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

q= sorted(p)

import numpy as np

r= np.cumsum(q)

print(r[k-1])

Submission status: Accepted

Solution code:
import numpy as np
N, K = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))

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

Submission status: Accepted

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

D=sorted(C)
print(sum(D[:b]))

Submission status: Accepted

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

ps.sort()


ans = sum(ps[:K])

print(ans)

Submission status: Accepted

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

p.sort()

l = 0
price = 0
while(l<K):
    price += p[l]
    l += 1
    
print(price)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x, k = map(int, input().split())
ps = list(map(int, input().split()))
ps = sorted(ps)
print(sum(i for i in ps[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
I1 = input().split()
I2 = input().split()
I2X = []
for a in I2:
    I2X.append(int(a))

I2X.sort()

print(sum(I2X[:int(I1[1])]))

Submission status: Accepted

Solution code:
import numpy as np
n,k = [int(e) for e in input().split()]
nums = np.array([int(e) for e in input().split()])
nums.sort()
ans = sum(nums[:k])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

yen = 0
if N >= K:
    for i in range(K):
        yen += p[i]

print(yen)

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(K):
    ans = ans + p_sort[j]

print(ans)

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
p = [int(x) for x in 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()
print(sum(p[0:K]))

Submission status: Accepted

Solution code:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
p=nl()
p.sort()
sum_m=0
for i in range(K):
    sum_m+=p[i]

print(sum_m)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
def _main(N, K, prices):
    prices.sort()
    print(sum(prices[0:K]))


def _entry():
    N, K = map(int, input().split())
    pricecs = list(map(int, input().split()))
    _main(N, K, pricecs)


if __name__ == "__main__":
    _entry()

Submission status: Accepted

Solution code:
input1 = list(map(int, input().split()))
p = list(map(int, input().split()))
N = input1[0]
K = input1[1]

p.sort()

print(sum(p[:K]))

Submission status: Accepted

Solution code:
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
#a = input()

#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
n,k = map(int, input().split())
#n = input()
p = list(map(int, input().split()))

'''
n,k = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
'''
 
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])

p.sort()
#print(p)
P=[]
for i in range(k):
    P.append(p[i])
print(sum(P))

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:
import sys

def main():
  # Xはもっとも近い整数，Nは与えられるP
  N,K = map(int, input().split())

  # listを取得
  arr = list(map(int, input().split()))
  arr.sort()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
all, kind = map(int, input().split())
price = list(map(int, input().split()))
price.sort()

print(sum(price[0:kind]))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#word = input()
nums = []
nums = input().split(" ")
num1 = int(nums[0])
num2 = int(nums[1])

money = []
money=input().split(" ")
#print(money)

money2 = []
for i in range(num1):
    money2.append(int(money[i]))

money2=sorted(money2)
#print(sorted(money2))

    
total=0
for i in range(num2):
    total = (money2[i])+total
print(total)

Submission status: Accepted

Solution code:
import heapq

n,k = list(map(int, input().split()))
#print(n,k)
p = list(map(int, input().split()))
#print(p)
print(sum(heapq.nsmallest(k, p)))

Submission status: Accepted

Solution code:
import numpy as np

s = input().split(" ")
p = input().split(" ")
N = int(s[0])
K = int(s[1])
p = np.array([int(p[n]) for n in range(N)])
print(np.sum(np.sort(p)[0:K]))