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:
import numpy as np
import sys

if __name__ == "__main__":
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines

    n, k = map(int, readline().split())
    p = np.array(readline().split(), np.int64)

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

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

n,k=sep()
ar=lis()
ar.sort()
print(sum(ar[:k]))

Submission status: Accepted

Solution code:
#B問題
ans = 0
n, k = map(int, input().split())
P = list(map(int, input().split()))
for i in range(k):
    ans += min(P)
    P.remove(min(P))

print(ans)

Submission status: Accepted

Solution code:
import heapq

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

aa = heapq.nsmallest(k, p)
print(sum(aa))

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()))
#print(sorted(p))
print(sum(sorted(p)[:K]))#前のK個を足す

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
sw=0
sum=0
for i in range(n):
    for j in range(n-1):
        if p[j]>=p[j+1]:
            sw=p[j]
            p[j]=p[j+1]
            p[j+1]=sw
for i in range(k):
    sum+=p[i]
print(sum)

Submission status: Accepted

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

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

price_list.sort()

answer = 0

for i in range(K):
    answer += price_list[i]

print(answer)

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

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

for k in range(k):
  count = count + int(P[k])

print(count)

Submission status: Accepted

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

ans = sum(p[0:k])
print(ans)

Submission status: Accepted

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

price=0
for idx in range(K):
    price=price+p[idx]
print(price)

Submission status: Accepted

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

p.sort()

d = sum(p[0:K])

print(d)

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

Submission status: Accepted

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

list.sort()

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

Submission status: Accepted

Solution code:
import collections
n, k = map(int, input().split())
p = list(map(int, input().split()))
selected = []
ans = 0
cnt = 0
choice = collections.defaultdict(int)
for i in range(len(p)):
    choice[p[i]] += 1
for v in sorted(choice.keys()):
    if cnt < k:
        if choice[v] > k - cnt:
            ans += v * k - cnt
            k -= k - cnt
        else:
            ans += v * choice[v]
            k -= choice[v]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a = 0

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

Submission status: Accepted

Solution code:
#ABC171b

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

print(sum(p[:k]))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def ans171(N:int, K:int, p:str):
    p_list=sorted(map(int,p.split()))
    price=0
    for i in range(0,K):
        price=price+p_list[i]
    return(price)

print(ans171(N,K,p))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(N, K, P):
    sorted_P = sorted(P)
    ans = sum(sorted_P[:K%N]) + sum(P)*(K//N)
    return ans

if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    ans = main(N, K, P)
    print(ans)

Submission status: Accepted

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

A.sort()

print(str(sum(A[:K])))

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

print(min)

Submission status: Accepted

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

Submission status: Accepted

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


p.sort()

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    fruits = list(map(int, input().split()))

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


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans = sum(p[0:K])
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:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))

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

Submission status: Accepted

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

print(result)

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

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

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

print(q)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_,k,*p=map(int,open(0).read().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()

ans = sum(p[:k])

print(ans)

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

Submission status: Accepted

Solution code:
def mix_juice():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    res = 0
    for i in range(K):
        res += p.pop(0)
    print(res)
    
mix_juice()

Submission status: Accepted

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

A.sort()
min = 0

for i in range(K):
  min += A[i]
  
print(min)

Submission status: Accepted

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

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

ans = sum(sorted(p_list)[:K])

print(ans)

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

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 = 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())
money = [int(x) for x in input().split()]
ans = 0

money.sort()

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

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

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    P = sorted(list(map(int,input().split())))
    print(sum(P[:k]))


if __name__=='__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
NK = [int(i) for i in input().split(' ')]
p=[int(i) for i in input().split(' ')]
p.sort()
S=sum(p[0:NK[1]])
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(lst[: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()))
p.sort()

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

Submission status: Accepted

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

arr.sort()

ans = 0

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

Submission status: Accepted

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

print(sum(prices[:k]))

Submission status: Accepted

Solution code:

def main():
    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
l = input().split()
n1 = int(l[0])
n2 = int(l[1])

money = input().split()

for i in range(n1):
    money[i] = int(money[i])

money.sort()

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
N = list(map(int,input().split()))
N.sort(key = int)
sum = 0

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

print(sum)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

P.sort()
result = 0
i = 0
for n in P :
    if i == K:
        break
    result+=n
    i+=1
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

P=list(map(int, input().split(" ")))

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

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

p=[int(i) for i 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())

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

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

Submission status: Accepted

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

pp = sorted(p)
ans = sum(pp[:k])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

p=list(p)
p.sort()

a=0

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

print(a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
r=0
for i in range(0,k):
  r=r+p[i]
print(r)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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()))
l = sorted(p)

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

Submission status: Accepted

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

Submission status: Accepted

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

p_list.sort()

ans = 0

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

Submission status: Accepted

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

for i in range(N):
    for n in range(N-1):
        if p[n]>p[n+1]:
            tmp = p[n]
            p[n] = p[n+1]
            p[n+1] = tmp

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

B = A[0:K]
ans = np.sum(B)
print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))

    p_lst.sort()

    print(sum(p_lst[:k]))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
total = 0
p = [int(i) for i in input().split()]
for j in range(K):
  p.sort()
  total += p[j]
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()))
Psort = sorted(P)
sum = 0

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

print(sum)

Submission status: Accepted

Solution code:
def sol():
    n, k = map(int, input().split())
    ps = list(map(int, input().split()))
    sort_ps = sorted(ps)
    ans = 0
    for i in range(k):
        ans += sort_ps[i]
    print(ans)
if __name__ == "__main__":
    sol()

Submission status: Accepted

Solution code:
n,k,*p=map(int,open(0).read().split());print(sum(sorted(p)[:k]))

Submission status: Accepted

Solution code:
n,k,*p=map(int,open(0).read().split())
print(sum(sorted(p)[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = input().split()
IK = int(K)
P = list(map(int, input().split()))
Sorted_P = sorted(P)
S = 0
i = 0

while i < IK:
    S = S + Sorted_P[i]
    i = i + 1


print(S)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
 
# 小さい方から順にK個、抜き出せばよい
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 = 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(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(map(int , input().split() ))

a = sorted(P)

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

print(ans)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
n, k = (int(x) for x in input().split())
list_p = sorted([int(y) for y in input().split()])
price = 0

for i in range(0, k):
    price += list_p[i]

print(price)

Submission status: Accepted

Solution code:
n, k = [int(n) for n in input().split(' ')]
p = [int(n) for n in 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()
ans = 0
for i in range(k):
  ans += p[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
p_sort = sorted(p)
print(sum(p_sort[0: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=input().split()
n=int(n)
k=int(k)
clist=list(map(int,input().split()))
clist.sort()

print(sum(clist[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

tot = 0
for i in range(K):
    tot += a[i]
print(tot)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
n, k, *p = map(int, read().split())
p.sort()
print(sum(p[:k]))

Submission status: Accepted

Solution code:
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")] 
ans=0
arr=sorted(arr)
for i in range(k):
    ans+=arr[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 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()
count = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    return sum(p[:K])


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K, p = map(int, line.split())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, p)
    print(answer)


if __name__ == "__main__":
    main()

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

s = sum(p[:k])

print(s)

Submission status: Accepted

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

min_price = 0
for i in range(k) : 
    min_price += price[i]
    
print(min_price)

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

Submission status: Accepted

Solution code:
_,k,*p=map(int,open(0).read().split())
p.sort()
print(sum(p[:k]))

Submission status: Accepted

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