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 sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int,ins()))
def lin(): return list(input())
def iin(): return map(int,ins())

class heapx:
    def __init__(self, array):
        self.array = array[:]
        self.heapify()

    def _down_value(self, index):
        try:
            return self.array[2*index+1],self.array[2*index+2]
        except:
            try:
                return self.array[2*index+1],float('inf')
            except:
                return float('inf'),float('inf')

    def _up_value(self, index):
        return self.array[(index-1)//2] if index>0 else -float('inf')

    def _shift(self, i1, i2):
        self.array[i1],self.array[i2]=self.array[i2],self.array[i1]

    def _down_heap(self, index):
        if index > self.leng()-1:
            return False
        i = self.array[index]
        j,k = self._down_value(index)
        if i<j and i<k:
            return
        else:
            if j<k:
                self._shift(index,2*index+1)
                self._down_heap(2*index+1)
            else:
                self._shift(index,2*index+2)
                self._down_heap(2 * index + 2)

    def heapify(self):
        for i in range(-len(self.array)//2-1,1):
            self._down_heap(-i)

    def pop(self):
        self._shift(0,-1)
        tmp = self.array.pop()
        if self.leng() > 0:
            self._down_heap(0)
        return tmp

    def leng(self):
        return len(self.array)

    def _up_heap(self, index):
        i = self.array[index]
        j = self._up_value(index)
        if i<j:
            self._shift(index,(index-1)//2)
            self._up_heap((index-1)//2)

    def push(self, item):
        self.array.append(item)
        self._up_heap(self.leng()-1)

    def poppush(self, item):
        tmp, self.array[0] = self.array[0], item
        self._down_heap(0)
        return tmp

    def pushpop(self, item):
        self.push(item)
        return self.pop()

#t = [5645425,5631,14536,5632,564,151635,563,561415,14563,3131]
#heap = heapx(t)
import math
n,m=iin()
a=heapx(list(map(lambda x:-int(x),ins())))
tmp = a.pop()
for i in range(m):
    tmp = a.pushpop(math.ceil(tmp/2))
print(-(sum(a.array)+tmp))

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))] = max(A) // 2
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a.sort()
for t in range(m):
  discount = a.pop() / 2.
  inserted = False
  for i in range(n - 1):
    if a[i] > discount:
      a.insert(i, discount)
      inserted = True
      break
  if not inserted:
    a.append(discount)
    
print(sum(map(int, a)))

Submission status: Time Limit Exceeded

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

for _ in range(M):
    i = max(range(len(A)), key=A.__getitem__)
    A[i] /= 2
A = list(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):
  ma=max(a)
  a.remove(ma)
  a.append(ma//2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
 
 
N, M = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
for i in range(M):
    A[-1] = A[-1]//2
    A = sorted(A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

N, M = [ int(n) for n in input().split() ]
A = [ int(n) for n in input().split() ]

if N == 1:
    for _ in range(M):
        A[0] //= 2
    print(A[0])
else:
    B = sorted(A, reverse=True)
    #print(B)
    for _ in range(M):
        b = B.pop(0) // 2
        K = math.ceil( math.log(N-1, 2) )
        #print("K: ", K)
        i = 0
        for k in range(K):
            if i+2**(K-1-k) < N-1 and B[i+2**(K-1-k)] > b:
                i += 2**(K-1-k)
            #print(k, i)
        B.insert(i+1,b)
        #print(b, i, B)

    s = 0
    #  s  is sum of the discounted prices.
    for b in B:
        s += b
    print(s)

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):
  bisect.insort(a, int(a.pop() / 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_index = a.index(max(a))
  a[max_index] = int(a[max_index] / 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(m):
  a[-1] = int(a[-1] / 2)
  
  if not(a[0:n-1] == []):
    if a[-1] < max(a[0:n-1]):
      a[-1], a[a.index(max(a[0:n-1]))] = a[a.index(max(a[0:n-1]))], a[-1]
    
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):#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):
         aa = max(a)
         a.append(aa//2)
         a.remove(aa)
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] = int(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(M):
    A[A.index(max(A))]/=2
A=list(map(int,A))
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
while M > 0:
    A[A.index(max(A))] //= 2
    M -= 1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())

a.sort(reverse=True)

a0 = 0
a1 = 0

if n == 1:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] == 0:
      break
else:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] < a[1]:
      if a[0] < a[2]:
        a.sort(reverse=True)
      else:
        a0 = a[0]
        a1 = a[1]
        a[0] = a1
        a[1] = a0

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
while M > 0:
    A.sort()
    A[-1]//= 2
    M -= 1
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=max(A)
    y=A.index(max(A))
    A[y]=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.sort()
    A[-1]//=2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())

a = sorted(a, reverse=True)

if n == 1:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] == 0:
      break
else:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] < a[1]:
      a = sorted(a, reverse=True)

print(sum(a))

Submission status: Time Limit Exceeded

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

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())
a = sorted(a, reverse=True)

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
first=list(map(int,input().split()))
first.sort()
for l in range(M):
  first[N-1]=(first[N-1])/2
  if first[N-2]>first[N-1]:
    i=0
    while i<=N-2:
        if first[i]>=first[N-1]:
            first.insert(i,first.pop())
            break
        else:
            i+=1
          

second=[]
for _ in range(N):
  second.append(0)
for i in range(N):
  second[i]=int(first[i])
print(sum(second))

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())
a = sorted(a, reverse=True)

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
first=list(map(int,input().split()))
for l in range(M):
  first.sort()
  first[N-1]=(first[N-1])/2

second=[]
for _ in range(N):
  second.append(0)
for i in range(N):
  second[i]=int(first[i])
print(sum(second))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

list.sort(A)  # 昇順にソート

for i in range(M):
    A[N-1] = A[N-1] // 2
    tmp = A[N-1]
    del A[N-1]
    insert_index = bisect.bisect_left(A, tmp)
    A.insert(insert_index, tmp)
    
print(sum(A))

Submission status: Time Limit Exceeded

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

A_sub = input().split(" ")
A = [int(n0) for n0 in A_sub]
#A.append(0)

#A.sort(reverse=True)
# print(A)

if N >1:
    for xi in range(M):
        max = 0
        for yi in range(N):
            if A[yi]>max:
                yisub = yi
                max = A[yi]
        A[yisub] = A[yisub]//2

    sum = 0
    for yi in range(N):
        sum = sum + A[yi]
    print(sum)
else:
    for yi in range(M):
        A[0]= A[0]//2
    print(A[0])

Submission status: Time Limit Exceeded

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

list.sort(A, reverse=True)  # 降順にソート

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

Submission status: Time Limit Exceeded

Solution code:
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
t.sort(reverse=True)
if s[0]>=2:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
    if t[0]<t[1]:
      t.sort(reverse=True)
else:
  for j in range(s[1]):
    t[0]=math.floor(t[0]/2)
a=sum(t)
print(a)

Submission status: Time Limit Exceeded

Solution code:
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=1
t.sort(reverse=True)
if s[0]>=2:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
    if t[0]<t[1]:
      t.sort(reverse=True)
else:
  for j in range(s[1]):
    b=b*2
  t[0]=math.floor(t[0]/b)

a=sum(t)
print(a)

Submission status: Time Limit Exceeded

Solution code:
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
t.sort(reverse=True)
for i in range(s[1]):
  t[0]=math.floor(t[0]/2)
  if s[0]>=2:
    if t[0]<t[1]:
      t.sort(reverse=True)
  else:
    continue
a=sum(t)
print(a)

Submission status: Time Limit Exceeded

Solution code:
import math

s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=int(s[1])
t.sort()
for i in range(s[1]):
  for j in range(s[0]):
    if 0<b:
      if max(t)==t[j]:
        t[j]=math.floor(t[j]/2)
        b=b-1
      else:
          continue
    else:
      break
a=sum(t)
print(a)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import heapq

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

for i in range(M):
  heapq.heapify(value)
  num = (heapq.heappop(value)*(-1)//2)*(-1)
  heapq.heappush(value,num)

print(sum(list(map(lambda x: x*(-1), value))))

Submission status: Time Limit Exceeded

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

for i in range(m):
    list_A = sorted(list_A)
    list_A[-1] = int(list_A[-1]/2)

            # print(i, j, list_A[j])

print(sum(list_A))

Submission status: Time Limit Exceeded

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

for i in range(m):
    max_tmp = max(list_A)
    for j in range(len(list_A)):
        if list_A[j] == max_tmp:
            list_A[j] = int(list_A[j]/2)
            break

            # print(i, j, list_A[j])

print(sum(list_A))

Submission status: Time Limit Exceeded

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

def discount(M, A):
    for _ in range(M):
        A.sort(reverse=True)
        A[0] = int(A[0]/2)
    return sum(A)

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=int(s[1])
for i in range(s[1]):
  for j in range(s[0]):
    if max(t)==t[j] and 0<b:
      t[j]=math.floor(t[j]/2)
      b=b-1
for l in range(s[0]):
  a=a+t[l]
print(a)

Submission status: Time Limit Exceeded

Solution code:
import math

s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
t.sort(reverse=True)
for i in range(s[1]):
  t[0]=math.floor(t[0]/2)
  t.sort(reverse=True)
for j in range(s[0]):
  a=a+t[j]
print(a)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
while m>0:
    l[0]//=2
    m-=1
    l.sort(reverse=True)
print(sum(l))

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))]//=2
print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
import heapq

def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
A = inpl()
S = set()
for i in range(N):
    S.add((A[i],i))
for _ in range(M):
    m = max(S)
    S.remove(m)
    S.add((m[0]//2, m[1]))
ans = sum(v for v, i in S)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(int,input().split()))

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

B = list(map(int,A))
ans = sum(B)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
inl = list(map(int, input().split()))
for i in range(m):
  mx = 0
  th = 0
  for j in range(n):
    if inl[j] > mx:
      mx = inl[j]
      th = j
  inl[th] = int(inl[th]/2)
sum = 0
for k in range(n):
  sum += inl[k]
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=list(map(float,item))
npitem=np.array(item)
for i in np.arange(1,M+1):
  npitem[np.argmax(npitem)]=np.floor(np.max(npitem)/2.0)
    
print(int(np.sum(npitem)))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=[float(d) for d in item]
npitem=np.array(item)
for i in np.arange(1,M+1):
  npitem[np.argmax(npitem)]=np.floor(np.max(npitem)/2.0)
    
print(int(np.sum(npitem)))

Submission status: Time Limit Exceeded

Solution code:
n,m = [int(s) for s in input().split()]
price = [int(s) for s in input().split()]
for i in range(m):
  price[price.index(max(price))]/= 2

answer = 0
for i in price:
  answer += int(i)
print(answer)

Submission status: Time Limit Exceeded

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

answer = 0
for i in price:
  answer += int(i)
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=[float(d) for d in item]
for i in range(1,M+1):
    item[item.index(max(item))]=math.floor(max(item)/(2.0))
    
print(int(sum(item)))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import array

n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):  # O(m*n)
    max_num = a[-1]  # O(1)
    index = bisect.bisect_left(a, max_num // 2)  # O(log n)
    a[index + 1:] = a[index:-1]
    a[index] = max_num // 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    import heapq
    input=sys.stdin.readline
    N,M=map(int,input().split())
    A=list(map(lambda x:-1*int(x),input().split()))
    for i in range(M):
        heapq.heapify(A)
        if i==0:
            temp = -(heapq.heappop(A))//2
        else:
            heapq.heappush(A,-temp)
            temp = -(heapq.heappop(A))//2
    print(-sum(A)+temp)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    import heapq
    input=sys.stdin.readline
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    A=[-x for x in A]
    for i in range(M):
        heapq.heapify(A)
        if i==0:
            temp = -(heapq.heappop(A))//2
        else:
            heapq.heappush(A,-temp)
            temp = -(heapq.heappop(A))//2
    print(-sum(A)+temp)
    
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 i in range(m):
    a.append(max(a)//2)
    a.remove(max(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.reverse()
    m -= 1
    a[0] = a[0] // 2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq as hq
n, m = map(int, input().split())
a = list(map(int, input().split()))
def heapSort(i):
    h = []
    for v in i:
        hq.heappush(h, v)
    return [hq.heappop(h) for i in range(len(h))]
for i in range(m):
    a = heapSort(a)
    a[n-1] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = [-int(i) for i in input().split()]

for _ in range(m):
	heapq.heapify(li) 
	x = heapq.heappop(li)
	if x % 2 == 0:
		heapq.heappush(li, x // 2)
	else:
		heapq.heappush(li, x // 2 + 1)
print(-sum(list(li)))

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_max = a.pop()
    bisect.insort(a, tmp_max // 2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
import heapq
 
n, m = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))
for i in range(m):
    heapq.heapify(A)
    min = (-1)*((-1)*(heapq.heappop(A))//2)
    heapq.heappush(A, min)
 
 
print(int(sum(A))*(-1))

Submission status: Time Limit Exceeded

Solution code:
while True:
	try:
		N, M = map(int, input().split())
		A = list(map(int, input().split()))
		if (N == 1):
			for i in range(M):
				A[0] //= 2
			print(A[0])
			continue
			
		while (M > 0):
			A.sort()
			n = A.pop()
			if (n == 0):
				break
			while (M > 0 and n >= A[-1]):
				n //= 2
				M -= 1
			A.append(n)
		print(sum(A))
	except:
		break

Submission status: Time Limit Exceeded

Solution code:
import math
import heapq

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))
for i in range(m):
    heapq.heapify(A)
    min = (-1)*((-1)*(heapq.heappop(A))//2)
    heapq.heappush(A, min)


print(int(sum(A))*(-1))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import array

n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):  # O(m*n)
    max_num = a.pop()  # O(1)
    index = bisect.insort(a, max_num // 2)  # O(log n)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

priceList.sort(reverse=True)
if N == 1:
    while M > 0:
        priceList[0] = priceList[0] // 2
        M -= 1
else:
    while M > 0:
        while priceList[0] >= priceList[1] and M > 0:
            priceList[0] = priceList[0] // 2
            M -= 1

        priceList.sort(reverse=True)

sum = 0
for i in range(N):
    sum += priceList[i]

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import bisect
import array
 
n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):  # O(m*n)
    max_num = a.pop()  # O(1)
    index = bisect.bisect(a, max_num // 2)  # O(log n)
    a.insert(index, max_num // 2)  # O(n)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import numpy as np

n, m = map(int, input().split())
a = map(int, input().split())
a = np.array(sorted(list(a)), dtype="uint64")
for _ in range(m):  # O(m*n)
    max_num = a[-1]  # O(1)
    index = bisect.bisect(a[:-1], max_num // 2)  # O(log n)
    if index != n - 1:
        a[index + 1:] = a[index:-1]
    a[index] = max_num // 2
print(int(sum(a)))

Submission status: Time Limit Exceeded

Solution code:
# 愚直にsortをする。TLEになるかな？
# 

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

order.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import bisect
import array

n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):  # O(m*n)
    max_num = a.pop()  # O(1)
    index = bisect.bisect(a, max_num // 2)  # O(log n)
    a.insert(index, max_num // 2)  # O(n)
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):
	c = a.index(max(a))
	a[c] = a[c]//2
	
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())
As = np.array( list( map(float, input().split()) ) )
As /= 2.0
As.sort()
N1 = int(N/10)
for _ in range(M):
    As[-1] /= 2.0
    if As.size == 1:
      continue
    elif (As[-1] < As[-2]):
        As.sort()

ans = np.sum(np.floor(As*2.0))
print(int(ans))

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

ans = 0
for i in range(n):
    ans += a[i] // 1

print(int(ans))

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

ans = 0
for i in range(n):
    ans += a[i] // 1

print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, 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:
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))

while M:
  m = A.index(max(A))
  A[m] //= 2
  M -= 1
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):
    a[0] = a[0] // 2
    a.sort(reverse=True)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq

N, M = map(int, input().split(" "))
A = [-int(_) for _ in input().split(" ")]

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

print(-sum(A))

Submission status: Time Limit Exceeded

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

for i in range(M):
    tmp_index = A.index(max(A))
    A[tmp_index] = A[tmp_index] // 2    # ここが修正箇所

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import heapq

N, M = map(int, input().split(" "))
A = [-int(_) for _ in input().split(" ")]

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

B = [math.floor(-A[i]) for i in range(len(A))]
print(sum(B))

Submission status: Time Limit Exceeded

Solution code:
a = []
a = input().split()
N = int(a[0])
M = int(a[1])

A = input().split()
A = [int(n) for n in A]
B = [[] for i in range(M+1)]
#B = [[]]

#B[0] = A
for i in range(M+1) :
#  B.append(A)
#  B[i+1].append(A)
  B[i] = A



count_j = [int(0) for i in range(N)]

for i in range(M) :
  for j in range(N) :
    if B[i][j] == max(B[i]) :
#      print('B[i][j]', B[i][j])
      count_j[j] = count_j[j] + 1
      B[i+1][j] = B[i+1][j] // (2)     
#      B[i+1][j] = B[0][j] // (2**(count_j[j]))
#      print('count_j', count_j)
#      print('A', A)
#      print('B', B)
      break

#print('N', N)
#print('M', M)
#print('A', A)
#print('B', B)
#print('count_j', count_j)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys
import bisect
import numpy as np


N, M = [int(i) for i in input().split()]
AS = input()

l = []
for a in AS.split():
    bisect.insort_left(l, int(a))

for i in range(M):
    n = l.pop()
    bisect.insort_left(l, n // 2)


print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
import sys
import bisect
import numpy as np


N, M = [int(i) for i in input().split()]
AS = input()

l = []
for a in AS.split():
    bisect.insort(l, int(a))

for i in range(M):
    n = l.pop()
    bisect.insort(l, n // 2)


print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
import heapq

N, M = [int(i) for i in input().split()]
a = input().split()
A = [int(i) for i in a]
#print(N, M)
#print(A)

def heapsort(list):
    h = []
    for i in A:
        heapq.heappush(h, i)
    return [heapq.heappop(h) for i in range(len(h))]

for i in range(M):
    A = heapsort(A)
    n = len(A) - 1
    A[n] = A[n]//2

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

B = sorted(A, reverse=True)
#print(B)
for _ in range(M):
    b = B.pop(0) // 2
    i = 0
    while i < N-1:
        if B[i] < b:
            break
        else:
            i += 1
    B.insert(i,b)

s = 0
for b in B:
    s += b
print(s)

Submission status: Time Limit Exceeded

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

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

    p = 0
    while p < N - 1 and A[p] < A[p + 1]:
        A[p], A[p + 1] = A[p + 1], A[p]
        p += 1

print(sum(map(int, A)))

Submission status: Time Limit Exceeded

Solution code:
import math

n, m =map(int,input().split()) 
a =list(map(int, input().split()))
b =[math.ceil(i/2) for i in a]

otoku = 0

while m >0:
    otoku =b.index(max(b))
    a[otoku] = a[otoku]-b[otoku]
    b[otoku] = math.ceil(a[otoku]/2)

    m = m-1
    if sum(a)==0:
        break
print(sum(a))

Submission status: Time Limit Exceeded

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

B = [A.pop()]

for m in range(M):
    
    if A == []:
        B[-1] //= 2
        B.sort()
    elif B[-1] > A[-1]:
        B[-1] //= 2
        B.sort()
    else:
        B.append(A.pop()//2)
        B.sort()
        
print(sum(A+B))

Submission status: Time Limit Exceeded

Solution code:
nm = input()
a = input()

nm = nm.split()
n = int(nm[0])
m = int(nm[1])
a = [int(x) for x in a.split()]

a.sort(reverse=True)

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

output = sum(a)
print(output)

Submission status: Time Limit Exceeded

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

a.sort(reverse=True)

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

print(sum(a))