ZhenlongDai/ACPR huggingface dataset:
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):




class Solution:
    

    @staticmethod
    def bubble_sort():
        
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        flag = 1
        count = 0
        while flag:
            flag = 0
            for j in range(array_length - 1, 0, -1):
                if unsorted_array[j] < unsorted_array[j - 1]:
                    unsorted_array[j], unsorted_array[j - 1] = unsorted_array[j - 1], unsorted_array[j]
                    flag = 1
                    count += 1
        print(unsorted_array)
        print(count)


if __name__ == '__main__':
    solution = Solution()
    solution.bubble_sort()

Failing test case input:
6
6 1 3 6 1 3

Expected output:
1 1 3 3 6 6
7


Actual output:
[1, 1, 3, 3, 6, 6]
7


Fixed submission (verdict: Accepted):




class Solution:
    

    @staticmethod
    def bubble_sort():
        
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        flag = 1
        count = 0
        while flag:
            flag = 0
            for j in range(array_length - 1, 0, -1):
                if unsorted_array[j] < unsorted_array[j - 1]:
                    unsorted_array[j], unsorted_array[j - 1] = unsorted_array[j - 1], unsorted_array[j]
                    flag = 1
                    count += 1
        print(" ".join(map(str, unsorted_array)))
        print(str(count))


if __name__ == '__main__':
    solution = Solution()
    solution.bubble_sort()

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A,N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for i in range(1,N):
            if A[N-i] < A[N-i-1]:
                A[N-i] , A[N-i-1] = A[N-i-1] , A[N-i]
                flag = 1
                count += 1
    return (count)

n = int(input())
data = [int(i) for i in input().split()]
print(bubbleSort(data,n))

Failing test case input:
6
1 1 0 2 0 0

Expected output:
0 0 0 1 1 2
8


Actual output:
8


Fixed submission (verdict: Accepted):
def bubbleSort(A,N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for i in range(1,N):
            if A[N-i] < A[N-i-1]:
                A[N-i] , A[N-i-1] = A[N-i-1] , A[N-i]
                flag = 1
                count += 1
    return (count)

n = int(input())
data = [int(i) for i in input().split()]
a = bubbleSort(data,n)
print(" ".join(map(str,data)))
print(a)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(i + 1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a]))
print(c)

Failing test case input:
6
1 1 0 2 0 -1

Expected output:
-1 0 0 1 1 2
10


Actual output:
1 0 -1 0 1 2
6


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a]))
print(c)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split(" ")))

def print_list(A):
    for a in A[:-1]:
        print ("%d "%a, end="")
    print(A[-1])

def BubbleSort(A, N):
    print_list(A)
    count = 0
    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
                count += 1
                flag = True
                
    return A, count

A_sorted, c = BubbleSort(A, N)

print_list(A_sorted)
print(c)

Failing test case input:
5
4 4 5 3 0

Expected output:
0 3 4 4 5
7


Actual output:
4 4 5 3 0
0 3 4 4 5
7


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split(" ")))

def print_list(A):
    for a in A[:-1]:
        print ("%d "%a, end="")
    print(A[-1])

def BubbleSort(A, N):
    count = 0
    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
                count += 1
                flag = True
                
    return A, count

A_sorted, c = BubbleSort(A, N)

print_list(A_sorted)
print(c)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
nums=list(map(int,input().split()))

k=0
for i in range(len(nums)-1):
    for j in range(len(nums)-1,i,-1):
        print(i,j)
        if nums[j]<nums[j-1]:
            nums[j],nums[j-1]=nums[j-1],nums[j]
            print(nums)
            k+=1

print(*nums)
print(k)

Failing test case input:
5
4 10 5 4 0

Expected output:
0 4 4 5 10
7


Actual output:
0 4
[4, 10, 5, 0, 4]
0 3
[4, 10, 0, 5, 4]
0 2
[4, 0, 10, 5, 4]
0 1
[0, 4, 10, 5, 4]
1 4
[0, 4, 10, 4, 5]
1 3
[0, 4, 4, 10, 5]
1 2
2 4
[0, 4, 4, 5, 10]
2 3
3 4
0 4 4 5 10
7


Fixed submission (verdict: Accepted):
n=int(input())
nums=list(map(int,input().split()))

k=0
for i in range(len(nums)-1):
    for j in range(len(nums)-1,i,-1):
        if nums[j]<nums[j-1]:
            nums[j],nums[j-1]=nums[j-1],nums[j]
            k+=1

print(*nums)
print(k)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A, N):
    cnt = 0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1, 0, -1):
            if(A[i-1] > A[i]):
                tmp = A[i-1]
                A[i-1] = A[i]
                A[i] = tmp
                cnt += 1
                flag = True
    print(cnt)
    B = list(map(str, A))
    print(" ".join(B))

print(*A)
bubble_sort(A, N)

Failing test case input:
6
2 1 -1 9 1 0

Expected output:
-1 0 1 1 2 9
9


Actual output:
2 1 -1 9 1 0
9
-1 0 1 1 2 9


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A, N):
    cnt = 0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1, 0, -1):
            if(A[i-1] > A[i]):
                tmp = A[i-1]
                A[i-1] = A[i]
                A[i] = tmp
                cnt += 1
                flag = True

    print(" ".join(list(map(str, A))))
    print(cnt)

bubble_sort(A, N)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A, N):
    swap_count = 0
    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = True
                swap_count += 1
                print(A)
    return swap_count

n = int(input())
A = list(map(int, input().split()))
count = bubbleSort(A,n)
print(*A)
print(count)

Failing test case input:
6
1 1 3 3 2 3

Expected output:
1 1 2 3 3 3
2


Actual output:
[1, 1, 3, 2, 3, 3]
[1, 1, 2, 3, 3, 3]
1 1 2 3 3 3
2


Fixed submission (verdict: Accepted):
def bubbleSort(A, N):
    swap_count = 0
    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = True
                swap_count += 1
    return swap_count

n = int(input())
A = list(map(int, input().split()))
count = bubbleSort(A,n)
print(*A)
print(count)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def bubble_sort(A, n):
    print_list(A)
    flg = 1 
    i = 0
    while flg:
        flg = 0
        for j in range(n-1, i+1, -1):
            if A[j-1] > A[j]:
                A[j-1], A[j] = swap(A[j-1], A[j])
                flg = 1
                print_list(A)
        i += 1

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

bubble_sort(A, n)


Failing test case input:
5
4 4 5 3 0

Expected output:
0 3 4 4 5
7


Actual output:
4 4 5 3 0
4 4 5 0 3
4 4 0 5 3
4 0 4 5 3
4 0 4 3 5
4 0 3 4 5


Fixed submission (verdict: Accepted):
def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def bubble_sort(A, n):
    flg = 1 
    i = 0
    replace_num = 0
    while flg:
        flg = 0
        for j in range(n-1, i, -1):
            if A[j-1] > A[j]:
                A[j-1], A[j] = swap(A[j-1], A[j])
                flg = 1
                replace_num += 1 
        i += 1
    print_list(A)
    print(replace_num)

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

bubble_sort(A, n)
Problem: p03987
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))

l=[]
r=[]
s=[]

for i,x in enumerate(a):
  left=i
  if len(s)>0 and x<s[-1][0]:
    left=s[-1][-1]
    s.pop()
  l.append(left)
  s.append([x,left])
  
  
s=[]
for i in range(N-1,-1,-1):
  right=i
  x=a[i]
  if len(s)>0 and x<s[-1][0]:
    right=s[-1][-1]
    s.pop()
  r.append(right)
  s.append([x,right])
r=r[::-1]
ans=0
for i,(x,le,ri) in enumerate(zip(a,l,r)):
  ans+=x*(i-le+1)*(ri-i+1)
print(ans)

Failing test case input:
8
4 5 8 1 2 6 7 3

Expected output:
86


Actual output:
69


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))

l=[]
r=[]
s=[]

for i,x in enumerate(a):
  left=i
  while len(s)>0 and x<s[-1][0]:
    left=s[-1][-1]
    s.pop()
  l.append(left)
  s.append([x,left])
  
  
s=[]
for i in range(N-1,-1,-1):
  right=i
  x=a[i]
  while len(s)>0 and x<s[-1][0]:
    right=s[-1][-1]
    s.pop()
  r.append(right)
  s.append([x,right])
r=r[::-1]
ans=0
for i,(x,le,ri) in enumerate(zip(a,l,r)):
  ans+=x*(i-le+1)*(ri-i+1)
print(ans)

Problem: p03987
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
d = {}
for i,j in enumerate(a):
    d[j] = i

uf = [-1]*n
def root(a):
    if uf[a] < 0:
        return a
    uf[a] = root(uf[a])
    return uf[a]
def unite(a,b):
    ra,rb = root(a),root(b)
    if ra==rb:
        return False
    if uf[ra] > uf[rb]:
        ra,rb = rb,ra
    uf[ra] += uf[rb]
    uf[rb] = ra
    return True

ans = 0
for i in range(n,0,-1):
    left=right=0
    ind = d[i]

    if ind<n-1 and a[ind] < a[ind+1]:
        right -= uf[ind+1]
        unite(ind, ind+1)
    if ind>0 and a[ind] < a[ind-1]:
        left -= uf[ind-1]
        unite(ind, ind-1)
    ans += i*(left+1)*(right+1)

print(ans)

Failing test case input:
8
5 4 8 1 2 6 7 3

Expected output:
85

Actual output:
44


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
d = {}
for i,j in enumerate(a):
    d[j] = i

uf = [-1]*n
def root(a):
    if uf[a] < 0:
        return a
    uf[a] = root(uf[a])
    return uf[a]
def unite(a,b):
    ra,rb = root(a),root(b)
    if ra==rb:
        return False
    if uf[ra] > uf[rb]:
        ra,rb = rb,ra
    uf[ra] += uf[rb]
    uf[rb] = ra
    return True

ans = 0
for i in range(n,0,-1):
    left=right=0
    ind = d[i]

    if ind<n-1 and a[ind] < a[ind+1]:
        right -= uf[root(ind+1)]
        unite(ind, ind+1)
    if ind>0 and a[ind] < a[ind-1]:
        left -= uf[root(ind-1)]
        unite(ind, ind-1)
    ans += i*(left+1)*(right+1)

print(ans)
Problem: p03987
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
A = list(enumerate(list(map(int,input().split()))))
left = [i-1 for i in range(N)]
right = [i+1 for i in range(N)]
A.sort(key=lambda x:x[1],reverse=True)
ans = 0
for i,a in A:
    il,ir = left[i],right[i]
    ans += a*(i-il)*(ir-i)
    if ir<N:
        left[ir] = il
    if il>0:
        right[il] = ir
print(ans)

Failing test case input:
8
4 5 8 1 2 6 7 3

Expected output:
86


Actual output:
73


Fixed submission (verdict: Accepted):

N = int(input())
A = list(enumerate(list(map(int,input().split()))))
left = [i-1 for i in range(N)]
right = [i+1 for i in range(N)]
A.sort(key=lambda x:x[1],reverse=True)
ans = 0
for i,a in A:
    il,ir = left[i],right[i]
    ans += a*(i-il)*(ir-i)
    if ir<N:
        left[ir] = il
    if il>-1:
        right[il] = ir
print(ans)
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

array.sort()

sum = 0
for i in range(k):
  sum += array[-(i+1)]

Failing test case input:
15 15
6 53 0 21 25 18 2 49 7 5 8 7 46 0 0

Expected output:
247


Actual output:

Fixed submission (verdict: Accepted):
n,k = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

array.sort()

sum = 0
for i in range(k):
  sum += array[-(i+1)]

print(sum)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
nums=input().split()

nums.sort()
nums.reverse()
ans=0

for v in range(0,k):
    ans=ans+int(nums[v])

print(ans)


Failing test case input:
0 2
1 2 4 18 0

Expected output:
22


Actual output:
6


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
nums=list(map(int,input().split()))

nums.sort()
nums.reverse()
ans=list()

for v in range(k):
    ans.append(nums[v])

print(sum(ans))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
l = list(map(int, input().split()))

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


Failing test case input:
5 5
2 2 3 4 5

Expected output:
16


Actual output:
[5, 4, 3, 2, 2]
16


Fixed submission (verdict: Accepted):
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)

Problem: p03658
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, k = [int(num) for num in input().split()]
list = [int(num) for num in input().split()]
list.reverse()
print(sum(list[:k]))

Failing test case input:
15 14
91 26 27 21 41 12 42 35 7 5 5 36 39 1 45

Expected output:
432


Actual output:
342


Fixed submission (verdict: Accepted):
n, k = [int(num) for num in input().split()]
list = [int(num) for num in input().split()]

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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n , k = map(int,input().split())
lis = list(map(int,input().split()))
lis = sorted(lis)
ans = 0
for i in range(k):
  ans += lis[i]
print(ans)

Failing test case input:
15 14
50 26 27 21 41 7 42 35 7 5 5 36 67 1 45

Expected output:
414


Actual output:
348


Fixed submission (verdict: Accepted):
n , k = map(int,input().split())
lis = list(map(int,input().split()))
lis = sorted(lis,reverse = True)
ans = 0
for i in range(k):
  ans += lis[i]
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
l = sorted(map(int, input().split())) [::-1]
print(sum(l[:k+1]))

Failing test case input:
15 14
50 26 27 21 41 7 42 9 7 5 5 1 55 1 45

Expected output:
341


Actual output:
342


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = sorted(map(int, input().split())) [::-1]
print(sum(l[:k]))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
for i in range(k+1):
  ans += i
print(ans)

Failing test case input:
15 14
50 26 27 21 41 7 42 9 7 5 6 1 55 1 45

Expected output:
342


Actual output:
105


Fixed submission (verdict: Accepted):
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)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()])
print(sum(l[:K]))


Failing test case input:
15 14
82 28 17 21 18 18 81 49 7 5 5 31 46 1 0

Expected output:
409


Actual output:
327


Fixed submission (verdict: Accepted):
N, K = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()], reverse=True)
print(sum(l[:K]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

sorted(L, reverse=True)
a = 0
for i in range(K):
    a += L[i]
print(a)


Failing test case input:
15 14
91 26 27 21 41 12 42 35 7 5 5 36 39 1 45

Expected output:
432


Actual output:
388


Fixed submission (verdict: Accepted):
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

l = sorted(L, reverse=True)
a = 0
for i in range(K):
    a += l[i]
print(a)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
l=list(map(int,input().split()))

l.sort(reverse=True)

print(sum(l[0:K+1]))

Failing test case input:
5 3
1 2 3 4 5

Expected output:
12

Actual output:
14


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
l=list(map(int,input().split()))

l.sort(reverse=True)

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

Problem: p03658
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, K=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
print(sum(l[:-K]))

Failing test case input:
2 15
6 108 0 37 25 18 0 12 3 5 8 2 26 2 0

Expected output:
252


Actual output:
0


Fixed submission (verdict: Accepted):
N, K=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
print(sum(l[-K:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
x = sorted(list(map(int,input().split())))
print(sum(x[k:]))


Failing test case input:
15 14
82 28 17 21 18 2 42 49 7 5 5 31 46 0 0

Expected output:
353


Actual output:
82


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
x = sorted(list(map(int,input().split())),reverse=True)
print(sum(x[:k]))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
s=0
for i in range(k):
    s+=l[i] 

Failing test case input:
15 15
82 53 17 21 18 18 37 49 7 5 5 31 46 0 0

Expected output:
389


Actual output:

Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
s=0
for i in range(k):
    s+=l[i] 
print(s)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())

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

l.sort()

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

Failing test case input:
15 14
82 28 17 21 18 18 42 49 7 5 5 31 46 0 0

Expected output:
369


Actual output:
287


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())

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

l.sort()

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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
L = sorted([int(_) for _ in range(N)], reverse=True)

print(sum(L[:K]))

Failing test case input:
15 15
30 53 0 21 25 18 2 49 7 5 5 7 46 0 0

Expected output:
268


Actual output:
105


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = sorted(list(map(int, input().split())), reverse=True)

print(sum(L[:K]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
l = map(int, input().split())
x = sorted(l)
print(sum(x[k:]))


Failing test case input:
2 15
6 108 0 37 25 18 0 12 3 5 8 7 26 2 0

Expected output:
257


Actual output:
0


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
l = list(map(int, input().split()))
x = sorted(l)
print(sum(x[n-k:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(sum(l[0:k-1]))

Failing test case input:
15 14
42 26 17 21 12 18 42 35 4 5 5 31 46 1 0

Expected output:
305


Actual output:
304


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(sum(l[0:k]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
l = na()

l.sort()
ans = sum(l[-1:n - k - 1:-1])

print(ans)

Failing test case input:
15 15
6 51 0 37 25 18 0 12 7 5 8 7 46 0 0

Expected output:
222


Actual output:
0


Fixed submission (verdict: Accepted):
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
l = na()

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

print(ans)
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
l.sort()
for i in range(K):
  ans += l[i]
print(ans)

Failing test case input:
15 14
42 26 27 21 12 18 42 35 7 5 5 31 46 1 0

Expected output:
318


Actual output:
272


Fixed submission (verdict: Accepted):
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)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())
ans = 0
l = [int(i) for i in input().split()]
l = sorted(l)
for i in range(K-1):
    ans += l[i]
print(ans)

Failing test case input:
0 3
1 1 4 7 10

Expected output:
21


Actual output:
2


Fixed submission (verdict: Accepted):
N,K = map(int, input().split())
ans = 0
l = [int(i) for i in input().split()]
l = sorted(l, reverse=True)
for i in range(K):
    ans += l[i]
print(ans)

Problem: p03658
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))

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

Failing test case input:
0 3
0 1 4 0 0

Expected output:
5


Actual output:
[4, 1, 0, 0, 0]
5


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))

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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
li=list(map(int,input().split()))
li_sort=sorted(li,reverse=True)
print(sum(li_sort[::K]))


Failing test case input:
15 15
34 53 17 21 18 18 7 49 7 5 8 31 46 0 0

Expected output:
314


Actual output:
53


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
li=list(map(int,input().split()))
li_sort=sorted(li,reverse=True)
print(sum(li_sort[:K]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
L=sorted(list(map(int,input().split())))
ans=sum(L[K:])
print(ans)


Failing test case input:
5 5
1 4 2 4 0

Expected output:
11


Actual output:
0


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
L=sorted(list(map(int,input().split())))
ans=sum(L[-K:])
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.reverse()
ans = 0
for i in range(k):
  ans += l[i]
print(ans)

Failing test case input:
15 14
49 26 27 26 33 7 42 35 7 5 5 36 39 1 45

Expected output:
382


Actual output:
334


Fixed submission (verdict: Accepted):
n, k = list(map(int, input().split()))
l = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(k):
  ans += l[i]
print(ans)
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
s=sum( sorted(list(map(int,input().split())))[-k:] )

Failing test case input:
15 15
34 53 0 21 25 18 7 49 7 5 8 19 46 0 0

Expected output:
292


Actual output:

Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
print(sum(sorted(list(map(int,input().split())))[-k:] ))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
l = list(map(int, input().split()))
x = sorted(l)
print(sum(x[k:]))

Failing test case input:
15 15
34 53 0 21 25 18 2 49 7 5 8 19 46 0 0

Expected output:
287


Actual output:
0


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
l = list(map(int, input().split()))
x = sorted(l)
print(sum(x[n-k:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = [int(i) for i in input().split()]

l = [int(j) for j in input().split()]

l = sorted(l)

ans = 0
for k in range(-1, -K-1 -1):
    ans += l[k]

print(ans)


Failing test case input:
15 15
6 53 0 21 25 18 2 49 7 5 8 7 46 0 0

Expected output:
247


Actual output:
0


Fixed submission (verdict: Accepted):
N, K = [int(i) for i in input().split()]

l = [int(j) for j in input().split()]

l = sorted(l)

ans = 0
for k in range(N-K, N, 1):
    ans += l[k]

print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
_,n=map(int,input().split());print(sum(sorted(map(int,input().split()))[n:]))

Failing test case input:
15 15
82 28 17 21 18 0 37 49 7 5 5 31 46 0 0

Expected output:
346


Actual output:
0


Fixed submission (verdict: Accepted):
_,n=map(int,input().split());print(sum(sorted(map(int,input().split()))[-n:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort(reverse=True)
listB = listA[:k]
sum(listB)


Failing test case input:
15 14
42 26 27 21 12 14 42 35 2 5 5 31 39 1 0

Expected output:
302


Actual output:

Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort(reverse=True)
listB = listA[:k]
print(sum(listB))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.reverse()
print(sum(l[:k]))

Failing test case input:
15 14
50 26 27 21 41 7 42 4 7 5 11 2 55 1 45

Expected output:
343


Actual output:
294


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
l.reverse()
print(sum(l[:k]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[k-1:]))

Failing test case input:
15 14
42 26 27 21 12 14 42 35 7 5 8 31 39 1 45

Expected output:
354


Actual output:
87


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[n-k:]))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
print(sum(L[-1:-K-1:-1]))


Failing test case input:
15 14
69 26 27 26 33 7 42 35 7 5 5 36 39 1 45

Expected output:
402


Actual output:
334


Fixed submission (verdict: Accepted):
N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
L.sort()
print(sum(L[-1:-K-1:-1]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
L = map(int, input().split())
print(sum(sorted(L, reverse=True)[:3]))


Failing test case input:
15 15
6 51 0 37 25 18 0 12 7 5 8 3 26 0 0

Expected output:
198


Actual output:
114


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = map(int, input().split())
print(sum(sorted(L, reverse=True)[:K]))

Problem: p03658
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[:k]))

Failing test case input:
15 14
42 26 27 21 12 14 42 35 7 5 5 31 39 1 45

Expected output:
351


Actual output:
307


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[:k]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K =map(int,input().split())
Int = list(input().split())
Int.sort()
length = 0

for i in range(len(Int)-1,len(Int)-(int(K)+1),-1):
	length +=int(Int[i])
print(length)

Failing test case input:
0 2
1 2 4 18 0

Expected output:
22


Actual output:
6


Fixed submission (verdict: Accepted):
N,K =map(int,input().split())
Int = list(map(int,input().split()))
Int.sort(reverse=True)
length = 0

for i in range(int(K)):
	length += int(Int[i])
print(length)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys

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

l.reverse()

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

print(sum)

Failing test case input:
15 14
49 26 27 21 33 7 42 35 7 5 5 31 39 1 45

Expected output:
372


Actual output:
324


Fixed submission (verdict: Accepted):

import sys

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

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

print(s)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
L = list(map(int, input().split()))

L.sort(reverse=True)
print(sum(L[:K+1]))

Failing test case input:
15 14
50 26 27 19 41 7 42 9 7 5 5 36 55 1 45

Expected output:
374


Actual output:
375


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = list(map(int, input().split()))

L.sort(reverse=True)
print(sum(L[:K]))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split(' '))
L = sorted(map(int,input().split(' ')))
print(L[:-K])

Failing test case input:
15 15
34 53 0 21 25 18 2 49 7 5 8 19 46 0 0

Expected output:
287


Actual output:

Fixed submission (verdict: Accepted):
N,K = map(int,input().split(' '))
L = sorted(map(int,input().split(' ')))
print(sum(L[N-K:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-N:]))

Failing test case input:
0 3
1 1 4 8 0

Expected output:
13


Actual output:
14


Fixed submission (verdict: Accepted):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-K:]))

Problem: p03658
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, K = map(int, input().split())
L = list(map(int, input().split()))

L.sort()
print(sum(L[-3:]))


Failing test case input:
15 15
34 53 0 21 25 18 2 49 7 5 8 19 46 0 0

Expected output:
287


Actual output:
148


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = list(map(int, input().split()))

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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))
lst = sorted(l, reverse=True)

print(sum(l[:k]))

Failing test case input:
15 14
49 26 27 21 41 12 42 35 7 5 5 36 39 1 45

Expected output:
390


Actual output:
346


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
del l[:n-k]
print(sum(l))

Problem: p03658
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))
    l_arr = list(map(int,_in[1].split(' ')))
    
    l_arr.sort(reverse=True)
    cnt = l_arr[:K]
    
    print(cnt)


Failing test case input:
0 3
1 1 4 7 10

Expected output:
21


Actual output:
[10, 7, 4]


Fixed submission (verdict: Accepted):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))
    l_arr = list(map(int,_in[1].split(' ')))
    
    l_arr.sort(reverse=True)
    cnt = sum(l_arr[:K])
    
    print(cnt)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K= list(map(int, input().split())) 
l = list(map(int, input().split()))

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

Failing test case input:
15 14
50 26 27 21 41 7 42 35 7 5 5 36 55 1 79

Expected output:
436


Actual output:
437


Fixed submission (verdict: Accepted):
N, K= list(map(int, input().split())) 
l = list(map(int, input().split()))

print(sum(sorted(l)[-K:]))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
listB = listA[:k]
sum(listB)


Failing test case input:
15 15
6 37 0 21 25 18 0 12 7 5 8 7 46 0 0

Expected output:
192


Actual output:

Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort(reverse=True)
listB = listA[:k]
print(sum(listB))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse = True)
print(L[:K])

Failing test case input:
15 15
30 53 0 21 25 18 2 49 7 5 8 7 46 0 0

Expected output:
271


Actual output:
[53, 49, 46, 30, 25, 21, 18, 8, 7, 7, 5, 2, 0, 0, 0]


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse = True)
print(sum(L[:K]))

Problem: p03658
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
print(a[:m])


Failing test case input:
15 14
49 26 27 21 33 7 42 35 7 5 5 31 39 1 45

Expected output:
372


Actual output:
[49, 45, 42, 39, 35, 33, 31, 27, 26, 21, 7, 7, 5, 5]


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
print(sum(a[:m]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
L = list(map(int, input().split()))

L.sort()
print(sum(L[:K+1]))

Failing test case input:
5 3
1 2 3 4 5

Expected output:
12

Actual output:
10


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = list(map(int, input().split()))

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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
hebi=input().split()
hebi1=list(map(int,hebi))
hebi1.reverse()
ans=0
for i in range(K):
    ans+=hebi1[i]
print(ans)    
    

Failing test case input:
15 14
50 26 27 21 41 7 42 35 7 5 5 36 33 1 45

Expected output:
380


Actual output:
331


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
hebi=input().split()
hebi1=list(map(int,hebi))
hebi1.sort()
hebi1.reverse()
ans=0
for i in range(K):
    ans+=hebi1[i]
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

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

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

l.sort()

max_length = 0
for item in l[n-1:n-k-1:-1]:
    max_length += item

print("{}".format(max_length))

Failing test case input:
2 15
3 108 0 37 25 18 0 12 3 5 16 0 26 2 0

Expected output:
255


Actual output:
0


Fixed submission (verdict: Accepted):
import sys

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

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









l.sort(reverse=True)

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

print("{}".format(max_length))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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


Failing test case input:
15 14
50 26 27 21 41 7 42 35 7 5 5 36 33 1 45

Expected output:
380


Actual output:
137


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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
ans = 0

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

nums.sort

for i in range(k):
  ans += nums.pop(0)
  
print(ans)

Failing test case input:
15 14
49 26 27 21 33 7 42 35 7 5 5 31 39 1 45

Expected output:
372


Actual output:
328


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
ans = 0

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

nums.sort(reverse=True)

for i in range(k):
  ans += nums.pop(0)
  
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = list(map(int ,input().split()))
sticks = list(map(int, input().split()))
sticks = sorted(sticks, reverse = True)
ans = 0
for s in sticks:
    ans += s
    if(sticks.index(s) == K-1):
        break
print(ans)

Failing test case input:
15 14
49 26 27 21 33 7 42 35 7 5 5 36 39 1 45

Expected output:
377


Actual output:
378


Fixed submission (verdict: Accepted):
N, K = list(map(int ,input().split()))
sticks = list(map(int, input().split()))
sticks = sorted(sticks, reverse = True)
ans = 0
for i in range(K):
    ans += sticks[i]
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, N = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[:K]))


Failing test case input:
5 3
1 1 4 4 10

Expected output:
18


Actual output:
20


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[:K]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int, input().split())
l=list(map(int, input().split()))
t=0
for i in range(k):
  t+=l[k-1-i]
print(t)

Failing test case input:
15 14
50 26 27 21 41 7 42 9 7 5 6 1 55 1 45

Expected output:
342


Actual output:
298


Fixed submission (verdict: Accepted):
n,k=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
t=0
for i in range(k):
  t+=l[n-1-i]
print(t)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

l.sort(reverse=True)

l = l[:3]

print(sum(l))


Failing test case input:
2 15
6 108 0 37 25 18 0 12 3 5 8 2 26 2 0

Expected output:
252


Actual output:
171


Fixed submission (verdict: Accepted):


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

l.sort(reverse=True)

l = l[:k]

print(sum(l))
Problem: p03658
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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)


Failing test case input:
15 15
6 51 0 37 25 18 0 12 7 5 8 7 46 0 0

Expected output:
222


Actual output:
51
97
134
159
177
189
197
204
211
217
222
222
222
222
222


Fixed submission (verdict: Accepted):
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)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
sorted(l)
for i in range(K):
  ans += l[-i-1]
print(ans)

Failing test case input:
15 14
82 28 17 21 18 18 42 49 7 5 5 31 46 1 0

Expected output:
370


Actual output:
288


Fixed submission (verdict: Accepted):
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)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr01=arr_data[1]

arr02=sorted(list(map(int, arr01)),reverse=True)

print(n,k,arr02)

mysum=0
for v in range(0,len(arr02)):

    if(v!=k):
        mysum+=arr02[v]
   
        
    else:
        break
print(mysum)

Failing test case input:
15 15
34 53 0 21 25 18 2 49 7 5 8 7 46 0 0

Expected output:
275


Actual output:
15 15 [53, 49, 46, 34, 25, 21, 18, 8, 7, 7, 5, 2, 0, 0, 0]
275


Fixed submission (verdict: Accepted):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr01=arr_data[1]

arr02=sorted(list(map(int, arr01)),reverse=True)



mysum=0
for v in range(0,len(arr02)):

    if(v!=k):
        mysum+=arr02[v]
   
        
    else:
        break
print(mysum)
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(k):
    ans += l[-i]
print(ans)


Failing test case input:
15 14
49 26 27 21 33 14 42 35 7 5 5 31 60 1 45

Expected output:
400


Actual output:
396


Fixed submission (verdict: Accepted):
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)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K= map(int,input().split())
L = input().split()
ans = 0
L = sorted(L,reverse = True)
for i in L[:K]:
    ans+=int(i)
print(ans)

Failing test case input:
0 2
1 2 4 18 0

Expected output:
22


Actual output:
6


Fixed submission (verdict: Accepted):
N,K= map(int,input().split())
L =list(map(int,input().split()))
ans = 0
L = sorted(L,reverse=True)
for i in L[:K]:
    ans+=int(i)
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

AMAX = A[0:3]

print(sum(AMAX))

Failing test case input:
15 14
42 28 17 21 12 18 20 35 7 5 5 31 46 1 0

Expected output:
288


Actual output:
123


Fixed submission (verdict: Accepted):
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

AMAX = A[0:K]

print(sum(AMAX))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = [ int(v) for v in input().split() ]
bar_list = sorted([ int(v) for v in input().split() ], reverse = True)
print(bar_list[:k])

Failing test case input:
15 14
42 26 17 21 12 18 42 35 7 5 5 31 46 1 0

Expected output:
308


Actual output:
[46, 42, 42, 35, 31, 26, 21, 18, 17, 12, 7, 5, 5, 1]


Fixed submission (verdict: Accepted):
n, k = [ int(v) for v in input().split() ]
bar_list = sorted([ int(v) for v in input().split() ], reverse = True)
print(sum(bar_list[:k]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ans = 0
n, k = map(int, input().split())
lst = input().split()
lst.sort()
lst.reverse()
for i in range(k):
    ans += int(lst[i])
print(ans)

Failing test case input:
0 2
1 2 4 18 0

Expected output:
22


Actual output:
6


Fixed submission (verdict: Accepted):
ans = 0
n, k = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
lst.reverse()
for i in range(k):
    ans += lst[i]
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))
print(sum(sorted(l, reverse=True)[:k + 1]))


Failing test case input:
15 14
50 26 27 19 41 7 42 9 7 5 5 36 55 1 45

Expected output:
374


Actual output:
375


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))
print(sum(sorted(l, reverse=True)[:k]))
Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=sorted(a)
ans=0
for i in range(k):
  ans+=a[(-1)*i]
print(ans)

Failing test case input:
15 14
91 26 27 21 41 12 42 35 7 5 5 36 39 1 45

Expected output:
432


Actual output:
407


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=sorted(a)
ans=0
for i in range(1,k+1):
  ans+=b[(-1)*i]
print(ans)

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())

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

L.sort()
L.reverse()
ans = 0
for i in range(0,n):
  ans += L[i]
  
print(ans)

Failing test case input:
15 14
91 26 27 21 41 12 42 35 7 5 5 36 39 1 45

Expected output:
432


Actual output:
433


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())

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

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

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
print(sum(N[K-1:]))

Failing test case input:
15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45

Expected output:
386

Actual output:
95


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
print(sum(l[-K:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())
l = list(map(int,input().split()))
lrev = l[::-1]
print(sum(lrev[:K]))


Failing test case input:
15 14
82 28 17 21 12 18 42 35 7 5 5 31 46 1 0

Expected output:
350


Actual output:
268


Fixed submission (verdict: Accepted):
N,K = map(int, input().split())
l = list(map(int,input().split()))
l.sort()
lrev = l[::-1]
print(sum(lrev[:K]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()

Failing test case input:
15 14
82 28 17 21 12 18 42 35 7 5 5 31 46 1 0

Expected output:
350


Actual output:

Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
print(sum(l[-k:]))

Problem: p03658
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int, input().split())
l=[int(x) for x in input().split()]

buf=sorted(l,reverse=True)
print(buf)
result=0

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

print(result)

Failing test case input:
15 15
34 53 0 21 25 18 7 49 7 5 8 19 46 0 0

Expected output:
292


Actual output:
[53, 49, 46, 34, 25, 21, 19, 18, 8, 7, 7, 5, 0, 0, 0]
292


Fixed submission (verdict: Accepted):
N,K=map(int, input().split())
l=[int(x) for x in input().split()]

buf=sorted(l,reverse=True)
result=0

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

print(result)