Harryxun/stf_run huggingface dataset:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,K=map(int,input().split())

A=list(map(int,input().split()))
mod=10**9+7
Am=[-i for i in A if i<0]
Ap=[i for i in A if i>=0]

Am.sort()
Ap.sort()
Am=deque(Am)
Ap=deque(Ap)



if N==K:
    c=1
    for a in A:
        c*=a
        c%=mod

elif len(Ap)==0 and K%2:
    c=1
    while K :
        c*=Am.popleft()

        K-=1
        c=-c
        c%=mod
    #print("unko")

else:
    #print(unko)
    c=1
    h=0
    w=0
    a="unko"
    b="unko"
    while K and (Am or Ap) :
        if Am and Ap:
            if Am[-1]>Ap[-1]:

                a=Am.pop()
                c*=a
                h+=1
            else:

                b=Ap.pop()
                c*=b

        elif Am:
            a=Am.pop()
            c*=a
            h+=1
        elif Ap:
            b=Ap.pop()
            c*=b
        K-=1
        c%=mod
    if h%2:
        if Am and Ap and a!="unko" and b!="unko":
            if Am[-1]*a>Ap[-1]*b:
                a=Am.pop()
                c*=a
                c*=pow(b,mod-2,mod)
            else:
                b=Ap.pop()
                c*=b
                c*=pow(a,mod-2,mod)
        if Am:
            a=Am.pop()
            c*=a
            c*=pow(b,mod-2,mod)
        else:
            b=Ap.pop()
            c*=b
            c*=pow(a,mod-2,mod)


print(c%mod)


### FIXED CODE ###

from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,K=map(int,input().split())

A=list(map(int,input().split()))
mod=10**9+7
Am=[-i for i in A if i<0]
Ap=[i for i in A if i>=0]

Am.sort()
Ap.sort()
Am=deque(Am)
Ap=deque(Ap)



if N==K:
    c=1
    for a in A:
        c*=a
        c%=mod

elif len(Ap)==0 and K%2:
    c=1
    while K :
        c*=Am.popleft()

        K-=1

        c%=mod
    c=-c
    c%=mod
    #print("unko")

else:
    #print(unko)
    c=1
    h=0
    a="unko"
    b="unko"
    while K and (Am or Ap) :
        if Am and Ap:
            if Am[-1]>Ap[-1]:

                a=Am.pop()
                c*=a
                h+=1
            else:

                b=Ap.pop()
                c*=b

        elif Am:
            a=Am.pop()
            c*=a
            h+=1
        elif Ap:
            b=Ap.pop()
            c*=b
        K-=1
        c%=mod

    if h%2:
        if Am and Ap and a!="unko" and b!="unko":
            if Am[-1]*a>Ap[-1]*b:
                a=Am.pop()
                c*=a
                c*=pow(b,mod-2,mod)
            else:
                b=Ap.pop()
                c*=b
                c*=pow(a,mod-2,mod)
        elif Am and b!="unko":
            a=Am.pop()
            c*=a
            c*=pow(b,mod-2,mod)
        else:
            b=Ap.pop()
            c*=b
            c*=pow(a,mod-2,mod)


print(c%mod)
a,b,c = list(map(lambda int: input().split(' '))
print(c-a+b)

### FIXED CODE ###

a,b,c = list(map(int, input().split(' ')))
print(max(0, c-a+b))
A,B=map(int,input().split())

if A=>1 and A<=9 and B=>1 and B<=9:
  print(A*B)
else:
  print(-1)

### FIXED CODE ###

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

if A>=1 and A<=9 and B>=1 and B<=9:
  print(A*B)
else:
  print(-1)
def main():
    S = input()
    N = len(S)
    S = int(S)
    work, temp = 0, [0] * 2019, 0
    for i in range(N+1): work[(S % 10**i) % 2019] += 1
    print(sum([w*(w-1)//2 for w in work]))
main()

### FIXED CODE ###

def main():
    S = input()
    work, temp = [0] * 2019, 0
    work[0] = 1
    a = 1
    for s in S[::-1]:
        temp += int(s) * a
        work[temp%2019] += 1
        a *= 10
        a %= 2019
    print(sum([w*(w-1)//2 for w in work]))
main()
r = int(input())
r = A * B
print(r)

### FIXED CODE ###

a,b = map(int, input().split())
r = a * b
print(r)
n = input()
p = list(map(int, input().split()))

dif = []
for i in range(1,n+1):
  if p[i-1] != i:
    dif.append(i)

if len(dif) == 0 or len(dif) == 2:
  print('YES')
else:
  print('NO')
    

### FIXED CODE ###

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

dif = []
for i in range(1,n+1):
  if p[i-1] != i:
    dif.append(i)

if len(dif) == 0 or len(dif) == 2:
  print('YES')
else:
  print('NO')
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

X2 = X[::-1]
Y2 = Y1[::-1]


def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))


if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    cn = (N + 1) // 200
    len1 = [0] * cn
    len2 = [0] * cn
    can1 = [0] * cn
    can2 = [0] * cn
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        ans = max(ans, len1[i], len2[i])

    for n, len_ in enumerate(len1):
        if len_ + 50 * L > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y1), ans)

    for n, len_ in enumerate(len2):
        if len_ + 50 * L > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y2), ans)
    print(ans)

### FIXED CODE ###

import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
X2 = L - X[::-1]
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]
Z = np.concatenate((np.arange(N, -1, -2), np.arange(N - 1, -1, -2)[::-1]))


def myfunc(n, x):
    return x[n + (N - n + 1)//2 - 1] - 2 * x[n - 1] - (L - x[N - (N - n + 1)//2])


len1 = np.dot(Z, Y1)
len2 = np.dot(Z, Y2)
x1 = X.tolist()
x2 = X2.tolist()
ans = max(len1, len2)
for n in range(1, (N + 1) // 2):
    len1 += myfunc(n, x1)
    len2 += myfunc(n, x2)
    ans = max(ans, len1, len2)

print(ans)
def solve(n, m, h, a, b):
    for j in range(m):
        a[j] -= 1
        b[j] -= 1
    parents = [i for i in range(n)]
    def root(x):
        return x if parents[x] == x else root(parents[x])

    for a_j, b_j in zip(a, b):
        if root(a_j) != root(b_j):
            if a_j > b_j:
                a_j, b_j = b_j, a_j
            parents[root(b_j)] = root(a_j)

    D = {}
    for j, pj in enumerate(parents):
        if not pj in D:
            D[pj] = []
        D[pj].append(h[j])
    ans = 0
    for k, v in D.items():
        if len(v) == 1:
            ans += 1
        else:
            v = sorted(v)
            ans += int(v[-1] > v[-2])
    return ans

n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for j in range(m):
    a[j], b[j] = map(int, input().split())
print(solve(n,m, h, a, b))

### FIXED CODE ###

def solve(n, m, h, a, b):
    for j in range(m):
        a[j] -= 1
        b[j] -= 1
    E = {i:[] for i in range(n)}
    for x, y in zip(a, b):
        E[x].append(y)
        E[y].append(x)
    ans = 0
    for i in range(n):
        ok = True
        for j in E[i]:
            if h[i] <= h[j]:
                ok = False
        ans += ok
    return ans
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for j in range(m):
    a[j], b[j] = map(int, input().split())
print(solve(n,m, h, a, b))
array1 = [int(input()) for i in range(5)]
array2 = [i for i in array1 if i % 10 == 0]
array3 = [i for i in array1 if i % 10 =! 0]
array4 = [i % 10 for i in array3]
sum1 = 0
sum2 = sum(array2)
if (len(array3) != 0):
  idx = array4.index(min(array4))
  for k, i in enumerate(array3):
    if (k == idx):
      sum1 += i
    else:
      sum1 += i + (10 - i % 10)
  print(sum1 + sum2)

### FIXED CODE ###

array1 = [int(input()) for i in range(6)]
array2 = array1[:5]
k = array1[5] 
 
for i in range(5):
  if (i < 4 and array2[4 - i] - array2[0] > k):
    print(':(')
    break
  if (i < 3 and array2[4 - i] - array2[1] > k):
    print(':(')
    break
  if (i < 2 and array2[4 - i] - array2[2] > k):
    print(':(')
    break
  if (i < 1 and array2[4 - i] - array2[3] > k):
    print(':(')
    break
  if (i == 4):
    print('Yay!')
if A = 5 and B = 5 and C = 7:
  print("YES")
  
elif A = 5 and B = 7 and C = 5:
  print("YES")
  
elif A = 7 and B = 5 and C = 5:
  print("YES")
  
else:
  print("NO")
  
  
  
  

### FIXED CODE ###

line = input().split()

cnt5 = line.count("5")
cnt7 = line.count("7")

if cnt5 == 2 and cnt7 == 1:
    print("YES")
else:
    print("NO")
A, op, B = intput().split()
if str(op) == "+" :
  print(int(A) + int(B))
else :
  print(int(A) - int(B))

### FIXED CODE ###

A, op, B = input().split()
if str(op) == "+" :
  print(int(A) + int(B))
else :
  print(int(A) - int(B))
n = int(input())
pr = list(map(int,input().split()))
#print(pr)
m = int(input())
f = lambda:map(int,input().split())
for i in range(m):
  n, d = f()
  #print(n,d)
  mot = pr[n-1]
  pr[n-1] = d
  print(sum(pr))
  pr[n-1] = mot

### FIXED CODE ###

a, p, b = map(str,input().split())
print(int(a)+int(b) if p == '+' else int(a)-int(b))
import sys

def jump(k: int, h, res):
    if ( k == 0 ):
        return 0

    if ( res[k] == -1 ):
        res[k] = jump(k - 1, h, res) + abs(h[k] - h[k - 1])
        if k >= 2:
            res[k] = min(res[k], jump(k - 2, h, res) + abs(h[k] - h[k - 2]))

    return res[k]


def main():
    #lines = []
    #for line in sys.stdin:
    #    lines.append([int(i) for i in line.strip().split(' ')])

    #n = int(lines[0][0])
    #h = lines[1]
    n = int(input())
    h = list(map(int, input().split(" ")))

    res = [ -1 ] * len(h)
    print(jump(n-1, h, res))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def calc_cost(h):
    if (len(h) == 0):
        return 0

    cost = [None] * len(h)
    cost[0] = 0
    for i in range(1, len(h)):
        cost[i] = cost[i-1] + abs(h[i] - h[i-1])
        if i>1:
            cost[i] = min(cost[i], cost[i-2] + abs(h[i] - h[i-2]))

    return cost[len(h)-1]

if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(" ")))
    res = calc_cost(h)
    print(res)
import sys
sys.setrecursionlimit(10000000000)
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
inf=1000000000000000
d=[[inf]*w for i in range(h)]


def dfs(i,j):
    global h,w,s
    nex=[(0,-1),(0,1),(-1,0),(1,0)]
    for k in range(4):
        l,m=i+nex[k][0],j+nex[k][1]
        if 0<=i+nex[k][0]<h and 0<=j+nex[k][1]<w:
            if s[l][m]=="." and d[l][m]>d[i][j]+1:
                d[l][m]=d[i][j]+1
                dfs(l,m)
d[0][0]=0
dfs(0,0)
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ans+=1

print(ans-d[h-1][w-1]-1)




### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)
c = 0

for i in range(max(A),1,-1):
    c = 0

    for j in A:
        if j % i != 0:
            c = c + 1
            if c >= 2:
                break
    else:
        if c <= 1:
            break
print(i)


### FIXED CODE ###

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

w_min = A[1]

for i in range(w_min,0,-1):
    count = 0
    for j in A:
        if j%i != 0:
            count = count + 1
            if count > 1:
                break
    if count < 2:
        print(i)
        break
import math

a, b = map(int, input().split())
c = math.gcd(a, b)
print(a*b//c)


### FIXED CODE ###

import fractions

a, b = map(int, input().split())
c = fractions.gcd(a, b)
print(a*b//c)
N = int(input())
a = [int(input()) for _ in range(N)]

button = 0
for i in range(1,N+1):
    button = a[a[button]]
    if button == 2:
        print(i)
else:
    print(-1)

### FIXED CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]

button = 1
for i in range(N):
    if button == 2:
        print(i)
        break
    button = a[button-1]
    
else:
    print(-1)
n = int(input())
s = input()
b = ""
ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(int(len(s))):
    for j in range(int(len(ab))):
        if (s[i] == ab[j]):
            if (int(j+n) > 25):
                b += ab[j+n-25]
                break
            else:
                b += ab[j+n]
                break

print(b)


### FIXED CODE ###

n = int(input())
s = input()
b = ""
ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(int(len(s))):
    for j in range(int(len(ab))):
        if (s[i] == ab[j]):
            if (int(j+n) > 25):
                b += ab[j+n-26]
                break
            else:
                b += ab[j+n]
                break

print(b)
import numpy as np

n,m = map(int,input().split())
list_a = list(map(int,input().split()))
#b_list = list(map(int,input().split()))
#print(" ".join(map(str,c_list)))
list_a.sort(reverse = True)
a_max = list_a[0] // 2
list_a[0] = a_max
count = 2
for i in range(m-1):
    if list_a[np.argmax(list_a[0:count])] < list_a[count]:
        #print(list_a[np.argmax(list_a[0:count])],list_a[count])
        list_a[count] = list_a[count] // 2 
        count += 1
    else:
        list_a[np.argmax(list_a[0:count])] = list_a[np.argmax(list_a[0:count])] // 2
        #print(list_a[np.argmax(list_a[0:count])])
    
print(sum(list_a))
"""
for i in range(m):
    count = 0
    while count == 0:

        for j in range(n):
            
            if list_a[j] > a_max:
                list_a[j] = list_a[j]//2
                a_max = a_max//2
                count = 1 
                print("c=1")
                print(a_max)
                print(list_a)
                break
        if count == 0:
            a_max -= 1
            print("c=0")
    
print(list_a)
"""

### FIXED CODE ###

import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    loop = 0
    #temp2 = temp
    temp = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        lst_a[loop] //= 2
        cnt += 1
        temp = max(temp,lst_a[loop])
        if cnt == m:
            #print(lst_a)
            print(sum(lst_a))
            sys.exit()
        if temp > max(lst_a[loop],lst_a[loop + 1]):
            break
        if lst_a[loop + 1] > lst_a[loop]:
            loop += 1
        
        
        
"""        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))
"""
from decimal import Decimal

X = int(input())

money = 100
cnt = 0

while money < X:
    money = Decimal(money*1.01)
    cnt += 1
print(cnt)

### FIXED CODE ###

X = int(input())

money = 100
cnt = 0

while money < X:
    money += money//100
    cnt += 1
print(cnt)
n,a=map(int,input().split())
if n//500>a:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

n=int(input())
a=int(input())

if n%500>a:
    print("No")
else:
    print("Yes")
N, M, C = map(int, input().split())
B=list(map(int, input().split))
for i in range(N):
  A=list(map(int, input().split))
  for j in range(M):
    sum=sum(B[j]*A[j])
  if sum+C>0:
  answer+=1
print(answer)


### FIXED CODE ###

N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    p=C
    for j in range(M):p+=A[j]*B[j]
    if p>0:count+=1
print(count)
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP=P,s=2):
    for i in range(s,lim+1):
        if newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP //= i
            s = i
            break
    
        if newP < i or i == lim+1:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
    my(N,newP,s)

my(N)

### FIXED CODE ###

N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP):
    for i in range(2,lim+1):
        while newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP = newP // i
        if newP < i or i == lim:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
my(N,P)
n=int(input())
a=[0]*n
sum=0
for i in range(n):
 a[i]= int(input())
 sum=sum+a[i]
a.sort()

print'%d,%d,%d'%(a[0],a[n-1],sum)

### FIXED CODE ###

int(input())
x=map(int,raw_input().split())
print min(x),max(x),sum(x)
S = raw_input()
t = ['dreamer','dream','eraser','erase']
while len(S) > 0:
    for i in t:
        if S[S.rfind(i):]==i:
            S = S[:S.rfind(t)]
            continue
        elif i == t[-1]:
            print "NO"
            exit()
print "YES"

### FIXED CODE ###

S = raw_input().split()[0]
t = ['dreameraser','dreamerase','dreamer','dream','eraser','erase']
while len(S) > 0:
    for i in t:
        if S[-len(i):]==i:
            S = S[:-len(i)]
            break
        elif i == t[-1]:
            print "NO"
            exit()
print "YES"
SS = input()
T = input()

L_S = len(SS)
L_T = len(T)

COND = 0
for i in range(L_S-L_T+1):
	cond = 1
	t = ('?' * i) + T + ('?' * (L_S-L_T-i))

	ans = ''
	for j in range(L_S):
		if SS[j] == '?' and t[j] == '?':
			ans += 'a'
			
		elif SS[j] == '?' and t[j] != '?':
			ans += t[j]
		elif SS[j] != '?' and t[j] == '?':
			ans += SS[j]
		else:
			if SS[j] != t[j]:
				cond = 0
				ans = ''
				break
			else:
				ans += t[j]

	if cond == 0:
		continue
	else:
		break

if ans == '':
	print('UNRESTORABLE')
else:
	print(ans)

### FIXED CODE ###

SS = input()
T = input()
ans = "z"*(len(SS)+1)

for i in range(len(SS) - len(T) + 1):
	temp = "?"*i + T + "?"*(len(SS)-i-len(T))
	cond = True
	for i in range(len(SS)):
		if SS[i] == "?" or temp[i] == "?":
			continue
		else:
			if SS[i] != temp[i]:
				cond = False
	if cond:
		temp_2 = []
		for i in range(len(SS)):
			if SS[i] == "?" and temp[i] == "?":
				temp_2.append("a")
			elif SS[i] == "?" and temp[i] != "?":
				temp_2.append(temp[i])
			else:
				temp_2.append(SS[i])
		temp_3 = "".join(temp_2)
		if temp_3 <= ans:
			ans = temp_3

if ans == "z"*(len(SS)+1):
	print("UNRESTORABLE")
else:
	print(ans)
a,b =map(int.(i) for i in input.split())
if a > b:
 print("a > b")
elif  a == b:
 print("a == b")
else : 
 print("a < b")


### FIXED CODE ###

a,b =map(int, input().split())
if a > b:
 print("a > b")
elif  a == b:
 print("a == b")
else : 
 print("a < b")
A = []
n = input()

for i in range(n):
    command = [0, 0]
    temp = raw_input().split()
    command[0] = temp[0]
    command[1] = int(temp[1])

    if command[0] == "insert":
        A.insert(0, command[1])
    elif command[0] == "delete":
        A.remove(command[1])
    elif command[0] == "deleteFirst":
        A.pop(0)
    elif command[0] == "deleteLast":
        A.pop()

print A

### FIXED CODE ###

A=[]
fp =0
bp =0
n=int(raw_input())
while n: 
    cmd = raw_input()
    if cmd[0] == 'i':
        A.append(int(cmd[7:]))
        fp += 1
    elif cmd[6] == ' ':
        try:
            i = A[::-1].index(int(cmd[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif cmd[6] == 'F':
        A.pop()
        fp -=1
    elif cmd[6] == 'L':
        bp +=1
    n -=1
 
for k in A[bp:fp+1][::-1]:
    print int(k),
Number= list(map(int, input().split()))
Number.sort()
if Number[0] == Number[1]:
    print(sum(Number))
else:
    print(f'{Number[1]*2 -1}')

### FIXED CODE ###

Number= list(map(int, input().split()))
Number.sort()
if Number[0] == Number[1]:
    print(sum(Number))
else:
    print(Number[1]*2 -1)
N, K = map(int, input().split())
A = list(map(int,input().split()))
P = 0
Q = [0] + [1 for _ in range(N-1)]
R = [-1] + [0 for _ in range(N-1)]
L = 0
for i in range(K):
    P = A[P]-1
    if Q[P] == 0:
        L = i - R[P]
        break
    if Q[P] == 1:
        R[P] = i
        Q[P] = 0
S = (K - R[P] - 1) % L
G = 0
for j in range(S + R[P] + 1):
    G = A[G]-1
print(G+1)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int,input().split()))
P = 0
Q = [0] + [1 for _ in range(N-1)]
R = [-1] + [0 for _ in range(N-1)]
L = 0
for i in range(K):
    P = A[P]-1
    if Q[P] == 0:
        L = i - R[P]
        S = (K - R[P] - 1) % L
        G = 0
        for j in range(S + R[P] + 1):
            G = A[G]-1
        print(G+1)
        exit()
    if Q[P] == 1:
        R[P] = i
        Q[P] = 0
print(P+1)
from sys import stdin


def sortFirst(val):
    return val[0]
N=stdin.readline().rstrip()
N=int(N)
l={}
for i in range(1,N+1):
    S,P = stdin.readline().rstrip().split()
    if S in l.keys():
        l[S].append([int(P),i])

    else:
        l[S]=[[int(P),i]]


for key in l.keys():
    l[key].sort(key=sortFirst,reverse=True)
for key in sorted(l):
    for val in l[key]:
        print "%d"%(val[1])


### FIXED CODE ###

from sys import stdin


def sortFirst(val):
    return val[0]
N=stdin.readline().rstrip()
N=int(N)
l={}
for i in range(1,N+1):
    S,P = stdin.readline().rstrip().split()
    if S in l.keys():
        l[S].append([int(P),i])

    else:
        l[S]=[[int(P),i]]


for key in l.keys():
    l[key].sort(key=sortFirst,reverse=True)
for key in sorted(l):
    for val in l[key]:
        print(val[1])
n = int(input())
a, b, c = map(int, input().split())

i = 0
while True:
    a_ans = divmod(a, 2)
    b_ans = divmod(b, 2)
    c_ans = divmod(c, 2)
    if a_ans[1] == 0 and b_ans[1] == 0 and c_ans[1] == 0 and a !=0 and b !=0 and c !=0:
        i += 1
        a = a_ans[0]
        b = b_ans[0]
        c = c_ans[0]
    else:
        break
print(i)

### FIXED CODE ###

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

i = 0
per = True
while per == True:
    for index in range(n):
        num = a[index]
        ans = divmod(num, 2)
        if num == 0 or ans[1] != 0:
            per = False
            break
        a[index] = ans[0]
    if per == True:
        i += 1
print(i)