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

Submission status: Accepted

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

Submission status: Accepted

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

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 list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7


Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

n,k = Ri()
a = Ri()
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())
Ps = list(map(int, input().split()))

Ps.sort()

print(sum(Ps[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()))
p = sorted(p)
print(sum(p[:k]))

Submission status: Accepted

Solution code:
"""
~~ Author : Bhaskar
~~ Dated : 10~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")
input = lambda : sys.stdin.readline()

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    a.sort()
    s = 0
    for i in range(k):
        s += a[i]
    print(s)


if __name__ == "__main__":
    try:
        sys.stdin = open('input.txt','r')
        sys.stdout = open('output.txt','w')
    except:
       pass
    solve()

Submission status: Accepted

Solution code:
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
N, K = rrm()
a = rrm()
a = sorted(a)
print(sum(a[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(a[:k]))

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

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

Submission status: Accepted

Solution code:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,k =MAP()

a = LIST()

a.sort()

print(sum(a[:k]))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) for x 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())
plist=list(map(int,input().split()))

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    p=LIST()
    p=sorted(p)
    print(sum(p[0:k]))
if __name__ == '__main__':
    do()

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

print(sum(p[:K]))

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)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
# for use in beginner level contests where speed is key

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, K = na()

p_array = na()

p_array.sort()

print(sum(p_array[:K]))

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
ans = sum(p[:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = [int(item) for item in input().split()]
a.sort()
print(sum(a[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k,*p = map(int,open(0).read().split())

p.sort()

a = sum(p[:k])
print(a)

Submission status: Accepted

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

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    print(sum(A[:K]))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

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


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, P):
    P.sort()
    return sum(P[:K])


def main():
    N, K = read_int_n()
    P = read_int_n()
    print(slv(N, K, P))


if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
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().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
ans = 0
A.sort()
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()))

p=sorted(p)

print(sum(p[:k]))

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)

n,k=l()
A=l()
A.sort()
print(sum(A[:k]))

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N, K = NMI()
    A = NLI()
    A.sort()
    print(sum(A[:K]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, K = ri_()
p = sorted(ri_())
print(sum(p[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
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)


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

    print(sum(A[:K]))


main()

Submission status: Accepted

Solution code:
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n,k = MI()
a = sorted(LI())
print(sum(a[:k]))

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
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 S(): return input()
def LS(): return input().split()


n, k = LI()
p = LI()
p.sort()
ans = sum(p[:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(Ps[:K]))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)

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

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

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

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=mp()
p=sorted(lmp())
print(sum(p[:k]))

Submission status: Accepted

Solution code:
# @author 

import sys

class BMixJuice:
    def solve(self, tc=0):
        n, k = [int(_) for _ in input().split()]
        p = [int(_) for _ in input().split()]
        p.sort()
        print(sum(p[:k]))


solver = BMixJuice()
input = sys.stdin.readline

solver.solve()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
p = na()
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 sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    N, K = list(map(int, input().strip().split()))
    P = list(map(int, input().strip().split()))
    return N, K, P


def solve(N, K, P):
    P.sort()
    return sum(P[:K])


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    P = sorted(list(map(int, input().split())))
    ans = 0
    for i in range(K):
        ans += P[i]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

    return sum(P[:K])

print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def resolve():
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))

    print(sum(A[:K]))

if __name__ == "__main__":
    resolve()

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:
# import sys
# input = sys.stdin.readline

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


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

n,k = mp()
p = lmp()
p.sort()
print(sum(p[:k]))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()
  l.sort()

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

# main()
print(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:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
N, K = map(int, input().split())
P = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n, k = LI()
	p_list = LI()
	p_list.sort()
	print(sum(p_list[:k]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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


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:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


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

Submission status: Accepted

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