Harryxun/stf_run huggingface dataset:
def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n):
        for a, b, c in ABC:
            if distance[a - 1] is not None and \
                distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for a, b, c in ABC:
        if distance[b - 1] < distance[a - 1] + c:
            return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))


### FIXED CODE ###

def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None:
                continue
            if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None or distance[b - 1] is None:
                continue
            if distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c
                if b == n:
                    return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))
from bisect import bisect_left
def main():
  s=input()
  t=input()
  n=len(t)
  m=len(s)
  lindex=[[] for _ in range(26)]
  for i in range(m):
    if s[i] in t:
      lindex[ord(s[i])-97].append(i)
  cnt=0
  for i in range(n-1):
    l=len(lindex[ord(t[i+1])-97])
    if l==0:
      print(-1)
      exit()
    if l==bisect_left(lindex[ord(t[i+1])-97],lindex[ord(t[i])-97][0]):
      cnt+=1
  k=lindex[ord(t[-1])-97][0]
  return print(m*cnt+k+1)
if __name__=='__main__':
  main()

### FIXED CODE ###

from bisect import bisect_right
def main():
  s=input()
  t=input()
  n=len(t)
  m=len(s)
  lindex=[[] for _ in range(26)]
  for i in range(m):
    if s[i] in t:
      lindex[ord(s[i])-97].append(i)
  for i in range(n):
    if len(lindex[ord(t[i])-97])==0:
      print(-1)
      exit()
  cnt=0
  inde=-1
  for i in range(n):
    l=len(lindex[ord(t[i])-97])
    idx=bisect_right(lindex[ord(t[i])-97],inde)
    if l==idx:
      cnt+=1
      inde=lindex[ord(t[i])-97][0]
    else:
      inde=lindex[ord(t[i])-97][idx]
  return print(m*cnt+inde+1)
if __name__=='__main__':
  main()
# -*- coding: utf-8 -*-

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    
    G = []
    i = 0
    g = 1

    while g <= len(A):
        G.append(g)
        g = 3*g+1
    G = G.reverse()

    for g in G:
        insertionSort(A, n , g)
    
    return A, G


if __name__ == '__main__':

    n = int(input())
    A = [int(input()) for i in range(n)]

    cnt = 0
    A, G = shellSort(A, n)
    
    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for i in range(n):
        print(A[i])




### FIXED CODE ###

# -*- coding: utf-8 -*-

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G


if __name__ == '__main__':

    n = int(input())
    A = [int(input()) for i in range(n)]

    cnt = 0
    A, G = shellSort(A, n)
    
    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for i in range(n):
        print(A[i])
a = {'Sunny' : 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny')
s = input()
print(a[s])

### FIXED CODE ###

a = {'Sunny' : 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}
s = input()
print(a[s])
import math

def get_lcm(x, y):
    return  math.gcd(x, y)
    return (x * y) // math.gcd(x, y)

def get_num(a, lcm):
    return lcm // a


N_str = input()
a_str = input()
a_str_list = a_str.split(" ")
a_list = list(map(lambda x: int(x), a_str_list))
lcm = 1
for a in a_list:
    lcm = get_lcm(lcm, a)

sum_a = 0
for a in a_list:
    sum_a += get_num(a, lcm)

result = lcm / sum_a
print(result)


### FIXED CODE ###

import fractions

def get_lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def get_num(a, lcm):
    return lcm // a


N_str = input()
a_str = input()
a_str_list = a_str.split(" ")
a_list = list(map(lambda x: int(x), a_str_list))
lcm = 1
for a in a_list:
    lcm = get_lcm(lcm, a)

sum_a = 0
for a in a_list:
    sum_a += get_num(a, lcm)

result = lcm / sum_a
print(result)
n=int(input())
t=list(set([int(input()) for _ in range(n)]))
T,l=max(t),len(t)

def f(j):
  for i in range(l):
    if (T*j)%t[i]!=0:
      return f(j+1)
      break
  return T*j

print(f(1))

### FIXED CODE ###

import fractions
n=int(input())
t=set([int(input()) for _ in range(n)])
ans=1
for i in t:
  ans=(i*ans)//fractions.gcd(i,ans)
print(ans)
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return v.copy()
    return [nlist(n[1:], v) for _ in range(n[0])]

# バイナリインデックス木
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
    def sum(self, i):
        s = 0
        while 0 < i:
            s += self.tree[i]
            s %= MOD
            i -= i & -i
        return s
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

# エントリーポイント
def main():
    N, K = input(int, int)
    A = input([int, N])

    MAX = 12
    bit = BIT(MAX)
    # 最終周をカウントする
    sum1 = []
    for i, a in enumerate(A, start=1):
        bit.add(a, 1)
        sum1.append(i - bit.sum(a))
    # 繰り返し周をカウントする
    sum2 = []
    for a in A:
        sum2.append(N - bit.sum(a))
    # (1 + (K - 1))回分を集計する
    ans = 0
    for v1, v2 in zip(sum1, sum2):
        ans += K * v1 + ((K * (K - 1)) // 2) * v2
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return v.copy()
    return [nlist(n[1:], v) for _ in range(n[0])]

# バイナリインデックス木
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
    def sum(self, i):
        s = 0
        while 0 < i:
            s += self.tree[i]
            s %= MOD
            i -= i & -i
        return s
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

# エントリーポイント
def main():
    N, K = input(int, int)
    A = input([int, N])

    MAX = 2010
    bit = BIT(MAX)
    # 最終周をカウントする
    sum1 = []
    for i, a in enumerate(A, start=1):
        bit.add(a, 1)
        sum1.append(i - bit.sum(a))
    # 繰り返し周をカウントする
    sum2 = []
    for a in A:
        sum2.append(N - bit.sum(a))
    # (1 + (K - 1))回分を集計する
    ans = 0
    for v1, v2 in zip(sum1, sum2):
        ans += K * v1 + ((K * (K - 1)) // 2) * v2
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()
N, M=input().split()
if N == M:
  print(AC)
else:
  print(WA)

### FIXED CODE ###

N, M=input().split()
if N == M:
  print("Yes")
else:
  print("No")
N,M,K=map(int,input().split())

A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]

a=0
b=0
ans=0
books=len(A)+len(B)
time=0


while(1):
    if a+b==books or time>=K:
        break
    
    elif (a!=N and b!=M):
        if A[a]>B[b]:
            if time+B[b]<=K:
                time+=B[b]
                b+=1
                ans+=1
            else:
                break
        
        elif B[b]>A[a]:
            if time+A[a]<=K:
                time+=A[a]
                a+=1
                ans+=1
            else:
                break
        
        else:
            if time+A[a]>K:
                break
            else:
                tmpa=a
                tmpb=b
                while(1):
                    tmpa+=1
                    tmpb+=1
                    if A[tmpa]>B[tmpb]:
                        time+=B[b]
                        b+=1
                        ans+=1
                        break
                    
                    elif A[tmpa]<B[tmpb]:
                        time+=A[a]
                        a+=1
                        ans+=1
                        break
            
    elif a==N and b!=M:
        time+=B[b]
        b+=1
        ans+=1
        
    elif b==M and a!=N:
        time+=A[a]
        a+=1
        ans+=1
print(ans)
        

### FIXED CODE ###

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

a=[0]
b=[0]

tmp_a=0
tmp_b=0
for i in A:
    tmp_a+=i
    a.append(tmp_a)

for i in B:
    tmp_b+=i
    b.append(tmp_b)
    

ans,j=0,M
for i in range(N+1):#i…A台の本数
    if a[i]>K:
        break
    while(1):
        if b[j]<=(K-a[i]):
            break
        j-=1
    ans=max(ans,i+j)
    
print(ans)
import math
def lcm(x, y):
    return math.floor(x * y/math.gcd(x, y))
a, b = map(int, input().split())
print(lcm(a,b))


### FIXED CODE ###

import math
def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
def lcm(m, n):
    return int(m*n/gcd(m,n))
a, b = map(int, input().split())
print(lcm(a,b))
import sys
S=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])
[print(S[int(line)]) for line in sys.stdin]



### FIXED CODE ###

import sys
S=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])
[print(i) for i in [S(int(line)) for line in sys.stdin]]
from collections import defaultdict
N, M = map(int, input().split())
E = defaultdict(list)
for i in range(M):
    x, y = map(int, input().split())
    E[x-1].append(y-1)
dp = [-1] * N
def solve(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = 0
    for nn in E[n]:
        dp[n] = max(dp[n], solve(nn)+1)
    return dp[n]
ans = 0
for i in range(N):
    ans = max(ans, solve(i))
print(ans)

### FIXED CODE ###

from collections import deque
from collections import defaultdict
N, M = map(int, input().split())
d = [0]*N
G = defaultdict(list)
for i in range(M):
    s, t = map(int, input().split())
    d[t-1] += 1
    G[s-1].append(t-1)
q = deque([])
for i in range(N):
    if d[i] == 0:
        q.append(i)
ans = []
while q:
    s = q.popleft()
    ans.append(s)
    for t in G[s]:
        d[t] -= 1
        if d[t] == 0:
            q.append(t)
dp = [0] * (N+1)
num = 0
for i in range(0,N):
    for n in G[ans[i]]:
        dp[n] = max(dp[n], dp[ans[i]]+1)
print(dp[ans[-1]])
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 
        2, 2, 5, 4, 1, 4, 1, 51]

index = input()
print(list[index-1: index-1])


### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 
        2, 2, 5, 4, 1, 4, 1, 51]

index = input()
index = int(index)
print(list[index-1])
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def B_strings(): 
    N = wczytaj_liste()[0]
    S = input()
    T = input()
    odp = []
    for i in range(N): 
        odp.append(S[i])
        odp.append(T[i])
    print(''.join(odp))

B_strings()

### FIXED CODE ###

def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def B_strings(): 
    N = wczytaj_liste()[0]
    wczytaj = input()
    S, T = wczytaj.split()
    odp = []
    for i in range(N): 
        odp.append(S[i])
        odp.append(T[i])
    print(''.join(odp))

B_strings()
a = int(input())
b = list(map(int,input().split()))
c = 0
for i in range(0,a-1):
  c += c + 1/b[i]
print(1/c)

### FIXED CODE ###

a = int(input())
b = list(map(int,input().split()))
c = 0
for i in range(a):
  c += 1/b[i]
print(1/c)
# -*- coding: utf-8 -*-                                                                              

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

killed = 0

for i in range(n):
    if b[i] <= a[i]:
        killed += b[i]
        continue
    else:
        b[i] -=	a[i]
        killed += a[i] + min(a[i+1], b[i])
	a[i+1] = max(0, a[i+1]-b[i])

print(killed)


### FIXED CODE ###

# -*- coding: utf-8 -*-                                                                              

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

killed = 0

for i in range(n):
    if b[i] <= a[i]:
        killed += b[i]
        continue
    else:
        b[i] -=	a[i]
        killed += a[i] + min(a[i+1], b[i])
        a[i+1] = max(0, a[i+1]-b[i])

print(killed)
N, x = map(int, input().split())

if x in [1, 2*N-1]:
  print('No')
else:
  print('Yes')
  if N == 2:
    print(*range(1, 4), sep='\n')
  else:
    ans = [0] * (2*N - 1)
    s = set(range(1, 2*N))
    if x >= N:
      ans[N-1] = x - 1; s.discard(x-1)
      ans[N] = x; s.discard(x)
      ans[N+1] = x + 1; s.discard(x+1)
      ans[N+2] = x - 2; s.discard(x-2)
    else:
      ans[N-1] = x + 1; s.discard(x+1)
      ans[N] = x; s.discard(x)
      ans[N+1] = x - 1; s.discard(x-1)
      ans[N+2] = x + 2; s.discard(x+2)
    for i in range(2*N-1):
      if ans[i]:
        continue
      ans[i] = s.pop()
    print(*ans, sep='\n')

### FIXED CODE ###

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

if x in [1, 2*N-1]:
  print('No')
else:
  print('Yes')
  if N == 2:
    print(*range(1, 4), sep='\n')
  else:
    ans = [0] * (2*N - 1)
    s = set(range(1, 2*N))
    if x >= N:
      ans[N-2] = x - 1; s.discard(x-1)
      ans[N-1] = x; s.discard(x)
      ans[N] = x + 1; s.discard(x+1)
      ans[N+1] = x - 2; s.discard(x-2)
    else:
      ans[N-2] = x + 1; s.discard(x+1)
      ans[N-1] = x; s.discard(x)
      ans[N] = x - 1; s.discard(x-1)
      ans[N+1] = x + 2; s.discard(x+2)
    for i in range(2*N-1):
      if ans[i]:
        continue
      ans[i] = s.pop()
    print(*ans, sep='\n')
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    l = [1]*a+[0]*b+[-1]*c
    print(sum(l[:k]))
    return

if __name__=='__main__':
    Main()

### FIXED CODE ###

import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    ta = min(k,a)
    tb = min(k-ta,b)
    if tb<0:    tb = 0
    tc = k-ta-tb
    print(ta-tc)
    return

if __name__=='__main__':
    Main()
from collections import defaultdict
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = input()
q = []
for _ in range(Q):
  q.append(input().split())
q.reverse()

dp = [[] for _ in range(N)]
for i in range(N):
  t, d = q[i]
  if t == s[0] and d == 'L':
    dp[i].append(0)
  elif t == s[N-1] and d == 'R':
    dp[i].append(N-1)
  
  if i == 0:
    continue

  for p in dp[i-1]:
    if p-1 >= 0 and t == s[p-1] and d == 'R':
      dp[i].append(p-1)
    elif p+1 <= N-1 and t == s[p+1] and d == 'L':
      dp[i].append(p+1)

print(N-len(dp[N-1]))

### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = input()
q = []
for _ in range(Q):
  q.append(input().split())
q.reverse()

l = 0
r = N-1
for i in range(Q):
  t, d = q[i]
  if l-1 >= 0 and t == s[l-1] and d == 'R':
    l -= 1
  elif t == s[l] and d == 'L':
    l += 1

  if r+1 <= N-1 and t == s[r+1] and d == 'L':
    r += 1
  elif t == s[r] and d == 'R':
    r -= 1

print(max(0, r-l+1))
input()
tmp = x = 0
for a in input():
  x += int(a.replace('I','1').replace('D','-1'))
  if tmp < x:
    tmp = x

print(max([,tmp]))


### FIXED CODE ###

a,b,c,d = [int(x) for x in input().split()]
print(a*b) if (a*b) >= (c*d) else print(c*d)
N,A=map(int, input().split())
x=list(map(int, input().split()))
dp=[]
for _ in range(N+1):
    dp.append([[0 for _ in range(N*max(x)+1)] for _ in range(N+1)])
for j in range(0,N+1):
    for k in range(0, N+1):
        for s in range(0, N*max(x)+1):
            if j>=1 and s<x[j-1]:
                dp[j][k][s]=dp[j-1][k][s]
            elif j>=1 and k>=1 and s>=x[j-1]:
                dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]]
            elif j==0 and k==0 and s==0:
                dp[0][0][0]=1
            else:
                dp[j][k][s]=0
ans=0
for k in range(1,N+1):
    ans+=dp[N][k][k*A]
print(ans)


### FIXED CODE ###

import sys
from sys import stdin
input = stdin.readline

def solve(N, A, x):
    W=sum(x)
    dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)]
    for j in range(N+1):
        dp[j][0][0]=1
    for j in range(1,N+1):
        xj=x[j-1]
        for k in range(1, N+1):
            for s in range(1, W+1):
                if s<xj:
                    dp[j][k][s]=dp[j-1][k][s]
                else:
                    dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-xj]

    ans=0
    for k in range(1,N+1):
        if k*A<=W:
            ans+=dp[N][k][k*A]
        else:
            break
    return ans


def main(args):
    N,A=map(int, input().split())
    x=[int(x) for x in input().split()]
    ans=solve(N,A,x)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])
N, M = map(int, input().split())
p_list = []

for i in range(N):
    a, b = map(int, input().split())
    p_list.append([a, b])
    
p_sort = sorted(p_list, key=lambda x:x[0])
num = 0
price = 0
i = 0
while num < M:
    num += p_sort[1][i]
    price += p_sort[1][i] * p_sort[0][i]
    if num > M:
      price -= (num - M) * p_sort[0][i]
    i += 1
print(price)

### FIXED CODE ###

N, M = map(int, input().split())
p_list = []

res = M
total_p = 0
for i in range(N):
    a, b = map(int, input().split())
    p_list.append(a)
    p_list.append(b)

for price, amount in sorted(zip(p_list[::2], p_list[1::2])):
    total_p += price * min(res, amount)
    res -= amount
    if res <= 0:
        break
        
print(total_p)
a = int(input())
b = int(input())
c = a * b

if c % 2 == 0:
  print("Even")
  
else:
  print("Odd")

### FIXED CODE ###

a, b = input().rsplit()
c = int(a) * int(b)

if c % 2 == 0:
  print("Even")
  
elif c % 2 != 0:
  print("Odd")
from fractions import gcd
from functools import reduce
def resolve():
    n=int(input())
    A=set(map(int,input().split()))
    ans=0
    if n==2:
        print(max(A))
        return
    for a in A:
        ans=max(ans,reduce(gcd,A^{a}))
    print(ans)
resolve()

### FIXED CODE ###

class Segtree(object):
    def __init__(self,A,f,u):
        n=2**(len(A).bit_length())
        N=2*n-1
        self.__num=n
        self.__len=N
        self.__seg=[u]*N
        self.__f=f
        self.__u=u
        # init
        for i in range(len(A)): # set
            self.__seg[n+i-1]=A[i]
        for i in range(n-2,-1,-1): # built, iの子のnodeは2i+1,2i+2
            self.__seg[i]=f(self.__seg[2*i+1],self.__seg[2*i+2])

    def __repr__(self):
        return str(self.__seg)

    def get_tree(self):
        return self.__seg

    def update(k,v):
        "A[k]=v"
        k+=self.__num-1
        self.__seg[k]=v
        while k+1: # k=0の処理が終わったら-1になってる
            k=(k-1)//2 # kの親のnodeは(k-1)//2
            self.__seg[k]=self.__f(self.__seg[k*2+1],self.__seg[k*2+2])

    def query(self,p,q): # reduce(f,A[p:q])
        if q<=p: return self.__u
        p+=self.__num-1
        q+=self.__num-2
        res=self.__u
        while q-p>1:
            if p&1==0:
                res=self.__f(res,self.__seg[p])
            if q&1==1:
                res=self.__f(res,self.__seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q: res=self.__f(res,self.__seg[p])
        else: res=self.__f(self.__f(res,self.__seg[p]),self.__seg[q])
        return res


def resolve():
    from fractions import gcd
    n=int(input())
    A=list(map(int,input().split()))
    if n==2:
        print(max(A))
        return
    seg=Segtree(A,gcd,0)
    ans=0
    for i in range(n):
        ans=max(ans,gcd(seg.query(0,i),seg.query(i+1,n)))
    print(ans)

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

if A == B:
  print('EQUAL')
elif A > B:
  print('GREATER')
else:
  print('LESS')

### FIXED CODE ###

A = int(input())
B = int(input())

if A == B:
  print('EQUAL')
elif A > B:
  print('GREATER')
else:
  print('LESS')
S = input()
Q = int(input())
for i in range(Q):
    inp = input().split()
    if len(inp) == 1:
        S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            S = c + S
        else:
            S = S + c
print(S)

### FIXED CODE ###

S = input()
if "A" not in S or "B" not in S:
    print("No")
else:
    print("Yes")
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[a[i]]
  if (i != n - 1 )and(a[i]  + 1 == a[i+1]):
    suf += c[i]
print(suf)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  suf += b[i]
  if i >= 1 and a[i - 1]  + 1 == a[i]:
    suf += c[a[i - 1] - 1]
print(suf)
a = int(input())

b=0#約数の個数

for i in range(1,a+1, 2):#i:1~inputまで,奇数だけ
  #ある数Niについて約数を数える
    yakusuu_array = []

    for i in range(1,num):
        if num % i == 0:
    	    yakusuu_array.append(i)
            
    if len(yakusuu_array) == 8:
  	    b += 1
print(b)

### FIXED CODE ###

a = int(input())
 
b=0#約数の個数
 
for num in range(1,a+1):#i:1~inputまで,奇数だけ
  if num % 2 == 1:
  #ある数Niについて約数を数える
    yakusuu = 0
    for i in range(1,num):
      if num % i == 0:
        yakusuu += 1
    if yakusuu == 7:
      b += 1
print(b)
N = input()
print(round((N/2)+0.01))

### FIXED CODE ###

N = int(input())
print(round((N/2)+0.01))