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

l.sort()
a = 0
for i in range(0,k):
    a += l[i]

print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

fruits_list_low = sorted(fruits_list)

cost = 0

for i in range(0, k):
    cost += fruits_list_low[i]
    
print(cost)

Submission status: Accepted

Solution code:
def MixJuice():

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

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

    value.sort()

    total = 0

    for i in range(Num[1]):
        total = total + value[i]

    print(total)

if __name__ == '__main__':
    MixJuice()

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()
r = 0
for i in range(k):
    r += p.pop(0)
print(r)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p_n.sort(reverse =True)
ans = 0
for i in range(K):
    ans +=p_n.pop()
    
print(ans)

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:
a,b = map(int,input().split())
listA = list(map(int,input().split()))
listA.sort()
all = 0

for i in range(b):
  all = all + listA[i]

print(all)

Submission status: Accepted

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

x = (sorted(p))
g = sum(x[:k])
print(g)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
p = list(map(int, input().split()))
ans=0
for i in range(k):
    an = min(p)
    ans=ans+an
    a = p.index(an)
    p.pop(a)

print(ans)

Submission status: Accepted

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

p_list.sort()

out = sum(p_list[0:k])
print(out)

Submission status: Accepted

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

a.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(k):
    sum+=val[j]

print(sum)

Submission status: Accepted

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

plist.sort()
ans = 0
for kk in range(k):
  ans += plist[kk]

print(ans)

Submission status: Accepted

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

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

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


print(co)

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

Submission status: Accepted

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

p = [int(x) for x in input().split()]
p.sort()

print(sum(p[:k]))

Submission status: Accepted

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

line = input().rstrip().split(' ')
p = []

for i in range(n):
    p.append(int(line[i]))

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()
print(sum(ps[0:k]))

Submission status: Accepted

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

k = nk[1]
p.sort()
a = 0
for j in range(k):

  a += p[j]
print(a)

Submission status: Accepted

Solution code:
sum=0
N,K=input().split(" ")

array=input().split(" ")
for i in range(int(N)):
  n=int(array[i])
  array[i]=n

array.sort()

for j in range(int(K)):
  sum=sum+array[j]
print(sum)

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

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

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

s = 0

p.sort()

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, p: "List[int]"):
    p.sort()
    ret = sum(p[:K])
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

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

pn.sort()

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############


test_case=1
while test_case:
    test_case-=1


    n, k=mi()
    a=li()
    a.sort()
    print(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 = [int(n) for n in input().split()]
p = [int(n) for n in input().split()]
p = sorted(p, reverse=False)
print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

if __name__ == '__main__':
    n, k = list(map(lambda x: int(x), sys.stdin.readline().split()))
    p = list(map(lambda x: int(x), sys.stdin.readline().split()))
    p = sorted(p)
    print(sum(p[:k]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

n,k = map(int, input().split())
p = list(map(int, input().split()))
ans=0
for i in range(k):
    an = min(p)
    ans=ans+an
    a = p.index(an)
    p.pop(a)

print(ans)

Submission status: Accepted

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

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

P = sorted(P)

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

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

Submission status: Accepted

Solution code:

if __name__ == "__main__":
  N, K = [int(a) for a in input().split()]
  P = list(map(int, input().split()))
  list.sort(P)
  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()
cost = 0
for i in range(K):
    cost += p[i]
print(cost)

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:
#Mix Juice
N, K = list(map(int, input().split()))
P = sorted(map(int, 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=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())
li=list(map(int,input().split()))

li=sorted(li)

total=[]
for i in range(1,k+1):
  total.append(li[i-1])
print(sum(total))

Submission status: Accepted

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

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

print(money)

Submission status: Accepted

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

p = sorted(p)
for i in range(int(k)):
    total.append(p[i])
print(sum(total))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

plist =    [int(n) for n in input().split()]

import numpy as np

parray = np.array(plist)

sortp = np.sort(parray)

result = sortp[:K]

print(result.sum())

Submission status: Accepted

Solution code:
N,K = [int(a) for a in input().split()]
P = [int(a) for a in input().split()]
for i in range(len(P)-1):
    for j in reversed(range(i, len(P)-1)):
        if P[j] > P[j+1]:
            P[j], P[j+1] = P[j+1], P[j]
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()))
v = sorted(p)
a = v[0:k]
print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

prices.sort()
result = 0

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

print(result)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
li=list(map(int,input().split()))
sum=0
for i in range(k):
  sum=sum+min(li)
  li.remove(min(li))
print(sum)

Submission status: Accepted

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

L_2=sorted(L)

L_3=L_2[0:k]
print(sum(L_3))

Submission status: Accepted

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

get = []
for i in range(K):
    get.append(L[i])

print(sum(get))

Submission status: Accepted

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
s=list(input().split())
r = [int(n) for n in s]
new=sorted(r)
output=sum(new[0:b])
print(output)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import sys
from io import BytesIO, IOBase


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



# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
get=lambda:map(int,input().split())
lget=lambda:list(map(int,input().split()))

N,K=get()
p=lget()

p.sort()
ans=0

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

Submission status: Accepted

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

l = input().split(" ")
l_si_i = [int(s) for s in l]
l_si_i.sort()

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

print(sum)

Submission status: Accepted

Solution code:
n,k = 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())
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:
n, k = map(int, input().split())
p = list(map(int,input().split()))
p = sorted(p, key = int)
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
i = 0
while i < k:
  ans = ans + p[i]
  i += 1
print(ans)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    # Problem A
    N, K = map(int, input().split(' '))
    P = [None] * N
    P = sorted(map(int, input().split(' ')))
    total=0
    for i in range(K):
        total+=P[i]
    print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    args = input().rstrip().split(' ')
    N, K = int(args[0]), int(args[1])
    args = input().rstrip().split(' ')
    p = np.array([int(i) for i in args])
    
    p = np.sort(p)
    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())
p = list(map(int,input().split()))
result = 0

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

Submission status: Accepted

Solution code:
result = 0

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

price_list.sort()
result = sum(price_list[:K])
print(result)

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

print(count)

Submission status: Accepted

Solution code:
from sys import stdin
import heapq 

N, K = map(int, input().split())
input_data = [int(x) for x in stdin.readline().strip().split(" ")]

heapq.heapify(input_data)
sumnum = 0
for k in range(K):
    sumnum += heapq.heappop(input_data)
print(sumnum)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
ar = list(map(int, input().split()))

ar = sorted(ar)
sum = 0
for i in range(y):
  sum += ar[i]
  
print(sum)

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

value = 0

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

print(value)

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,K = map(int, input().split())
p=list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
ako = len(p)
p.sort()
nedan = 0
if (1<= K <= N <= 1000) and 1 <= ako <= 1000:
    for i in range(K):
        nedan += p[i]
print(nedan)

Submission status: Accepted

Solution code:
_, t = [int(x) for x in input().split()]
s = sorted([int(x) for x in input().split()])
c = 0
for i in range(t):
    c += s[i]
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(N)
K = int(K)


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

nums = nums[:K]


print(sum(nums))

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()
p1 = p[:K]
print(sum(p1))

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

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n, k, *p = map(int, read().split())

p = sorted(p)

print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import heapq
nk = input()
allp = input()
nklis = nk.split(" ")
plis = allp.split(" ")
plis = [int(n) for n in plis]
n = int(nklis[0])
k = int(nklis[1])
print(sum(heapq.nsmallest(k, plis)))

Submission status: Accepted

Solution code:
n = input().split(" ")
p = input().split(" ")
n = list(map(int,n))
p = list(map(int,p))
#a = [chr(ord("a")+i) for i in range(26)]

p.sort()
sum = 0
for i in range(n[1]):
  sum += p[i]
  
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

nums=list(map(int,input().split()))
nums.sort()
sum=0

for k in range(K):
    sum+=nums[k]

print(sum)

Submission status: Accepted

Solution code:
k = int(input().rstrip().split()[1])
p = [int(x) for x in input().rstrip().split()]
p.sort()
ans = 0
for i in range(0, k):
    ans += p[i]

print(ans)

Submission status: Accepted

Solution code:

n,k = map(int, input().split())
num_list = list(map(int, input().split()))
num_list.sort()
s = sum(num_list[0:k])
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def IL():
    return list(map(int,input().split()))
    
N,K=IL()
fruits=IL()
fruits.sort()
ans=0
for k in range(K):
    ans+=fruits[k]

print(ans)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

p = sorted(wklst)

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

print(rs)

Submission status: Accepted

Solution code:
select = list(map(int, input().split()))
goods  = list(map(int, input().split()))

sorted_goods = sorted(goods)
print(sum(sorted_goods[:select[1]]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

# nk=[5, 3]
# p=[50, 100, 80, 120, 80]

# nk=[1,1]
# p=[1000]

ps = sorted(p)
print(sum(ps[:nk[1]]))

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 itertools
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
cumsum = itertools.accumulate(p)
print(list(cumsum)[k-1])

Submission status: Accepted

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

ni.sort()
thum = 0

for i in range(k):
    thum += ni[i]

print(thum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# import itertools

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

# tmp = itertools.combinations_with_replacement(P, K)
# tmp = itertools.combinations(P, K)

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

# hoge = []
# for i in tmp:
#     hoge.append(sum(i))

# print(min(hoge))

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n, k = lr()
p = lr()

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

Submission status: Accepted

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

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

for i in range(k):
    nmin = min(p)
    sum += nmin
    p.remove(nmin)

print(sum)