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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

a.sort()
x = 0
for i in range(K):
    x = x + a[i]
    
#print(a)
print(x)

Submission status: Accepted

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

sum_money = 0
for i in range(K):
  sum_money = sum_money + p_list[i]

print(sum_money)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

ans = sum(price[:k])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
tmp_nk = input().split()
n = int(tmp_nk[0])
k = int(tmp_nk[1])

tmp_p = input().split()
p_list = [int(x) for x in tmp_p]

p_list.sort()
answer = sum(p_list[:k])
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

p_sort = sorted(p)
ans = 0

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

Submission status: Accepted

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

num_list = [i for i in map(int,input().split())]
num_list.sort()

total = sum(num_list[:K])
print(total)

Submission status: Accepted

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

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

ans = []
for i in range(n[1]):
    a = min(m)
    ans.append(a)
    m.remove(a)
    
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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 = ans + arr[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list.sort(p_list)

amount = 0
for i in range(K):
    amount += p_list[i]
print(amount)

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 = ans + p[i]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

n, k = input().strip().split(' ')
p = [int(x.strip()) for x in input().strip().split(' ')]
p.sort()
sum = 0
for i in range(0, int(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_sorted = sorted(P)
ans = 0
for i in range(K):
    ans += P_sorted[i]
print(ans)

Submission status: Accepted

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

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

p.sort()

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

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-21 20:42:23 +0900
# LastModified: 2020-06-21 21:10:40 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


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

ans = sum(p[:k])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re


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


def main():
    N, K = LI()
    pArray = LI()
    pArray.sort()

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

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

    p_list = sorted(p_list)

    f_list = []
    for i in range(k):
        f_list.append(p_list[i])

    out = sum(f_list)
    
    print(out)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
a = [int(x) for x in input().split()]
a.sort()
print(sum(a[: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:
in1 = list(map(int, input().split()))
in2 = list(map(int, input().split()))

in2.sort()
sum = 0
for i in range(in1[1]):
  sum += in2[i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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(n, k)
#print(P)

P.sort()

#print(P)

kaimono = 0
count = 1
for p in P:
  if count > k:
    break
  #print(kaimono)
  kaimono += P[count-1]
  count = count + 1
  
print(kaimono)

Submission status: Accepted

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

A.sort()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq

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

p1 = heapq.nsmallest(k, p)

print(sum(p1))

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

sorted_list = sorted(p_list)
print(sum(sorted_list[:K]))

Submission status: Accepted

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

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

A.sort()
B = A[:K]
print(sum(B))

Submission status: Accepted

Solution code:
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

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

p = list(input().split())

def convert(arg):
    return int(arg)
nums = p.maps(convert)

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

Submission status: Accepted

Solution code:
line = input().split(" ")

fruit_obj = int(line[0])
buy_obj = int(line[1])

line2 = input().split(" ")

urine = []
for j in range(len(line2)):
    urine.append(int(line2[j]))

urine.sort()

price = 0
for i in range(buy_obj):
    price = price + int(urine[i])

print(price)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

p = sorted(p)

print(sum(p[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

list.sort(P)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(c) for c in input().strip().split()]
p = [int(c) for c in input().strip().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 = sorted(P)

ans = 0
count = 0
for i in P:
    if count >= K:
        break
    ans += i
    count += 1

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:
import math
n,k = input().split(" ")
p = input().split(" ")
a = []
for i in p:
  a.append(int(i))
a.sort()
sum = 0
k = int(k)
for j in range(k):
  sum = sum + a[j]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
g, num = map(int, input().split())
price_list = list(map(int, input().split()))
price_list.sort()
gokei = 0
for i, _ in enumerate(range(num)):
    gokei += price_list[i]
print(gokei)

Submission status: Accepted

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

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

y = (sorted(x)[:K])

print(sum(y))

Submission status: Accepted

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

for x in range(k):
    kei += m[x]

print(kei)

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(x) for x in input().split())
p = [int(x) for x in input().split()]
newlist = sorted(p)

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

pn2 = sorted(pn)
Ans = 0
for i in range(k):
    Ans = Ans + pn2[i]
print(Ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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




if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
p.sort()
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()
sm=sum(p[:k])
print(sm)

Submission status: Accepted

Solution code:
def mergesort(l):
    n = len(l)
    if(n == 1):
        return l
    elif(n <= 2):
        if(l[0] > l[1]):
            return [l[1],l[0]]
        else:
            return l
    else:
        tmp1 = mergesort(l[:n//2])
        tmp2 = mergesort(l[n//2:])
        x = n//2
        y = n-x
        l = []
        for i in range(n):
            if(tmp1[-x] < tmp2[-y]):
                l.append(tmp1[-x])
                x -= 1
            else:
                l.append(tmp2[-y])
                y -= 1
            if(x*y == 0):
                if(x == 0):
                    l += tmp2[-y:]
                else:
                    l += tmp1[-x:]
                break
        return l
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = mergesort(p)
q = 0
for i in range(k):
    q += p[i]
print(q)

Submission status: Accepted

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

sum_price = 0

for i in range(K):
    min_price = min(prices)
    sum_price += min_price
    prices.remove(min_price)

print(sum_price)

Submission status: Accepted

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

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

Submission status: Accepted

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

p_sort = sorted(p)

ans = 0
cnt = 0
for _ in p_sort:
    ans += _
    cnt += 1

    if cnt >= k:
        break

print(ans)

Submission status: Accepted

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

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

print(str(ans))

Submission status: Accepted

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

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

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

 
   
list = heapq.nsmallest(k, p)

print(sum(list))

Submission status: Accepted

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    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(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= list(map(int,input().split()))
P = list(map(int,input().split()))
N = A[0]
K = A[1]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

price=sorted(p)

pk=[price[k] for k in range(K)]
print(sum(pk))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# p = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
p.sort()
#
# print(p)
total = sum(p[:k])
print(total)

Submission status: Accepted

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

A.sort()
a = sum(A[0:K])
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def juice(k,a):
    return sum(a[:k])

if __name__ == "__main__":
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    a.sort()
    print(juice(k,a))

Submission status: Accepted

Solution code:
#coding:utf-8

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

P = [int(y) for y in input().split()]

P.sort()

count = 0

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a0=input().split()
n=int(a0[0])
k=int(a0[1])

b0=input().split()
nl=[]
for i in range(n):
  nl.append(int(b0[i]))
  
nl.sort()
ans=0
for i in range(k):
  ans+=nl[i]
print(ans)

Submission status: Accepted

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

#print(data)
#print(price)

price.sort()

#print(price)

res = 0

for i in range(data[1]):
#    print ( 'i = {}'.format(i))
    res += price[i]

print(res)

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

Submission status: Accepted

Solution code:
n = input().split()
N = int(n[0])
K = int(n[1])

p = [int(item) for item 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()))
P.sort()

sum = 0
for i in range(K):
    sum += P.pop(0)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
[_n, _k] = list(map(int, input().split(" ")))
_fruits = list(map(int, input().split(" ")))
_fruits.sort()
_sum = 0
for _i in range(_k):
  _sum += _fruits[_i]
print(_sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p1 = sorted(p)
#print(p1)
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    prices = list(map(int, input().split()))
    prices = sorted(prices)
    print(sum(prices[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

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


main()

Submission status: Accepted

Solution code:

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

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

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    A=list(map(int,input().split()))
    N=A[0]
    K=A[1]
    p=list(map(int,input().split()))
    p.sort()
    kingaku=0
    for i in range(K):
        kingaku+=p[i]
    print(kingaku)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

p.sort()

sum=0
count=0

for i in range(N):
    sum+=p[i]
    count+=1
    if count==K:
        break
print(sum)

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

data = sys.stdin.readlines()
_data = data[0].split()
kakaku = data[1].split()
ans = 0

kazu = int(_data[1])
list_int = [int(n) for n in kakaku]
list_int.sort()
for i in range(kazu):
  ans += list_int[i]
  
print(ans)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
temp1 = input().split(" ")
temp2 = input().split(" ")

n = int(temp1[0])
k = int(temp1[1])

prices = [int(i) for i in temp2]

prices.sort()

print(sum(prices[:k]))

Submission status: Accepted

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

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:
_in1 = [int(x) for x in input().split(' ')]
n = _in1[0]
k = _in1[1]

result = 0
_list = [int(x) for x in input().split(' ')]
_list.sort()

for i in range(k):
  result += _list[i]

print(result)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
a = input().split()
N = int(a[0])
K = int(a[1])
list = []
price = 0
b = input().split()
for i in range(len(b)):
    list.append(int(b[i]))
list = sorted(list)
for i in range(K):
    price+= list[i]
print(price)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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