Harryxun/stf_run huggingface dataset:
N,C = map(int,input().split())
p = [list(map(int,input().split())) for i in range(N)]
p.sort()
ch = [[0,0] for i in range(C+1)]
p_true = []
for i in range(N):
  [s,t,c] = p[i]
  if ch[c][1] == s:
    ch[c][1] = t
  elif ch[c] == [0,0]:
    ch[c] = [s,t]
  else:
    p_true.append([*ch[c],c])
    ch[c] = [s,t]
for i in range(1,C+1):
  if ch[i] != [0,0]:
    p_true.append([*ch[i],i])
p_true.sort()

### FIXED CODE ###

from itertools import accumulate
import sys
input = sys.stdin.readline
N,C = map(int,input().split())
p = [list(map(int,input().split())) for i in range(N)]
p.sort()
ch = [[0,0] for i in range(C+1)]
p_true = []
for i in range(N):
  [s,t,c] = p[i]
  if ch[c][1] == s:
    ch[c][1] = t
  elif ch[c] == [0,0]:
    ch[c] = [s,t]
  else:
    p_true.append([ch[c][0],ch[c][1],c])
    ch[c] = [s,t]
for i in range(1,C+1):
  if ch[i] != [0,0]:
    p_true.append([ch[i][0],ch[i][1],i])
p_true.sort()
time = [0 for i in range(100002)]
for i in range(len(p_true)):
  [s,t,c] = p_true[i]
  time[s] += 1
  time[t+1] -= 1
print(max(accumulate(time)))
def main():
    n = int(input())
    data = list(map(int, input().split()))

    for k in data:
        if k == 0:
            return 0

    up = 0
    for i in range(n):
        up *= data[i]

    down = 0
    for j in range(n):
        down += up / data[j]

    return up / down

print(main())


### FIXED CODE ###

def main():
    n = int(input())
    data = list(map(int, input().split()))

    for k in data:
        if k == 0:
            return 0

    up = 1
    for i in range(n):
        up *= data[i]

    down = 0
    for j in range(n):
        down += up / data[j]

    return (up / down)

print(main())
import sys
sys.setrecursionlimit(10 ** 7)

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

if X < N :
    print(0)
else :
    burger = [-1] * (N + 1)
    def makeBurger(level) :
        if level == 0 :
            return '1'
        if burger[level] == -1 :
            middle = makeBurger(level - 1)
            burger[level - 1] = middle
        else :
            middle = burger[level - 1]
        return '0' + middle + '1' + middle + '0'
    ans = makeBurger(N)[:X]
    print(ans.count('1'))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

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

if X < N :
    print(0)
else :
    pat = [0] * (N + 1)  # パティ数
    ban = [0] * (N + 1)  # バンズ数
    pat[0] = 1
    for i in range(1, N + 1) :
        pat[i] = 2 * pat[i - 1] + 1
        ban[i] = 2 * ban[i - 1] + 2
    def sol(level, height) :
        if height <= 0 :
            return 0
        if level == 0 :
            return 1
        if height <= 1 :
            return 0
        if height < pat[level - 1] + ban[level - 1] :
            return sol(level - 1, height - 1)
        if height == pat[level - 1] + ban[level - 1] + 1 :
            return pat[level - 1]
        if height == pat[level - 1] + ban[level - 1] + 2 :
            return pat[level - 1] + 1
        return pat[level - 1] + 1 + sol(level - 1, height - (pat[level - 1] + ban[level - 1] + 2))

    ans = sol(N, X)
    print(ans)
import math
n = gets.to_i
print(math.factorical(n) % (10**9 + 7))


### FIXED CODE ###

import math
n = int(input())
print(math.factorial(n) % (10**9 + 7))
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
ki=[[] for i in range(n+1)]
for i in range(n-1):
    ki[ab[i][0]].append(ab[i][1])
    ki[ab[i][1]].append(ab[i][0])
# print(ki)
kyori=[[0,0] for i in range(n+1)]
def tansaku(m, dis, hito):
    if not ki[m]:
        kyori[m][hito]=dis
        return
    elif kyori[m][hito]!=0:
        return
    else:
        kyori[m][hito]=dis
        for i in range(len(ki[m])):
            # print(m)
            tansaku(ki[m][i], dis+1, hito)
tansaku(1,1,0)
tansaku(n,1,1)
fe,su=0,0

for i in range(1,n+1):
    if kyori[i][0]<kyori[i][1]:
        fe+=1
    else:
        su+=1

if fe>su:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000)
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
ki=[[] for i in range(n+1)]
for i in range(n-1):
    ki[ab[i][0]].append(ab[i][1])
    ki[ab[i][1]].append(ab[i][0])
# print(ki)
kyori=[[float("INF"), float("INF")] for i in range(n+1)]
def tansaku(m, dis, hito):
    q=[[m,dis]]
    while q:
        po=q.pop()
        for i in ki[po[0]]:
            if kyori[i][hito]>po[1]:
                kyori[i][hito]=po[1]
                q.append([i,po[1]+1])

tansaku(1,1,0)
tansaku(n,1,1)
fe,su=0,0

for i in range(1,n+1):
    if kyori[i][0]<=kyori[i][1]:
        fe+=1
    else:
        su+=1

if fe>su:
    print("Fennec")
else:
    print("Snuke")
A, B, K = map(int, raw_input().split())
AB = range(A, B + 1)
for i in AB[:K]:
	print i
for i in AB[-K:]:
	print i


### FIXED CODE ###

A, B, K = map(int, raw_input().split())
if B - A + 1 > 2 * K:
	for i in range(A, A + K):
		print i
	for i in range(B - K + 1, B + 1):
		print i
else:
	for i in range(A, B + 1):
		print i
import sys
input = sys.stdin.readline

S = input().split()
if S[2]==S[3] and S[4]==S[5]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

s = input()
if s[2]==s[3] and s[4]==s[5]:
  print("Yes")
else:
  print("No")
import sys

# sys.setrecursionlimit(2000)

tmp=input().split(" ")
n = int(tmp[0])
m = int(tmp[1])

node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])

hubensa_list = [0] * (m + 1)
hubensa_list[m] = n*(n-1)//2

def root(i):
    if node_groups[i] == i:
        #print(i, "is root.")
        return i
    else:
        #_1 = node_groups[i]
        node_groups[i] = root(node_groups[i])
        #_2 = node_groups[i]
        #print ("root: ", _1, _2)
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    a = root(a)
    b = root(b)

    if a == b:
        return
    
    group_sizes[a] += size(b)
    node_groups[b] = a


for i in range(m-1, -1, -1):
    edge = edges[i]
    print("edge: ",edge)
    #print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)
    if root_1 == root_2:
        hubensa_list[i] = hubensa_list[i+1]
        continue

    # 不便さをだす
    hubensa_list[i] = hubensa_list[i+1] - (size(root_1) * size(root_2))

    unite(root_1, root_2)

#print("node_groups: ", node_groups)


for i in range(1, m+1):
    print(hubensa_list[i])

### FIXED CODE ###

import sys

sys.setrecursionlimit(100000)

tmp=input().split(" ")
n = int(tmp[0])
m = int(tmp[1])

node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])

hubensa_list = [0] * (m + 1)
hubensa_list[m] = n*(n-1)//2

def root(i):
    if node_groups[i] == i:
        #print(i, "is root.")
        return i
    else:
        #_1 = node_groups[i]
        node_groups[i] = root(node_groups[i])
        #_2 = node_groups[i]
        #print ("root: ", _1, _2)
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    a = root(a)
    b = root(b)

    if a == b:
        return
    
    group_sizes[a] += size(b)
    node_groups[b] = a


for i in range(m-1, -1, -1):
    edge = edges[i]
    # print("edge: ",edge)
    #print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)
    if root_1 == root_2:
        hubensa_list[i] = hubensa_list[i+1]
        continue

    # 不便さをだす
    hubensa_list[i] = hubensa_list[i+1] - (size(root_1) * size(root_2))

    unite(root_1, root_2)

#print("node_groups: ", node_groups)


for i in range(1, m+1):
    print(hubensa_list[i])
inl=map(int, raw_input().split())

if inl[0]>=inl[2]+inl[4] and inl[2]+inl[4]>=0 and inl[1]>=inl[3]+inl[4] and inl[3]+inl[4]>=0
  print "Yes"
else:
  print "No"

### FIXED CODE ###

inl=map(int, raw_input().split())

if inl[0]>=inl[2]+inl[4] and inl[2]-inl[4]>=0 and inl[1]>=inl[3]+inl[4] and inl[3]-inl[4]>=0:
  print "Yes"
else:
  print "No"
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
print(l.most_common()[0][1])

### FIXED CODE ###

from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
used = [0] * N
def dfs(s):
    used[s] = 1
    res = 1
    for t in G[s]:
        if not used[t]:
            res += dfs(t)
    return res
g = min(dfs(0), dfs(1))
print(N*(N-1)//2 - g*(N - g) - M)


### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
used = [0] * N
def dfs(s):
    st = [s]
    used[s] = 1
    res = 0
    while st:
        s = st.pop()
        res += 1
        for t in G[s]:
            if not used[t]:
                used[t] = 1
                st.append(t)
    return res
g = min(dfs(0), dfs(1))
print(N*(N-1)//2 - g*(N - g) - M)
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()
# n = int(input())
x,y = map(int, input().split())
# a = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# ab=[]
# for i in range(m):
#     a,b = map(int, input().split())
#     ab.append((a,b))

print(x)
     
def main():
    ans = 0
    val = x
    while val <=y:
        ans+=1
        x*=2
    print(ans)
        
    

    
    

if __name__ == '__main__':
    main()

### FIXED CODE ###

import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()
# n = int(input())
# a,b = map(int, input().split())
# a = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# ab=[]
# for i in range(m):
#     a,b = map(int, input().split())
#     ab.append((a,b))
     
def main():
    a,b = map(int, input().split())
    ans = 0
    while a <=b:
        ans+=1
        a*=2
    print(ans)
        
if __name__ == '__main__':
    main()
import numpy as np
import sys
def solve():
    N=int(sys.stdin.readline())
    dp=np.zeros((3,N)).astype('int64')
    for i in range(N):
        a,b,c=list(map(int,sys.stdin.readline().split()))
        if i:
            dp[0,i]=max(dp[1,i-1]+a,dp[2,i-1]+a)
            dp[1,i]=max(dp[0,i-1]+b,dp[2,i-1]+b)
            dp[2,i]=max(dp[1,i-1]+c,dp[0,i-1]+c)
        else:
            dp[0,i]=a
            dp[1,i]=b
            dp[2,i]=c

    return np.max(dp[:,N-1])
    
if __name__ == '__main__':
    print(solve())

### FIXED CODE ###

import numpy as np
import sys
def solve():
    N=int(sys.stdin.readline())
    dp=np.zeros((3,N)).astype('int64')
    for i in range(N):
        a,b,c=list(map(int,sys.stdin.readline().split()))
        if i:
            dp[0,i]=max(dp[1,i-1]+a,dp[2,i-1]+a)
            dp[1,i]=max(dp[0,i-1]+b,dp[2,i-1]+b)
            dp[2,i]=max(dp[1,i-1]+c,dp[0,i-1]+c)
        else:
            dp[0,i]=a
            dp[1,i]=b
            dp[2,i]=c

    return np.max(dp[:,N-1])
    
if __name__ == '__main__':
    print(solve())
while (1):
    print(int(input())+int(input()))
##

### FIXED CODE ###

import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )
N=int(input())
dataH=[int(e) for e in input().split(' ')]
Hmax=max(dataH)

dataH.reverse()
print(len(dataH)-dataH.index(max))


### FIXED CODE ###

N=int(input())
dataH=[int(e) for e in input().split(' ')]
c=0
for i,H in enumerate(dataH):
  c=c+1 if max(dataH[:i+1])==H else c
print(c)
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

import functools
@functools.lru_cache(maxsize=None)
def make_divisors(n):
  if n == 1:
    divisors.append(1)
    return divisors
  for i in range(int(n**0.5)+1,1,-1):
    if n % i == 0:
      divisors.append(i)
      break
  return make_divisors(n//i)

N = I()
a = IL()
cnt = [0]*N

ans = ""
M = 0
for i in range(N-1,-1,-1):
  if cnt[i]%2 == 0 and a[i] == 1 or cnt[i]%2 == 1 and a[i] == 0:
    M += 1
    ans += str(i+1) + " "
  if a[i] == 1:
    divisors = []
    l = make_divisors(i+1)
    for j in l:
      cnt[j-1] += 1

if ans == "":
  print(0)
else:
  print(M)
  print(ans[:-1])

### FIXED CODE ###

import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
cnt = [0]*(N+1)
ans = []
M = 0
for i in range(N-1,-1,-1):
  tmp = sum(cnt[i::i+1])
  if tmp%2 != a[i]:
    ans.append(str(i+1))
    cnt[i] = 1
    M += 1

if M == 0:
  print(0)
else:
  print(M)
  print(" ".join(ans))
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]

L_minus = [[] for i in range(N)]
L_plus = [0 for i in range(N)]

dp = [0 for i in range(N)]

for i in range(M) :
    x,y = L[i]
    x -= 1
    y -= 1
    L_plus[y] += 1
    L_minus[x].append(y)

A = []

for i in range(N) :
    if L_plus[i] == 0 :
        A.append(i)

while A :
    x = A.popleft()
    
    for y in L_minus[x] :
        L_plus[y] -= 1
        if L_plus[y] == 0 :
            A.append(y)
        dp[y] = max(dp[y], dp[x]+1)

ans = max(dp)

print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]

L_minus = [[] for i in range(N)]
L_plus = [0 for i in range(N)]

dp = [0 for i in range(N)]

for i in range(M) :
    x,y = L[i]
    x -= 1
    y -= 1
    L_plus[y] += 1
    L_minus[x].append(y)

A = []

for i in range(N) :
    if L_plus[i] == 0 :
        A.append(i)

while A :
    x = A.pop()
    
    for y in L_minus[x] :
        L_plus[y] -= 1
        if L_plus[y] == 0 :
            A.append(y)
        dp[y] = max(dp[y], dp[x]+1)

ans = max(dp)

print(ans)
import sys
input=sys.stdin.readline

n,k=map(int,input().split())
step=list(map(int,input().split()))
n,k=map(int,input().split())
step=list(map(int,input().split()))
dp=[0]*n
if n>=k:
  for i in range(1,k):
    min=10**7
    for j in range(1,i+1):
      if dp[i-j]+abs(step[i]-step[i-j])<min:
        min=dp[i-j]+abs(step[i]-step[i-j])
    dp[i]=min
  for i in range(k,n):
    min=10**7
    for j in range(1,k+1):
      if dp[i-j]+abs(step[i]-step[i-j])<min:
        min=dp[i-j]+abs(step[i]-step[i-j])
    dp[i]=min
else:
  for i in range(1,n):
    min=10**7
    for j in range(1,i+1):
      if dp[i-j]+abs(step[i]-step[i-j])<min:
        min=dp[i-j]+abs(step[i]-step[i-j])
    dp[i]=min
print(dp[n-1])

### FIXED CODE ###

def solve():
  n,k=[int(i) for i in input().split()]
  step=[int(i) for i in input().split()]
  dp=[0]*n
  for i in range(1,n):
    dp[i]=min([dp[j] + abs(step[i]-step[j]) for j in range(max(i-k,0),i)])
  return dp[n-1]
print(solve())
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
A.sort(reverse=True)
list = []
start = 0
while start < N:
    if A[start] == A[start+1]:
        list.append(A[start])
        start += 2
    else:
        start += 1
if len(list) >= 2:
    print(list[0]*list[1])
else:
    print(0)

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
A.sort(reverse=True)
list = []
start = 0
while start < N-1: 
    if A[start] == A[start+1]:
        list.append(A[start])
        start += 2
    else:
        if start == N-2:
            break
        start += 1
if len(list) >= 2:
    print(list[0]*list[1])
else:
    print(0)
n=int(input())
s=[input().sort() for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(n):
    if i>=j:
      continue
    if s[i]==s[j]:
      cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
ans=0
cnt={}
for i in range(n):
  if s[i] in cnt:
    cnt[s[i]]+=1
  else:
    cnt[s[i]]=1
print(sum(cnt[key]*(cnt[key]-1)//2 for key in cnt))
K=int(input())
A, B = map(int, input().split())
for i in range(A,B+1):
    if i%K==0:
        return "OK"
    return "NG"

### FIXED CODE ###

K=int(input())
A,B = map(int, input().split())
count=0
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        count+=1
        break
if count==0:
    print("NG")
n=int(input())
a=list(map,input().split())

cnt=0
for i in range(n):
    if all([i%2!=0 for i in a])==True: #すべての要素が奇数ならbreak
        break
    elif a[i]%2!=0: #奇数なら3倍
        a[i]*=3
    elif a[i]%4==2: #4の剰余が2（e.g.,2,6,10,...）なら3倍
        a[i]*=3
    elif a[i]%4==0: #4の剰余が0なら1/2倍
        a[i]//=2
    cnt+=1
print(cnt)

### FIXED CODE ###

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

def cnt_div2(n):
    cnt=0
    while n%2==0:
        n//=2
        cnt+=1
    return cnt

#各要素に対して，2で割ることのできる回数をカウント
lis = [cnt_div2(i) for i in a]
print(sum(lis))
N = int(input())
A = list(map(int, input().split()))
res = 1

if 0 in A :
    res = 0

for x in range(N) :
    res *= A[x]
    if res > 10**18
        res = -1
        break

print(res)


### FIXED CODE ###

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)
import math
from itertools import accumulate

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

L = [0]+list(accumulate(a, math.gcd))
R = list(accumulate(reversed(a), math.gcd))[::-1]+[0]


ans = 0

for i in range(n):
    ans =max(math.gcd(L[i],R[i+1]),ans)

if n == 2:
    print(max(a))
else:
    print(ans)


### FIXED CODE ###

from fractions import gcd

n = int(input())
list_ = list(map(int, input().strip().split()))

gcd_from_left = [0]
gcd_from_right = [0]
for i in range(n):
    gcd_from_left.append(gcd(gcd_from_left[i], list_[i]))
    gcd_from_right.append(gcd(gcd_from_right[i], list_[-(i + 1)]))

gcd_from_left.insert(0, 0)
gcd_from_right.insert(0, 0)
gcd_from_right.reverse()

print(max(gcd(gcd_from_left[i], gcd_from_right[i]) for i in range(n + 2)))
import math


def kari():
    a = list(map(int, input().split()))
    b = map(int, input().split())


def start_process(num, data):
    kouyakusuu1, kouyakusuu2, kouyakusuu3 = math.gcd(data[0], data[1]), max(data[0], data[1]), min(data[0], data[1])
    # print(kouyakusuu2, kouyakusuu3)

    for i in range(2, num):
        if i == 2:
            a = math.gcd(data[i], kouyakusuu2)
            b = math.gcd(data[i], kouyakusuu3)
            kari1 = max(a, b)
            kari2 = kouyakusuu1

            kari3 = math.gcd(data[i], kouyakusuu1)
        else:
            kari1 = math.gcd(data[i], kouyakusuu2)
            kari2 = kouyakusuu1

            kari3 = math.gcd(data[i], kouyakusuu1)



        kouyakusuu1 = kari3
        kouyakusuu2 = max(kari1, kari2)



    print(max(kouyakusuu1, kouyakusuu2))

# def start_process(num, data):
#     for i in range(num)

def main():
    num = int(input())
    data = list(map(int, input().split()))
    start_process(num, data)



if __name__ == '__main__':
    main()


### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def kari():
    a = list(map(int, input().split()))
    b = map(int, input().split())


def start_process(num, data):
    kouyakusuu1, kouyakusuu2, kouyakusuu3 = gcd(data[0], data[1]), max(data[0], data[1]), min(data[0], data[1])
    # print(kouyakusuu2, kouyakusuu3)

    for i in range(2, num):
        if i == 2:
            a = gcd(data[i], kouyakusuu2)
            b = gcd(data[i], kouyakusuu3)
            kari1 = max(a, b)
            kari2 = kouyakusuu1

            kari3 = gcd(data[i], kouyakusuu1)
        else:
            kari1 = gcd(data[i], kouyakusuu2)
            kari2 = kouyakusuu1

            kari3 = gcd(data[i], kouyakusuu1)



        kouyakusuu1 = kari3
        kouyakusuu2 = max(kari1, kari2)



    print(max(kouyakusuu1, kouyakusuu2))

# def start_process(num, data):
#     for i in range(num)

def main():
    num = int(input())
    data = list(map(int, input().split()))
    start_process(num, data)



if __name__ == '__main__':
    main()
N = int(input())
A, B = map(int, input().split())

ans = 0
for i in range(N + 1):
    if A <= sum(map(int, list(str(i)))) <= B:
        ans += i
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(N + 1):
    if A <= sum(list(map(int, list(str(i))))) <= B:
        map(int, list(str(i)))
        ans += i
print(ans)
from heapq import heappop, heappush
x,y,a,b,c = map(int, input().split())

aa = sorted(map(int, input().split()), reverse=True)
bb = sorted(map(int, input().split()), reverse=True)
cc = sorted(map(int, input().split()), reverse=True)
heap = []
used = {}
for i in range(min(c,x)):
    heappush(heap, [-cc[i], 2, i])
for i in range(x):
    heappush(heap, [-aa[i], 0, i])

ans = 0
for i in range(x):
    value, color, pos = heappop(heap)
    ans -= value
    if color == 2:
        used.add(pos)

i = 0
heap = []
while len(heap) < y and i < c:
    if i not in used:
        heappush(heap, -cc[i])
    i += 1
for i in range(y):
    heappush(heap, -bb[i])

for i in range(y):
    value = heappop(heap)
    ans -= value

print(ans)


### FIXED CODE ###

from heapq import heappop, heappush
x,y,a,b,c = map(int, input().split())

aa = sorted(map(int, input().split()), reverse=True)
bb = sorted(map(int, input().split()), reverse=True)
cc = sorted(map(int, input().split()), reverse=True)
dd = []
for i in aa[:x]:
    heappush(dd,i)
for i in bb[:y]:
    heappush(dd, i)

for i in range(c):
    heappush(dd, cc[i])
    heappop(dd)

print(sum(dd))
import sys
h, w = map(int, input().split())
sq = []

for i in range(h):
    sq.append(input())

print(sq)

def is_valid(i, j):
    valid = False
    if i > 0 and sp[i-1][j] == '#':
        valid = True
    elif i < h-1 and sp[i+1][j] == '#':
        valid = True
    elif j > 0 and sp[i][j-1] == '#':
        valid = True
    elif j < w-1 and sp[i][j+1] == '#':
        valid = True
    return valid

for i in range(h):
    for j in range(w):
        #print(sq[i][j])
        c = sq[i][j]
        if c == '#':
            if not is_valid(i, j):
                print('No')
                sys.exit()

print('Yes')


### FIXED CODE ###

import sys
h, w = map(int, input().split())
sq = []

for i in range(h):
    sq.append(input())

def is_valid(i, j):
#    global sq
    valid = False
    if i > 0 and sq[i-1][j] == '#':
        valid = True
    elif i < h-1 and sq[i+1][j] == '#':
        valid = True
    elif j > 0 and sq[i][j-1] == '#':
        valid = True
    elif j < w-1 and sq[i][j+1] == '#':
        valid = True
    return valid

for i in range(h):
    for j in range(w):
        c = sq[i][j]
        if c == '#':
            if not is_valid(i, j):
                print('No')
                sys.exit()

print('Yes')