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:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    ret = sum(A[:M])

    print(ret)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import heapq

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

print(sum(heapq.nsmallest(K,P)))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(p_k))

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    number_of_types,number_of_purchase = map(int,input().split())
    price_list = list(map(int,input().split()))
    price_list.sort()
    sum_price = sum([item for suffix,item in enumerate(price_list) if suffix < number_of_purchase])
    print(sum_price)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

P = map(int, raw_input().split())
P.sort()

print sum(P[:K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
S = sorted(P)
sum = 0 
for i in range(K):
  sum+= S[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=s+l[i]
print(s)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

prices_arr = np.array(prices)
answer = prices_arr[0:k].sum()

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000000)

N, K = map(int, input().split())
prices = list(map(int, input().split()))
INF = 10000000000

memo = {}

def minPrice(n, k):
    if (n, k) in memo:
        return memo[(n, k)]
    if n < k:
        return INF
    if k == 0:
        return 0
    take = prices[n-1] + minPrice(n-1, k-1)
    skip = minPrice(n-1, k)
    ans = min(INF, take, skip)
    memo[(n, k)] = ans
    return ans

print(minPrice(N, K))

Submission status: Accepted

Solution code:


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

# sort = [1000] * K
# for n in range(N):
#     k = 0
#     while True:
#         if sort[k]>
p.sort()
# print(p)
print(sum(p[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = sorted([int(x) for x in input().split()])
print(sum(lst[: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:
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  n, k = I()
  p = LI()
  p.sort()
  ans = 0
  for i in range(k):
    ans += p[i]
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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())
price = list(map(int,input().split()))

price.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

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

print(m)

Submission status: Accepted

Solution code:
a, b = input().split()
n = sorted([int(x) for x in input().split()])
print(sum(n[:int(b)]))

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

r = sum(sorted(l)[:k])

print(r)

Submission status: Accepted

Solution code:
a = input().split(" ")
b = input().split(" ")
c = []
for i in b:
    c.append(int(i))

c.sort()
sum = 0
for i in c[0:int(a[1])]:
    sum += int(i)
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
hairu = input()
koi = hairu.split(" ")
ne = input()
kak = ne.split()
ka = []
for ne in range(len(kak)):
    ka.append(int(kak[ne]))
ka.sort()
total = 0
for i in range(int(koi[1])):
    total += int(ka[i])
print(total)

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# coding:utf-8

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

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

Submission status: Accepted

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

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(k):
  a = a + l[i]
print(a)

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

Submission status: Accepted

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


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

    p.sort()
    print(sum(p[:K]))
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_min = sorted(p)
print(sum(p_min[: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:
A = input()
A = A.split(' ')
N = int(A[0])
K = int(A[1])
p = sorted(list(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())
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 = [int(x) for x 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())
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())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(k):
    ans += A[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n,k=iia()
arr=iia()
arr.sort()
s=0
for i in range(k):
    s+=arr[i]
print(s)

Submission status: Accepted

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

p.sort()
p = p[:k]
ans = sum(p)
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 = 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()]
nums = [int(x) for x in input().split()]
print(sum(sorted(nums)[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

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

p.sort()

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

print(total)

Submission status: Accepted

Solution code:
nn,kk=map(int,input().split())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n=int(input())
n,k=map(int,input().split())
pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

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

Submission status: Accepted

Solution code:
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,k = (int(x) for x in input().split())
seq = sorted((int(x) for x in input().split()))
print(sum(seq[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()
r = sum(p[0:K])

print(r)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
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")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
#vsInput()


n,k=value()
a=sorted(array())

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
a.sort()
print(sum(a[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

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

p_sort = p.sort()

ans = sum(p[:n])

print(ans)

Submission status: Accepted

Solution code:
_,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:
inp1 = input()
inp2 = input()

lists1 = inp1.split()
lists2 = inp2.split()

N = int(lists1[0])
K = int(lists1[1])
values = sorted([int(i) for i in lists2])

result = sum(values[:K])

print(result)

Submission status: Accepted

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

s = input().split(" ")
p = []
for S in s:
    p.append(int(S))

sum = 0
for i in range(K):
    n = p.index(min(p))
    sum += p[n] 
    p.pop(n)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = sorted(p)

print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

array.sort()
print(sum(array[: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())
# x1、x2と複数入力
x = list(map(int,input().split()))
x.sort()
print(sum(x[0:k]))

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n, k = rl()
    P = rl()
    print (sum(sorted(P)[:k]))






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Submission status: Accepted

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

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, K = MII()
    p = LII()

    p.sort()

    print(sum(p[:K]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import heapq
n,k = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
heapq.heapify(P)
for i in range(k):
    ans += heapq.heappop(P)
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 = list(map(int,input().split()))
ans = 0
for i in range(k):
    m = min(P)
    ans += m
    P.remove(m)
print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
values = sorted([int(i) for i in input().split()])
sum_least = 0
for i,value in enumerate(values):
    if i > K-1:
        break
    sum_least += values[i]

print(sum_least)

Submission status: Accepted

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

kMin = sum(fruits[:k])
print(kMin)

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()
	p = inputList()

	p.sort()

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

	print(ans)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

p_s = sorted(p)

# print(p_s)

sum_v = sum(p_s[0:k])

print(sum_v)

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:
from typing import List


def main():
    _, K = map(int, input().split())
    p_lst: List[int] = list(map(int, input().split()))

    p_lst.sort()

    total: int = 0
    total = sum(p_lst[0: K])

    print(total)


if __name__ == "__main__":
    main()

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

print(sum)

Submission status: Accepted

Solution code:
#abc171b
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:
n,k,*p=map(int,open(0).read().split())
p.sort()
ans=sum(p[:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

list_buy = []

for i in range(k):
    min = 1001
    for j in range(n):
        if p[j] < min:
            min = p[j]
            ind = j
    list_buy.append(min)
    p[ind] = 1000

print(sum(list_buy))

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

print(sum(p[:K]))

Submission status: Accepted

Solution code:
N, 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())
C = list(map(int, input().split()))
C.sort()
i = out = 0
while(i+1 <= K):
  out += C[i]
  i += 1
print(out)

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

Submission status: Accepted

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

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

ans = sum([p[i] for i in range(k)])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, K = LI()
P = LI()


def main():
    P.sort()
    ans = sum(P[:K])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    n, k = tuple(input_ints())
    ps = input_ints()
    ps.sort()
    print(sum(ps[0:k]))


main()

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

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