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: Runtime Error

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if n>k:
    s=p[0]+p[1]+p[2]
    print(s)
else:
    if n==k and k==len(p):
        print(sum(p))

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
list = []
sum = 0
for x in range(n):
    p = int(input())
    list.append(p)
for i in range(k):
    mini = min(list)
    sum += mini
    list.remove(mini)
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def num2alpha(num):
    if num<=26:
        return chr(97+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(97+num%26)

if __name__ == '__main__':
  n = int(input())
  print(num2alpha(n))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
l = m[2:]
s = sorted(l, reverse=True)
p = 0
for i in range(0,int(m[1])):
    p = p + int(l[i])
print(int(p))

Submission status: Runtime Error

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

p.sort(reverse=True)

i = 0
while i < k:
  i += p[i]
  i ++
  
print(i)

Submission status: Runtime Error

Solution code:
l=[]
for i in range(1,N):
  n.append(i)
  i+=1
l.sort()
print(l[:K].sum())

Submission status: Runtime Error

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

print(s)

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
l = m[2:]
a = sorted(l, reverse=True)
p = 0
for i in range(0,int(m[1])):
    p = p + int(c[i])
print(int(p))

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
print(m)
l = m[2:]
a = sorted(l, reverse=True)
p = 0
for i in range(0,int(m[1])):
    p = p + int(c[i])
print(int(p))

Submission status: Runtime Error

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

print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = input().split()
p = [int(i) for i in input().split()]
p_ascending = p.sort()
total = 0
for i in p_ascending[0,int(K)]:
  total += i
  
print(total)

Submission status: Runtime Error

Solution code:
def insertion_sort(a):
    for j in range(1, len(a)):
        key = a[j]
        # a[j]をソート列a[0..j-1]に挿入
        i = j-1
        while (i>-1) and (a[i]>key):
            a[i+1] = a[i]
            i = i-1
        a[i+1] = key


N=int(input())
K=int(input())
a=[]
Sum=0

while N>0:
    auau=int(input())
    a.append(auau)
    N-=1
insertion_sort(a)
while K>0:
    Sum+=a[K-1]
    K-=1
print(Sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
prod = functools.partial(functools.reduce, operator.mul)
n,k=map(int,input().split())
price=list(map(int,input().split()))

n_list=[]
for com in itertools.combinations(price,k):
    s=sum(com)
    n_list.append(s)
print(min(n_list))

Submission status: Runtime Error

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

sort(p)
for i range k:
    s+=a[i]

print(s)

Submission status: Runtime Error

Solution code:
import itertools
 
N = int(input())
K = int(input())
p = list(map(int,input().split(" ")))
lists = []
for l in itertools.combinations(p, K):
  sums = sum(list(l))
  lists.append(sums)
 
print(min(lists))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K;
  cin >> N >> K;
  
  priority_queue<int, vector<int>, greater<int>> p;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    p.push(a);
  }
  
  int sum = 0;
  
  for(int i = 0; i < K; i++){
    sum += p.top();
    p.pop();
  }
  cout << sum << endl;
}

Submission status: Runtime Error

Solution code:
N, K = int(input())
p = [int(i) for i in input().split()]
p_ascending = p.sort()
total = 0
for i in p_ascending[0,K]:
  total += i
  
print total

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
K = int(input())
p = list(map(int,input().split()))
lists = []
for l in itertools.combinations(p, K):
  sums = sum(list(l))
  lists.append(sums)

print(min(lists))

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = list(map(int, input().rstrip().split()))
p = list(map(int, input().rstrip().splist()))
p = np.sort(np.array(p))

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if n>k:
    s=p[0]+p[1]+p[2]
    print(s)
elif n==k:
    print(sum(p))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
import sys
if N==1:
    print(input())
    sys.exit()
list = input().split()
MIN = int(list[0])
SUM = 0
for j in range(0,K):
  for i in list:
    if MIN > int(i):
      MIN = int(i)
  list.remove(str(MIN))
  SUM += MIN
  MIN = int(list[0])
print(SUM)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
K = int(input())
p = list(map(int, input().split()))
lists = []
for l in itertools.combinations(p, K):
  sums = sum(list(l))
  lists.append(sums)

print(min(lists))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split)
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)

new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

if n == len(l):
  pass
else:
  return

for i in range(k):
  shukei += min(l)
  l.remove(min(l))

print(shukei)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
list = input().split()
MIN = int(list[0])
SUM = 0
for j in range(0,K):
  for i in list:
    if MIN > int(i):
      MIN = int(i)
  list.remove(str(MIN))
  SUM += MIN
  MIN = int(list[0])
print(SUM)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
p = list(map(int, input().split()))
lists = []
for l in itertools.combinations(p, K):
  sums = sum(list(l))
  return lists.append(sums)

print(min(lists))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = input().split()
n = int(n)
k = int(k)
listnum = []
newlist = []
sumnum = 0
for a in range(n):
    listnum.append(int(input())
newlist = sorted(listnum)
for b in range(k):
    sumnum = sumnum + list[0]
print(sumnum)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
p = list(map(int, input().split()))
lists = []
for l in itertools.combinations(p, 3):
  sums = sum(list(l))
  return lists.append(sums)

print(min(lists))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
list = input().split()
MIN = int(list[0])
SUM = 0
import sys
if K<1 or N<1 or K>1000 or N>1000:
    sys.exit()
for j in range(0,K):
  for i in list:
    if(i<1 or i>1000):
        sys.exit()
    if MIN > int(i):
      MIN = int(i)
  list.remove(str(MIN))
  SUM += MIN
  MIN = int(list[0])
print(SUM)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
a = list(map(int,input().split()))
asr = sorted(a)
del asr[0:n-k]
ans = sum(asr)
print(str(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if n>k:
    s=p[0]+p[1]+p[2]
    print(s)
    exit()

if n==k:
    print(sum(p))

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
price = []
cost = 0
for p in range(n):
        p = int(input())
        price.append(p)

price.sort()
del price[k:]
for p in price:
        cost += p

print(cost)

Submission status: Runtime Error

Solution code:
N,K=[int(i) for i in input().split()]
P=[int(i) for i in input().split()]
minS=float('inf')
for i in range(2**N):
  cmb=bin(i)[2:]
  cmb=((‘0’*N)+cmb)[-N:]
  cmb=[int(i) for i in cmb]
  if sum(cmb)!=K:
    continue
  s=sum([P[i]*cmb[i] for i in range(N)])
  if minS > s:
    minS=s
print(minS)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
list[N] = input().split()
MIN = int(list[0])
SUM = 0
for j in range(0,K):
  for i in list:
    if MIN > int(i):
      MIN = int(i)
  list.remove(str(MIN))
  SUM += MIN
  MIN = int(list[0])
print(SUM)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split(' '))
P = list(map(int,input().spllit(' ')))
if(k==1):
  print(min(P))
else:
  res=[]
  for i in range(K):
    res[i].append(min(P))
    P.remove(min(P))
  print(sum(res))

Submission status: Runtime Error

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

price = 0
if N > 0:
    for j in range(3):
        price += p[j]
print(price)

Submission status: Runtime Error

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

  min_ = float('inf')

  all_ = list(range(N))
  for items in itertools.combinations(all_, K):
    sum_ = sum([P[i] for i in items])
    min_ = min(min_, sum_)

  print(min_)


if(__name__ == '__main__'):
  main()

Submission status: Runtime Error

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

for _ in range(K):
	total += min(li)
	li = li.remove(min(li))

print(total)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
p = list(map(int, input().split()))
lists = []
  
for x,y,z in p:
  n = x + y + z
  return lists.append(n)

print(min(lists))

Submission status: Runtime Error

Solution code:
a,b=(int(x) for x in input().split())
num_list = list(map(int, input().split())).sort
ans = 0

for i in range(b):
  ans += num_list[i]

print(ans)

Submission status: Runtime Error

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

s = input().rstrip().split(' ')
a = int(s[0]) 
sorted = []
sorted.append(a)

for i in range(1,n):
  a = int(s[i]) 
  sorted.append(a)
  
  main = i
  sub = i-1
  while main = 0:
    if(sorted[sub] > sorted[main]):
      stock = sorted[sub]
      sorted[sub] = sorted[main]
      sorted[main] = stock
    else:
      break
     
    main -= 1
    sub -= 1

sum = 0
for j in range(0,k):
  sum += sorted[j]
  
print(sum)

Submission status: Runtime Error

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

mix = []

for mix in range(k):
    mix.append(min(fruits))
    fruits.remove(min(fruits))

print(sum(mix))

Submission status: Runtime Error

Solution code:
K=int(input())
N=int(input())
li=[]
for i in range(0,K):
  fruit=int(input())
  li.append(fruit)
  li.sort()
  sum1=0
  for i in range(0,N):
    sum1=sum1+li[i]
  print(sum1)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(nput())
price = []
cost = 0
for p in range(n):
        p = int(input())
        price.append(p)

price.sort()
for  p in price:
        cost += p

print(price)

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
C = list(map(int,input().split()))
C.sort()
D = C[0]+C[1]+C[2]
print(D)

Submission status: Runtime Error

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

price = 0
for j in range(3):
    price += p[j]
print(price)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

price = 0
for i in range(3):
    price += p[i]
print(price)

Submission status: Runtime Error

Solution code:
N,K=[int(i) for i in input().split()]
P=[int(i) for i in input().split()]
minS=float('inf')
for i in range(2**N):
  cmb=bin(i)[2:]
  cmb=[int(i) for i in cmb]
  if sum(cmb)!=K:
    continue
  s=sum([P[i]*cmb[i] for i in range(N)])
  if minS > s:
    minS=s
print(minS)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(nput())
price = []
cost = 0
for p in range(n + 1):
        p = int(input())
        price.append(p)

price.sort()
for  p in price:
        cost += p

print(price)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
price=list(map(int,input().split()))
price.sort(reverse=True)
price_N=price[:K]
j=0
for i in price_K:
	j+=i
print(j)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
pList = map(int, input().split())
#n, k = 5, 3
#pList = [50, 100, 80, 120, 80]
list.sort(pList)
score = 0
for i in range(k):
    score += pList[i]
print(score)

Submission status: Runtime Error

Solution code:
a,b=(int(x) for x in input().split())
num_list = list(map(int, input().split())).sort
ans = 0

for i in range(b):
  ans += num_list[b]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
init = input().split()
N = int(init[0])
K = int(init[1])
 
prices = [int(input()) for i in range(N)]
prices.sort()
 
sum = 0
for i, ele in enumerate(prices):
  if i >= K:
    break
  else
  	sum = sum + ele
print(sum)

Submission status: Runtime Error

Solution code:
n = input()
k = input()
price = []
cost = 0
for p in range(n + 1):
        p = int(input())
        price.append(p)

price.sort(reverse = True)
for  p in price:
        cost += p

print(price)

Submission status: Runtime Error

Solution code:
Iimport math as mt
import sys
I=lambda:list(map(int,input().split()))
n,k=I()
l=sorted(I())
print(sum(l[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a_lst = list(map(int, input().split()))
a_lst.sort()
if n > k or k == 3:
    print(a_lst[0]+a_lst[1]+a_lst[2])
elif k == 2:
    print(a_lst[0]+a_lst[1])
else:
    print(a_lst[0])

Submission status: Runtime Error

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

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

ps = p.sort()
ans = 0

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
list = map(int,input().split())
MIN = list[0]
SUM = 0
for j in range(1,K):
  for i in list:
    if MIN > list[i]:
      MIN = list[i]
  list.delete(MIN)
  SUM += MIN
  MIN = list[0]
print(SUM)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

prices = sorted(prices)

print(sum(prices[:k])

Submission status: Runtime Error

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

for i in range(b):
  all = all + list[i]

print(all)

Submission status: Runtime Error

Solution code:
import numpy as np
from itertools import combinations
if n==1:
    print(int(input()))
else:
    n,k = map(int,input().split())
    lis = input().split()
    total =np.inf

    for i in combinations(lis,k):
        ml =0

        for a in i:

            ml += int(a)

        total = min(total,ml)


    print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import functools
n,k=int(input())
p=list(map(int,input().split()))
p.sort()
cost=functools.reduce(lambda x,y:x+y,p[:k],0)
print(cost)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

p = sorted(p, key = int)
print(sum(p[:2]))

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c = []
for _ in range(a):
	c.append(int(input()))
sort(c)
print(sum(c[0:b]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

prices = [int(input()) for i in range(N)]
prices.sort()

sum = 0
for i, ele in enumerate(prices):
  if i == K:
    break
  else
  	sum = sum + ele
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print( sum( p[ : K ] ) )

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
if len(p) >= 3:
    print(p[0]+p[1]+p[2])
else if len(p) == 2:
    print(p[0] + p[1])
else:
    print(p[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

sortp = sorted(p)

sum = sortp[0]+sortp[1]+sortp[2]

print(sum)

Submission status: Runtime Error

Solution code:
i = list(map(int, input().split()))
s = list(map(int, input().split()))

out=0
s = sorted(s)
for i in range(3):
  out+=s[i]
print(out)

Submission status: Runtime Error

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

if __name__ == "__main__":
	main(

Submission status: Runtime Error

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: Runtime Error

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

print(p[0]+p[1]+p[2])

Submission status: Runtime Error

Solution code:
1 1
1000

Submission status: Runtime Error

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

Submission status: Runtime Error

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

num_list.sort()
ans = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
sorted(p)
print(p[0]+p[1]+p[2])

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
n,k = lr()
p = lr()

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' ')
print sum(prices[:k])

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
import numpy as np


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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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