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())
price = [int(input()) for _ in range(N)]
price.sort()
print(sum(price[:3]))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
price = [input() for _ in range(N)]
price.sort()
print(sum(price[:3]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

print(sum(l[:k]))

Submission status: Runtime Error

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

p=list(p)
p.sort()

a=0

for i in range(3):
    a+=p[i]

print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
AB=input().split("\n")
N,K=AB[0].split()
p=AB[1].split()
print(sum(sort([int(i) for i in p])[:N]),end="")

Submission status: Runtime Error

Solution code:
N,K=input().strip().split()
print(sum(input().strip().split()[:N]),end="")

Submission status: Runtime Error

Solution code:
N,K = input().strip().split()
sum(sort(input().strip().split())[:N])

Submission status: Runtime Error

Solution code:
N,K=input().strip().split()
vals=input().strip().split()
print(sum(vals.sort()[:N]),end="")

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,i,j,k,s=0,c=1,x=1,t;
   cin>>n>>k;
   ll a[n+1];
   for(i=0;i<n;i++)
          cin>>a[i];
   sort(a,a+n);
   for(i=0;i<k;i++)
          s+=a[i];
   cout<<s;
}

Submission status: Runtime Error

Solution code:
a=int(100)
x=int(input())
i=0
for i in range(10000):
  if a < x:
    a*=1.01
    a=int(a)
    i+=1
  elif a>=x:
    break
print(i)

Submission status: Runtime Error

Solution code:
a=int(100)
x=int(input())
for i in range(10000):
  if a < x:
    a*=101//100
    a=int(a)
    i+=1
  else:
    break
print(i)

Submission status: Runtime Error

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

print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")]
arrs=sorted(arr)
print(arrs)
ans=0
for i in range(k):
    ans+=arrs[k]
print(ans)

Submission status: Runtime Error

Solution code:
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")]
arr=sorted(arr)
ans=0
for i in range(k):
    ans+=arr[k]
print(ans)

Submission status: Runtime Error

Solution code:
#include <stdio.h>

void swap(int *a,int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;    
    return;
}

int main(void){
    int i,j,ans=0,N,K,p[1000];

    //入力部
    scanf("%d %d",&N,&K);
    for(i=0; i<N; i++){
        scanf("%d",&p[i]);
    }

    //計算部
    for(i=0;i<N-1;i++){
        for(j=i;j<N-1;j++){
            if(p[j]>p[j+1]){
                swap(&p[j],&p[j+1]);
            }
        }
    }
    for(i=0;i<K;i++){
        ans+=p[i];
    }

    //表示部
    printf("%d\n",ans);

    return 0;
}

Submission status: Runtime Error

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

print(sum(p[0:K])

Submission status: Runtime Error

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

P.sort()

sum(P[0:k])

Submission status: Runtime Error

Solution code:
a,b = input().split()
c = list(map(int,input().split()))
c.sort
d = [0]*b
e = 0

if c[0] == c[b-1]:
  print(str(c[0]))
  
for i in range(a):
  for k in range(b):
    if c[i] > c[i-1] :
      d[k] = c[i]
      
for j in range(b):
  e += d[j]
  
print(str(e))

Submission status: Runtime Error

Solution code:
a,b = input().split()
c = list(map(int,input().split()))
c.sort
d = [0]*b
e = 0

for i in range(len(c)):
  for k in range(len(b)):
    if c[i] > c[i-1] :
      d[k] = c[i]
      
for j in range(len(b)):
  e += d[j]
  
print(str(e))

Submission status: Runtime Error

Solution code:

import sys
import math
input = sys.stdin.readline

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


n, k = inlt()
p = inlt()
p = math.sort(p)
print(sum(p[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# ---------------------------------------------------------------------------------------!
import os
import sys
from io import BytesIO, IOBase
# from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
# from bisect import bisect_right as br               #c++ upperbound br(array,element)


# ---------------------------------------MAIN()-----------------------------------------------!
def main():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
    n, k = map(int, input().split(" "))
    l = list(map(int, input().split(" ")))
    l.sort()
    s=0
    for i in range(k):
        s+=l[i]
    print(s)


# -----------------------------------------------------------------------------------------!
# region fastio
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)
def input(): return sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    main()

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

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

Submission status: Runtime Error

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

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

p.sort()

print(sum(p[:k]))

Submission status: Runtime Error

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

Solution code:
N = int(input())
K = int(input())
prices = list()
for i in range(N):
    prices.append(int(input()))
sum = 0
for i in prices:
    x = min(prices)
    sum = sum + x
    prices.remove(x)
    K = K - 1
    if K == 0: break
print(sum)

Submission status: Runtime Error

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[k]
print(_sum)

Submission status: Runtime Error

Solution code:
n, k = mapt(int, input().split(" "))
p = mapt(int, input().split(" "))
print(sum(sorted(p)[:3]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
k=int(input())
a=input().split(" ")
a.sort()
sum,i=0,0
while i<k :
  sum+=a[i]
  i+=1
print(sum)

Submission status: Runtime Error

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

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

print(s)

Submission status: Runtime Error

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

Pn.sort()
s = 0
for i in range(K):
	s += Pn[K]

print(s)

Submission status: Runtime Error

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

Pn.sort()
sum = 0
for i in range(K):
	sum += Pn[K]

print(sum)

Submission status: Runtime Error

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

Pn.sort()
sum = 0
for i in range(K):
	sum += Pn[K]

print(sum)

Submission status: Runtime Error

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

Qn = sorted(Pn)
sum = 0
for i in range(K):
	sum += Qn[K]

print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
Pn = []
for i in range(N):
	Pn.append(input())

Qn = sorted(Pn)
sum = 0
for i in range(K):
	sum += Qn[K]

print(sum)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from math import ceil
from collections import defaultdict as D
 
def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(S())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])
 
N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from math import ceil
from collections import defaultdict as D

def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(Ss())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])

N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# input
a, b = map(int, input().split())
x = list(map(int, input()))
x.sorted()
o = 0
for i in range(b):
    o = O+x[i]
print(o)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
lst = [int(input()) for i in range(n)]
l = sorted(lst)
sum(l[:k])

Submission status: Runtime Error

Solution code:
a=input()
l=a.split(" ")
n=int(l[0])
k=int(l[1])
f=input()
fruits=int(f.split(" "))
for d in range(0, len(fruits)):
    fruits[d]=int(fruits[d])
ans=0
b=0
while(b<k):
    g=max(fruits)
    ans+=g
    fruits.remove(g)
    b+=1
print(ans)

Submission status: Runtime Error

Solution code:
import math 
n = int(input())
print(math.ceil(n/ 1000) * 1000 - n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
result = 0
for i in range(N):
    for j in range(i):
        if A[i-j-1] > A[i-j]:
            tmp = A[i-j]
            A[i-j] = A[i-j-1]
            A[i-j-1] = tmp
        print(A)

for i in range(K):
    result += A[i]

print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = input()
n = input()
price = list(input().split()).sort

total = sum(prices[:n])
print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = inpl()
p = inpl()
p = sorted(p)
ans = 0
for i in range(n):
    ans += p[i]
    if i+1 == k:
        break
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

return sorted(fruit)[:K]

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
value = []
sum = 0

for i in range(N):
    value.append(int(input())) 
newValue = sorted(value)

for j in range(K):
    sum = sum + newValue[j]

print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
5 3
50 100 80 120 80

Submission status: Runtime Error

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

sort(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(reverse = True)
print(sum(p[:K]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

p.sort()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

numbers = input().split(" ")
numbers.sotr()

a = 0

for i in range(K):
	a += numbers[i]
print(a)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
length= int(input())
num=int(input())
i=0
j=0
p=0
fruits=[]
for i in range(length):
	fruits.append(int(input())
fruits.sort()
for j in range(num):
	p+=fruits[j]
print(p)
# for x in fruits:
# 	print(x)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

p.sort()

for i in range(K+1):
  l.append(p[i])
print(sum(l))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k = map(input().split())
p = map(input)
print(sum(p,:k)

Submission status: Runtime Error

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

plist.sort()
ans = 0
for i in rangr(k):
    ans += plist[i]

print(ans)

Submission status: Runtime Error

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

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

price2 = sorted(price)
i = 0
sum = 0
while (i < K):
  sum += price2[i]
  i += 1

print(sum)

Submission status: Runtime Error

Solution code:
n, k = [int(x) for x in stdin.readline().rstrip().split()]
y = list(map(int, input().split()))


z = sorted(y)

print(sum(z[:k]))

Submission status: Runtime Error

Solution code:
n, k = [int(x) for x in stdin.readline().rstrip().split()]
y = list(map(int, input().split()))
z = sorted(y, reverse=True)

print(sum(z[:k]))

Submission status: Runtime Error

Solution code:
x = input().rstrip().split(" ")
n = int(x[0])
k = int(x[1])

y = list(map(int,input().split()))
z = sorted(y, reverse = Ture)

print(sum(z[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

p1 = sorted(p)

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

Submission status: Runtime Error

Solution code:
n = int(input("enter n : "))
k =  int(input("enter k : "))
l = list([])
for i in range(n) : 
    x = int(input("enter x "))
    l.append(x)
l.sort()
sum =0 
for j in range(k) : 
    sum += l[j]
print(sum)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

N, K = input()
que = input()
try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]

#print(que)
"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

for x in itertools.combinations(que, K):
    tmp = np.sum(x)
    if tmp < min_val:
        min_val = tmp

print(min_val)

Submission status: Runtime Error

Solution code:
N, K = input()

que = input()

que = [x for x in que.split()]
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

N, K = input()
que = input()
try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]

#print(que)
"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

for x in itertools.combinations(que, K):
    tmp = np.sum(x)
    if tmp < min_val:
        min_val = tmp

print(min_val)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l1=list(map(int.input().split()))
l1.sort()
price = 0
count= 0
for i in range(n-1):
  if count=k:
      break
  else:    
     if l1[i]!=l1[i+1]:
          price+=l1[i]
          count+=1
print(price)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l1=list(map(int.input().split()))
l1.sort()
price = 0
for i in range(n-1):
  if l1[i]!=l1[i+1]:
    price+=l1[i]
print(price)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
l = [int(input()) for i in range(n)]

l.sort()

print(sum(l[:m]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
i=0
p = []
while i < n:
    p.append(int(input()))
    i += 1
#print(p)
#s=0
#l=0
#while l < k:
#    s += min(p)
#    p = p.remove(min(p))
#    l += 1
#print(s)　こっちはうまくいかない
p.sort()
s= sum(p[:k])
print(s)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
i=0
p = []
while i < n:
    p.append(int(input()))
    i += 1

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

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
i=0
p = []
while i < n:
    p.append(int(input()))
    i += 1
#print(p)
#s=0
#l=0
#while l < k:
#    s += min(p)
#    p = p.remove(min(p))
#    l += 1
#print(s)
p.sort()
s= sum(p[:k])
print(s)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
n, k = input().strip().split()
n, k = [int(n), int(k)]

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

def calc_min(cur_id, cur_v, cur_num_select):
    if cur_num_select == k:
        return cur_v
    elif cur_id == n and cur_num_select < k:
        return 1000 * 1000

    l_v = calc_min(cur_id + 1, cur_v + p[cur_id], cur_num_select + 1)
    r_v = calc_min(cur_id + 1, cur_v, cur_num_select + 0)

    return min([l_v, r_v])


print(calc_min(0, 0, 0))

Submission status: Runtime Error

Solution code:
inputs = [input() for i in range(2)]

N = inputs[0].split()[0]
K = inputs[0].split()[1]
p = [int(pn) for pn in inputs[1].split()]

ans = sum(p.sort()[0:K])
print(ans)

Submission status: Runtime Error

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

list = sorted(list)

a = 0

for i in range(k):
    a += list[k]

print(a)

Submission status: Runtime Error

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

a = 0

for i in range(k):
    a += list[k]

print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(k):
  a += list[i]

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
_, k = input().split()

prices = input().split().map(lambda x : int(x))

prices.sort()

sum = 0
for i in range(k):
	sum += prices(i)
print(sum)

Submission status: Runtime Error

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

for i in range(3) :
    x = min(fruits)
    total += x
    fruits.remove(x)
    
print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = [0,0]
N = list(map(int,input().split()))
N = N[0]
K = N[1]
p = [0]*N
p = list(map(int,input().split()))
Sum = 0

for i in range(K):
  Sum = Sum + min(p)
  
print(Sum)