Problem:


Score : 400 points

Problem Statement

Takahashi is going to buy N items one by one.

The price of the i-th item he buys is A_i yen (the currency of Japan).

He has M discount tickets, and he can use any number of them when buying an item.

If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.

What is the minimum amount of money required to buy all the items?

Constraints

All values in input are integers.

1 \leq N, M \leq 10^5

1 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N M
A_1 A_2 ... A_N

Output

Print the minimum amount of money required to buy all the items.

Sample Input 1

3 3
2 13 8

Sample Output 1

9

We can buy all the items for 9 yen, as follows:

Buy the 1-st item for 2 yen without tickets.

Buy the 2-nd item for 3 yen with 2 tickets.

Buy the 3-rd item for 4 yen with 1 ticket.

Sample Input 2

4 4
1 9 3 5

Sample Output 2

6

Sample Input 3

1 100000
1000000000

Sample Output 3

0

We can buy the item priced 1000000000 yen for 0 yen with 100000 tickets.

Sample Input 4

10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 4

9500000000



Sample input:
3 3
2 13 8


Sample output:
9

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()


for _ in range(m):
  a = A.pop() // 2
  A.insert(bisect.bisect_left(A,a),a)
print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    A.sort()
    A[-1] = A[-1]//2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m=map(int,input().split())
a=list(map(int, input().split()))
if len(a)==1:
  print(int(a[0]/(2**m)))
  exit(0)
a=sorted(a)
for i in range(m):
  x=a.pop(-1)
  bisect.insort_right(a, int(x//2))
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
while m != 0:
    maxa = max(a)
    for i in range(n):
        if a[i] == maxa:
            a[i] /= 2
            m -= 1

ans = 0
#print(a)
for i in range(n):
    ans += int(a[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()
maxa = a[0]
for i in range(m):
    a[0] = a[0] / 2
    a.sort()
    a.reverse()
ans = 0
#print(a)
for i in range(n):
    ans += int(a[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
a.sort(reverse=True)

ans = 0
search_idx = 0

for i in range(m):
    max_idx = 0
    if search_idx+2 >= n:
        search_idx = n - 2
    for j in range(0, search_idx+2):
        if a[max_idx] < a[j]:
            max_idx = j
        if search_idx < max_idx:
            search_idx = max_idx
    a[max_idx] //= 2
    #print(a)

print(sum(a))

Submission status: Time Limit Exceeded

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

for i in range(n[1]):
    a[a.index(max(a))] = int(max(a) / 2)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import bisect

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(int, input().strip().split())))
  for _ in range(m):
    x = As.pop(len(As)-1)
    x >>= 1
    As.insert(bisect.bisect_left(As, x), x)
  print(sum(As))
    

if __name__=='__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
cnt = 0
if N == 1:
    print(int(A[0]/(2**M)))
    exit()
else:
    while cnt < M:
        A[-1] /= 2
        a = A[-1]
        del A[-1]
        bisect.insort_left(A, a)
        cnt += 1

A = [int(A[i]) for i in range(N)]
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
cnt = 0
if N == 1:
    print(int(A[0]/(2**M)))
    exit()
else:
    while cnt < M:
        A[-1] /= 2
        if A[-1] < A[-2]:
            a = A[-1]
            del A[-1]
            bisect.insort_left(A, a)
        cnt += 1

A = [int(A[i]) for i in range(N)]
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())#nは品物の数　mは割引券の数
a = sorted(list(map(int,input().split())),reverse = True)#値段一覧
for i in range(m):
    if len(a) == 1:
        a[0] = a[0]//2
        if a[0] == 0:
            print(a[0])
            exit()
    elif a[0] >= a[1]:
        a[0] = a[0]//2
        a.sort(reverse = True)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math

n, m = [int(x) for x in input().split()]
a = list(map(int, input().split()))

for i in range(m):
    a = sorted(a, reverse=True)
    a[0] = math.floor(a[0] / 2)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(1,m+1):
  a[-1]=a[-1]//2
  a.sort()

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(0,M):
    m=max(A)
    index=A.index(m)
    A[index]=m//2
print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    max_value = max(A)
    max_index = A.index(max_value)
    A[max_index] = A[max_index]//2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
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))

Submission status: Time Limit Exceeded

Solution code:
# 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))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))

for _ in range(m):
  max_i = a_list.index(max(a_list))
  a_list[max_i] = a_list[max_i] // 2

print(sum(a_list))

Submission status: Time Limit Exceeded

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

for i in range(m):
  a.sort(reverse = True)
  a[0] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math

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

a = sorted(list(map(int,input().split())),reverse=True)

for _ in range(m):
    #print(a)
    a[0] = a[0]/2
    i = 0
    #print("->{}".format(a))
    while i<n-1:
        if a[i]<a[i+1]:
            a[i],a[i+1] = a[i+1],a[i]
            i+=1
        else:
            break
    #print("->->{}".format(a))

a = list(map(math.floor,a))
#print()
#print(a)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

for _ in range(m):
    maxv = a.index(max(a))
    a[maxv] = a[maxv]/2

a = list(map(math.floor,a))

print(sum(a))

Submission status: Time Limit Exceeded

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

for i in range(m):
    a = sorted(a, reverse=True)
    a[0] = a[0]//2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    test = a.pop(-1)
    bisect.insort(a, test // 2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for i in range(m):
    a = A.pop(-1)
    a //= 2
    bisect.insort_left(A, a)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for i in range(m):
    a = A.pop(-1)
    a /= 2
    bisect.insort_left(A, a)

A = map(int, A)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = sorted(list(map(int, input().split())))

for i in range(m):
    A[-1] /= 2
    A.sort()

A = map(int, A)

print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    A.sort()
    A[N-1] //= 2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int,input().split()))
max_item = 0
for _ in range(M):
    max_item = A.index(max(A))
    A[max_item] //= 2
total = sum(A)
print(total)

Submission status: Time Limit Exceeded

Solution code:
N,M = list(map(int,input().split()))
list_A = list(map(int,input().split()))
for i in range(M):
    A = max(list_A)
    list_A.remove(A)
    list_A.append(A // 2)
print(sum(list_A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m=list(map(int,input().split()))
a=sorted(list(map(int,input().split())))

for i in range(m):
  a[-1]//=2
  bisect.insort_left(a,a[-1])
  a.pop()
  if a[-1]<1:break
print(sum(a))

Submission status: Time Limit Exceeded

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

for i in range(m):
  a[a.index(max(a))]//=2
  if a[a.index(max(a))]<1:break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#import heapq
n, m = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(m):
  lst[lst.index(max(lst))] //= 2
print(sum(lst))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, A: "List[int]"):
    
    A = sorted(A,reverse=True)
    while True:
        A[0] = A[0] // 2
        M -= 1
        if M == 0:
            break
        if N == 1:
            continue

        for i in range(N-1):
            if i == M:
                break
            if A[i] < A[i+1]:
                tmp = A[i+1]
                A[i+1] = A[i]
                A[i] = tmp
            else:
                break
    print(sum(A))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, A: "List[int]"):
    
    A = sorted(A,reverse=True)
    while True:
        A[0] = A[0] // 2
        M -= 1
        if M == 0:
            break
        if N == 1:
            continue

        for i in range(N-1):
            if A[i] < A[i+1]:
                tmp = A[i+1]
                A[i+1] = A[i]
                A[i] = tmp
            else:
                break
    print(sum(A))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, A: "List[int]"):
    
    while True:
        A = sorted(A,reverse=True)
        A[0] = A[0] // 2
        M -= 1
        if M == 0:
            break
    print(sum(A))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(M):
  A[0] //= 2
  if N > 1:
    if A[0] < A[1]:
      A.sort(reverse=True)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    new_price = price[-1] // 2
    bisect.insort_left(price, new_price)
    del price[-1]
    m -= 1
    
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    new_price = price[-1] // 2
    bisect.insort_left(price, new_price)
    price.pop(-1)
    m -= 1
    
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

if n == 1:
    price[0] //= (2 ** m)
else:
    while m >= 1:
        while price[-1] >= price[-2]:
            price[-1] //= 2
            m -= 1
        price.sort()
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    price[-1] //= 2
    m -= 1
    price.sort()
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for _ in range(m):
  p = a.pop()//2
  up=n-1
  low=0
  while up > low:
    nb = (up+low)//2
    if p >= a[nb]:
      low = nb+1
    else:
      up = nb
  a.insert(up, p)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for _ in range(m):
  p = a[n-1]//2
  up=n-1
  low=0
  while up-low > 1:
    nb = low+(up-low)//2
    if p >= a[nb]:
      low = nb
    else:
      up = nb
  a.insert(up, p)
print(sum(a[:n]))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for _ in range(m):
  p = a[n-1]//2
  up=n-1
  low=0
  while up-low != 1:
    nb = low+(up-low)//2
    if p >= a[nb]:
      low = nb
    else:
      up = nb
  a.insert(up, p)
print(sum(a[:n]))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for _ in range(m):
  a[-1] = a[-1]//2
  a.sort()
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
i=0
while True:
    a[i]=a[i]//2
    a=sorted(a)[::-1]
    m-=1
    if m==0:
        break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq
N,M = map(int,input().split())
Alist = list(map(int,input().split()))
newA = list(map(lambda x: x*(-1),Alist))
for i in range(M):
    heapq.heapify(newA)
    current = -heapq.heappop(newA)
    heapq.heappush(newA,-(current//2))

cost = 0
for i in range(N):
    cost += newA[i]
print(-cost)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(M):
    Alist.sort(reverse=True)
    Alist[0] = Alist[0]//2
cost = 0
for i in range(N):
    cost += Alist[i]
print(cost)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
for k in range(m):
    A[A.index(max(A))]//=2

print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    idx=A.index(max(A))
    A[idx]=A[idx]//2

print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(m):
    a.sort(reverse=True)
    a[0] = a[0]//2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
i = 0
if N == 1:
    print(A[0]//(2**M))
else:
    while i < M:
        if A[-2] != 0:
            j = A[-1]//A[-2]
        else:
            j = A[-1]
        if i + j <= M:
            A[-1] //= 2**j
            i += j
        else:
            A[-1] //= 2**(M-i)
            i = M
        A.sort()
    print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse = True)
i = 0
while i < M:
    A[0] //= 2
    i += 1
    A.sort(reverse = True)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n,m = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for  i in range(0,m):
    max = np.argmax(a)
    a[max] = a[max] // 2

for j in range(0,n):
    ans += a[j]

print(ans)

Submission status: Time Limit Exceeded

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

import numpy as np
l = np.array(list(map(int, input().split())))

for _ in range(M):
	max_ind = np.argmax(l)
	l[max_ind] = l[max_ind]//2

print(np.sum(l))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
*a, = sorted(map(int, input().split()))

for i in range(m):
    _a = a.pop()//2
    bisect.insort_left(a, _a)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
import numpy as np
A = [i for i in map(int,input().split())]
A = np.array(A)

for i in range(M):
  index = np.argmax(A)
  A[index] //= 2
  
print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split(" "))
    A = list(map(int, input().split(" ")))
    while M > 0:
        A.sort()
        if A[-1] == 0:
            break
        A[-1] //= 2
        M -= 1
    print(sum(A))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, M = map(int, input().split(" "))
    A = list(map(int, input().split(" ")))
    while M > 0:
        A.sort()
        A[-1] //= 2
        M -= 1
    print(sum(A))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for _ in range(m):
  a.sort()
  a[-1]//=2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
for _ in range(m):
    idx = a.index(max(a))
    a[idx] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
for i in range(M):
    A[-1] = A[-1] // 2
    A.sort()
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()

    for i in range(M):
        a = A.pop()
        a = a // 2
        bisect.insort_right(A, a)

    # print(A)
    x = sum(A)
    print(x)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

A.sort()

for i in range(M):
    a = A.pop()
    a = a // 2
    bisect.insort_right(A, a)

# print(A)
x = sum(A)
print(x)

Submission status: Time Limit Exceeded

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

for i in range(M):
    A.sort(reverse=True)
    A[0] = A[0] // 2

x = sum(A)
print(x)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
N, M = map(int, input().split())
A = list(map(int, input().split()))
# A.sort(reverse=True)
for i in range(M):
    A.sort(reverse=True)
    A[0] //= 2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# ABC-141-D
N, M = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(M):
    A[A.index(max(A))] //= 2
    
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))

    for i in range(m):
        a.sort(reverse=True)
        a[0] = a[0] // 2
    print(sum(a))
if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N, M = LI()
    A = LI()
    total = sum(A)
    discount = []
    for a in A:
        while a > 0:
            disc = (a+1)//2
            discount.append(disc)
            a -= disc
    discount = sorted(discount)[::-1]
    discount = discount[:M]
    print(total - sum(discount))
main()

Submission status: Time Limit Exceeded

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

A.sort()
for i in range(M):
    A[-1] = A[-1]//2
    A.sort()

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
for i in range(m):
    l[-1] = l[-1]//2
    l.sort()
print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
N,M = list(map(int,input().split(" ")))
list = list(map(int,input().split(" ")))
for i in range(M):
    list.sort(reverse=True)
    list[0] = list[0] // 2
print(sum(list))

Submission status: Time Limit Exceeded

Solution code:
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

for i in range(M):
        tmp = A.pop(-1) // 2
        index = bisect.bisect_left(A, tmp)
        A.insert(index, tmp)


print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
item = []
a = input()
for i in range(n):
  item.append(int(a.split(" ")[i]))

for j in range(m):
  item[item.index(max(item))] //= 2
print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
for i in range(m):
    p = a[n-1]//2
    a.pop()
    a.insert(bisect.bisect_left(a,p),p)

print(sum(a))

Submission status: Time Limit Exceeded

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

while M>0:
    A[A.index(max(A))] /= 2
    M -= 1


ans = 0

for i in A:
    ans += int(i)

print(ans)

Submission status: Time Limit Exceeded

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

A.sort()

while M>0:
    A[N-1] /= 2
    M -= 1
    A[A.index(max(A))],A[N-1] = A[N-1],max(A)


ans = 0

for i in A:
    ans += int(i)

print(ans)

Submission status: Time Limit Exceeded

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

A.sort()

while M>0:
    A[N-1] /= 2
    M -= 1
    A.sort() 

ans = 0

for i in A:
    ans += int(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n,m = map(int, input().split())
a = [int(x) for x in input().split()]
for _ in range(m):
  a[a.index(max(a))] >>= 1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
n,m = map(int, input().split())
a = [int(x) for x in input().split()]
for _ in range(m):
  a.append(math.floor(max(a)/2))
  a.remove(max(a))
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
n,m = map(int, input().split())
a = [int(x) for x in input().split()]
for _ in range(m):
  a[a.index(max(a))]  = math.floor(max(a)/2)
print(sum(a))

Submission status: Time Limit Exceeded

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

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


for i in range(m):
    a[a.index(max(a))]//=2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq
n,m=[int(i) for i in input().split()]
a=[-1*int(i) for i in input().split()]
for i in range(m):
    heapq.heapify(a)
    b=heapq.heappop(a)
    b=b/2
    heapq.heappush(a,b)
ans=0
for i in a:
    ans-=int(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import heapq
n,m=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
d=[-1*i for i in a]
for i in range(m):
    heapq.heapify(d)
    b=heapq.heappop(d)
    b=b/2
    heapq.heappush(d,b)
c=[int(i) for i in d]

ans=0
for i in c:
    ans+=i
print(-1*ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

for i in range(m):
    a.sort()
    b=a.pop()
    b=b/2
    a.append(b)
c=[int(i) for i in a]

ans=0
for i in c:
    ans+=i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(m):
    i = A.index(max(A))
    A[i] /= 2
A = [int(a) for a in A]

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
for _ in range(m):
    A[-1] /= 2
    A.sort()
A = [int(a) for a in A]

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
li = list(map(int, input().split()))
while  M > 0:
	li[li.index(max(li))] /= 2
	M -= 1
ans = 0
for i in range(len(li)):
	ans += int(li[i])
print(ans)

Submission status: Time Limit Exceeded

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

for _ in range(m):
    a[a.index(max(a))] = a[a.index(max(a))] // 2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
li = list(map(int, input().split()))
while M > 0:
    for i in range(len(li)):
        if i == max(li):
            li[i] /= 2
            continue
ans = 0
for j in li:
    ans += int(j)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))


if n == 1:
    ans = a[0]//(2**m)
    print(ans)

else:
    for i in range(m):
        l = max(a)
        c = a.index(l)
        a[c] = a[c]//2
    print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
a.reverse()

if n == 1:
    ans = a[0]//(2**m)
    print(ans)
    exit()
while m > 0:
    for i in range(0,n):
        l = max(a)
        if a[i] > l//2:
            if m - 1 >= 0:
                a[i] = a[i]//2
            m -= 1
        else:
            break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,m = map(int,input().split())
value_lis = list(map(int,input().split()))

for _ in range(m):
    value_lis[value_lis.index(max(value_lis))] = int(max(value_lis) / 2)

print(sum(value_lis))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,m = map(int,input().split()) 
value_lis = list(map(int,input().split()))

value_lis.sort(reverse=True)

for i in range(m):
    value_lis[0] =int(value_lis[0] / 2)
    if len(value_lis) != 1 and value_lis[0] < value_lis[1]:
        value_lis.sort(reverse=True)

print(sum(value_lis))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
L=list(map(int,input().split()))
import bisect
from collections import deque
L.sort()
Ld=deque(L)
for i in range(m):
    x=L.pop()//2
    y=bisect.bisect_left(L,x)
    L.insert(y,x)
print(sum(L))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
L=list(map(int,input().split()))
import bisect
L=list(sorted(L))
for i in range(m):
    x=L.pop()//2
    y=bisect.bisect_left(L,x)
    L.insert(y,x)
print(sum(L))

Submission status: Time Limit Exceeded

Solution code:
import math

def log2(x):
    return math.log10(x)/math.log10(2)

N,M = map(int,input().split())
A = [0]*N
A = list(map(int,input().split()))
if (N == 1):
    print(A[0]//(2**M))
else:
    while (M != 0):
        A.sort(reverse=True)
        y = min(math.floor(log2(A[0]/A[1])+1),M)
        A[0] //= 2**y
        M -= y

    print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

N,M = map(int,input().split())
A = [0]*N
A = list(map(int,input().split()))
if (N == 1):
    print(A[0]//(2**M))
else:
    while (M != 0):
        A.sort(reverse=True)
        y = min(math.floor(math.log2(A[0]/A[1])+1),M)
        A[0] //= 2**y
        M -= y

    print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import bisect

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

A.sort()

for m in range(M):
    bisect.insort(A, math.floor(A.pop(-1) / 2))

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for m in range(M):
    max_value = max(A)
    max_index = A.index(max_value)
    A[max_index] = math.floor(max_value / 2)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
arr = np.array(a)
for i in range(m):
    ind = arr.argmax()
    arr[ind] = arr[ind]//2
print(arr.sum(dtype=np.int64))

Submission status: Time Limit Exceeded

Solution code:
# 12:10 
import numpy as np
n,m = map(int,input().split())
a = list(map(int,input().split()))
arr = np.array(a)
for i in range(m):
    ind = arr.argmax()
    arr[ind] = arr[ind]//2
print(arr.sum(dtype=np.int64))

Submission status: Time Limit Exceeded

Solution code:
# 12:10
import numpy as np
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(m):
    ind = np.argmax(a)
    a[ind] = a[ind]//2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq

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

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

for _ in range(M):
    A.sort(reverse=True)
    A[0] //= 2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort_left 

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()

for i in range(M):
    x = A.pop()
    insort_left(A,x//2)

print(sum(A))