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

# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

a=min(A)
ans=0

for i in range(1,int(a**0.5)//1+1):
    judge=True
    for item in A:
        if item%i!=0:
            judge=False
    if judge:
        ans=max(ans,i)

    judge=True
    for item in A:
        if item%(a//i)!=0:

            judge=False
    if judge:
        ans=max(ans,(a//i))
        
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

a=min(A)
ans=0
l=[]

def gcd(lis,num):
    temp=[]
    for item in lis:
        if num%item!=0:
            pass
        else:
            temp.append(item)
    return temp

for i in range(1,int(a**0.5)//1+1):
    if a%i==0:
        l.append(i)
        l.append(a//i)

for item in A:
    l=gcd(l,item)

print(max(l))
### BUGGY CODE ###

s = input()
q = int(input())
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        s = s[::-1]
    else:
        if query[1] == "1":
            s = query[2] + s
        else:
            s = s + query[2]
print(s)


### FIXED CODE ###

def main():
    s = input()
    q = int(input())
    reverse = 0
    head = ""
    tail = ""
    for _ in range(q):
        query = input().split()
        if query[0] == "1":
            reverse = not(reverse)
        else:
            if (reverse^int(query[1]))&1:
                head += query[2]
            else:
                tail += query[2]
    s = head[::-1] + s + tail
    if reverse&1:
        print(s[::-1])
    else:
        print(s)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

ans = sum(a)
A = ''
for i in range(n):
    A += ' ' + str(a[i])

B = []
C = []
for i in range(q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(q):
    s = A.replace(str(B[i]), str(C[i]))
    cnt = A.count(str(B[i]))
    ans += (C[i]-B[i])*cnt
    print(ans)
    A = s


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())

ans = sum(a)
A = Counter(a).most_common()
d = [0] * (10**5+10)
for i in range(len(A)):
    d[A[i][0]] = A[i][1]

B = []
C = []
for i in range(q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(q):
    d[C[i]] += d[B[i]]
    cnt = d[B[i]]
    ans += (C[i]-B[i])*cnt
    print(ans)
    d[B[i]] = 0
### BUGGY CODE ###

from itertools import permutations

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conf = [[int(x) for x in input().split()] for _ in range(n)]
# conf = sorted([[int(x) for x in input().split()] for _ in range(n)], reverse=True)

maxres = 0
for cc in permutations(conf, min(m, len(conf))):
  res = 0
  for i, c in enumerate(cc):
    if i + c[0] <= m:
      res = res + c[1]
    else:
      break
  if res > maxres:
    maxres = res
print(maxres)


### FIXED CODE ###


import collections
import heapq

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conditions = collections.deque([])
for i in range(n):
  conditions.append([int(x) for x in input().split()])

conditions = sorted(conditions)

cnt, ans = 0, 0
candidates = []
for reversed_day in range(1, m + 1):
  while cnt < len(conditions) and conditions[cnt][0] <= reversed_day:
    heapq.heappush(candidates, -conditions[cnt][1])
    cnt += 1

  if len(candidates) == 0:
    continue
  ans -= heapq.heappop(candidates)

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

import numpy as np
N,W=map(int,input().split())
weight=np.zeros(N,np.int64)
values=np.zeros(N,np.int64)
for i in range(N):
  weight[i],values[i]=map(int,input().split())

dp=np.zeros((N+1,W+1),np.int64)

for i in range(N):
  for w in range(W+1):
    if w>=weight[i]:
      dp[i+1][w]=max(dp[i][w],dp[i][w-weight[i]]+values[i])
    else:
      dp[i+1][w]=dp[i][w]
      
print(dp[N][W])


### FIXED CODE ###

def calc():
  N,W=map(int,input().split())
  dp=[-1]*(W+1)
  dp[0]=0
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W-w,-1,-1):
      if dp[j]!=-1:
        if dp[j+w]<dp[j]+v:
          dp[j+w]=dp[j]+v
  print(max(dp))
  
calc()
### BUGGY CODE ###

import collections
def main():

    N, K = map(int, input().split())
    if K == 1:
        if N == 1: return 1
        else: return 0

    tree = collections.defaultdict(list)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    mod = pow(10, 9) + 7

    v = inv_factorial(K-1, mod)
    invf = [v]
    for i in range(K-1, 0, -1):
        invf.append(invf[-1] * i)
    invf = invf[::-1]

    f = [1]
    for i in range(1, K):
        f.append(f[-1]*i)

    ans = K
    cur = []
    visited = set([1])
    for b in tree[1]:
        cur.append(b)
        visited.add(b)
    l = len(cur)
    if l > K-1: return 0
    ans *= (f[K-1]*invf[K-1-l]) % mod
    ans %= mod

    while cur:
        temp = []
        for a in cur:
            l = len(tree[a])-1
            if l > K-2: return 0
            ans *= (f[K-2]*invf[K-2-l]) % mod
            ans %= mod
            for b in tree[a]:
                if b not in visited:
                    temp.append(b)
                    visited.add(b)
        cur = temp

    return ans


def quickpow(x, y, mod):
    if y == 0: return 1
    elif y == 1: return x
    elif y % 2 == 0: return pow(quickpow(x, y//2, mod), 2) % mod
    elif y % 2 == 1: return (pow(quickpow(x, y//2, mod), 2) * x) % mod

def factorial(x, mod):
    v = 1
    for i in range(2, x+1):
        v *= i
        v %= mod
    return v

def inv_factorial(x, mod):
    v = factorial(x, mod)
    return quickpow(v, mod-2, mod)


if __name__ == '__main__':
    print(main())

### FIXED CODE ###

import collections
def main():

    N, K = map(int, input().split())
    if K == 1:
        if N == 1: return 1
        else: return 0

    tree = collections.defaultdict(list)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    mod = pow(10, 9) + 7

    v = inv_factorial(K-1, mod)
    invf = [v]
    for i in range(K-1, 0, -1):
        invf.append((invf[-1] * i) % mod)
    invf = invf[::-1]

    f = [1]
    for i in range(1, K):
        f.append((f[-1]*i) % mod)

    ans = K
    cur = []
    visited = set([1])
    for b in tree[1]:
        cur.append(b)
        visited.add(b)
    l = len(cur)
    if l > K-1: return 0
    ans *= (f[K-1]*invf[K-1-l]) % mod
    ans %= mod

    while cur:
        temp = []
        for a in cur:
            l = len(tree[a])-1
            if l > K-2: return 0
            ans *= (f[K-2]*invf[K-2-l]) % mod
            ans %= mod
            for b in tree[a]:
                if b not in visited:
                    temp.append(b)
                    visited.add(b)
        cur = temp

    return ans


def quickpow(x, y, mod):
    if y == 0: return 1
    elif y == 1: return x
    elif y % 2 == 0: return pow(quickpow(x, y//2, mod), 2) % mod
    elif y % 2 == 1: return (pow(quickpow(x, y//2, mod), 2) * x) % mod

def factorial(x, mod):
    v = 1
    for i in range(2, x+1):
        v *= i
        v %= mod
    return v

def inv_factorial(x, mod):
    v = factorial(x, mod)
    return quickpow(v, mod-2, mod)


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

N, M = [int(x) for x in input().split(' ')]

As = [int(x) for x in input().split(' ')]
As.sort()

for _ in range(M):
  b, c = [int(x) for x in input().split(' ')]
  for i in range(b):
    if As[i] <= c:
      As[i] = c
    else:
      break
  As.sort()
  
print(sum(As))

### FIXED CODE ###

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

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    
    if a >= c:
      break
    else:
      num += c
      i += 1
      
    if i == len(As):
      break
      
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)
### BUGGY CODE ###

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

attendance = []

for i in range(1, N+1):
    attendance.append(l.index(i)+1)

print(" ".join(map(str, attendance)))


### FIXED CODE ###

N = int(input())
A = map(int, input().split())
L = [0] * N

for i,val in enumerate(A):
    L[val-1] = i + 1

print(*L)
### BUGGY CODE ###

import itertools
N,P = map(int,input().split())
A = list(map(int,input().split()))
even = [a for a in A if a%2==0]
odd = [a for a in A if a%2==1]
ans = 0
if P==0:
    for i in range(len(even)+1):
        tmp1 = len(list(itertools.combinations(even,i)))
        for j in range(0,len(odd)+1,2):
            tmp2 = len(list(itertools.combinations(odd,j)))
            ans += tmp1*tmp2
else:
    for i in range(1,len(odd)+1,2):
        tmp1 = len(list(itertools.combinations(odd,i)))
        for j in range(len(even)+1):
            tmp2 = len(list(itertools.combinations(even,j)))
            ans += tmp1*tmp2
print(ans)

### FIXED CODE ###

N,P = map(int,input().split())
A = list(map(int,input().split()))
for i in A:
    if i%2==1:
        print(2**(N-1))
        exit()
print(0 if P==1 else 2**N)
### BUGGY CODE ###


def resolve():
    n, m = map(int, input().split())
    jobs = []
    for i in range(n):
        days, reward = map(int, input().split())
        jobs.append([reward, days])

    jobs = sorted(jobs, reverse=True)
    res = 0
    # 残りi日の時点でどの仕事をするか
    for i in range(m+1):
        for j in jobs:
            if j[1] <= i:
                res += j[0]
                j[1] = 100001
                break

    print(res)
resolve()

### FIXED CODE ###

from heapq import heappush, heappop

def resolve():
    n, m = map(int, input().split())
    jobs = [[] for _ in range(m+1)]
    for i in range(n):
        days, reward = map(int, input().split())
        if days <= m:
            jobs[days].append(-reward)

    res = 0
    heap = []
    # 残りi日の時点でどの仕事をするか
    for i in range(m+1):
        for j in jobs[i]:
            heappush(heap, j)
        if len(heap) > 0:
            res += -heappop(heap)

    print(res)
resolve()
### BUGGY CODE ###

N,M = map(int,input().split())
for i in range(M//N,0,-1):
    if M%i==0: break
print(i)

### FIXED CODE ###

def solve():
    n,m = map(int,input().split())
    for i in range(m//n,0,-1):
        if m%i==0: break
    print(i)
solve()
### BUGGY CODE ###

K=int(input())
n=len(str(K))
N=int("7"*n)
if K%2==0:
    print(-1)
else:
    while N%K!=0:
        n+=1
        N=N*10+7
        N%=K
    print(n)

### FIXED CODE ###

K=int(input())
n=len(str(K))
N=int("7"*n)
if K%2==0 or K%5==0:
    print(-1)
else:
    while N%K!=0:
        n+=1
        N=N*10+7
        N%=K
    print(n)
### BUGGY CODE ###

A,B = map(int, input().strip().split(' '))
now = A
for i in range(A+1,B+1):
  now ^= i
print(now)

### FIXED CODE ###

A,B = map(int, input().strip().split(' '))

if B-A < 4:
  answer = 0
  for i in range(A,B+1):
    answer ^= i
  print(answer)
  exit()
	
if A%2 == 0:
  head = 0
  left = A
else:
  head = A
  left = A+1

if B%2 == 0:
  tail = B
  right = B-1
else:
  tail = 0
  right = B

body = int(((right-left+1)/2)%2)
  
print(head^body^tail)
### BUGGY CODE ###

n=int(input())
s=input()
print(min(s[:i].count("W")+s[i+1:].count("E")for i in range(n)))

### FIXED CODE ###

from numpy import*
n=int(input())
s=input()
x=[0]+[1 if i=="W" else 0 for i in s]
del x[-1]
y=[1 if i=="E" else 0 for i in s]
print(min(array(cumsum(x))+s.count("E")-array(cumsum(y))))
### BUGGY CODE ###

N, C = list(map(int,input().split()))
x_list = [0]
v_list = []

for i in range(N):
    x, v = list(map(int,input().split()))
    x_list.append(x)
    v_list.append(v)

max_c = 0

# 時計回りスタート
for i in range(N):
#    print("------")
#    print(i)
    c = 0
    x_tmp = x_list.copy()
    v_tmp = v_list.copy()
    for j in range(i):
        c += v_tmp[j]
#        print(v_tmp[j],"を食べた")
        c -= x_tmp[j+1] - x_tmp[j]
#        print(c)
        if max_c < c:
            max_c = c
    
    x_tmp = x_tmp[i:]
    v_tmp = v_tmp[i:]
    
    v_tmp = v_tmp[::-1]
    
    x_tmp = [x_tmp[0]+C] + x_tmp[1:][::-1]
    
#    print(x_tmp)
#    print(v_tmp)
    
    for j in range(N - i):
        c += v_tmp[j]
#        print(v_tmp[j],"を食べた")
        c -= x_tmp[j] - x_tmp[j+1]
#        print(c)
        if max_c < c:
            max_c = c
            
# 反時計回りスタート
# xとvの置き換えることで対応する
x_list = [x_list[0]] + [C-x for x in x_list[1:][::-1]]
v_list = v_list[::-1]
for i in range(N):
#    print("------")
#    print(i)
    c = 0
    x_tmp = x_list.copy()
    v_tmp = v_list.copy()
    for j in range(i):
        c += v_tmp[j]
#        print(v_tmp[j],"を食べた")
        c -= x_tmp[j+1] - x_tmp[j]
#        print(c)
        if max_c < c:
            max_c = c
    
    x_tmp = x_tmp[i:]
    v_tmp = v_tmp[i:]
    
    v_tmp = v_tmp[::-1]
    
    x_tmp = [x_tmp[0]+C] + x_tmp[1:][::-1]
    
#    print(x_tmp)
#    print(v_tmp)
    
    for j in range(N - i):
        c += v_tmp[j]
#        print(v_tmp[j],"を食べた")
        c -= x_tmp[j] - x_tmp[j+1]
#        print(c)
        if max_c < c:
            max_c = c

            
print(max_c)

### FIXED CODE ###

# kopipe
from numpy import array as n

N, C = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(N)]
r1, r2, l1, l2 = [0],[0],[0],[0]
sum = 0
for x, cal in xy:
    sum += cal
    r1.append(max(r1[-1], sum-x))
    r2.append(max(r2[-1], sum-2*x))
sum = 0
for x, cal in xy[::-1]:
    sum += cal
    l1.append(max(l1[-1], sum-C+x))
    l2.append(max(l2[-1], sum-2*(C-x)))
a = max(n(r1)+n(l2[::-1]))
b = max(n(r2)+n(l1[::-1]))
print(max(a,b))
### BUGGY CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(N-1) :
    for k in range(i+1, N):
        if H[i] - H[k] > 1 :
            print('No')
            ans = 1
            exit()
if ans == 0:
    print('Yes')


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
for i in range(N - 1):
    if H[i] < H[i+1] :
        H[i+1] -= 1

    elif H[i] > H[i+1]:
        print('No')
        exit()

print('Yes')
### BUGGY CODE ###

N = int(input())
p = 1
for i in range(N):
    p *= (i+1)
tp = p%((10**9)+7)
print(tp)

### FIXED CODE ###

ans=1
n=int(input())
for i in range(1,n+1):
    ans*=i
    ans=ans%(10**9+7)
print(ans)
### BUGGY CODE ###

import bisect
N, M = map(int, input().split())
P, Y = [], []
pref = [[] for _ in range(N+1)] # non-0-indexed
for m in range(M):
    p,y = map(int, input().split())
    P.append(p)
    Y.append(y)
    pref[p].append(y)

    
for p,y in zip(P,Y):
    ans = "{:0>6}".format(p)
    i = bisect.bisect(sorted(pref[p]), y)
    ans += "{:0>6}".format(i)
    print(ans)

### FIXED CODE ###

import bisect
N, M = map(int, input().split())
P, Y = [], []
pref = [[] for _ in range(N+1)] # non-0-indexed
for m in range(M):
    p,y = map(int, input().split())
    P.append(p)
    Y.append(y)
    pref[p].append(y)

for i,pre in enumerate(pref):
    pref[i] = sorted(pre)

for p,y in zip(P,Y):
    a = "{:0>6}".format(p)
    i = bisect.bisect(pref[p], y)
    a += "{:0>6}".format(i)
    print(a)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
cs = []
q = deque()
s = set()
for h in range(H):
    cs.append(input())
    for w in range(W):
        if cs[h][w] == '#':
            s.add((h+1, w+1))
            q.append((h+1, w+1, 0))
vx = [0, 1, 0, -1]
vy = [1, 0, -1, 0]
ans = 0
while len(s) < H * W:
    y, x, n = q.popleft()
    for i in range(4):
        ny = y + vy[i]
        nx = x + vx[i]
        if ny >= 1 and ny <= H and nx >= 1 and nx <= W:
            if cs[ny-1][nx-1] == '.' and ((ny, nx) not in s):
                s.add((ny, nx))
                q.append((ny, nx, n+1))
                ans = max(ans, n+1)
print(ans)


### FIXED CODE ###

import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
    A.append([0 if i == "#" else H+W for i in list(input())])
A = np.array(A)

for i in range(H-1):
  A[i+1, :] = np.minimum(A[i, :] + 1, A[i+1, :])
for i in range(H-1,0,-1):
  A[i-1,:] = np.minimum(A[i,:]+1,A[i-1,:])
for i in range(W-1):
  A[:,i+1] = np.minimum(A[:,i]+1,A[:,i+1])
for i in range(W-1,0,-1):
  A[:,i-1] = np.minimum(A[:,i]+1,A[:,i-1])
print(np.max(A))
### BUGGY CODE ###

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

ret = 1
for i in range(1, len(p)):
    if min(p[:i]) > p[i]:
        ret +=1
print(ret) 

### FIXED CODE ###

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

ret = 0
c_min = 2e5

for i in p:
    if c_min >= i:
        c_min = i
        ret+=1
print(ret)
### BUGGY CODE ###

N, K = map(int, input().split())
for i in range(10**9):
    if N > K** i and N < K**(i+1):
        print(i+1)
        break

### FIXED CODE ###

N, K = map(int, input().split())
i = N/K
cnt = 1
while i >= 1:
    i = i/K
    cnt += 1
print(cnt)
### BUGGY CODE ###

N = int(input())
L = [1,2,4,8,16,32,64]
while N > 1:
  if N in L:
    print(N)
  else:
    N = N - 1
print(1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
x = 1
while N >= 2**x:
  x = x+1
  
print(2 ** x //2)
### BUGGY CODE ###

from fractions import gcd
def lcm(a,b):
    return(a*b//gcd(a,b))

N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

value=A[0]
for i in range(1,N):
    value=lcm(value,A[i])

count=0
for a in A:
    count+=(value//a)%mod
    count%=mod
print(count)


### FIXED CODE ###

mod=10**9+7
ferumaC=300000
fac=[0 for i in range(ferumaC)]
fac[0]=1
ifac=[0 for i in range(ferumaC)]
ifac[0]=1
def mpow(x,n):
    num=1
    while n > 0:
        if n&1:
            num=num*x%mod
        x=x*x%mod
        n=n>>1
    return(num)

for i in range(0,ferumaC-1):
    fac[i+1]=(fac[i]*(i+1))%mod
    ifac[i+1]=ifac[i]*mpow(i+1,mod-2)%mod
def comb(a,b):
    if a==0 and b==0:return(1)
    if a<b or a<0:return(0)
    tmp=ifac[a-b]*ifac[b]%mod
    return(tmp*fac[a]%mod)


from fractions import gcd
def lcm(a,b):
    return(a*b//gcd(a,b))

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

value=A[0]
for i in range(1,N):
    value=lcm(value,A[i])
value%=mod
count=0
for a in A:
    count+=value*(mpow(a,mod-2))%mod
    count%=mod
print(count)
### BUGGY CODE ###

n = int(input())
s = input()
s_list = list(s)
ans = 0
total = s_list.count("R") * s_list.count("G") * s_list.count("B")
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if j - i == k - j:
                if (s_list[i] != s_list[j]) and (s_list[j] != s_list[k]) and (s_list[k] != s_list[i]):
                    ans +=1
print(total - ans)

### FIXED CODE ###

n = int(input())
s = input()
s_list = list(s)
ans = 0
total = s_list.count("R") * s_list.count("G") * s_list.count("B")
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + j - i
        if n >= k + 1:
            if (s_list[i] != s_list[j]) and (s_list[j] != s_list[k]) and (s_list[k] != s_list[i]):
                ans += 1
print(total - ans)
### BUGGY CODE ###

n = int(input())
num_list = []

for _ in range(n):
    cmd = (input().split())
    if   cmd[0] == 'insert':
        num_list.insert(0,cmd[1])
    elif cmd[0] == 'delete':
        if cmd[1] in num_list:
            idx = num_list.index(cmd[1])
            del(num_list[idx])
    elif cmd[0] == 'deleteFirst':
        del(num_list[0])
    elif cmd[0] == 'deleteLast':
        num_list.pop()

print(' '.join(num_list))


### FIXED CODE ###

from collections import deque
dq = deque()
for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b)
print(" ".join(dq))
### BUGGY CODE ###

import collections

N = int(input())
S = input()
tonum = {"R": 0, "G": 1, "B": 2}
ans = 0
for i in range(1, N - 1):
    d = tonum[S[i]]
    c2 = collections.Counter()
    for j in range(i + 1, N):
        c2[tonum[S[j]]] += 1
    for j in range(i):
        dj = tonum[S[j]]
        if dj == d:
            continue
        dk = 3 - d - dj
        ans += c2[dk]
        kk = i + (i - j)
        if kk < N and tonum[S[kk]] == dk:
            ans -= 1
print(ans)


### FIXED CODE ###

import collections

N = int(input())
S = input()
tonum = {"R": 0, "G": 1, "B": 2}
ans = 0
for i in range(1, N - 1):
    d = tonum[S[i]]
    c2 = collections.Counter()
    for j in range(i + 1, N):
        c2[tonum[S[j]]] += 1
    for j in range(i):
        dj = tonum[S[j]]
        if dj == d:
            continue
        dk = 3 - d - dj
        ans += c2[dk]
        kk = i + (i - j)
        if kk < N and tonum[S[kk]] == dk:
            ans -= 1
print(ans)
### BUGGY CODE ###

D = input().split(' ')
N = int(D[0])
M = int(D[1])
D2 = input().split(' ')

A = []
for i in D2:
  A.append(int(i))

A.sort(reverse=True)

used = 0
n = 0

while True:
  A[0] = int(A[0] / 2)
  k = 0
  for k in range(N - 1):
    if A[k] < A[k + 1]:
      tmp = A[k]
      A[k] = A[k + 1]
      A[k + 1] = tmp
    else:
      break
      
  used = used + 1
  if used == M:
    break

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

### FIXED CODE ###

D = input().split(' ')
N = int(D[0])
M = int(D[1])
D2 = input().split(' ')

A = []
for i in D2:
  A.append(int(i))

A.sort(reverse=True)

used = 0

while True:
  max = A[0]
  n = 0
  while True:
    if A[n] >= int(max / 2):
      A[n] = int(A[n] / 2)
      used = used + 1
    else:
      break
      
    n = n + 1

    if n == N or used == M:
      break
      
  if used == M:
    break
    
  A.sort(reverse=True)
    
sum = 0
for i in range(N):
  sum = sum + A[i]
  
print(sum)
### BUGGY CODE ###

from heapq import heapify, heappush, heappop
N = 4
m = {0: {1, 4}, 1: {0, 2, 5}, 2: {1, 3, 6}, 3: {2, 7},
     4: {0, 5, 8}, 5: {1, 4, 6, 9}, 6: {2, 5, 7, 10}, 7: {3, 6, 11},
     8: {4, 9, 12}, 9: {5, 8, 10, 13}, 10: {6, 9, 11, 14}, 11: {7, 10, 15},
     12: {8, 13}, 13: {9, 12, 14}, 14: {10, 13, 15}, 15: {11, 14}}
goal = 0x123456789abcdef0
def g(i, j, a):
    t = (a >> 4 * j) % 16
    return a - (t << 4 * j) + (t << 4 * i)
def solve():
    MAP = sum((input().split() for _ in range(N)), [])
    start = int("".join(f"{int(i):x}" for i in MAP), base=16)
    if start == goal:
        return 0
    zero = 15 - MAP.index("0")
    dp = [(0, start, zero)]
    TABLE = {start}
    while dp:
        cnt, M, yx = heappop(dp)
        if M == goal:
            return cnt
        cnt += 1
        for nyx in m[yx]:
            key = g(yx, nyx, M)
            if key in TABLE:
                continue
            TABLE.add(key)
            if cnt > 45:
                continue
            heappush(dp, (cnt, key, nyx))
def MAIN():
    print(solve())
MAIN()



### FIXED CODE ###

from heapq import heappop, heappush
manhattan = tuple(tuple(abs((i % 4) - (j % 4)) + abs((i // 4) - (j // 4)) for j in range(16)) for i in range(16))
movables = ((1, 4), (0, 2, 5), (1, 3, 6), (2, 7), (0, 5, 8), (1, 4, 6, 9), (2, 5, 7, 10), (3, 6, 11),
            (4, 9, 12), (5, 8, 10, 13), (6, 9, 11, 14), (7, 10, 15), (8, 13), (9, 12, 14), (10, 13, 15), (11, 14))
swap_mul = tuple(tuple((1 << mf) - (1 << mt) for mt in range(0, 64, 4)) for mf in range(0, 64, 4))
destination = 0xfedcba9876543210
i = 0
board_init = 0
blank_init = 0
for _ in range(4):
    for n in map(int, input().split()):
        if n:
            n -= 1
        else:
            n = 15
            blank_init = i
        board_init += n * 16 ** i
        i += 1
estimation_init = sum(manhattan[i][((board_init >> (4 * i)) & 15)] for i in range(16) if i != blank_init)
queue = [(estimation_init, board_init, blank_init)]
visited = set()
while True:
    estimation, board, blank = heappop(queue)
    if board in visited:
        continue
    elif board == destination:
        print(estimation)
        break
    visited.add(board)
    for new_blank in movables[blank]:
        num = (board >> (4 * new_blank)) & 15
        new_board = board + swap_mul[new_blank][blank] * (15 - num)
        if new_board in visited:
            continue
        new_estimation = estimation + 1 - manhattan[new_blank][num] + manhattan[blank][num]
        if new_estimation > 45:
            continue
        heappush(queue, (new_estimation, new_board, new_blank))