Problem:
 Score : 200 points    Problem Statement Snuke has N sticks.
The length of the i -th stick is l_i .  Snuke is making a snake toy by joining K of the sticks together.  The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.      Constraints  1 \leq K \leq N \leq 50  1 \leq l_i \leq 50  l_i is an integer.         Input Input is given from Standard Input in the following format:  N  K  l_1  l_2  l_3  ...  l_{N}       Output Print the answer.        Sample Input 1 5 3
1 2 3 4 5      Sample Output 1 12  You can make a toy of length 12 by joining the sticks of lengths 3 , 4 and 5 , which is the maximum possible length.       Sample Input 2 15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45      Sample Output 2 386

Solution (Python):
A = input().split()

N = int(A[0])
K = int(A[1])

A = input().split()
l = []

for n in range(N):
    l.append(int(A[n]))

l.sort(reverse=True)
sum=0
for i in range(K):
    sum = sum + l[i]
print(sum)

Solution (Python):
a,b = map(int,input().split())
c = list(map(int,input().split()))
d = 0
for x in range(b):
    cc = max(c)
    d += cc
    c.remove(cc)
print(d)

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

l.sort()
l.reverse()

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

print(sum)

Solution (Python):
N, K = tuple(map(int, input().split()))
Ls = list(map(int, input().split()))

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

Solution (Python):
N, K = list(map(int, input().split()))
l = [int(0)] * N
l = list(map(int, input().split()))
l.sort()
sum=0
for i in range(K):
    sum+=l[N-1-i]
print(sum)

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

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

def main(K):
    ans = 0
    L.sort()
    L.reverse()
    i = 0
    while i < K:
        ans += L[i]
        i += 1
    return ans

print(main(K))

Solution (Python):
(N, K) = map(int, input().split(" "))
a = map(int, input().split())
sa = sorted(a)
leng = sum(sa[:-(K+1):-1])
print(leng)

Solution (Python):







A = input().split()
B = input().split()





N = int(A[0])
K = int(A[1])

C = []

for i in range(N):
    C.append(int(B[i]))

D = sorted(C)

ans = 0

for i in range(K):
    x = N - i -1
    ans = ans + D[x]

print(ans)

Solution (Python):
if(__name__ == "__main__"):
    N, K =[int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    
    
    maxlist = a[:K]
    
    for i in range(K,N):
        if(min(maxlist) < a[i]):
            maxlist.remove(min(maxlist))
            maxlist.append(a[i])
            
        
    print(sum(maxlist))

Solution (Python):
def main():
    N, K = list(map(int, input().strip().split()))
    ls = list(map(int, input().strip().split()))
    k_total = sum(sorted(ls, reverse=True)[:K])
    print(k_total)

if __name__ == '__main__':
    main()

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

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

list.sort()
list.reverse()

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

print(sum)

Solution (Python):

import itertools
import numpy as np

N,K = map(int,input().split())
l = np.array(list(map(int,input().split())))

ans = 0
for i in range(K):
    max_i = np.argmax(l)
    ans += l[max_i]
    l = np.delete(l,max_i)

print(ans)

Solution (Python):

n, k = map(int, raw_input().split())
l = map(int, raw_input().split())
l.sort(reverse=True)

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

print a

Solution (Python):
N, K = map((int), input().split())
l = [int(item) for item in input().split()]

l.sort(reverse = True)

s = 0
for i in range(K):
    s += int(l[i])

print(s)

Solution (Python):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
print(sum(sorted(l, reverse=True)[:k]))

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

Solution (Python):
n,k=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l.sort()
a=0
for i in range(k):
  a+=l[n-1-i]
print(a)

Solution (Python):
if __name__=='__main__':
    index_src = input()
    index = index_src.split(' ')
    alls = int(index[0])
    adds = int(index[1])
    numbers_src = input().split(' ')
    numbers_int =[]
    for i in numbers_src:
        numbers_int.append(int(i))
    numbers_int.sort()
    numbers_int.reverse()
    ans = 0
    for i in range(0,adds):
        ans += numbers_int[i]
    print(ans)

Solution (Python):
N,K = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
l1 = 0
for i in range(K):
    l1 = l1+l[-1-i]
print(l1)

Solution (Python):


import sys

def main(argv):
    N, K = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
    while N and K:
        L = map(lambda x: int(x), raw_input().split(" ", N))
        print(sum(sorted(L)[-K:]))

        line = sys.stdin.readline()
        if line:
            N, K = map(lambda x: int(x), line.split(" ", 2))
        else:
            N = None
            K = None

if __name__ == "__main__":
    main(sys.argv)

Solution (Python):


N,K=map(int,raw_input().split())
l=map(int,raw_input().split())
l.sort()
print sum(l[len(l)-K:len(l)])

Solution (Python):


l = map(int, raw_input().split())

N=l[0]
K=l[1]



a = map(int, raw_input().split())



a.sort()
a.reverse()



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

print sum

Solution (Python):
a,b = map(int,input().split())
n = list(map(int,input().split()))
n.sort()
print(sum(n[-b:]))

Solution (Python):
N,K  = map(int, raw_input().split())
l =  map(int, raw_input().split())
l.sort(reverse=True)
sum = 0
for i in range(K):
    sum += l[i]
print(sum)

Solution (Python):
N , K = map(int, input().split())
lenghths = list(map(int , input().split()))

lenghths.sort(reverse=True)
answer = sum(lenghths[0:K])
print(answer)

Solution (Python):
nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
bars = [int(y) for y in input().split()]
bars.sort()
bars.reverse()
ans = 0
for i in range(k):
    ans += bars[i]
print(ans)

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

Solution (Python):
N, K = (int(i) for i in input().split())  
l = [int(i) for i in input().split()]
ans = 0

for i in range(K):
	ans += max(l)
	l.pop(l.index(max(l)))

print(ans)

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

Solution (Python):


N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]

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

Solution (Python):
def main():
    N, K = map(int, input().split())
    L = tuple(map(int, input().split()))

    stick = sorted(L, reverse=True)
    print(sum(stick[:K]))

main()

Solution (Python):
N,K=map(int,input().split())
l=sorted(map(int,input().split()),reverse=True)
print (sum(l[:K]))

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

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

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

print(ans)

Solution (Python):



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

ls = sorted([x for x in map(int, input().split())])

print(sum(ls[-K:]))

Solution (Python):


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

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

print(sum(sorted(l, reverse = True)[0:K]))

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

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

Solution (Python):


n, k = map(int, raw_input().split())
l = map(int, raw_input().split())

l.sort()
print sum(l[-k:])

Solution (Python):
def main():
    N, K = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)

    print(sum(L[:K]))

if __name__ == "__main__":
    
    
    main()

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

l.sort()
ans = 0
for i in range(k):
    ans += l[-i - 1]

print(ans)

Solution (Python):
n,k = map(int,input().split())
L = input().split()
l = []
for x in L:
 l.append(int(x))
l.sort()
sum = 0
for x in range(1,k+1):
 sum += l[-x]
print(sum)

Solution (Python):
N,K = [int(i) for i in input().split(" ")]
l = [int(i) for i in input().split(" ")]
l.sort()
print(sum(l[N-K:N]))

Solution (Python):
m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))

Solution (Python):
n, k = map(int, input().split(" "))
l = map(int, input().split(" "))

print(sum(sorted(l)[-k:]))

Solution (Python):
N, K = list(map(int, input().split()))
l_list = list(map(int, input().split()))

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

Solution (Python):
N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

l.sort()
l = l[::-1]

print sum(l[:K])

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))

l.sort()
l.reverse()

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

Solution (Python):


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

if __name__ == '__main__':
	main()

Solution (Python):
s = input().split()
s = [int(i) for i in s]
N = s[0]
K = s[1]

s = input().split()
s = [int(i) for i in s]
s = sorted( s )
bubun = s[-K : ]
print(sum(bubun))

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(key=lambda x: -x)
ans = 0
for i in range(K):
    ans += l[i]
print(ans)

Solution (Python):
N,K = map(int, input().split())
src = list(map(int, input().split()))
src.sort()
print(sum(src[-K:]))

Solution (Python):
n,k=map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse=True)

print(sum(l[:k]))

Solution (Python):


N,K = list(map(int, input().split()))
l = list(map(int, input().split()))
l = sorted(l, reverse=True)
s = sum( l[:K] )
print(s)

Solution (Python):
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    k = int(lst[1])

    line = sys.stdin.readline()
    lst = line.split()
    l_lst = sorted([int(l) for l in lst], reverse=True)

    print(sum(l_lst[:k]))


    return 0

if __name__ == '__main__':
    sys.exit(main())

Solution (Python):
n, k =(int (i) for i in input().split())
l=[int(i) for i in input().split()]
l.sort()
sum=0
for i in range(0,k):
    sum += l.pop()

print(sum)

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[0:K]))

Solution (Python):
N, K = map(int, raw_input().split())
l = list(map(int, raw_input().split()))

l.sort(reverse=True)

print sum(l[:K])

Solution (Python):
N,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
print(sum(L[-K:]))

Solution (Python):


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

Solution (Python):
N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 0

l.sort(reverse=True)
for i in range(K):
	ans += l[i]

print(ans)

Solution (Python):
nums = [int(x) for x in input().split()]
N,K = nums[0],nums[1]
L = [int(x) for x in input().split()]
L.sort(reverse=True)
ans = sum(L[:K])
print(ans)

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

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

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

l.sort()
l.reverse()

print(sum(l[0:k]))

Solution (Python):



import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    n, k = map(int, input().split())
    ls = list(map(int, input().split()))

    ls.sort(reverse=True)
    ans = sum(ls[:k])
    print(ans)

if __name__ == "__main__": main()

Solution (Python):
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse = True)
print(sum(l[:k]))

Solution (Python):
import sys
n, k = map(int, sys.stdin.readline().split())
a = sorted(map(int, sys.stdin.readline().split()))


print sum (a[n - k:])

Solution (Python):

def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N, K = get_ln_int_inputs()
    l = get_ln_int_inputs()

    print(sum(sorted(l)[::-1][:K]))


main()

Solution (Python):
N,K = list(map(int,input().split()))
L =list(map(int,input().split()))

L.sort()

print(sum(L[-K:]))