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:
#AtCoder

import sys
import math
import itertools
input = sys.stdin.readline

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

A.sort(reverse=True)

if len(A) == 1:
	print(A[0]//(2**M))
	exit()

for _ in range(M):
	A[0] = A[0] // 2
	if A[0] < A[1]:
		for i in range(1,len(A)):
			if A[0] > A[i]:
				head = A[1:i]
				head.append(A[0])
				tail = A[i:]
				A = head + tail
				break


sum = 0
for i in range(len(A)):
	sum += A[i]

print(sum)



"""

"""

Submission status: Time Limit Exceeded

Solution code:
import math

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

# 割引は出来るだけする
for i in range(M):
	item_list[item_list.index(max(item_list))] = math.floor(max(item_list) / 2)

print(sum(item_list))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
input = sys.stdin.readline

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

A.sort(reverse=True)

if len(A) == 1:
	print(A[0]//(2**M))
	exit()

for _ in range(M):
	A[0] = A[0] // 2
	if A[0] < A[1]:
		A.sort(reverse=True)


sum = 0
for i in range(len(A)):
	sum += A[i]

print(sum)

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)

if len(A) == 1:
	print(A[0]//(2**M))
	exit()

for m in range(M):
	A[0] = A[0] // 2
	if A[0] < A[1]:
		A.sort(reverse=True)


sum = 0
for i in range(len(A)):
	sum += A[i]

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

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

A.sort(reverse=True)

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


sum = 0
for i in range(len(A)):
	sum += A[i]

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(m):
    i=a.index(max(a))
    a[i]=int(a[i]/2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
N,M = [int(X) for X  in input().split()]
A = [int(X) for X  in input().split()]
for i in range(M):
  A[A.index(max(A))] /=2

ans = 0
for i in A:
  ans += math.floor(i)
print(ans)

Submission status: Time Limit Exceeded

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

print(sum(price))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N,M = [int(i) for i in input().split(' ')]
itemList = np.array([int(i) for i in input().split(' ')])

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

print(sum(itemList))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = [int(i) for i in input().split(' ')]
itemList = [int(i) for i in input().split(' ')]
itemList.sort(reverse=True)

for _ in range(M):
    itemList[0] //= 2        
    for i in range(1,N):
        if itemList[0] > itemList[i]:
            item = itemList.pop(0)
            itemList.insert(i-1,item)
            break
        if i == N-1:
            item = itemList.pop(0)
            itemList.append(item)
print(sum(itemList))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = [int(i) for i in input().split(' ')]
itemList = [int(i) for i in input().split(' ')]

for _ in range(M):
    itemList.sort()
    itemList[-1] //= 2
    
print(sum(itemList))

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int, input().split()))
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:
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
ans = 0
for i in range(0,M):
  max_A_index = A.index(max(A))
  A[max_A_index] = A[max_A_index]/2
print sum(A)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
data = sorted(list(map(int, input().split())),reverse=True)
data.append(0)
while m > 0:
  data[0] = data[0] // 2
  now = 0
  ne_index = 1
  while data[now] < data[ne_index] and now < m:
    data[now],data[ne_index] = data[ne_index],data[now]
    now += 1
    ne_index += 1
  
  m -= 1
print(sum(data))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import numpy as np
import sys, math

class Heapque():
    
    def __init__(self):
        pass
        
    def pop(self, que):
        
        if len(que) >= 2:
            val = que.pop(1)
            
            return(que, val)
            
        else:
            
            return(0)
            
    def sort(self, que, i=1):
        
        #print("sort", que)
        parent = que[i]
        
        if len(que) <= i*2:
            #print("sort", que, type(que))
            
            return(que)
            
        elif len(que) <= i*2+1:
            left_child = que[i*2]
            if parent < left_child:
                que[i] = left_child
                que[i*2] = parent
            #print("sort", que, type(que))
            
            return(que)
            
        else:
            left_child = que[i*2]
            right_child = que[i*2+1]
        
        max_val = max(parent, max(left_child, right_child))
        
        if max_val == parent:
            
            pass
            
        elif max_val == left_child:
            
            que[i] = left_child
            que[i*2] = parent
            que = self.sort(que, i*2)
        
        else:
            que[i] = right_child
            que[i*2+1] = parent
            que = self.sort(que, i*2+1)
            
        return(que)
    
    def add(self, que, val):
        #print("def add: que", que)
        que.insert(1, val)
        que = self.sort(que, 1)
        
        return(que)
        
if __name__ == "__main__":
    n, m = map(int, input().split())
    A_list = list(map(int, input().split()))
    que = sorted(A_list, reverse=True)
    
    hq = Heapque()
    que.insert(0, 0)
    #print("A_list", A_list, type(A_list))
    
    #print(que)
    
    for i in range(m):
        #print(i)
        que, val = hq.pop(que)
        val = math.floor(val/2)
        que = hq.add(que, val)
        
    print(sum(que))

Submission status: Time Limit Exceeded

Solution code:
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

A.sort(reverse=True)
for i in range(M):
    A[0] = int(A[0]/2)
    for j in range(1,N-1):
        if A[j] >= A[0] and A[0] >= A[j+1]:
            A.insert(j+1,A[0])
            A.pop(0)
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:
    i = A.index(max(A))
    A[i] = A[i]//2
    m -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
ans = 0
for i in range(0,M):
  max_A = max(A)
  max_A_index = A.index(max(A))
  max_A = max_A / 2
  A[max_A_index] = max_A  
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 = sorted(A, reverse=True)
    A[0] = A[0]//2
    m -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, raw_input().split())
A = list(map(int,raw_input().split()))	
A=sorted(A)
ans = 0
for i in range(0,M):
  max_A = A[N-1]
  max_A = max_A / 2
  A[N-1] = max_A
  A = sorted(A)
for i in A:
  ans = ans+i
  
print ans

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import numpy as np
import sys, math

class Heapque():
    
    def __init__(self):
        pass
        
    def pop(self, que):
        
        if len(que) >= 2:
            val = que.pop(1)
            
            return(que, val)
            
        else:
            
            return(0)
            
    def sort(self, que, i=1):
        
        #print("sort", que)
        parent = que[i]
        
        if len(que) <= i*2:
            #print("sort", que, type(que))
            
            return(que)
            
        elif len(que) <= i*2+1:
            left_child = que[i*2]
            if parent < left_child:
                que[i] = left_child
                que[i*2] = parent
            #print("sort", que, type(que))
            
            return(que)
            
        else:
            left_child = que[i*2]
            right_child = que[i*2+1]
        
        max_val = max(parent, max(left_child, right_child))
        
        if max_val == parent:
            
            pass
            
        elif max_val == left_child:
            
            que[i] = left_child
            que[i*2] = parent
            que = self.sort(que, i*2)
        
        else:
            que[i] = right_child
            que[i*2+1] = parent
            que = self.sort(que, i*2+1)
            
        return(que)
    
    def add(self, que, val):
        #print("def add: que", que)
        que.insert(1, val)
        que = self.sort(que, 1)
        
        return(que)
        
if __name__ == "__main__":
    n, m = map(int, input().split())
    A_list = list(map(int, input().split()))
    
    #print("A_list", A_list)
    hq = Heapque()
    que = [0]
    
    for i in range(n):
        #print(A_list[i])
        que = hq.add(que, A_list[i]) 
        #print(que)
        
    #print(que)
    
    for i in range(m):
        que, val = hq.pop(que)
        val = math.floor(val/2)
        que = hq.add(que, val)
        
    print(sum(que))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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.sort(reverse = True)
    a[0] //= 2
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.sort(reverse = True)
    a[0] = a[0] // 2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
M = int(s[0].split()[1])
A = list(map(int, s[1].split()))

A.sort(reverse=True)

# 2で割って小数点切り下げする操作を大きい金額から順次M回繰り返す
for i in range(M):
    A[0] = A[0] // 2
    A.sort(reverse=True)

P = sum(A)

# Output
print(P)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
M = int(s[0].split()[1])
A = list(map(int, s[1].split()))

A.sort(reverse=True)

# 2で割って小数点切り下げする操作を大きい金額から順次M回繰り返す
for i in range(M):
    A[A.index(max(A))] = max(A) // 2

P = sum(A)

# Output
print(P)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
M = int(s[0].split()[1])
A = list(map(int, s[1].split()))

A.sort(reverse=True)

# 2で割って小数点切り下げする操作を大きい金額から順次M回繰り返す
for i in range(M):
    A[A.index(max(A))] = max(A) // 2

P = sum(A)

# Output
print(P)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
M = int(s[0].split()[1])
A = list(map(int, s[1].split()))

A.sort(reverse=True)

# 2で割って小数点切り下げする操作を大きい金額から順次M回繰り返す
for i in range(M):
    A[A.index(max(A))] = max(A) // 2

P = 0
for i in range(N):
    P = P + A[i]

# Output
print(P)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
M = int(s[0].split()[1])
A = list(map(int, s[1].split()))

A.sort(reverse=True)

# 2で割って小数点切り下げする操作を大きい金額から順次M回繰り返す
while M > 0:
    A[A.index(max(A))] = max(A) // 2
    M = M - 1

P = 0
for i in range(N):
    P = P + A[i]

# Output
print(P)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
M = int(s[0].split()[1])
A = list(map(int, s[1].split()))

# 2で割って小数点切り下げする操作を大きい金額から順次M回繰り返す
while M > 0:
    A[A.index(max(A))] = max(A) // 2
    M = M - 1

P = 0
for i in range(N):
    P = P + A[i]

# Output
print(P)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for i in range(m):
  b = max(a)
  c = a.index(b)
  a[c] = b//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):
    b = a.index(max(a))
    a[b] = a[b]//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 = sorted(a, reverse=True)
    a[0] = a[0]//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()))
    total = 0
    for _ in range(m):
        mx = max(a)
        a[a.index(mx)] //= 2
    for i in range(n):
        total += a[i]
    print(total)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]

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

ans = 0
for i in range(N):
    ans += A[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]

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

ans = 0
for i in range(N):
    ans += A[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split(" "))
A=[int(S) for S in input().split(" ")]

for i in range(M):
    A=sorted(A)
    A[N-1]=A[N-1]//2
ans=sum(A)

print(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):
  index = A.index(max(A))
  A[index] = A[index]//2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
nyuryoku=list(map(int,input().split()))
syouhinn=list(map(int,input().split()))
for i in range(nyuryoku[1]):
  maxs=max(syouhinn)
  syouhinn[syouhinn.index(maxs)]=int(maxs/2)
print(sum(syouhinn))

Submission status: Time Limit Exceeded

Solution code:
import math
import heapq

n, m =map(int,input().split()) 
a =list(map(int, input().split()))
h =[]
for i in a:
    heapq.heappush(h, i*(-1))


while m >0:
    heru = math.ceil((heapq.heappop(h))/2)
    heapq.heappush(h,heru)
    m = m-1
    if sum(h)==0:
        break
print((-1)*sum(h))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def heap_localsort(Array, i):
    lsub, rsub = 2*i+1, 2*i+2
    maxIndex = i
    if lsub <= len(Array)-1 and Array[lsub] > Array[maxIndex]:
        maxIndex = lsub
    if rsub <= len(Array)-1 and Array[rsub] > Array[maxIndex]:
        maxIndex = rsub
    Array[i], Array[maxIndex] = Array[maxIndex], Array[i]
    return(Array)

def heap_sort(Array):
    for i in reversed(range(int(len(Array)/2))):
        heap_localsort(Array, i)
    return(Array)

def heap_push(Array, addElem):
    Array.append(addElem)
    return(heap_sort(Array))

def heap_pop(Array):
    init = A[0]
    Array[0], Array[len(Array)-1] = Array[len(Array)-1], Array[0]
    Array.pop(len(Array)-1)
    heap_sort(A)
    return(init)
 
def function(A, M):
    heap_sort(A)
    for i in range(M):
        max = heap_pop(A)
        heap_push(A, int(max / 2))
    return sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(int, (input().split(' '))))
print(function(A, N[1]))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import math
def input():
    return sys.stdin.readline()[:-1]

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

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

for _ in range(M):
    A[np.argmax(A)] = math.floor(max(A) / 2)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
def heap_localsort(Array, i):
    lsub, rsub = 2*i+1, 2*i+2
    maxIndex = i
    if lsub <= len(Array)-1 and Array[lsub] > Array[maxIndex]:
        maxIndex = lsub
    if rsub <= len(Array)-1 and Array[rsub] > Array[maxIndex]:
        maxIndex = rsub
    Array[i], Array[maxIndex] = Array[maxIndex], Array[i]
    return(Array)

def heap_sort(Array):
    for i in reversed(range(int(len(Array)/2))):
        heap_localsort(Array, i)
    return(Array)

def heap_push(Array, addElem):
    Array.append(addElem)
    return(heap_sort(Array))

def heap_pop(Array):
    init = A[0]
    Array.pop(0)
    heap_sort(A)
    return(init)
 
def function(A, M):
    heap_sort(A)
    for i in range(M):
        max = heap_pop(A)
        heap_push(A, int(max / 2))
    return sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(int, (input().split(' '))))
print(function(A, N[1]))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
price_list = sorted(list(map(int,input().split())),reverse = True)
for num in range(m):
    price_list[0] = price_list[0]//2
    price_list = sorted(price_list,reverse = True)
print(sum(price_list))

Submission status: Time Limit Exceeded

Solution code:
import math
from copy import deepcopy
import sys
from itertools import combinations_with_replacement
def input():
    return sys.stdin.readline()[:-1]
# input
N, M = map(int, input().split())
As = list(map(int, input().split()))
ind = [i for i in range(N)]

min_val = None
for combo in combinations_with_replacement(ind, M):
    price = deepcopy(As)
    for i in combo:
        price[i] = math.floor(price[i]/2)
    if min_val is None:
        min_val = sum(price)
    else:
        if sum(price) <= min_val:
            min_val = sum(price)

print(min_val)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
def input():
    return sys.stdin.readline()[:-1]

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

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

for _ in range(M):
    max_index = np.argmax(A)
    A[max_index] = int(A[max_index] / 2)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys
from bisect import insort_left
input = sys.stdin.readline
 
def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    for _ in range(m):
        b = a.pop()//2
        insort_left(a, b)
    print(sum(a))
 
 
main()

Submission status: Time Limit Exceeded

Solution code:
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda x: -int(x), input().split()))

for i in range(M):
    heapq.heapify(A)
    _ = -heapq.heappop(A)
    _ = int(_ / 2)
    heapq.heappush(A, -_)

print(-sum(A))

Submission status: Time Limit Exceeded

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

#　貪欲法で現在の価格がもっとも大きいものから割引券を使っていけば良い
current_value=goods_value
left_discount = M
while left_discount > 0:
    maximum_value = max(current_value)
    maximum_value_index = current_value.index(maximum_value)
    current_value[maximum_value_index] = maximum_value // 2
    left_discount -= 1
    
print(sum(current_value))

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()
    A[N-1] = int(A[N-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()))

# 以下を割引券の枚数分繰り返す
# 品物の値段を高い順にソート
# 最も高い品物に割引券を1枚使う
for i in range(M):
	A.sort(reverse=True)
	A[0] = math.floor(A[0] / 2)

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):
    max_value = max(A)
    max_index = A.index(max_value)
    A[max_index] = int(A[max_index] / 2)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M= list(map(int, input().split()))
A= list(map(int, input().split()))
A.sort(reverse=True)
A1=A[:M]
A2=A[M:]
for i in range(M):
    tmp=max(A1)
    A1[A1.index(tmp)]//=2
print(sum(A1)+sum(A2))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop


def solve(string):
    n, m, *a = map(int, string.split())
    while m > 0:
        a.sort(reverse=True)
        b = a[0] // 2
        for i, _a in enumerate(a):
            if m == 0 or _a <= b:
                break
            a[i] //= 2
            m -= 1
    return str(sum(a))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Time Limit Exceeded

Solution code:
import bisect


def main():
    n, m = map(int, input().split(' '))
    a_s = list(sorted(map(int, input().split(' '))))
    
    for _ in range(m):
        value = int(a_s[n-1]/2)
        i = bisect.bisect_left(a_s[:n-1], value)
        a_s[i+1:n] = a_s[i:n-1]
        a_s[i] = value
    print(sum(a_s))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect


def main():
    n, m = map(int, input().split(' '))
    a_s = list(sorted(map(int, input().split(' '))))
    
    for _ in range(m):
        value = int(a_s[n-1]/2)
        i = bisect.bisect_left(a_s[:n-1], value)
        a_s = a_s[:i] + [value] + a_s[i:n-1]
    print(sum(a_s))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

some = input().split()
value = input().split()
su = 0
for a in range(int(some[0])):
    value[a] = int(value[a])
    
for b in range(int(some[1])):
    value.sort(reverse = True)
    value[0] = value[0] // 2
    
for c in value:
    su += c
    
print(su)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
for i in range(M):
  A.sort()
  A[N-1] = A[N-1] // 2
print(np.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):
    x = a.pop()
    x = x // 2
    bisect.insort(a, x)



print(sum(map(int, a)))

Submission status: Time Limit Exceeded

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

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

a.append(0)
a.sort()

for i in range(m):
    for j in range(len(a)):
        if a[n - j - 1] == max(a):
            a[n - j - 1] = a[n - j - 1] // 2
            if a[n - j - 1] < a[n - j - 2]:
                a[n - j - 1], a[n - j - 2] =a[n - j - 2], a[n - j - 1]
            #print(a)
            break
print(sum(a))

Submission status: Time Limit Exceeded

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

while m > 0:
    a.sort(reverse=True)
    tmp = a[0] // 2
    for i in range(n):
        if a[i] > tmp and m > 0:
            a[i] //= 2
            m -= 1
        else:
            break

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
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:
N, M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
if N==1:
  print(A[0]//(2**M))
else:
  while M>0:
    while M>0 and A[-1]>=A[-2]:
      A[-1]=A[-1]//2
      M-=1
    A.sort()
  print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
N, M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
if N==1:
  print(A[0]//(2**M))
else:
  while M>0:
    while M>0 and A[-1]>=A[-2]:
      A[-1]=A[-1]//2
      M-=1
    idx=bisect_left(A, A[-1])
    A.insert(idx, A[-1])
    A.pop()
  print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
N, M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
for i in range(M):
  A[-1]=A[-1]//2
  idx=bisect_left(A, A[-1])
  A.insert(idx, A[-1])
  A.pop()
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(M):
  A[-1]=A[-1]//2
  A.sort()
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-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 _pf(s): return print(s, flush=True)

N, M = LI()
A = LI()

pq = PriorityQueue()
for a in A:
    pq.put((-a, a))

for i in range(M):
    val = pq.get()[1]
    val = math.floor(val/2)
    pq.put((-val, val))

ans = 0
while not pq.empty():
    ans += pq.get()[1]
print(ans)

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]):
    for Index, Kakaku in enumerate(A):
        if Kakaku == max(A):
            A[Index] = int(Kakaku / 2)
            break

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:
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(0,m):
  b=a.index(max(a))
  a[b]=a[b]//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(0,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())
A = list(map(int, input().split()))
for i in range(M):
    max_A = max(A)
    num_A= A.index(max_A)
    A[num_A] = 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()))
A.sort(reverse=True)
for i in range(M):
    fir = A[0] // 2
    if N != 1:
        for i in range(1, N):
            if fir < A[i]:
                A[i-1]=A[i]
                if i == N-1:
                    A[i] = fir
            else:
                A[i-1]=fir
                break
    else:
        A[0] = fir

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 = list(map(int, input().split()))
a.sort()

for _ in range(m):
    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()))
a.sort()

while m:
    a[-1] //= 2
    a.sort()
    m -= 1

print(sum(a))

Submission status: Time Limit Exceeded

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

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

for i in range(M):
    if sum(n)==0:
        break
    
    Y = n.index(max(n))
    n.append(n.pop(Y)//2)
    


print(sum(n))

Submission status: Time Limit Exceeded

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

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

for i in range(M):
    
    Y = n.index(max(n))
    n.append(n.pop(Y)//2)
    


print(sum(n))

Submission status: Time Limit Exceeded

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

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

for i in range(M):
    n.sort(reverse=False)
    n.append(n[len(n)-1]//2)
    n.pop(len(n)-2)


print(sum(n))