Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

for i in range(m):
  b, c = map(int, input().split())
  a += (b * [c])

a.sort()
l = len(a)
for i in range(l-n, l):
  sum += a[i]

print(sum)

### FIXED CODE ###

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

for i in range(n):
  s.append((a[i], 1))

for _ in range(m):
  b, c = map(int, input().split())
  s.append((c, b))
#  for j in range(b):
#    a.append(c)

s.sort(reverse=True)
idx = 0
sum = 0
for i in range(n):
  if idx + s[i][1] > n:
    sum += s[i][0] * (n-idx)
    break

  sum += s[i][0] * s[i][1]
  idx += s[i][1]


# for i in range(l-n, l):
#  sum += a[i]

print(sum)
### BUGGY CODE ###

s = input()
k = int(input())
lis = []
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        lis.append(s[i:j])
print(sorted(list(set(lis)))[k - 1])

### FIXED CODE ###

s = input()
k = int(input())
a = set()
for i in range(len(s) + 1):
    for j in range(1, 6):
        a.add(s[i:i + j])
print(sorted(list(a))[k])
### BUGGY CODE ###

import bisect, heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

for i in range(1,N+1):
    a = bisect.bisect_right(A,i) - bisect.bisect_left(A,i)
    b = bisect.bisect_right(B,i) - bisect.bisect_left(B,i)

    if a + b > N:
        print("No")
        exit()

new_B = B[::-1]

for i in range(N):
    if A[i] == new_B[i]:
        for j in range(N):
            if A[j] != new_B[i] and new_B[j] != A[i]:
                new_B[i], new_B[j] = new_B[j], new_B[i]
                break

print("Yes")
for b in new_B:
    print(b,end=" ")
print("")





### FIXED CODE ###

import bisect, heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

for i in range(1,N+1):
    a = bisect.bisect_right(A,i) - bisect.bisect_left(A,i)
    b = bisect.bisect_right(B,i) - bisect.bisect_left(B,i)

    if a + b > N:
        print("No")
        exit()

B = B[::-1]

j, bef = 0, -1
for i in range(N):
    if A[i] != bef:
        j = 0
    if A[i] == B[i]:
        while j < N:
            if A[j] != B[i] and B[j] != A[i]:
                B[i], B[j] = B[j], B[i]
                break
            j += 1
    bef = A[i]

print("Yes")
for b in B:
    print(b,end=" ")
print("")
### BUGGY CODE ###

from collections import defaultdict

n, t = map(int, input().split())
menu = []

for _ in range(n):
    a, b = map(int, input().split())
    menu.append((a, b))

menu = sorted(menu)

dp = defaultdict(int)
dp[0] = 0

score = 0

for a, b in menu:
    for time, utility in list(dp.items()):
        if time + a >= t:
            score = max(score, utility + b)
        else:
            dp[time + a] = max(dp[time + a], utility + b)

print(max(score, max(dp.values())))

### FIXED CODE ###

from collections import defaultdict

n, t = map(int, input().split())
menu = []

for _ in range(n):
    a, b = map(int, input().split())
    menu.append((a, b))

menu = sorted(menu)

dp = defaultdict(int)
dp[0] = 0

score = 0

for a, b in menu:
    for time, utility in list(dp.items()):
        if time + a >= t:
            score = max(score, utility + b)
        else:
            dp[time + a] = max(dp[time + a], utility + b)

print(max(score, max(dp.values())))
### BUGGY CODE ###

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

for i in range(1,N+1):
    print(A.index(i)+1)

### FIXED CODE ###

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

B = [0]*N
for i in range(0,N):
    B[A[i]-1] = i+1

for i in B:
    print(i)
### BUGGY CODE ###

import sys

N,K = map(int,input().split())
sys.setrecursionlimit(N + 1)
A = list(map(int,input().split()))
town = [[] for _ in range(N)]
visited = [0]

for i in range(N):
  town[i] = [i,A[i] - 1]

def teleport(i,con):
  goal = town[i][1]
  if goal in visited or con == N:
    return goal
  else:
    visited.append(goal)
    return teleport(goal,con + 1)

l = teleport(visited[0],0)

if K <= len(visited):
  print(visited[K] + 1)
else:
  cs = visited.index(l)
  cycle = visited[cs:]
  K = (K - len(visited)) % len(cycle)
  print(cycle[K] + 1)
  
##i

### FIXED CODE ###

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

A = list(map(int,input().split()))
town = [[] for _ in range(N)]
visited = [0]
flag = [-1] * N

for i in range(N):
  town[i] = [i,A[i] - 1]

f = 0

while flag[f] == -1:
  t = town[f][1]
  flag[f] = t
  f = town[t][0]
  visited.append(t)
  
l = visited[-1]
lv = len(visited)

if K <= lv:
  print(visited[K] + 1)
else:
  cs = visited.index(l)
  cycle = visited[cs:-1]
  lc = len(cycle)
  print(cycle[(K - lv + 1) % lc] + 1)
##i
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from collections import deque


def solve(N: int, A: "List[int]"):
    s = sorted(A)
    s = deque(s)
    min_s = s[0]
    max_s = s[-1]
    lim = int(-(-max_s**0.5//1))+1
    if min_s == 1:
        print((A.count(1)==1)*1)
        return
    
    ans = 0
    # print(s)
    temp = s.popleft()
    ct = 1
    while (len(s)>0) and (s[0] == temp) :
        ct+=1
        temp = s.popleft()
    if ct==1: ans+=1
    # print(ct)
    # print(temp)
    while (len(s)>0):
        new_s = deque()
        while(len(s)>0):
            t = s.popleft()
            if t%temp!=0:
                new_s.append(t)
        s = new_s
        temp = s.popleft()
        ct = 1
        while (len(s)>0) and (s[0] == temp) :
            ct+=1
            temp = s.popleft()
        if ct==1: ans+=1
        # print(temp, s)
        
    print(ans + len(s))

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import deque, Counter


def solve(N: int, A: "List[int]"):
    d_A = Counter(A)
    s = sorted(d_A.keys())
    if s[0] == 1:
        print((d_A[1] == 1)*1)
        return
    
    is_d = [0]*(2*10**6)

    for s_t in s:
        lim = 10**6 // s_t +1
        for i in range(1,lim):
            is_d[i*s_t] +=1
    
    ans = 0
    for s_t in s:
        if (d_A[s_t] == 1) and (is_d[s_t]==1):
            ans+=1
    print(ans)


        

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

A, B, C, D, E, F = map(int, input().split())

memo = {}
memo.update(density=0, sugerwater=0, suger=0)
for a in range(F//(100*A) + 1):
    for b in range(F//(100*B) + 1):
        for c in range(E*(A*a + B*b)//C + 1):
            for d in range(E*(A*a + B*b)//D + 1):
                # print(100*(A*a + B*b) + C*c + D*d)
                if 100 * (A * a + B * b) + C * c + D * d <= F and C * c + D * d <= E * (A * a + B * b) and (100 * (A * a + B * b) + C * c + D * d) != 0:
                    dens_tmp = 100*(C*c + D*d)/(100*(A*a + B*b) + C*c + D*d)
                    if dens_tmp >= memo['density']:
                        memo.update(density=dens_tmp, sugerwater=100 *
                                    (A * a + B * b) + C * c + D * d, suger=C * c + D * d)

print(memo['sugerwater'], memo['suger'])

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())

memo = {}
memo.update(density=0, sugerwater=0, suger=0)
for a in range(F//(100*A) + 1):
    for b in range(F//(100*B) + 1):
        for c in range(E*(A*a + B*b)//C + 1):
            for d in range(E*(A*a + B*b)//D + 1):
                # print(100*(A*a + B*b) + C*c + D*d)
                if 100 * (A * a + B * b) + C * c + D * d <= F and C * c + D * d <= E * (A * a + B * b) and (100 * (A * a + B * b) + C * c + D * d) != 0:
                    dens_tmp = 100*(C*c + D*d)/(100*(A*a + B*b) + C*c + D*d)
                    if dens_tmp >= memo['density']:
                        memo.update(density=dens_tmp, sugerwater=100 *
                                    (A * a + B * b) + C * c + D * d, suger=C * c + D * d)

print(memo['sugerwater'], memo['suger'])
### BUGGY CODE ###

def apc001_c():
    import sys
    n = int(input())

    lower = 0
    print(lower)
    sys.stdout.flush()
    seat_low = str(input())
    if seat_low == 'Vacant': return

    upper = n-1
    print(upper)
    sys.stdout.flush()
    seat_up = str(input())
    if seat_up == 'Vacant': return

    cnt = 0
    while upper - lower > 1:
        x = (upper + lower) // 2
        print(x)
        sys.stdout.flush()
        s = str(input())
        if s == seat_low: lower = x
        elif s == seat_up: upper = x
        else: return
        cnt += 1
        if cnt > 20: break

if __name__ == '__main__':
    apc001_c()

### FIXED CODE ###

def apc001_c():
    import sys
    n = int(input())

    def ask(x:int):
        print(x)
        sys.stdout.flush()
        res = str(input())
        return res

    lower = 0
    seat_low = ask(lower)
    if seat_low == 'Vacant': return

    upper = n-1
    seat_up = ask(upper)
    if seat_up == 'Vacant': return

    while upper - lower > 1:
        x = (upper + lower) // 2
        s = ask(x)
        if s == 'Vacant': return
        if x % 2 == 0:
            if s == seat_low: lower = x
            else: upper = x
        else:
            if s == seat_up: lower = x
            else: upper = x

if __name__ == '__main__':
    apc001_c()
### BUGGY CODE ###

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

ans = []
flag = False
for i in range(n):
    if x in ans:
        v = x
        flag = True
        break
    ans.append(x)
    x = x**2 % m
if flag:
    p = ans.index(v)
    l = len(ans) - p
    d, e = divmod(n-p, l)
    print(sum(ans[:p]) + d*sum(ans[p:]) + sum(ans[p:p+e]))
else:
    print(sum(ans))

### FIXED CODE ###

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

ans = []
flag = False
for i in range(n):
    if x in ans:
        v = x
        flag = True
        break
    ans.append(x)
    x = x**2 % m
if flag:
    p = ans.index(v)
    l = len(ans) - p
    d, e = divmod(n-p, l)
    print(sum(ans[:p]) + d*sum(ans[p:]) + sum(ans[p:p+e]))
else:
    print(sum(ans))
### BUGGY CODE ###

s = input()
mod = 10 ** 9 + 7

dp = [0] * 13
dp[0] = 1
for c in s:
  tmp = dp[:]
  if c == '?':
    dp = [0] * 13
    for n in range(10):
      for i in range(13):
        dp[(10 * i + n) % 13] += tmp[i]
    for i in range(13):
      dp[i] %= mod
  else:
    n = int(c)
    for i in range(13):
      dp[(10 * i + n) % 13] = tmp[i]
print(dp[5])

### FIXED CODE ###

s = input()
mod = 10 ** 9 + 7

dp = [1] + [0] * 12
for c in s:
  tmp = dp[:]
  if c == '?':
    dp = [0] * 13
    for n in range(10):
      for i in range(13):
        index = (10 * i + n) % 13
        dp[index] = (dp[index] + tmp[i]) % mod
  else:
    n = int(c)
    for i in range(13):
      dp[(10 * i + n) % 13] = tmp[i]
print(dp[5])
### BUGGY CODE ###

import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [(n,n)]
r = [(n,n)]
mc = n
mr = n
for _ in range(q):
    m, q = list(map(int, input().split()))
    if m == 1:
        l = len(r)
        mini = 0
        maxi = l - 1
        i = (maxi + mini) // 2
        col, pos = r[i]
        while maxi > mini:
            if col >= q:
                maxi = i
            else:
                mini = i + 1
            i = (maxi + mini) // 2
            col, pos = r[i]
        if q < mc:
            mc = q
            for i,(_, row) in enumerate(c):
                if row >= q:
                    break
            c.insert(i, (pos, q))
        if q not in [1,n]:
            count -= max(0, pos - 2)
    else:
        l = len(c)
        mini = 0
        maxi = l - 1
        i = (maxi + mini) // 2
        row, pos = c[i]
        while maxi > mini:
            if row >= q:
                maxi = i
            else:
                mini = i + 1
            i = (maxi + mini) // 2
            row, pos = c[i]
        if q < mr:
            mr = q
            for i,(_, col) in enumerate(r):
                if col > q:
                    break
            r.insert(i, (pos, q))
        if q not in [1,n]:
            count -= max(0, pos - 2)
print(count)



### FIXED CODE ###

import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [n] * (n + 1)
r = [n] * (n + 1)
mc = n
mr = n
for _ in range(q):
    m,q = list(map(int, input().split()))
    if m == 1:
        if q <= mc:
            count -= mr -2
            for p in range(q+1, mc):
                c[p] = mr
            c[q] = 0
            mc = q
        else:
            count -= c[q] - 2
    else:
        if q <= mr:
            count -= mc -2
            for p in range(q+1, mr):
                r[p] = mc
            r[q] = 0
            mr = q
        else:
            count -= r[q] - 2
print(count)
### BUGGY CODE ###

n, m = map(int, input().split())
l1, r1 = map(int, input().split())
li = set(list(range(l1, r1+1)))

for i in range(m-1):
    l,r = map(int, input().split())
    li = li & set(list(range(l,r+1)))
print(len(li))

### FIXED CODE ###

a,b= map(int,input().split())
x, y= zip(*[list(map(int,input().split())) for i in range(b)])
f=  min(y) - max(x) 
if f< 0 :
  print(0)
else :
  print(min(y) - max(x) +1)
### BUGGY CODE ###

N = int(input())
a_list = list(map(int,input().split()))


from collections import Counter
a_dict = Counter(a_list)

start = a_list[0]
# 数を減らさない。
# a_dict[a] -= 1

a_keys = a_dict.keys()

def check():
    for a1 in a_keys:
#         print("for1",start,a1)
        a0 = start
        tmp_dict = a_dict.copy()
#         tmp_dict[a1] -= 1
        for i in range(N):
#             print(" for2",i,a0,a1)
#             print(tmp_dict)
            next_a = int(bin(a0^a1), 0)
            if not next_a in tmp_dict:
#                 print(next_a," not in dict")
                break
            if tmp_dict[next_a] <= 0:
                tmp_dict.pop(next_a)
                break
            a0 = a1
            a1 = next_a
            tmp_dict[next_a] -= 1
#             if tmp_dict[next_a] == 0:
#                 tmp_dict.pop(next_a)
            if i == N-1:
                return True
    return False

if check():
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from collections import Counter
N = int(input())
a_list = list(map(int,input().split()))

l = len(set(a_list))

def check():
    counter = Counter(a_list)
    if l == 1:
        if a_list[0] == 0:
            return True
        return False
    if l == 2:
        if counter[0] == N/3:
            return True
        return False
    if l == 3:
        x,y,z = set(a_list)
        if int(bin(x^y^z), 0) == 0 and set(list(counter.values()))==set([N/3]):
            return True
        return False
    return False

if check():
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

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


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


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

    result = 0

    for a in A:
        result += prime_decomposition(a).count(2)
    print(result)


if __name__ == "__main__":
    main()


### FIXED CODE ###

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


def div_two(num):
    cnt = 0
    while num % 2 == 0:
        num = num // 2
        cnt += 1
    return cnt


def main():
    N = int(input())

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

    print(sum(div_two(i) for i in A))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import collections
import copy

N = int(input())
A = list(map(int, input().split()))
C = collections.Counter(A)

for a in A:
    pC = copy.deepcopy(C)

    ans = 0
    for k, v in pC.items():
        if k == a:
            ans += (v - 1) * (v - 2) // 2
        else:
            ans += v * (v - 1) // 2
    print(ans)



### FIXED CODE ###

import collections

N = int(input())
A = list(map(int, input().split()))
C = collections.Counter(A)

D = collections.defaultdict(int)

for k, v in C.items():
    D[k] += v * (v - 1) // 2

pans = sum(D.values())

for a in A:
    p = (C[a] - 1) * (C[a] - 2) // 2
    ans = pans - D[a] + p

    print(ans)
### BUGGY CODE ###

from collections import deque

def main():
  n, m = map(int, input().split())
  graph = [[] for _ in range(n)]

  for i in range(m):
    a, b = map(int, input().split())
    if b-1 not in graph[a-1]:
      graph[a-1].append(b-1)
      graph[b-1].append(a-1)
  
  unsearched = list(range(n))
  result = 0
  border = n//2
  while len(unsearched) > 0:
    s = unsearched[0]
    tmp, cnt = dfs(graph, unsearched, s)
    if cnt > result:
      result = cnt
      
  print(result)

def dfs(graph, unsearched, s):
  stack = deque([s])
  searched = [s]
  while len(stack):
    cur = stack.pop()
    unsearched.remove(cur)
    for i in graph[cur]:
      if i not in searched:
        stack.append(i)
        searched += [i]
  return searched, len(searched)

main()

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

def main():
  n, m = map(int, input().split())
  uf = UnionFind(n)

  for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b-= 1;
    uf.union(a, b)
  
  ans = 0
  for i in range(n):
    ans = max(ans, uf.size(i))
      
  print(ans)
  
main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

route = [1]
index = k
for i in range(n+1):
    _next = a[route[-1]]
    if _next in route:
        route.append(_next)
        index -= (i+1)
        break
    route.append(_next)

if index <= 0:
    print(route[k])
else:
    route = route[route.index(route[-1]):-1]
    print(route[index % len(route)])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

route = [1]
index = k
hit = set([1])
for i in range(n+1):
    _next = a[route[-1]]
    if _next in hit:
        route.append(_next)
        index -= (i+1)
        break
    route.append(_next)
    hit.add(_next)

if index <= 0:
    print(route[k])
else:
    route = route[route.index(route[-1]):-1]
    print(route[index % len(route)])
### BUGGY CODE ###

from itertools import combinations
import copy

n = int(input())
ls = [int(input()) for _ in range(n)]

def function(n,ls):
    array = copy.deepcopy(ls)
    array.pop(n)
    return max(array)
    
for i in range(n):
    print(function(i,ls))

### FIXED CODE ###

n = int(input())
ls = [int(input()) for _ in range(n)]
ls_sort = sorted(ls,reverse=True)

for i in range(n):
    if ls[i] == ls_sort[0]:
        print(ls_sort[1])
    else:
        print(ls_sort[0])
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
info = [list(map(int, input().split())) for _ in range(q)]
ans = []
lt = []
rt = []
all = s.count('AC')
for i in range(n):
    lt.append(all - s[i:].count('AC'))
    rt.append(all - s[:n-i].count('AC'))
rt.reverse()
# print(lt)
# print(rt)
for l, r in info:
    ans.append(all - (lt[l-1] + rt[r-1]))

for i in range(q):
    print(ans[i])

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
info = [list(map(int, input().split())) for _ in range(q)]
all = s.count('AC')
ans = []
lt = [all]
rt = [all]
# for i in range(n):
#     lt.append(all - s[i:].count('AC'))
#     rt.append(all - s[:n-i].count('AC'))
for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        lt.append(lt[i-1] - 1)
    else:
        lt.append(lt[i-1])
    if s[n-i-1] == 'A' and s[n-i] == 'C':
        rt.append(rt[i-1] - 1)
    else:
        rt.append(rt[i-1])

rt.reverse()
# print(lt)
# print(rt)
# print(rt)
for l, r in info:
    ans.append(lt[l-1] + rt[r-1] - all)

for i in range(q):
    print(ans[i])
### BUGGY CODE ###

import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N))
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X-1, Y-1] = 1
lil[Y-1, X-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil)
for i in range(1,N):
    print((np.count_nonzero(lil2 == i)) // 2)

### FIXED CODE ###

import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype = int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X-1, Y-1] = 1
lil[Y-1, X-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
ans = np.bincount(lil2.ravel(), minlength = N) // 2
for i in range(1,N):
    print(ans[i])
### BUGGY 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))

### FIXED CODE ###

import heapq

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

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

heapq.heapify(arr)

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

print(-sum(arr))
### BUGGY CODE ###

N = int(input())
for a in range(1, 3501):
    for b in range(1, 3501):
        c2 = 4 * a * b - b * N - a * N
        if c2 <= 0:continue
        c1 = a * b * N
        if c1/c2 == c1//c2:
            print(a,b,c1//c2)
            exit()

### FIXED CODE ###

N = int(input())
for a in range(1, 3501):
    for b in range(a+1, 3501):
        c2 = 4 * a * b - b * N - a * N
        if c2 <= 0:continue
        c1 = a * b * N
        if c1/c2 == c1//c2:
            print(a,b,c1//c2)
            exit()