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: Wrong Answer

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

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

p.sort()
print(p)

sum = 0

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

Submission status: Wrong Answer

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

fruit.sort()
price = 0
for i in range(N) :
    if i>2 :
        break
    price += fruit[i]
    
print(price)

Submission status: Wrong Answer

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

fruit.sort()
price = 0
for i in range(N) :
    if i>3 :
        break
    price += fruit[i]
    
print(price)

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
fruit = input().split()
#print(fruit)
fruit = [int(x) for x in fruit]
#print(fruit)
fruit.sort()
#print(fruit)
print(sum(fruit[:3]))

Submission status: Wrong Answer

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

cost = input().split(" ")

cost.sort()

sum = 0
for i in range(int(k)):
  sum += int(cost[i])
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=input().split()
N=int(N)
K=int(K)
a=[]
a=[int(a) for a in input().split()]
a.sort()
print(sum(a[0:K-1]))

Submission status: Wrong Answer

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

A.sort(reverse = True)
min = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

P = sorted(P)
print(P)

print(sum(P[:K]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = input().split()
n1 = int(l[0])
n2 = int(l[1])

money = input().split()

for i in range(n1):
    money[i] = int(money[i])

money.sort()
print(money)

ans = 0

for i in range(n2):
    ans += money[i]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

p = sorted(p, reverse=True)
ans = 0
for k in range(K):
  ans += p[k]

Submission status: Wrong Answer

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

p = sorted(p,reverse=True)
ans = 0
for i in range(k):
  ans += p[i]
print(ans)

Submission status: Wrong Answer

Solution code:
#B - Mix Juice
import math
from itertools import combinations 
n,k=map(int,input().split())
ｌ=list(map(int,input().split()))
min1=min(list(combinations(l,k)))
sum1=int(math.fsum(min1))
print(sum1)

Submission status: Wrong Answer

Solution code:
import math
from itertools import combinations 
n,k=map(int,input().split())
ｌ=list(map(int,input().split()))
min1=min(list(combinations(l,k)))
sum1=int(math.fsum(min1))
print(sum1)

Submission status: Wrong Answer

Solution code:
import math
from itertools import combinations 
n,k=map(int,input().split())
ｌ=list(map(int,input().split()))
min1=min(list(combinations(l,k)))
print(int(math.fsum(min1)))

Submission status: Wrong Answer

Solution code:
s=input()
if s.isupper():
 print("A")
else:
 print("a")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p.sort()
print(p)

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

Submission status: Wrong Answer

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

P.sort()

sum(P[0:k])

Submission status: Wrong Answer

Solution code:
n,k = input().split()
a = list()
a = input().split(" ")
a.sort()

k = int(k)
i = 0
sum = 0
while i<k:
    sum+=int(a[i])
    i+=1
    
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

print(p_list[:K])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:3]))

Submission status: Wrong Answer

Solution code:
N, K = input().split()
p = list(input().split())
p = list(map(int, p))
p = p.sort()
buy = 0
for item in range(int(K)):
  buy += item
print(buy)

Submission status: Wrong Answer

Solution code:
def mapt(fn, *args):
  return tuple(map(fn, *args))


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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lst = list(map(int,(input()).split()))
l = sorted(lst)
sum(l[:k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(total)

Submission status: Wrong Answer

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

print(total)

Submission status: Wrong Answer

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

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

total=0

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

Submission status: Wrong Answer

Solution code:
x = input()
arr = [int(j) for j in x.split()]
y = input()
main = [int(i) for i in y.split()]
main = sorted(main)
sum = 0
r = 0
while r < arr[1]:
  sum+=main[r]
  r+=1
print(main)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p.sort(reverse=True)
print(sum(p[:K]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A=input()
B=input()
nk=A.split()
N=int(nk[0])
K=int(nk[1])
list=B.split()
list_2=sorted(list)
sum=0
for i in range(K):
  sum+=int(list_2[i])
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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.pop(0)

Submission status: Wrong Answer

Solution code:
a = input().split()
# a[0] is N個
# a[1] is K個
b = list(map(int, input().split()))
b.sort()

print(b)
sum = 0

for i in range(int(a[1])):
    sum += b[i]

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input().split()
# a[0] is N個
# a[1] is K個
b = input().split()
b.sort()
sum = 0

for i in range(int(a[1])):
    sum += int(b[i])

print(sum)

Submission status: Wrong Answer

Solution code:
a = input().split()
b = input().split()
b.sort()
sum = 0

for i in range(int(a[1])):
    sum += int(b[i])

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

pa = sorted(p)

print(sum(pa[:3]))

Submission status: Wrong Answer

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

status = line[0].split()
fruits = line[1].split()

i = 1
total = 0
for fruit in fruits:
    i += 1
    total += int(fruit)
    if int(status[1]) < i:
        break
print(total)

Submission status: Wrong Answer

Solution code:
(N, K) = input().split(' ')
a = input().split(' ')
a.sort()
x = 0
print(a)
for i in range(int(K)):
    x += int(a[i])
print(x)

Submission status: Wrong Answer

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

plist.sort()
ans = sum(plist, k)

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
l1 = sorted(l, reverse= False)
sum = sum(l1[0:3])
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
l1 = sorted(l, reverse= False)
sum = sum(l[0:3])
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

tmp = input()
N,K = tmp.split()
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

que = sorted(que)

#for x in itertools.combinations(que, K):

x = [que[i] for i in range(K)]
tmp = np.sum(x)

print(min_val)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

tmp = input()
N,K = tmp.split()
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

que = sorted(que)

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

print(min_val)

Submission status: Wrong Answer

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

ans=0
if n!=1:
    for i in range(k):
        min=p[i]
        for j in range(i+1,n):
            if min>p[j]:
                min=p[j]
                p[j]=p[i]
        ans+=min
else:
    ans=p[0]
print(ans)

Submission status: Wrong Answer

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

ans=0
if n!=1:
    for i in range(k):
        min=p[i]
        for j in range(i+1,n):
            if min>p[j]:
                min=p[j]
                p[j]=p[i]
        ans+=min
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(sum(list(set(p))))

Submission status: Wrong Answer

Solution code:
import sys
nsel = int(input().split()[1])
fruits = [int(fr) for fr in input().split()]
for fr in sorted(fruits)[:nsel]: sys.stdout.write(str(fr)+" ")

Submission status: Wrong Answer

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

for i in range(len(prices)):
    prices[i] = int(prices[i])

pricesSum = 0
while K > 0:
    newFruit = min(prices) 
    index = prices.index(newFruit)
    prices.pop(index)
    pricesSum += newFruit
    K -= 1

Submission status: Wrong Answer

Solution code:
a = input() # 5 3
b = input() # 50 100 80 120 80
c = a.split() 
d = b.split()
e = sorted(d) # 50 80 80 100 120
f = int(c[1])
for i in range(f):
  print(e[i])

Submission status: Wrong Answer

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

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

p.sort

print(f'{sum(p[0:k])}')

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
if n<=3:
    print(sum(p))
else:
    minimum=p[1]
    maximum=p[2]
    if minimum>maximum:
        minimum=p[2]
        maximum=p[1]
    for i in p:
        if maximum+i<=minimum+maximum:
            maximum=i
    print(maximum+minimum+p[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
string = input()
if string.isupper() == True:
    print("A")
else:
    print("a")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

P.sort()
print(sum(P[0:3]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
print('0'if n%k==0 else'1')

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
S=[0]*(N+1);w=0
P=list(map(int,input().split()))
for i in range(1,N+1):
  S[i-1]=[i,P[i-1]]
S[-1]=[0,1000]
S.sort(key=lambda x: x[1])
print(S)
for i in range(K):
  w=w+S[i][1]
print(w)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N,k = [int(item) for item in input().split()]
    price_arr = [int(p) for p in input().split()]
    print(sum(sorted(price_arr,reverse=True)[:k]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p.sort
total=0

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

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = list(map(int, input().split()))
a = []
for i in range(k):
    a.append(1000)

for i in p:
    for j in a:
        if i < j:
            a.append(i)
            a.remove(j)
            p.remove(i)
            break

print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = input().split()
n = int(n)
k = int(k)
prices = [int(p) for p in input().split()]
min = prices[:k]
for p in prices[k:]:
    for i in range(k):
        if min[i] > p:
            min.append(p)
            min.pop(i)
sum = 0
for p in min:
    sum = sum+p
print(sum)

Submission status: Wrong Answer

Solution code:
import collections

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

for i in range(0,s[1]):
	a.append(p[i])
print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


# 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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect


input = lambda: sys.stdin.readline().rstrip("\r\n")
read = lambda: list(map(int, input().strip().split(" ")))





def solve():
    n, k = read(); arr = read()
    if n == 1:print(arr[0]);return

    def chk(x):
        ans = 0; i = 0
        while i < n:
            t = 0; c = 0
            while i < n and arr[i]+t <= x and c < 2:
                print(arr[i], t, c)
                c += 1
                i += 1
            ans += 1
            # i += 1
        return(ans)
    print(chk(9))

    # lo, hi = arr[-1], arr[-1]+arr[-2]
    # last = 0
    # while lo < hi:
    #     mid = (lo+hi)//2
    #     if chk(mid) <= k:
    #         last = mid
    #         lo = mid+1
    #     else:
    #         hi = mid-1








    


  

if __name__ == "__main__":
	solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

p.sort()

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

Submission status: Wrong Answer

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

p = p.sort

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

print(K)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
if len(p) <=3:
    for x in p:
        ans += x
else:
    p.sort()
    ans += p[0]+p[1]+p[2]

print(ans)

Submission status: Wrong Answer

Solution code:
N,K=(int(x) for x in input().split())
p=list(map(int, input().split()))
ld = sorted(p, reverse=True)
l=(ld[:K])
print(sum(l))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input().split(" ")
b = input().split(" ")
c = []
for i in b:
    c.append(i)
c.sort()
sum = 0
for i in c[0:int(a[1])]:
    sum += int(i)
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p.sort()
r = sum(p[0:3])

print(r)

Submission status: Wrong Answer

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])
print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
res = 0
i = 0
while(K):
	res += P[i]
	K -= 1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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])
  
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(sum(sorted(p)[:n+1]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
s = list(map(int, input().split()))
s.sort()
h=s[:i[1]-1]
print(sum(h))

Submission status: Wrong Answer

Solution code:

N, K, *p = map(int, open(0).read().split())

import itertools
lis = list(itertools.combinations(range(N), 3))

if len(lis) == 0:
    print(p[0])
    import sys
    sys.exit()

mi = -1
for x in lis:
    cur = 0
    for pos in x:
        cur += p[pos]

    print(cur)

    if mi == -1:
        mi = cur
    else:
        mi = min(mi, cur)

print(mi)
#print(lis)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

c = sorted(b, reverse=True)
p = 0
for i in range(int(m[0]) - int(m[1]),int(m[0])):
    p = p + int(c[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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.remove(min(p))
  
print(sum(lists))

Submission status: Wrong Answer

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

li.sort(key = int)

print(li)

j = 0
i = 0

while i <= k-1:
  
  j += int(li[i])
  i += 1

print(j)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = [int(m) for m in input().split()]
p.sort()
ans = 0

if K == 0:
    print(0)
elif K == 1:
    print(*p)
elif K == 2:
    print(p[0]+p[1])
else:
    for i in range(K):
        ans += p[i]
    print(ans)

Submission status: Wrong Answer

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

new_list = sorted(li)

j = 0
i = 0

while i <= k-1:
  j += int(new_list[i])
  i += 1

print(j)