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:
def processValue(array:list):
	global minimumValue
	value = 0
	for i in array:
		value += fruits[i]
	
	if minimumValue == -1 or value < minimumValue:
		minimumValue = value

def combi(n,k,i,array):
	if i == k:
		processValue(array)
		return
	for j in range(array[i-1],n):
		if j in array[0:i]:
			continue
		array[i] = j
		combi(n,k,i+1,array)

fruits = []
minimumValue = -1
n,k = map(int,input().split())
fruits = [int(f) for f in input().split()]
combi(n,k,0,[0 for _ in range(k)])
print(minimumValue)

Submission status: Runtime Error

Solution code:
fruits = []
minimumValue = -1

def processValue(array:list):
	global minimumValue
	value = 0
	for i in array:
		value += fruits[i]
	
	if minimumValue == -1 or value < minimumValue:
		minimumValue = value

def combi(n,k,i,array):
	if i == k:
		processValue(array)
		return
	for j in range(array[i-1],n):
		if j in array[0:i]:
			continue
		array[i] = j
		combi(n,k,i+1,array)

n,k = map(int,input().split())
fruits = [int(f) for f in input().split()]
combi(n,k,0,[0 for _ in range(k)])
print(minimumValue)

Submission status: Runtime Error

Solution code:
fruits = []
minimumValue = -1

def processValue(array:list):
	global minimumValue
	value = 0
	for i in array:
		value += fruits[i]
	
	if minimumValue == -1 or value < minimumValue:
		minimumValue = value

def combi(n,k,i,array):
	if i == k:
		processValue(array)
		return
	for j in range(array[i-1],n):
		if j in array[0:i]:
			continue
		array[i] = j
		combi(n,k,i+1,array)

def main():
	global fruits
	global minimumValue
	n,k = map(int,input().split())
	fruits = [int(f) for f in input().split()]
	combi(n,k,0,[0 for _ in range(k)])
	print(minimumValue)

main()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

price.sort()

for p in range(1,K):
	ans  += price[p]

print(ans)

Submission status: Runtime Error

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

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

price.sort

for p in range(1,K):
	ans  += price[p]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#関数リスト
import sys
import numpy as np
input = sys.stdin.readline

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

n, k = MI()
mylist = LI()
mylist.sort()
print(sum(mylist[:k+1]))

Submission status: Runtime Error

Solution code:
n=input()
k=input()

for i in range(0,n):
    p=input()
    list=list+'p'

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

Submission status: Runtime Error

Solution code:
n=input()
k=input()

for i in range(0,n):
    p=input()
    list=list+p

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = input()
print("A" if ord(a) < 92 else "a")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
k=int(input())
a = [int(input()) for i in range(n)]
a.sort()
print(sum(a[:k]))

Submission status: Runtime Error

Solution code:
n=input()
k=input()
a = [int(input()) for i in range(int(n))]
a.sort()
print(sum(a[:int(k)]))

Submission status: Runtime Error

Solution code:
def main():
  N = int(input())
  K = int(input())

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

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def main():
	N = int(input())
	K = int(input())

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

	part = price[0:K]

	print(sum(part))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
	N = int(input())
	K = int(input())

	list = []

	for i in range(N):
		list.append(int(input()))
	
	list.sort()

	part = list[0:K]

	print(sum(part))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().splilt())
p = list(map(int, input().splilt()))
print(sum(sorted(p)[:M]))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().splilt())
L = list(map(int, input().splilt()))
print(sum(sorted(L)[:M]))

Submission status: Runtime Error

Solution code:
N, M = int(input().split())
list = str(input().split())
list.sort()
total = 0
for i in [0:M]:
  total += list[i]
print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
for i,v in enumerate(p):
    ans += v
    if i == 2:
        print(ans)
        exit()
print(ans)

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:
import collections

s = [int(i) for i in input().split(" ")]
print(s)
p = [int(i) for i in input().split(" ")]
print(p)
a = []
p.sort()
print(p)

for i in range(0,s[1]):
	a = p[i]
b = [int(b) for b in a]
print(sum(b))

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:
def quick_sort(plices):
    if len(plices) <= 1:
        return plices

    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    sorted_plices = quick_sort(plices)

    # print(sorted_plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

Submission status: Runtime Error

Solution code:

def quick_sort(plices):
    if len(plices) == 1:
        return plices


    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    sorted_plices = quick_sort(plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

Submission status: Runtime Error

Solution code:
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,k,ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    rep(i,k) ans+=p[i];
    cout << ans << endl;
}

Submission status: Runtime Error

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

N = a[0]
K = a[1]

p.sort()

g = 0
for k in range(K)
	g = g+p[k]
print(g)

Submission status: Runtime Error

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

N = a[0]
K = a[1]

p = p.sort

g = sum(p[0:K-1])
print(g)

Submission status: Runtime Error

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

N = a[0]
K = a[1]

p = p.sort

g = 0
for i in range(K):
    g = K+p(i)

print(g)

Submission status: Runtime Error

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

prices = prices.sorted()

answer = 0
for i in range(0, k, 1):
  answer = answer + prices[i]
print(answer)

Submission status: Runtime Error

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


INF = 10000000000

memo = {}

def minPrice(n, k):
    if (n, k) in memo:
        return memo[(n, k)]
    if n < k:
        return INF
    if k == 0:
        return 0
    if k == 1:
        return min(prices)
    take = prices[n-1] + minPrice(n-1, k-1)
    skip = minPrice(n-1, k)
    ans = min(INF, take, skip)
    memo[(n, k)] = ans
    return ans

print(minPrice(N, K))

Submission status: Runtime Error

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

L=sum(L.sorted[:K])
print(L)

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:
a = input().split(" ")
b = input().split(" ").sort()
sum = 0
for i in a[1]:
    sum += i
print(sum)

Submission status: Runtime Error

Solution code:
x=int(input())
y=int(input())

lst=[]
for i in range (0,x) :
    z=int(input())
    lst.append(z)

lst.sort()

sum=0

for j in range(0,y):
    sum = sum + lst[j]

print(sum)

Submission status: Runtime Error

Solution code:
nn,kk=map(int,input.split())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)

Submission status: Runtime Error

Solution code:
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)

Submission status: Runtime Error

Solution code:
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
   goukei=gokei+num_value[i]
print(goukei)

Submission status: Runtime Error

Solution code:
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    for k in range(nn-i):
        if num_value[i]>num_value[k]:
            num_value[i],num_value[k]=num_value[k],num_value[i]
goukei=goukei+num_value[i]
print(goukei)

Submission status: Runtime Error

Solution code:
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    goukei=goukei+num_value[kk]
print(goukei)

Submission status: Runtime Error

Solution code:
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    goukei=goukei+num_value[kk]
print(goukei)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
LIst_1 = sorted(list(map(int, input().split())), reverse=True)
K = K+1
ans = sum(List_1[:K])

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
p = []

for i in range(N):
    x = int(input())
    p.append(x)

p.sort()

y = 0

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

print(y)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(sum(p[:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n, k =map(int,input().split())
# x1、x2と複数入力
x = list(input().split()) for i in range(n)
x.sort()
print(sum(list[0:k]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = (int(i) for i in input().split(" "))
p_dict = {c:int(i2) for c, i2 in enumerate(input().split(" "))}
sort_p_list = sorted(p_list.items(), key=lambda x:x[1])
sum=0
for k in range(K):
  sum += sort_p_list[k][1]
print(sum)

Submission status: Runtime Error

Solution code:
l=map(int,open(0).read().split());print(sum(sorted(l[2:])[:l[1]]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = [int(j) for j in input().split(' ')]
p = input().split(' ')
 
p.sort()
sum = 0
 
for i in range(0,k):
  sum+=int(p[i])
  
return sum

Submission status: Runtime Error

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

p.sort()
sum = 0

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

Submission status: Runtime Error

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

ans=0
for i in range(k):
  mi=min(lis)
  ans+=mi
  lis.remove(mi)
  
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

P = [int(p) for p in input().split()]

P.sort()

for q in range(int(K)):
    X = X + int(q)

print(X)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

pr.sort()

print(sum(pr[0:k])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=input();print(sum(list(map(int,input().split()))[:int(a[2])]))

Submission status: Runtime Error

Solution code:
N = input()
K = input()
lists = []
B = 0

for i in range(int(N)):
    A = input()
    lists.append(int(A))
    #print(A)

lists.sort()
#print(lists)

for j in range(int(K)):
  B += int(lists[j])
 
print(B)

Submission status: Runtime Error

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

P.sort()
 
total=0

for i in range(int(K)+1):
  total=total+P[i]
 
print(total)

Submission status: Runtime Error

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

# N=5
# K=2
# P=[10, 20, 40, 2, 6]

P.sort()
 
total=0

for i in range(int(K)+1):
  total=total+P[i]
 
print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x=0
final_list=[]
for i in range(0,K):
	min1 = 9999999; 
    
	for j in range(len(p)):       
  		if p[j]<min1: 
    		min1 = p[j]; 
	p.remove(min1); 
	final_list.append(min1) 
           

for ele in range(0, len(final_list)): 
	x = x + final_list[ele] 
  
print(x)

Submission status: Runtime Error

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

P.sort()

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

Submission status: Runtime Error

Solution code:
N = input()
K = input()
lists = []
A = 0

for i in range(int(N)):
  lists.append((input()))
 
lists.sort()
 
A = sum(lists[:K])
 
print(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
def order (p):
    return (sorted(p))         
def Mix_Juice (p):
    p[1] = K
    a = order (p[2:])
    b = 0
    for i in range (0, K):
        b = b + a[i]
    return b
p = list(map(int, input().split()))
Mix_Juice (p)

Submission status: Runtime Error

Solution code:
N = int(input())

K = int(input())

p = [int(input()) for i in range(N)]

p.sort()

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

Submission status: Runtime Error

Solution code:
sum=26
count=0
n = int(input())
k = ord('a')-1
while(sum<n) :
  count+=1
  sum+=26**(count+1)

current=n
mozi=''
mozi1=''
for i in range(count+1) :
  mozi+='z'
if current==sum :
  print(mozi)
else :
  for i in reversed(range(count+1)) :
    c=current//26**i

    mozi1+=chr(c+k)
    current = current % 26 ** i
  print(mozi1)

Submission status: Runtime Error

Solution code:
N=0
K=0
N = int(input())
K = int(input())
p = [int(input()) for i in range(N)]

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

Submission status: Runtime Error

Solution code:
sum=26
count=0
n = int(input())
k = ord('a')-1
while(sum<n) :
  count+=1
  sum+=26**(count+1)

current=n
mozi=''
mozi1=''
for i in range(count+1) :
  mozi+='z'
if current==sum :
  print(mozi)
else :
  for i in reversed(range(count+1)) :
    c=current//26**i
    
    mozi1+=chr(c+k)
    current = current % 26 ** i
  print(mozi1)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
num, select = map(int, input())
l = list(map(int, input()))

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

print(sum)

Submission status: Runtime Error

Solution code:
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = []
for l in range(K):
  lists.append(min(p))
  lists.drop(min(p))
  
print(sum(lists))

Submission status: Runtime Error

Solution code:
N = input()
K = input()
lists = []
A = 0

for i in range(int(N)):
  lists.append((input()))
 
lists.sort()
 
for j in range(int(K)):
  A += int(lists[j])
 
print(A)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
lst = []
result = []
for i in range(n):
    lst.append(int(input()))
for i in range(k):
    temp = min(lst)
    result.append(temp)
    lst.remove(temp)
print(sum(result))

Submission status: Runtime Error

Solution code:
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = []
for l in range(K):
  lists.append(min(l))
  lists.drop(min(l))
  
print(sum(lists))

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
n, k = int(input()), int(input())
lst = []
result = []
for i in range(n):
    lst.append(int(input()))
for i in range(k):
    temp = min(lst)
    result.append(temp)
    lst.remove(temp)
print(sum(result))

Submission status: Runtime Error

Solution code:
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = [1000000000000]
x = list(itertools.combinations(p, K))
counts = len(list(x))
for l in range(1,x+1):
    sums = sum(list(x[counts - 1]))
    if int(sums) <= int(lists[l-1]):
        lists.append(sums)
    else:
        continue

print(min(lists))

Submission status: Runtime Error

Solution code:
x, y = list(map(int, input().split()))
arr = list(map(int, input().split()))


def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    if(1 <= x, y <= 1000 and 1 <= max(arr) <= 1000 and 1 <= min(arr) <= 1000):
        # データの状態に左右されないためにrandom.choice()を用いることもある。
        # ref = random.choice(arr)
        ref = arr[0]
        ref_count = 0

        for ele in arr:
            if ele < ref:
                left.append(ele)
            elif ele > ref:
                right.append(ele)
            else:
                ref_count += 1
        left = quick_sort(left)
        right = quick_sort(right)
        return left + [ref] * ref_count + right


sorted_list = quick_sort(arr)

result = sorted_list[0] + sorted_list[1] + sorted_list[2]

print(result)

Submission status: Runtime Error

Solution code:
import sys
def order (p):
    return (sorted(p))         
def Mix_Juice (p):
    p[0] = len (p)
    p[1] = K
    a = order (p[2:p[0]])
    b = 0
    for i in range (0, K-1):
        b = b + a[i]
    return b
p = list(map(int, input().split()))
Mix_Juice (p)

Submission status: Runtime Error

Solution code:
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = [1000000000000]
x = list(itertools.combinations(p, K))
counts = len(list(x))
  for l in range(1,x+1):
    sums = sum(list(x[counts - 1]))
  	if sums <= lists[l-1]:
    	lists.append(sums)
    else:
        continue

print(min(lists))

Submission status: Runtime Error

Solution code:
N = input()
K = input()
 
for i in range(N):
  list[i] = input()
 
list.sort()
 
for j in range(K):
  A += list[j]
 
print(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = [1000000000000]
x = itertools.combinations(p, K)
counts = len(list(x)
  for l in range(1,x+1):
    sums = sum(list(l))
  	if sums <= lists[l-1]:
    	lists.append(sums)
    else:
        continue

print(min(lists))

Submission status: Runtime Error

Solution code:
N = input()
K = input()

for i in range(N):
  list.append(input())

list.sort()

for j in range(K):
  A += list[j]

print(A)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
p = map(int,input().split())
newlist = sorted(p, reverse=False)
ans_list=[]
for i in range(1,K+1):
    ans.append(newlist[i-1])
print(sum(ans_list))

Submission status: Runtime Error

Solution code:
n,k=(int(x) for x in input.split())
array = list(map(int, input().strip().split()))
print(f'{n} {k}')
print(sum(array[0:k]))

Submission status: Runtime Error

Solution code:
x, y = list(map(int, input().split()))
arr = list(map(int, input().split()))


def bubble_sort(arr):
    change = True
    while(change):
        change = False
        if(1 <= x, y <= 1000 and 1 <= max(arr) <= 1000 and 1 <= min(arr) <= 1000):
            for i in range(len(arr) - 1):
                if arr[i] > arr[i + 1]:
                    arr[i], arr[i + 1] = arr[i + 1], arr[i]
                    change = True
    return arr


sorted_list = bubble_sort(arr)

result = sorted_list[0] + sorted_list[1] + sorted_list[2]

print(result)

Submission status: Runtime Error

Solution code:
import itertools
import sys
from typing import Callable, List, NoReturn


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline
    n, k = map(int, readline().rstrip().split())  # type: int,...
    p: List[int] = [int(_) for _ in readline().rstrip().split()]

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


plist = list(range(N))
plist = (int(x) for x in input().split())

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

Submission status: Runtime Error

Solution code:
N, K = int(input().split())
juice = []
for i in range(N):
    juice.append(list(input().split()))
juice.sort()
for i in range(K):
  print (juice[0:K])

Submission status: Runtime Error

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

# plist = list(range(N))
# for i in range(N):
#     plist[i]=int(input())
plist = list(range(N))
plist = (int(x) for x in input().split())

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

plist = list(range(N))
for i in range(N):
    plist[i]=int(input())

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

Submission status: Runtime Error

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

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 and k==len(p):
        print(sum(p))

Submission status: Runtime Error

Solution code:
import itertools
N, K = map(int, input().split())
p = [int(n) for n in input().split()]
p = list(itertools.combinations(p, K))
min = p[0][0] + p[0][1] + p[0][2]
for i in range(len(p)):
    a = p[i][0] + p[i][1] + p[i][2]
    if a < min:
        min = a
print(min)

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
for i in range(0, len(m)):
    m[i] = int(m[i])
a = m[0]
b = m[1]
m = m[2:]
p = 0
for i in range(a-b,a):
    p = p + int(m[i])
print(int(p))

Submission status: Runtime Error

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

plist = list(range(N))
for i in range(N):
    plist[i]=int(input())

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

Submission status: Runtime Error

Solution code:
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = s[1]
p = list(map(int, input().strip().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 itertools
 
N = int(input().split())
K = int(input().split())
p = list(map(int, input().strip().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 = input()
m = n.split()
for i in range(0, len(m)):
    m[i] = int(m[i])
a = m[0]
b = m[1]
m = m[2:]

p = 0
for i in range(a-b,a):
    p = p + int(c[i])
print(int(p))

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
a 

for i in range(0, len(m)):
    m[i] = int(m[i])
a = m[0]
b = m[1]
m = m[2:]
print(m,a,b)

p = 0
for i in range(a-b,a):
    p = p + int(c[i])
print(int(p))

Submission status: Runtime Error

Solution code:
import itertools
 
N = int(input())
K = int(input())
p = list(map(int, input().strip().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 = int(input())
k = int(input())
sum = 0
p = [int(input()) for x in range(n)]
for i in range(k):
    mini = min(p)
    sum += mini
    p.remove(mini)
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
print(m)
a = [input() for l in range(0,1)]
b = a[0].split()
print(b)

for i in range(0, len(b)):
    b[i] = int(b[i])

c = sorted(b, reverse=True)
print(c)
p = 0
for i in range(int(m[0]) - int(m[1])+1,int(m[0])+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()))
p.sort()
if len(p) >= 3 :
    print(str(p[0] + p[1] + p[2]))
elif len(p) == 2 :
    print(str(p[0]+p[1])
elif len(p) == 1 :
    print(str(p[0]))

Submission status: Runtime Error

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

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

B = [1001 fo i in range(K)]

for x in A:
  for i in range(K):
    if x < B[i]:
      B[i] = x
      break

S = 0
for y in B:
  S += y
print(S)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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