Buggy python submission (verdict: Time Limit Exceeded):
S = input().split(" ")
N = int(S[0])
M = int(S[1])

S = input().split(" ")

arr =  [int(s) for s in S]
arr2 = arr.copy()
brr =  [0 for s in S]

def calculate(m,arr,brr):


    for i in range(m):
        maxValue = max(arr)
        maxIndex = arr.index(maxValue)
        arr[maxIndex] = arr[maxIndex]//2
        brr[maxIndex] = brr[maxIndex] + 1

    return brr

result = calculate(M,arr,brr)


for index,br in enumerate(brr):
    arr2[index] = arr2[index]//(2**br)

print(sum(arr2))

Fixed submission:
import heapq

S = input().split(" ")
N = int(S[0])
M = int(S[1])
S = input()

arr = [-int(s) for s in S.split(" ")]

heapq.heapify(arr)

for i in range(M):
    maxValue = -heapq.heappop(arr)
    heapq.heappush(arr,-(maxValue//2))

print(-sum(arr))

Buggy python submission (verdict: Runtime Error):


S = input().split(" ")
N = int(S[0])
M = int(S[1])

S = input().split(" ")

arr =  [int(s) for s in S]
arr2 = arr.copy()
brr =  [0 for s in S]

def calculate(m,arr,brr):


    for i in range(m):
        maxValue = max(arr)
        maxIndex = arr.index(maxValue)
        arr[maxIndex] = arr[maxIndex]//2
        brr[maxIndex] = brr[maxIndex] + 1

    return brr

result = calculate(M,arr,brr)


for index,br in enumerate(brr):
    arr2[index] = arr2[index]//(2**br)

print(sum(arr2))

Fixed submission:
import heapq

S = input().split(" ")
N = int(S[0])
M = int(S[1])
S = input()

arr = [-int(s) for s in S.split(" ")]

heapq.heapify(arr)

for i in range(M):
    maxValue = -heapq.heappop(arr)
    heapq.heappush(arr,-(maxValue//2))

print(-sum(arr))

Buggy python submission (verdict: Time Limit Exceeded):
# N = 4
# M = 4
#
# arr = list([1,9,3,5])
# arr2 = list([1,9,3,5])
# brr = list([0,0,0,0])


S = input().split(" ")
N = int(S[0])
M = int(S[1])

S = input().split(" ")

arr =  [int(s) for s in S]
arr2 = [int(s) for s in S]
brr =  [0 for s in S]

def calculate(m,arr,brr):


    for i in range(m):
        maxValue = max(arr)
        maxIndex = arr.index(maxValue)
        arr[maxIndex] = arr[maxIndex]//2
        brr[maxIndex] = brr[maxIndex] + 1

    return brr

result = calculate(M,arr,brr)


for index,br in enumerate(brr):
    arr2[index] = arr2[index]//(2**br)

print(sum(arr2))

Fixed submission:
import heapq

S = input().split(" ")
N = int(S[0])
M = int(S[1])
S = input()

arr = [-int(s) for s in S.split(" ")]

heapq.heapify(arr)

for i in range(M):
    maxValue = -heapq.heappop(arr)
    heapq.heappush(arr,-(maxValue//2))

print(-sum(arr))

Buggy python submission (verdict: Runtime Error):
import math

def getMax(arr):
    maxValue = max(list(arr))
    maxIndex = list(arr).index(maxValue)

    return maxIndex,maxValue


def getSum(arr):
    return sum(list(arr))

def calculate(arr,n):
    if n == 0:
        return getSum(arr)
    else:
        index,value = getMax(arr)
        if value == 0:
            return value
        n -= 1
        arr[index] = math.floor(value/2)
        return calculate(arr,n)

S = input().split(' ')
m = int(S[0])
n = int(S[1])

T = input().split(' ')
arr = list(map(int, list(T)))


result = calculate(arr,n)
print(result)

Fixed submission:
import heapq

S = input().split(" ")
N = int(S[0])
M = int(S[1])
S = input()

arr = [-int(s) for s in S.split(" ")]

heapq.heapify(arr)

for i in range(M):
    maxValue = -heapq.heappop(arr)
    heapq.heappush(arr,-(maxValue//2))

print(-sum(arr))