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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

p.sort()

min = 0

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

print(min)

Submission status: Accepted

Solution code:
N,K=map(int,input().split(" "))
p=[int(_) for _ in 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 = map(int,input().split())
p =  list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

m.sort()
for _ in range(k):
  ans=ans+m[_]
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

prices = sorted(prices)
account = 0

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

Submission status: Accepted

Solution code:
#! -*- coding: utf-8 -*-
n, k = map(int, input().split())
price = list(map(int, input().split()))
sorted_price = sorted(price)

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

Submission status: Accepted

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

list.sort(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()

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

ans = 0
for _ in range(K):
    min_index = p.index(min(p))
    minv = p.pop(min_index)
    ans += minv

print(ans)

Submission status: Accepted

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

A = p[0:K]
ans = sum(A)

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

  print(s)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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:

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

  print(sum(
    sorted(map(int, input().split()))[:k]
  ))


main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# nums = list(set([x for x in nums]))
nums = sorted(nums)

s = 0
c= 0
for num in nums:
	s+= num
	c += 1
	if c >= K:
		break
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

# 求解処理
sorted_p = list(sorted(p))
ans = sum(sorted_p[:K])

# 結果出力
print(ans)

Submission status: Accepted

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

price_list.sort()
if K == 1:
    print(price_list[0])
else:
    print(sum(price_list[:K]))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
S=L[:K]
print(sum(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:
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
d=0
for i in range(b):
  d+=c[i]
print(d)

Submission status: Accepted

Solution code:
# import sys
# input = sys.stdin.readline
# import re
import itertools

def main():
    n, k = input_list()
    p = input_list()

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

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
N , K =map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for k in range(K):
    ans += p[k]
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:
def bubble_sort(input_list):
    total_number = len(input_list)
    flag = True
    finished = 0

    while flag:
        flag = False
        for i in range(total_number-1-finished):
            if input_list[i] > input_list[i+1]:
                input_list[i], input_list[i+1] = input_list[i+1], input_list[i]
                flag = True
        finished += 1
        
    return(input_list)

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

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

s = input().split()

p = []

for i in s:
    p.append(int(i))

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

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

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

Submission status: Accepted

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

fruit.sort()

buylist = fruit[0:k]
print(sum(buylist))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n, k = map(int, input().split())
p = list(map(int, input().split()))
sort = sorted(p)
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

p = input().split()
p = [int(i) for i in p]
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 = sorted(p)
print(sum(p_sorted[:k]))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

s_price = sorted(price)

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

P.sort()

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def get_int(): return int(sys.stdin.readline().strip())
def get_ints(): return map(int, sys.stdin.readline().strip().split()) 
def get_list(): return list(map(int, sys.stdin.readline().strip().split())) 
def get_string(): return sys.stdin.readline().strip()
def out(data): return sys.stdout.write(str(data))
def out_list(arr): return sys.stdout.write(' '.join(str(e) for e in arr))

MAX = 10**9
MOD = 10**9 + 7

n, k = get_ints()
arr = get_list()
arr.sort()

out(sum(arr[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n, k= map(int, input().split())
p = input().split()
npp=np.array(p, dtype=int)

new_npp = sorted(npp)

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

#%%
L.sort()
print(sum(L[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())
p = list(map(int, input().split()))

sum = 0

list.sort(p)

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

print(sum)

Submission status: Accepted

Solution code:
import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,
                  log2, pi, radians, sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

# For getting input from input.txt file
# sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
# sys.stdout = open('output.txt', 'w')


def inp():
    return(int(input()))


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


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


def def_value():
    return 0


n, k = invr()
a = inlist()
a = sorted(a)
res = sum(a[:k])
print(res)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,k = na()
p = na()

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

Submission status: Accepted

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


def main():
    [n, k] = [int(e) for e in si().split()]
    l = [int(e) for e in si().split()]
    l.sort()
    s = 0
    for i in range(k):
        s += l[i]

    print(s)


if __name__ == '__main__':
    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, M = map(int, input().split())
X = list(map(int,input().split()))

Z = sorted(X)

print(sum(Z[0:M]))

Submission status: Accepted

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

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

Submission status: Accepted

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    _, k = map(int, input().strip().split())
    ps = sorted(map(int, input().strip().split()))
    print(sum(ps[:k]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(z1) for z1 in input().split()]
arr = [int(z2) for z2 in input().split()]
arr.sort()
print(sum(arr[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

min_cost = 0

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

print(min_cost)

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

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
#from numba import njit

(N, K) = map(int, input().split())
A = np.array(list(map(int, input().split())))

#@njit
def solve(N,K,A):
    return np.sum(np.sort(A)[0:K])
    

print(solve(N,K,A))

Submission status: Accepted

Solution code:
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort()

n = 0
for i in range(b):
  n += c[i]
  
print(n)

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

    p.sort()

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

    print(ans)
    
main()

Submission status: Accepted

Solution code:
def main():
    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)
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()
print(sum(p[:k]))

Submission status: Accepted

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

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

plist.sort()

print(sum(plist[:K]))

Submission status: Accepted

Solution code:
import numpy as np
N,K = map(int, input().split())
Ps = np.array(list(map(int, input().split())))

Ps = np.sort(Ps)
res = Ps[:K].sum()
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    sum = 0
    for i in range(0, k):
        sum += p_s[i]
    print(sum)
    return

main()

Submission status: Accepted

Solution code:
def main():
    a, b = map(int, input().split())
    array = list(map(int, input().split()))

    new_array = sorted(array)
    sum  = 0
    for i in range(b):
        sum += new_array[i]

    print(sum)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N_syu, K_ko = map(int, input().split())
prices = list(map(int, input().split()))

prices.sort()

ans = sum(prices[:K_ko])
print(ans)

Submission status: Accepted

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

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

sum = 0
l.sort()
for i in range(m):
  sum += l[i]

print(sum)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

n, k = map(int, input().split())
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n.sort()
p_n = p_n.reshape(-1)
print(sum(p_n[:k]))

Submission status: Accepted

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

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

print(sum(pp[:k]))

Submission status: Accepted

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
p = list(map(int, input().split()))
p.sort()
ans =p[:K]
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
count=0
while k>0:
    count+=min(p)
    p.remove(min(p))
    k-=1
print(count)

Submission status: Accepted

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

print(sum(P))

Submission status: Accepted

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

print(price)

Submission status: Accepted

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

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

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

l=sorted(p)
s=0
for m in range(k):
    s+=l[m]

print(s)

Submission status: Accepted

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

p_list = sorted(p_list)

print(sum(p_list[:K]))

Submission status: Accepted

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

def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

plist.sort(reverse=False)

print(sum(plist[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

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[i] for i in range(K)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')

def main():
    N,K = MI()
    price_list = LI()
    price_list.sort()
    count = 0
    ans = 0
    for p in price_list:
        ans+=p
        count+=1
        if count == K:
            print(ans)
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from numpy import sort

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

num_list.sort()

ans = sum(num_list[:b])

print(ans)

Submission status: Accepted

Solution code:
shurui, kosuu = [int(idx) for idx in input().split()]
price = [int(idx) for idx in input().split()]

price.sort()
result = 0
for idx in range(kosuu):
  result += min(price)
  price.remove(min(price))
  
print(result)

Submission status: Accepted

Solution code:
import math

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

p.sort()

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(count)

Submission status: Accepted

Solution code:
# coding cell (SUBMIT ONLY THIS CELL)

N, K = list(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=[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:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, k = LI()
    p = LI()
    q = sorted(p)
    ans = 0
    for i in range(k):
        ans += q[i]
    print(ans)
    return


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
while True:
    try:
        listp=list(map(int,input().split()))
    except:
        break;
listp.sort()
print(sum(listp[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from collections import Counter

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

s = sorted(P)[0:K]
ans = 0
for i in s:
    ans = ans + i

print(ans)

Submission status: Accepted

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

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

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