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

Submission status: Accepted

Solution code:
import numpy as np

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

p = sorted(p)

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

print(int(ans))

Submission status: Accepted

Solution code:

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

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

p = sorted(p)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

n, k = multi_int_input()

prices = list_input()

prices.sort()

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

print(s)

Submission status: Accepted

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

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:
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]
    ans = 0
    a.sort()
    for i in range(c):
        ans+=a[i]
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

p = sorted(p)

ans = sum(p[:k])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

    P.sort()

    print(sum(P[:K]))


resolve()

Submission status: Accepted

Solution code:
## coding: UTF-8

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:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, K = map(int, input().split())
    p_lsit = list(map(int, input().split()))

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    #print(inlis)
    inlis.sort()
    ans = 0
    for i in range(k):
        ans += inlis[i]
    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()

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 = sorted(p)

print(sum(p_sort[:K]))

Submission status: Accepted

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    p = sorted(i2nn())
    print(sum(p[:K]))
    return

main()

Submission status: Accepted

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

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

ls = sorted(ls)

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

Submission status: Accepted

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

p.sort()

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

print( cost )

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
P=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:
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())
ps = sorted(list(map(int,input().split())))
ans = 0
for k in range(K):
  ans += ps[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:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    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:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,K=pin()
    P=sorted(lispin())[:K]
    print(sum(P))

#%%submit!
resolve()

Submission status: Accepted

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

A.sort()

print(sum(A[:k]))

Submission status: Accepted

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

p_L = list(sorted(p_L))
print(sum(p_L[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

a.sort()

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

print(price)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
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()))
p.sort()
s=0
for i in range(k):
    s+=p[i]
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import cs_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    p = list(map(int,ipt().split()))
    p.sort()
    ans = 0
    for i in p[:k:]:
        ans += i
    print(ans)

    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
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 = sorted(list(map(int, input().split())))

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

Submission status: Accepted

Solution code:
n, k = [int(_) for _ in input().split(' ')]
a = sorted([int(_) for _ in input().split(' ')])
print(sum(a[0:k]))

Submission status: Accepted

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

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

print(val)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
A = readInts()
mi = float('inf')
A = sorted(A)

print(sum(A[:k]))

Submission status: Accepted

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


n, k = map(int, input().split())
p = readints()
pp = sorted(p)
# print(pp)
ans = 0
for i in range(k):
    ans += pp[i]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
counta = 0
result = 0
for i in p:
    if counta == k:
        break
    counta+=1
    result += i
print(result)

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

n,k = LI()
p = LI()

p.sort()

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline



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

ListP=list(map(int,input().split()))
ListP.sort()#reverse=True)

ans=0
for i in range(K):
    ans+=ListP[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:
def solve(n, k, p_list):
    p_list_s = list(sorted(p_list))
    return sum(p_list_s[:k])


def main():
    n, k = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve(n, k, p_list)
    print(res)


def test():
    assert solve(5, 3, [50, 100, 80, 120, 80]) == 210
    assert solve(1, 1, [1000]) == 1000


if __name__ == "__main__":
    test()
    main()

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
Amin = A[:k]
print(sum(Amin))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(s[:k]))

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N, K = mulinputs()
    ps = list(mulinputs())

    ps.sort()
    print(sum(ps[: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:
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 sys

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

Submission status: Accepted

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

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

p_list.sort(reverse=False)
# print(p_list)

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

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

P.sort()

print(sum(P[:k]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
x=[int(x) for x in input().split()]
x.sort()
print(sum(x[0: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:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
p = LIST()
p = sorted(p)
print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = [int(v) for v in input().split()]
P = [int(v) for v in 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())))
ans = 0
for i in range(k):
    ans += p[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    P.sort()
    print(sum(P[:k]))
    return 

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    p = sorted(map(int, input().split()))
    return sum(p[:K])
    
if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().split())
P = [int(x) for x in sys.stdin.readline().split()]

P.sort()

print(sum(P[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n,k = invr()
    a = inlt()
    a.sort()
    print(sum(a[:k]))
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * (max(a) + 1)
    for i in range(len(a)):
        q[a[i]] = q[a[i]] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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


plist.sort()

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #= str(stdin.readline().rstrip())
    n,k = map(int, stdin.readline().rstrip().split())
    p = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)

main()

Submission status: Accepted

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

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