from fractions import Fraction
from math import log, ceil
import heapq

(n, m), aa = [list(map(int, s.split())) for s in open(0)]
aa = [-Fraction(a) for a in aa]

heapq.heapify(aa)

while m:
    m1 = heapq.heappop(aa)
#     print(f'{m=},{m1=}')
    if len(aa):
        m2 = aa[0]
        use = min(max(ceil(log(m1/m2)/log(2)), 1), m)
#         print(f'{m2=},{use=}')
    else:
        use = min(max(ceil(log(-m1)/log(2)), 1), m)
#         print(f'else, {use=}')
#         print(f'{ceil(log(-m1)/log(2))=}')
#     print(f'{m1/Fraction(2**use)}')
    heapq.heappush(aa, m1 / Fraction(2**use))
    m -= use
    if -(aa[0]) < 1:
        break

aa = [int(-a) for a in aa]

print(sum(aa)) from fractions import Fraction from math import log, ceil import heapq heapq list(map(int, s.split())) for s in open(0) for s in open(0) s open(0) open 0 for s in open(0) list(map(int, s.split())) list map(int, s.split()) map int s.split() s.split s split (n, m), aa = [list(map(int, s.split())) for s in open(0)] (n, m) n m [list(map(int, s.split())) for s in open(0)] aa -Fraction(a) for a in aa for a in aa a aa for a in aa -Fraction(a) Fraction(a) Fraction a aa = [-Fraction(a) for a in aa] aa [-Fraction(a) for a in aa] heapq.heapify(aa) heapq.heapify heapq heapify aa while m:
    m1 = heapq.heappop(aa)
#     print(f'{m=},{m1=}')
    if len(aa):
        m2 = aa[0]
        use = min(max(ceil(log(m1/m2)/log(2)), 1), m)
#         print(f'{m2=},{use=}')
    else:
        use = min(max(ceil(log(-m1)/log(2)), 1), m)
#         print(f'else, {use=}')
#         print(f'{ceil(log(-m1)/log(2))=}')
#     print(f'{m1/Fraction(2**use)}')
    heapq.heappush(aa, m1 / Fraction(2**use))
    m -= use
    if -(aa[0]) < 1:
        break m m1 = heapq.heappop(aa) m1 heapq.heappop(aa) heapq.heappop heapq heappop aa if len(aa):
        m2 = aa[0]
        use = min(max(ceil(log(m1/m2)/log(2)), 1), m)
#         print(f'{m2=},{use=}')
    else:
        use = min(max(ceil(log(-m1)/log(2)), 1), m)
#         print(f'else, {use=}')
#         print(f'{ceil(log(-m1)/log(2))=}')
#     print(f'{m1/Fraction(2**use)}')
     len(aa) len aa m2 = aa[0] m2 aa[0] aa 0 use = min(max(ceil(log(m1/m2)/log(2)), 1), m) use min(max(ceil(log(m1/m2)/log(2)), 1), m) min max(ceil(log(m1/m2)/log(2)), 1) max ceil(log(m1/m2)/log(2)) ceil log(m1/m2)/log(2) log(m1/m2) log m1/m2 m1 m2 log(2) log 2 1 m use = min(max(ceil(log(-m1)/log(2)), 1), m) use min(max(ceil(log(-m1)/log(2)), 1), m) min max(ceil(log(-m1)/log(2)), 1) max ceil(log(-m1)/log(2)) ceil log(-m1)/log(2) log(-m1) log -m1 m1 log(2) log 2 1 m heapq.heappush(aa, m1 / Fraction(2**use)) heapq.heappush heapq heappush aa m1 / Fraction(2**use) m1 Fraction(2**use) Fraction 2**use 2 use m -= use m use if -(aa[0]) < 1:
        break -(aa[0]) < 1 -(aa[0]) aa[0] aa 0 1 break int(-a) for a in aa for a in aa a aa for a in aa int(-a) int -a a aa = [int(-a) for a in aa] aa [int(-a) for a in aa] print(sum(aa)) print sum(aa) sum aa aa = [int(-a) for a in aa] [int(-a) for a in aa] aa aa = [list(map(int, s.split())) for s in open(0)] [list(map(int, s.split())) for s in open(0)] aa m -= use use m use = min(max(ceil(log(-m1)/log(2)), 1), m) min(max(ceil(log(-m1)/log(2)), 1), m) use aa = [-Fraction(a) for a in aa] [-Fraction(a) for a in aa] aa m2 = aa[0] aa[0] m2 use = min(max(ceil(log(m1/m2)/log(2)), 1), m) min(max(ceil(log(m1/m2)/log(2)), 1), m) use m1 = heapq.heappop(aa) heapq.heappop(aa) m1
from fractions import Fraction
from math import log, ceil
import heapq

(n, m), aa = [list(map(int, s.split())) for s in open(0)]
aa = [-Fraction(a) for a in aa]

heapq.heapify(aa)

while m:
    m1 = heapq.heappop(aa)
#     print(f'{m=},{m1=}')
    if len(aa):
        m2 = aa[0]
        use = min(max(ceil(log(m1/m2)/log(2)), 1), m)
#         print(f'{m2=},{use=}')
    else:
        use = min(max(ceil(log(-m1)/log(2)), 1), m)
#         print(f'else, {use=}')
#         print(f'{ceil(log(-m1)/log(2))=}')
#     print(f'{m1/Fraction(2**use)}')
    heapq.heappush(aa, m1 / Fraction(2**use))
    m -= use
    if -(aa[0]) < 1:
        break

aa = [int(-a) for a in aa]

print(sum(aa))