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

import heapq
def SME(start,end):

    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
  
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.998
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

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

l = sorted(a[:N])
r = sorted(a[N:])

lsum = sum(l)
rsum = sum(r[:N])

import bisect

ans = lsum - rsum
for i in range(N):
    c = a[N+i]
    li = bisect.bisect_left(l, c)
    ri = bisect.bisect_left(r, c)
    if li > 0: 
        lsum = lsum + c - l[0]
        l.insert(li, c)
        del l[0]
    if ri < N:
        rsum = rsum - c + r[N]
    del r[ri]
    ans = max(ans, lsum - rsum)

print(ans)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
 
import heapq

left = [0]*(N+1)
l = a[:N]
left[0] = sum(l)

heapq.heapify(l)
for i in range(1, N+1):
    c = a[N+i-1]    
    lmin = heapq.heappop(l)
    if lmin < c:
        left[i] = left[i-1] + c - lmin
        heapq.heappush(l, c)
    else:
        left[i] = left[i-1]
        heapq.heappush(l, lmin)

a = [-x for x in a[::-1]]
right = [0]*(N+1)
r = a[:N]
right[0] = sum(r)

heapq.heapify(r)
for i in range(1, N+1):
    c = -a[N+i-1]    
    rmax = -heapq.heappop(r)
    if rmax > c:
        right[i] = right[i-1] - c + rmax
        heapq.heappush(r, -c)
    else:
        right[i] = right[i-1]
        heapq.heappush(r, -rmax)

ans = -10**20
for i in range(N+1):
    ans = max(ans, left[i] + right[N-i])

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

from collections import deque
n,m = map(int,input().split())

maze = [list(input()) for _ in range(n)]

def bfs():
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)
    d = [([-1]*m)for _ in range(n)]
    q = deque([])
    for i in range(n):
        for j in range(m):
            if maze[i][j] == "#":
                d[i][j] = 0
                q.append((i,j))


    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0<= nx < n and 0<= ny < m and maze[nx][ny] != '#' and d[nx][ny] == -1:
                q.append((nx,ny))
                d[nx][ny] = d[x][y] +1
    return max(sum(d,[]))

print(bfs())

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())

maze = [list(input()) for _ in range(n)]

def bfs():
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)
    d = [([-1]*m)for _ in range(n)]
    q = deque([])
    for i in range(n):
        for j in range(m):
            if maze[i][j] == "#":
                d[i][j] = 0
                q.append((i,j))
    a = 0

    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0<= nx < n and 0<= ny < m and maze[nx][ny] != '#' and d[nx][ny] == -1:
                q.append((nx,ny))
                d[nx][ny] = d[x][y] +1
                a = max(a,d[nx][ny])
    return a

print(bfs())
### BUGGY CODE ###

n,m = map(int,input().split())
A = list(map(int, input().split()))
for i in range(m):
    A.sort()
    b,c = map(int,input().split())
    for j in range(b):
        if A[j]<c:
            A[j]=c
        else:
            break
print(sum(A))


### FIXED CODE ###

n,m = map(int,input().split())
A = list(map(int, input().split()))
BC = []
for i in range(m):
    b,c = map(int, input().split())
    BC.append([c,b])
A.sort()
BC=sorted(BC, key=lambda x :x[0])
BC.reverse()
ans = sum(A)
cnt=0
for i in range(m):
    for j in range(cnt,BC[i][1]+cnt):
        if BC[i][0]>A[j]:
            ans+=BC[i][0]-A[j]
            cnt+=1
            if j==n-1:
                print(ans)
                exit()
        else:
            break
print(ans)
### BUGGY CODE ###

import numpy as np
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
np_a = np.array(A)

ng_count = 0

for a in A:
    # 自分は必ず割り切れる 他にいたら 0が2以上になるはず
    if np.count_nonzero(a % np_a == 0) > 1:
        ng_count += 1

print(N - ng_count)


### FIXED CODE ###

import numpy as np
from collections import Counter
from math import sqrt
from time import time


def main():
    N = int(input())
    np_a_o = list([int(x) for x in input().split()])
    np_a = Counter(np_a_o)

    np_a_keys = set(np_a.keys())

    div_list = set()
    key_max = max(np_a_keys)

    c = 0

    for key in np_a_keys:
        for div in range(key*2, key_max+1, key):
            div_list.add(div)

    r = np_a_keys - div_list

    u, count = np.unique(np.array(np_a_o), return_counts=True)
    r -= set(u[count > 1])

    print(len(r))


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

n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    for j in range(i,n):
        ans += a[i] ^ a[j]
        ans %= 10**9 +7

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = str(bin(a[i]))

ans = [0] * 65
for i in a:
    for j in reversed(range(len(i))):
        if i[j] == '1':
            ans[-len(i)+j] += 1
        elif i[j] == '0':
            continue
        elif i[j] == 'b':
            break

tmp = 0
for i in range(len(ans)):
    tmp += 2 ** abs(i - 64) * (n - ans[i]) * ans[i]
    #print(i,2 ** abs(i - 64) * (n - ans[i]) * ans[i])
    tmp %= 10**9+7

print(tmp)
### BUGGY CODE ###

S = input()
c = 0
while True:
    c += S.count("BW")
    replaced = S.replace("BW", "WB")
    if replaced == S:
        break
    else:
        S = replaced
print(c)

### FIXED CODE ###

S = input()
c = 0
current_B_counter = 0
for s in S:
    if s == "B":
        current_B_counter += 1
    if s == "W":
        c += current_B_counter

print(c)
### BUGGY CODE ###

def check(mp):
  for i in range(n):
    for j in range(i, n):
      if mp[i][j] != mp[j][i]: return 0
  return 1

n = int(input())
mp = [input() for _ in range(n)]
ans = 0
for a in range(n):
  mp.insert(0, mp.pop())
  for b in range(n):
    for y in range(n):
      mp[y] = mp[y][-1] + mp[y][:-1]
    ans += check(mp)
print(ans)


### FIXED CODE ###

from collections import deque


def main():
  def check(mp):
    for i in range(n):
      for j in range(i, n):
        if mp[i][j] != mp[j][i]: return 0
    return 1
  n = int(input())
  mp = deque([deque(list(input())) for _ in range(n)])
  ans = 0
  for a in range(n):
    mp.rotate()
    ans += check(mp)
  print(ans * n)
  
main()
### BUGGY CODE ###

N = int(input())
S = list(input())

sum = 0
for i in range(N-2):
    for j in range(i+1,N):
        for k in range(j+1, N):
#            print(i, j, k)
            if S[i] == S[j] or S[j] == S[k] or S[i] == S[k]:
                continue
            elif j - i == k - j:
                continue
            else:
                sum += 1

print(sum)

### FIXED CODE ###

N = int(input())  #数字
S = list(input()) #スペース抜きの複数行,１文字ずつ

cou = 0

for i in range(0,N):
    j = 1
    while i + (2 * j) <= N-1:
        if S[i] != S[i + j] and S[i + j] != S[i + (2*j)] and S[i] != S[i + (2*j)]:
            cou += 1
        j += 1

print(S.count("R")*S.count("G")*S.count("B")-cou)
### BUGGY CODE ###

n,k,q = map(int,input().split())
a_inputs = [int(input())-1 for i in range(q)]

ans_li = [True]*n
score_li = [k]*n


for a in a_inputs:
    score_li[a]+=1
    score_li = list(map(lambda x:x-1,score_li))
    for i in range(n):
        if score_li[i]<=0:
            ans_li[i]=False

for member in ans_li:
    if member:
        print('Yes')
    else:
        print('No')



### FIXED CODE ###

from collections import Counter 

n,k,q = map(int,input().split())
a_inputs = [int(input())-1 for i in range(q)]

a_dic = Counter(a_inputs)

score_li = [k]*n
for key,value in a_dic.items():
    score_li[key]+=value
score_li = list(map(lambda x:x-q,score_li))

for member in score_li:
    if member<=0:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

N,W = [int(i) for i in input().split()]
dp = [0 for i in range(W+1)] # dp[i] is the the max value you have achieve with weight i
for i in range(N):
  w,value = [int(i) for i in input().split()]
  for weight in range(W-w, -1, -1): # range of kanpsack weight in which i can push the current item
    dp[weight + w] = max(dp[weight + w], dp[weight] + value)
print("%s" % dp[W])


### FIXED CODE ###

N, W = [int(i) for i in input().split()]
weight = []
value = []
for i in range(N):
  w, val = [int(i) for i in input().split()]
  weight.append(w)
  value.append(val)
# changing to value max as W_max ~ 10^9 and val_max ~= 1000 * next
val_max = 0
for i in range(N):
  val_max += value[i]
dp = [float('inf') for i in range(val_max+1)] # dp[i] is the min weight required for the value 
# hence our ans would be in the max value where the weight < knapsack weight
dp[0] = 0
for i in range(N):
  for v in range(val_max-value[i], -1, -1): # range of kanpsack weight in which i can push the current item
    dp[v + value[i]] = min(dp[v + value[i]], dp[v] + weight[i])
    #print(dp)
sol = 0
for i in range(val_max+1):
  if dp[i] <= W:
    sol = i
print("%s" % sol)
### BUGGY CODE ###

N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
value=0
mod=10**9 + 7
if K==1:
    print(0)
    exit()
z=1
for i in range(N):
    if i>=K-1:
        a=z%mod
        value+=(a*A[i])%mod
        value-=(a*A[N-1-i])%mod
        z*=i-(K-1) + K
        z//=i-(K-1) + 1

    value%=mod
print(value)


### FIXED CODE ###

mod = 10**9 + 7
kaijotable = [0 for i in range(200100)]
kaijotable[0] = 1
for i in range(1, 200051):
    kaijotable[i] = (kaijotable[i - 1] * i) % mod

def doubling(x, y, mod):
    if y == 0:
        return 1
    if y == 1:
        return x
    elif y % 2 == 0:
        val = (doubling(x, y // 2, mod) ** 2) % mod
        return val
    else:
        val = (doubling(x, y // 2, mod) ** 2) * x % mod
        return val

def gyaku(x):
    gyaku = doubling(x, mod - 2, mod) % mod
    return gyaku

gyakutable = [0 for i in range(200100)]
gyakutable[200050] = gyaku(kaijotable[200050])
for i in range(200050, 0, -1):
    gyakutable[i - 1] = i * gyakutable[i] % mod

N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
value=0
mod=10**9 + 7
if K==1:
    print(0)
    exit()

z=0

for i in range(N):
    if i>=K-1:
        c=kaijotable[z+K-1] * gyakutable[K-1] * gyakutable[z+K-1-(K-1)] % mod
        value+=c*A[i]
        value-=c*A[N-1-i]

        z+=1
    value%=mod
print(value)
### BUGGY CODE ###

n = int(input())
count = 0
for c in range(1,n):
    ab = n - c
    for a in range(1,n):
        if ab % a == 0:
            count += 1
print(count)

### FIXED CODE ###

n = int(input())
count = 0
for a in range(1,n):
    count += (n-1)//a
print(count)
### BUGGY CODE ###

import sys
n,m=map(int,input().split())
l=[[int(i) for i in l.split()] for l in sys.stdin]
s=[[0] for i in range(10**5+1)]
for i in l:
  s[i[0]].append(i[1])
for i in range(len(s)):
  if len(s[i])>2:
    s[i].sort()
for i in l:
  print('{:0>6}{:0>6}'.format(str(i[0]),str(s[i[0]].index(i[1]))))

### FIXED CODE ###

import sys
import bisect
n,m=map(int,input().split())
l=[[int(i) for i in l.split()] for l in sys.stdin]
s=[[0] for i in range(10**5+1)]
for i in l:
  s[i[0]].append(i[1])
for i in range(len(s)):
  s[i].sort()
for i in l:
  print('{:06}{:06}'.format(i[0],bisect.bisect_left(s[i[0]],i[1])))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
a = sorted(list(set(a)))
while len(a) > 1:
  b = a.pop()
  d = []
  for i in a:
    c = b%i
    if c != 0:
      d.append(c)
  a = sorted(list(set(d+a)))
print(a[0])

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a = sorted(list(set(a)))
while len(a) > 1:
  b = a.pop(0)
  d = []
  for i in a:
    c = i%b
    if c != 0:
      d.append(c)
  a = sorted(list(set(d+[b])))
print(a[0])
### BUGGY CODE ###

a,b = map(int,input().split())
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

cf = cf(a,b)
ans = 1
for c in cf:
    if is_prime(c) == True:
        ans += 1
        cf = [i for i in cf if i % c != 0]
print(ans)


### FIXED CODE ###

a,b = map(int,input().split())
import fractions
import collections
import copy
def prime_factorization(n):
    a = [1]
    n1 = copy.deepcopy(n)
    while n % 2 == 0:
        n //= 2
    if n1 != n:
        a.append(2)
    f = 3
    while f * f <= n:
        if n % f == 0:
            n //= f
            if a[-1] != f:
                a.append(f)
        else:
            f += 2
    if a[-1] != n and n != 1:
        a.append(n)
    return a
print(len(prime_factorization(fractions.gcd(a,b))))
### BUGGY CODE ###

n = int(input())
s = input()
cnt = 0

for v in range(1000):
    v = str(v).zfill(3)
    f = 0
    for i in range(n):
        if f == 2:
            if v[2] == s[i]:
                cnt += 1
                break
        elif f == 1:
            if v[1] == s[i]:
                f = 2
        else:
            if v[0] == s[i]:
                f = 1
print(cnt)

### FIXED CODE ###

n = int(input())
s = input()
cnt = 0
for i in range(1000):
    i = str(i).zfill(3)
    j = s.find(i[0])
    if j != -1:
        k = s[j + 1:].find(i[1])
        if k != -1:
            if s[j + k + 2:].find(i[2]) != -1:
                cnt += 1
print(cnt)
### BUGGY CODE ###


import heapq
h,w,k = list(map(int, input().split()))
x1,y1,x2,y2 = list(map(int, input().split()))
x1,y1,x2,y2 = x1-1,y1-1,x2-1,y2-1
c = [[]*w for _ in range(h)]
dp = [[0]*w for _ in range(h)]
que = []
for i in range(h):
  for j,s in enumerate(input()):
    c[i].append(s)
    if s != '.':
      dp[i][j] = -1

ans = 0
dp[x1][y1] = 1
heapq.heappush(que, (dp[x1][y1], [x1,y1]))
dx = [1,0,-1,0]
dy = [0,1,0,-1]

while que:
  p= heapq.heappop(que)
  p = p[1]
  if (p[0] == x2) & ( p[1] == y2):break
  for i in range(4):
    for ki in range(1,k+1):
      nx = p[0] + dx[i]*ki
      ny = p[1] + dy[i]*ki
      if (p[0] == x2) & ( p[1] == y2):break
      if (nx<0) | (nx>(h-1))| (ny<0) | (ny>(w-1)):break
      if dp[nx][ny] == -1:break
      if 0 < dp[nx][ny] <= dp[p[0]][p[1]]:break
      dp[nx][ny] = dp[p[0]][p[1]] + 1
      heapq.heappush(que, (dp[nx][ny], [nx,ny]))

if dp[x2][y2] != 0:
  print(dp[x2][y2]-1)
else:
  print(-1)


### FIXED CODE ###

#import heapq
from collections import deque
h,w,k = list(map(int, input().split()))
x1,y1,x2,y2 = list(map(int, input().split()))
x1,y1,x2,y2 = x1-1,y1-1,x2-1,y2-1
dp = [[-1]*w for _ in range(h)]
#que = []
que = deque()
c = [input() for _ in range(h)]

dp[x1][y1] = 0
#heapq.heappush(que, (dp[x1][y1], [x1,y1]))
que.append((x1,y1))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
while que:
  x,y=que.popleft()
  if x==x2 and y==y2:
    exit(print(dp[x][y]))
  for dx,dy in [[1,0],[-1,0],[0,-1],[0,1]]:
    for i in range(1,k+1):
      xx=x+dx*i
      yy=y+dy*i
      if not(0<=xx<h and 0<=yy<w) or c[xx][yy]=="@":break
      if 0<=dp[xx][yy]<=dp[x][y]:break
      if dp[xx][yy]==-1:que.append((xx,yy))
      dp[xx][yy]=dp[x][y]+1
print(-1)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
else:
    for i in a :
        ans = ans*i

if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
    print(0)
else:
    for i in a :
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
### BUGGY CODE ###

import numpy as  np

#入力取得
N, M = map(int, input().split())


gate = []
count = 0

for i in range(M):
    x = list(map(int,input().split()))
    gate.append(x)


l_b = list(np.arange(gate[0][0], gate[0][1]+1, 1))


for i in range(len(gate)):

    l_a = list(np.arange(gate[i][0], gate[i][1]+1, 1))


    l_b = list(set(l_a) & set(l_b))


print(len(l_b))

### FIXED CODE ###

#入力取得
N, M = map(int, input().split())

#最大と最小を選べば良い

left_max = 0
right_min = N


for i in range(M):

    tmp_left,tmp_right = map(int, input().split())


    if tmp_left > left_max:
        left_max = tmp_left

    if tmp_right < right_min:
        right_min = tmp_right



result = right_min - left_max

if result < 0:
    print(0)
else:
    print(result + 1)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from math import factorial 
from math import floor
P = int(1e9)+7
def c(n, m, P):
       ch = 1
       for i in range(m):
           ch *= (n-i)
           ch %= P
       b = factorial(m) 
       b = pow(b, P-2, P)
       return ch*b%P
def main():
    x, y = map(int, readline().split())
    a = (2*y-x)/3
    b = (2*x-y)/3
    if (a < 0) or (b < 0):
        print(0)
        return
    if floor(a)-a != 0: 
        print(0)
        return
    if floor(b)-b != 0:
        print(0)
        return

    a = int(a)
    b = int(b)
    print(c(a+b, a, P)) 
if __name__ == '__main__':
    main()


### FIXED CODE ###

#python3
from math import factorial
from math import floor
MOD = int(1e9+7)

def comb(n, m, mod):
    comb_a = 1
    for i in range(m): 
        comb_a *= (n-i)
        comb_a %= mod
    comb_tmp = factorial(m) 
    comb_b = pow(comb_tmp, mod-2, mod)
    return (comb_a * comb_b)%mod
def main():
    x, y = map(int, input().split())
    k = (2*x-y)/3
    l = (2*y-x)/3

    if floor(k) - k != 0:
        print(0)
        return
    if floor(l) - l != 0:
        print(0)
        return 
    if k<0:
        print(0)
        return
    if l<0:
        print(0)
        return
    k = int(k)
    l = int(l)
    print(comb(k+l, k, MOD)%MOD) 

main()
### BUGGY CODE ###

N = int(input())
S = []
c = input()
S.extend(c)

if "W" in S and "R" in S:
    for i in range(N):
        S_r = S[::-1]
        min_W = S.index("W")
        max_R = N - 1 - S_r.index("R")
        if min_W>max_R:
            print(i)
            break
        S[min_W],S[max_R] = S[max_R],S[min_W]
else:
    print(0)

### FIXED CODE ###

N = int(input())
S = []
c = input()
S.extend(c)

if "W" in S and "R" in S:
    t = S.count("R")
    S = S[:t]
    r = S.count("W")
    print(r)
else:
    print(0)
### BUGGY CODE ###

k,s=map(int,input().split())
c=0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i+j+k==s:
                c+=1
print(c)

### FIXED CODE ###

k,s=map(int,input().split())
c=0
#x>=y>=z
for i in range(k+1):
    for j in range(k+1):
        if 0<=s-i-j<=k:
          c+=1
print(c)
### BUGGY CODE ###

from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    h, w, d = map(int, input().split())

    x = [0] * (h * w)
    y = x.copy()
    for i in range(h):
        a = list(map(int, input().split()))
        for j in range(w):
            x[a[j] - 1] = i
            y[a[j] - 1] = j

    ans = []
    q = int(input())
    for _ in range(q):
        # s = answer
        s = 0
        l, r = map(int, input().split())
        for i in range(l-1, r-1, d):
            s += abs(x[i] - x[i+d]) + abs(y[i] - y[i+d])
        ans.append(s)

    for i in ans:
        print(i)

main()

### FIXED CODE ###

from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    h, w, d = map(int, input().split())

    x = [0] * (h*w)
    y = x.copy()
    for i in range(h):
        a = list(map(int, input().split()))
        for j in range(w):
            x[a[j] - 1] = i
            y[a[j] - 1] = j

    # 累積和
    cost = [[0] for _ in range(d)]
    for i in range(d, h*w):
        cost[i%d].append(cost[i%d][-1] + abs(x[i]-x[i-d]) + abs(y[i]-y[i-d]))

    ans = []
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        ans.append(cost[r%d][r//d] - cost[l%d][l//d])

    for i in ans:
        print(i)

main()
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
res=0
for d in range(60,-2,-1):
    if(d!=-1 and K&(1<<d)==0):
        continue
    tmp=0
    for e in range(60,-1,-1):
        mask=1<<e
        num=0
        for i in range(N):
            if(mask&A[i]):
                num+=1
        #numというのはd桁目の1が立ってる数
        #e>dというのはxとkは上からみてd桁目で0と1が変わるってことでfor文まわしてるから
        #つまりe>dというのはd桁目より大きい所を見てる感じ、だからその部分はkとxは同じ数字にになってるよね、そう考えると
        if(e>d):
            #ここではKのe桁目が1のときnumというのは1がたってる数だからそれらがeが1で反転しちゃうから足し合わせるのは0になってる法(つまりN-num)
            if(K&mask):
                tmp+=mask*(N-num)
            #上と全く逆
            else:
                tmp+=mask*num
        #e==dというのはちょうどKとXの桁が変わるところK>=XだからK=1,X=0になるよね、だから足すのはnumの方
        elif(e==d):
            tmp+=mask*num      
        #e<dではxは01好きな方を使っていいよね、、ということは足し合わせるのはnumでもN-numでもどっちでもOK!
        else:
            tmp+=mask*max(num,N-num)
    #この処理をdが大きいところから順にやってあげて一番大きくなったのが答え!
    res=max(res,tmp)
print(res)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
res=0
for d in range(40,-2,-1):
    if(d!=-1 and K&(1<<d)==0):
        continue
    tmp=0
    for e in range(40,-1,-1):
        mask=1<<e
        num=0
        for i in range(N):
            if(mask&A[i]):
                num+=1
        #numというのはd桁目の1が立ってる数
        #e>dというのはxとkは上からみてd桁目で0と1が変わるってことでfor文まわしてるから
        #つまりe>dというのはd桁目より大きい所を見てる感じ、だからその部分はkとxは同じ数字にになってるよね、そう考えると
        if(e>d):
            #ここではKのe桁目が1のときnumというのは1がたってる数だからそれらがeが1で反転しちゃうから足し合わせるのは0になってる法(つまりN-num)
            if(K&mask):
                tmp+=mask*(N-num)
            #上と全く逆
            else:
                tmp+=mask*num
        #e==dというのはちょうどKとXの桁が変わるところK>=XだからK=1,X=0になるよね、だから足すのはnumの方
        elif(e==d):
            tmp+=mask*num      
        #e<dではxは01好きな方を使っていいよね、、ということは足し合わせるのはnumでもN-numでもどっちでもOK!
        else:
            tmp+=mask*max(num,N-num)
    #この処理をdが大きいところから順にやってあげて一番大きくなったのが答え!
    res=max(res,tmp)
print(res)
### BUGGY CODE ###

import fractions
import functools


n = int(input())
a = list(map(int, input().split()))
nl = set(range(n))
gcd_list = [0]
for i in nl:
    tmp, a[i] = a[i], 0
    gcd_list.append(functools.reduce(fractions.gcd, a))
    a[i] = tmp
ans = max(gcd_list)
print(ans)

### FIXED CODE ###

import fractions


n = int(input())
a = list(map(int, input().split()))
nl = set(range(n))
l = [0]
r = [0]
m = []
for i in nl:
    l.append(fractions.gcd(l[i], a[i]))
    r.append(fractions.gcd(r[i], a[-i-1]))
r.reverse()
for i in nl:
    m.append(fractions.gcd(l[i], r[i+1]))
ans = max(m)
print(ans)