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())
listP = list(map(int, input().split()))
listP.sort()
mon = 0
count = 0
for p in listP:
    if count < k:
        count+=1
        mon+=p
    if count >= k:
        break
print(mon)

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

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

    return ans


print(solve())

Submission status: Accepted

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

    p.sort()

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

Submission status: Accepted

Solution code:
import sys



if(__name__ == "__main__"):

    NK= input().strip().split()
    N = int( NK[0] )
    K = int( NK[1] )
    prices = [0] * N
    prices_str = input().strip().split()
    for i in range(N):
        prices[i] = int(prices_str[i])
    prices.sort()
    sum = 0
    for j in range(K):
        sum += prices[j]
    print(sum)

Submission status: Accepted

Solution code:
def main():
    import sys
    #int(sys.stdin.readline())
    #s = sys.stdin.readline().rstrip()
    N, K = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    P.sort()
    print(sum(P[0:K]))




if __name__=='__main__':
    main()

Submission status: Accepted

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

P.sort()

print(sum(P[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k= map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans = 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 = result + P[i]
print(result)

Submission status: Accepted

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

p_list.sort()

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

Submission status: Accepted

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

res = 0

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

Submission status: Accepted

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

a = sorted(a)
ans = sum(a[:k])
print(ans)

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

if __name__ == '__main__':
    resolve()

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

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

li.sort()

print(sum(li[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

prices.sort()

print(sum(prices[:K]))

Submission status: Accepted

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

list.sort()
i=0
res=0

while(i<K):
  res+=list[i]
  i+=1

print(res)

Submission status: Accepted

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, k = map(int, input().split())
    p = [int(i) for i in input().split()]
    p.sort()
    ans = sum(p[:k])
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = list(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())
a = list(map(int, input().split()))
a.sort()
sum = 0
count = 1
for i in a:
  sum += i
  count += 1
  if count > K:
    break
print(sum)

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:
import sys
from collections import deque
import copy
def main():
    N, K = map(int, input().split())
    p = [int(i) for i in input().split()]
    p.sort()
    ans = 0
    for i in range(K):
        ans += p[i]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

p_list.sort()
p_list = p_list[:K]
print(sum(p_list))

Submission status: Accepted

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

def main(n,k,p):
    ps=sorted(p)
    sum=0
    for i in range(k):
        sum+=ps[i]
    
    return sum

if __name__=='__main__':
    n,k,p=readinput()
    ans=main(n,k,p)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

p.sort()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
p = sorted(list(map(int, input().split())))
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:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from decimal import Decimal
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())

N,K = LI()
P = LI()
P.sort()

#print(N,K,P)
print(sum(P[:K]))

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

prices.sort()
x = 0
for i in range(line[1]):
  x += prices[i]
print(x)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

p = sorted(p)

print(sum(p[:K]))

Submission status: Accepted

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


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


def str_array():
    return input().strip().split()

######################### TEMPLATE ENDS HERE ##################################

n, k = int_array()
arr = sorted(int_array())
print(sum(arr[:k]))

Submission status: Accepted

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

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

new_list = sorted(p_list)
new_list = new_list[:k]
print(sum(new_list))

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:
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:
###<ABC.171>
#<A>ac(3)
##n = input()
##if n.islower():
##    print("a")
##else:
##    print("A")

#<B>
n, k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
p = p[:k]
print(sum(p))

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

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








if __name__ == "__main__":

    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限
n,k=map(int,input().split())
p = list(map(int,input().split()))
p.sort()

price = 0
for _ in range(k):
    price+=p[_]
print(price)

Submission status: Accepted

Solution code:
import sys

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

N,K = LI()
p = LI()

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 = [int(x) for x in 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[0:k]))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

ans = 0

p.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

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


if __name__ == "__main__":
    main()
    sys.exit(0)

Submission status: Accepted

Solution code:
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N,K = mips()
ans = 0
P = [p for p in mips()]
P.sort()
for i in range(K):
    ans += P[i]
print(ans)

Submission status: Accepted

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

l = list(map(int, input().split()))
l.sort()
total = 0
for i in range(K):
    total += l[i]
print(total)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
p = inl()
p.sort()
print(sum(p[:k]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    P = sorted(p)
    ans = sum(P[:K])
    print(ans)

if __name__ == '__main__':
    main()

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

    print(sum(P[:K]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common

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

P.sort()


a=sum(P[0:K])
print(a)

Submission status: Accepted

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

import sys


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


def resolve():
    n, k = map(int, input().split())
    p_list = list(map(int, input().split()))

    p_list.sort()

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

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

p.sort()
ans=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,  K = 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()))

po = sorted(p)

print(sum(po[:k]))

Submission status: Accepted

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

p.sort()

ans=sum(p[:K])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
P.sort()

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

print(ans)

Submission status: Accepted

Solution code:
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:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,K,*P = map(int, read().split())

    P.sort()

    print(sum(P[:K]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

plist = sorted(plist)

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

print(sum)

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

Submission status: Accepted

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

def main():
    n, k = map(int, input().split())
    p_li = list(map(int, input().split()))

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
data = input().split()
data = [int(s) for s in data]
sum = 0
data.sort()
for i in range(K):
    sum += data[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[:k]))

Submission status: Accepted

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

p.sort()

k = p[0:M]

print(sum(k))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(P[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

ans = sum(p[:K])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    p.sort()
    pl=0
    for i in range(k):
        pl+=p[i]
    print(pl)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
for k in range(K):
    ans += P_S[k]
print(ans)

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:

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

print(sum(P[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

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

st = sorted(ps)

print(sum(st[:k]))

Submission status: Accepted

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

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

cnt = 0
ret = 0
while cnt < K:
    ret += P[cnt]
    cnt += 1

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

sorted_p = sorted(p_list)

print(sum(sorted_p[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def MI():
    return map(int, input().split())

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

N, K = MI()
P = LI()
P.sort()

print(sum(P[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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)
    
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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

als = sorted(al)

print(sum(als[:b]))

Submission status: Accepted

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

Ali.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

n,k = MAP()
p = LMAP()

p.sort()

print(sum(p[:k]))

Submission status: Accepted

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

p.sort()

print(sum(p[:K]))