Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
n,m,p=map(int,input().split())
edge = [[] for i in range(m)]
for i in range(m):
  a,b,c=map(int,input().split())
  edge[i]=[a-1,b-1,-c+p]

def sp(s,n,w,es):
  d=[float("inf")]*n
  d[s]=0
  count=0
  ret=[]
  for i in range(2*n):
    update=False
    for i in range(w):
      e0,e1,e2=es[i]
      if d[e0]!=float("inf") and d[e1]>d[e0]+e2:
        d[e1]=d[e0]+e2
        update=True
    if not update:
      ret=[d[-1],d[-1]]
      break
    else:
      if (i+1)%n==0 and len(ret)<2:
        ret.append(d[-1])
  return ret
d1,d2=sp(0,n,m,edge)
print(-1 if d1!=d2 else max(0,-d2))


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m,p=map(int,input().split())
edge = [[] for i in range(m)]
for i in range(m):
  a,b,c=map(int,input().split())
  edge[i]=[a-1,b-1,-c+p]
d=[float("inf")]*n
d[0]=0

for _ in range(n):
  for i in range(m):
    e0,e1,e2=edge[i]
    d[e1]=min(d[e1],d[e0]+e2)
ans1=d[-1]
for _ in range(n):
  for i in range(m):
    e0,e1,e2=edge[i]
    if d[e1]>d[e0]+e2:
      d[e1]=-float("inf")
ans2=d[-1]
print(-1 if ans1!=ans2 else max(0,-ans1))
import math
from itertools import accumulate

Q = int(input())
LR = []

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    # print(int(math.sqrt(n)))
    for i in range(2,int(math.sqrt(n))+1):
        for j in range(i*2, n+1 ,i):
            is_prime[j] = False

    return is_prime

def like2017(is_prime,n):
    solve = [0] * (n+1)
    for i in range(3,n+1,2):
        if is_prime[i] and is_prime[int((i+1)/2)]:
            solve[i] = 1
        
    return solve

for _ in range(Q):
    t = [int(i) for i in input().split(' ')]
    LR.append(t)

L = 100
is_prime = primes(L)
solve = like2017(is_prime,L)
# print(solve)
ans = list(accumulate(solve))
# print(ans)

for l, r in LR:
    print(ans[r] - ans[l-1])

### FIXED CODE ###

import math
from itertools import accumulate

Q = int(input())
LR = []

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    # print(int(math.sqrt(n)))
    for i in range(2,int(math.sqrt(n))+1):
        for j in range(i*2, n+1 ,i):
            is_prime[j] = False

    return is_prime

def like2017(is_prime,n):
    solve = [0] * (n+1)
    for i in range(3,n+1,2):
        if is_prime[i] and is_prime[int((i+1)/2)]:
            solve[i] = 1
        
    return solve

for _ in range(Q):
    t = [int(i) for i in input().split(' ')]
    LR.append(t)

L = 10 ** 5
is_prime = primes(L)
solve = like2017(is_prime,L)
# print(solve)
ans = list(accumulate(solve))
# print(ans)

for l, r in LR:
    print(ans[r] - ans[l-1])
s = intput()
if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')

### FIXED CODE ###

s = input()
if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')
import sys
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
K = ir()
length = 0
for i in range(1, 100):
    if 10 ** i > N:
        length = i
        break

c = factorial(length) // factorial(K) // factorial(lenght-K)
c_1 = factorial(length-1) // factorial(K-1) // factorial(lenght-K-1)
print(c)
answer = 0
top = int(str(N)[0])
answer = factorial(length-1) // factorial(K) // factorial(lenght-K-1) * 9 ** K # 一個前まで
answer += factorial(length) // factorial(K) // factorial(lenght-K) * (top-1) * 9 ** K # 一桁目がtopより小さい数
print(answer)

### FIXED CODE ###

import sys
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
K = ir()
length = 0
for i in range(1, 102):
    if 10 ** i > N:
        length = i
        break

answer = 0
def F(length, K, N):
    ret = 0
    if length == 1:
        if K == 1:
            return N
        elif K == 0:
            return 1
        else:
            return 0
    if length < K:
        return 0
    top = int(str(N)[0])
    if length-K >= 1:
        ret += factorial(length-1) // factorial(K) // factorial(length-K-1) * 9 ** K # 一個前まで    
    ret += factorial(length-1) // factorial(K-1) // factorial(length-K) * (top-1) * 9 ** (K-1) # 一桁目がtopより小さい数  
    if K > 1: # 一桁目がtopと同じ数
        N = int(str(N)[1:])
        length = 0
        for i in range(1, 100):
            if 10 ** i > N:
                length = i
                break
        ret += F(length, K-1, N)
    else:
        ret += 1 # 2000のような数
    return ret

answer = F(length, K, N)
print(answer)
S = input('天気が雨である日が連続していた最大の日数を出力せよ。')
if S == SSS
	print(0)
else if S == SSR
	print(1)
else if S == SRR
	print(2)
else if S == SRS
	print(1)
else if S == RSS
	print(1)
else if S == RRS
	print(2)
else if S == RRR
	print(3)
else if S == RRS
	print(2)

### FIXED CODE ###

S = input()
if S == 'SSS':
  print(0)
elif S == 'SRR':
  print(2)
elif S == 'RRS':
  print(2)
elif S == 'RRR':
  print(3)
else:
  print(1)
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
def primes(n):#nまでの素数を列挙
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**(0.5)+1)):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    m = min(A,B)
    pr = primes(m)
    c = 0
    if len(pr)==0:
      print(1)
    for k in pr:
        if A%k == 0 and B%k == 0:
            c += 1
        else:
          continue
    print(c+1)


### FIXED CODE ###


"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))
    if temp != 1:
        arr.append((temp, 1))
    if arr == []:
        arr.append((n, 1))
    return arr

import fractions
a, b = map(int, input().split())
li = factorization(fractions.gcd(a, b))

if li[0][0] == 1:
    print(1)
else:
    print(len(li)+1)
from collections import izip

N, M, C = (int(x) for x in raw_input().split())
B = [int(x) for x in raw_input().split()]
A = [[int(x) for x in raw_input().split()] for i in xrange(N)]
result = 0
for i in xrange(N):
  cur_sum = C
  for a, b in izip(A, B):
    cur_sum += a * b
  if cur_sum > 0:
    result += 1
print(result)


### FIXED CODE ###

from itertools import izip

N, M, C = (int(x) for x in raw_input().split())
B = [int(x) for x in raw_input().split()]
A = [[int(x) for x in raw_input().split()] for i in xrange(N)]
result = 0
for i in xrange(N):
  cur_sum = C
  for a, b in izip(A[i], B):
    cur_sum += a * b
  if cur_sum > 0:
    result += 1
print(result)
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
s_max = sum(s)

if s_max % 10 != 0:
    print(s_max)
else:
    for i in s if i % 10 != 0:
        print(s_max - i)
        exit()

print(0)

### FIXED CODE ###

n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
s_max = sum(s)

if s_max % 10 != 0:
    print(s_max)
    exit()
else:
    for i in s:
        if i % 10 != 0:
            print(s_max - i)
            exit()

print(0)
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0
for k in range(n):
    cnt += 1/a[k]
print(1/cnt)

### FIXED CODE ###

n = int(input())
a = map(int, input().split())
print(1/sum(1/i for i in a))
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = [0]*10
for i in range(N):
    li[A[i]] += 1
li.sort(reverse=True)
print(sum(li[K:]))

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
li = [0]*10**6
for i in range(N):
    li[A[i]] += 1
# print(li)
li.sort(reverse=True)
# print(li)
print(sum(li[K:]))
def solve(A, m):
	if m == 0:
		return True
	if m<0 or len(m)==0:
		return False
	else:
		no_use = solve(A[1:], m-int(A[0]))
		if no_use:
			return True
		else:
			return (solve(A[1:], m))

def main():
	n = int(input())
	A = input()
	A = A.split()
	q = int(input())
	ms= input()
	for m in ms.split():
		if solve(A, int(m)):
			print('yes')
		else:
			print('no')

if __name__ == '__main__':
	main()

### FIXED CODE ###

def power_set(A, s):
	if len(A) == 0:
		return {s}
	else:
		return power_set(A[1:], s) | power_set(A[1:], s+A[0])

def main():
	n = int(input())
	A = input()
	#print(n)
	A = list(map(int, A.split()))
	q = int(input())
	m = input()
	ms = list(map(int, m.split()))
	powerset = power_set(A, 0)
	
	for m in ms:
		if m in powerset:
			print('yes')
		else:
			print('no')

if __name__ == '__main__':
	main()
n,k= map(int, input().split())
a= list(map(int, input().split()))
a.sort()



# めぐる式二部探索
l=-1
r=a[-1]+1
while r-l>1:
    # rは常にOK、lは常にNG。
    mid=l+(r-l)//2
    cnt=k
    flag=True
    for i in range(n):
        if a[i]>mid:
            cnt-=a[i]//mid
            if cnt<0:
                flag=False
                break


    # なんらかの判定
    if flag:
        r = mid  # 判定がOKのとき→範囲を左に狭める
    else:
        l = mid  # 判定がNGのとき→範囲を右に狭める


print(r)

### FIXED CODE ###

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

if k==0:
    print(a[-1])
    exit()


# めぐる式二部探索
l=0
r=pow(10,11)
while r-l>1:
    # rは常にOK、lは常にNG。
    mid=l+(r-l)//2
    cnt=k
    flag=True
    for i in range(n):
        if a[i]>mid:
            x=-(-a[i]//mid)-1
            cnt-=x

    # なんらかの判定
    if cnt>=0:
        r = mid  # 判定がOKのとき→範囲を左に狭める
    else:
        l = mid  # 判定がNGのとき→範囲を右に狭める

print(r)
import numpy as np

N = int(input())
ABC = np.array([list(map(int,input().split())) for _ in range(N)])


dp = [[0, 0, 0] for _ in range(N)]
dp[0] = ABC[0]

select_action = [[1,2], [0,2], [0,1]]
for i in range(1,N):
    for j in range(3):
        abc1 = select_action[j][0]
        abc2 = select_action[j][1]

        dp[i][j] = max(dp[i-1][abc1], dp[i-1][abc2]) + ABC[i][j]


print(max(dp[-1]))

### FIXED CODE ###

N = int(input())
ABC = [list(map(int,input().split())) for _ in range(N)]


dp = [[0, 0, 0] for _ in range(N)]
dp[0] = ABC[0]

select_action = [[1,2], [0,2], [0,1]]
for i in range(1,N):
    for j in range(3):
        abc1 = select_action[j][0]
        abc2 = select_action[j][1]

        dp[i][j] = max(dp[i-1][abc1], dp[i-1][abc2]) + ABC[i][j]


print(max(dp[-1]))
k = int(input())
ans = 0
import math
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      f = gcd(i,j)
      ff = gcd(f,l)
      ans += ff
print(ans)

### FIXED CODE ###

k = int(input())
ans = 0
import math
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      f = math.gcd(i,j)
      ff = math.gcd(f,l)
      ans += ff
print(ans)
import sys
import math


def main():
    a = int(sys.argv[1])
    p = int(sys.argv[2])
    return math.floor((a * 3 + p) / 2)


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


### FIXED CODE ###

# -*- coding: utf-8 -*-
import math


def main():
    inp = input().split()
    a = int(inp[0])
    p = int(inp[1])
    return math.floor((a * 3 + p) / 2)


if __name__ == '__main__':
    print(main())
a=set(map,input().split())
print(len(a))

### FIXED CODE ###

a=set(map(int,input().split()))
print(len(a))
= int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))
S = input()
A = [0]*len(S)
for i in range(len(S)):
  A[S[i]] += 1
if max(A) == 1:
  print("yes")
else:
  print("no")

### FIXED CODE ###

from collections import defaultdict
S = input()
d = defaultdict(int)
for i in range(len(S)):
  d[S[i]] += 1
for val in d.values():
  if val != 1:
    print("no")
    exit()
print("yes")
import sympy
N = int(input())
count = 0
for i in range(1,N):
    count += len(sympy.divisors(N-i))
print(count)

### FIXED CODE ###

n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)
A,op,B=list(map(int, input().split()))
if op=='+':
  print(A+B)
else:
  print(A-B)

### FIXED CODE ###

A,op,B=input().strip().split()
if op == '+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
N = int(input())
s = len(N)

if s = 1 :
	print(N)
if s = 2 :
	print(9)
if s = 3 :
	print(9 + N -99)
if s = 4 :
	print(909)
if s = 5 :
	print(909 + N - 9999)
if s = 6 :
	print(90909)

### FIXED CODE ###

n = int(input())
 
if  n <= 9:
    print(n)
elif 10 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(n-99+9)
elif 1000 <= n <= 9999:
    print(909)
elif 10000 <= n <= 99999:
    print(n-9999+909)
elif n == 100000:
    print(90909)
a,b,c,k = map(int,input().split())

if k<=a:
	amount=k
	print(amount)
elif k<=a+b:
	amount=a
	print(amount)
else:
	amount=a+(-1)*(k-a-b)
	print(amount)

### FIXED CODE ###

s=str(input())
t=str(input())
if len(s)-len(t)==-1:
	if s==t[0:len(s)]:
		print("Yes")
	else:
		print("No")
else:
	print("No")
import sys
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[i]+B[i])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break:
    while b[l] + a[k] > K:
        j -= 1
    ans = max(ans,k+j)
print(ans) 


### FIXED CODE ###

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

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break
    while b[l] > K - a[k]:
        l -= 1
    ans = max(ans,k+l)
print(ans)
a = [int(input()) for i in range(4)]
print(min(a[0],a[1])+min(a[2],a[3])

### FIXED CODE ###

a = [int(input()) for i in range(4)]
print(min(a[0],a[1])+min(a[2],a[3]))
N = int(input())
S, T = input().split()
 
res = ''
 
for i in range(N):
  res = res + str(S[i]) + str(T[i])
  
print(res)

### FIXED CODE ###

a = int(input())
b = int(input())
 
if (a != 1 and b != 1):
  print(1)
elif (a != 2 and b != 2):
  print(2)
else:
  print(3)
N = int(input())
A = list(map(int, input().split()))

A.sort(resverse = True)

print(sum(A[0::2]) - sum(A[1::2]))

### FIXED CODE ###

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

a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))
from collections import deque

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

A.sort()
A = deque(A)

X = A.copy()

B = deque([X.pop()])
flg = True
while X:
    if flg:
        B.append(X.popleft())
        if X:
            B.appendleft(X.popleft())
    else:
        B.append(X.pop())
        if X:
            B.appendleft(X.pop())
    flg = not flg

X = A.copy()
C = deque([X.popleft()])
flg = True
while X:
    if flg:
        C.append(X.pop())
        if X:
            C.appendleft(X.pop())
    else:
        C.append(X.popleft())
        if X:
            C.appendleft(X.popleft())
    flg = not flg

print(max(sum([abs(B[i]-B[i-1]) for i in range(1,N)]), sum([abs(C[i]-C[i-1]) for i in range(1,N)])))

### FIXED CODE ###

from collections import deque

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

A.sort()

X = deque(A.copy())

B = deque([X.pop()])
flg = True
while X:
    if flg:
        B.append(X.popleft())
        if X:
            B.appendleft(X.popleft())
    else:
        B.append(X.pop())
        if X:
            B.appendleft(X.pop())
    flg = not flg

X = deque(A.copy())
C = deque([X.popleft()])
flg = True
while X:
    if flg:
        C.append(X.pop())
        if X:
            C.appendleft(X.pop())
    else:
        C.append(X.popleft())
        if X:
            C.appendleft(X.popleft())
    flg = not flg

print(max(sum([abs(B[i]-B[i-1]) for i in range(1,N)]), sum([abs(C[i]-C[i-1]) for i in range(1,N)])))
from itertools import combinations
 
n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
 
fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x)
 
while all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)
from itertools import combinations

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)

fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x)

while all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)


### FIXED CODE ###

from itertools import combinations

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)

fail = lambda x: (not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x))

while n and all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)
N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print(0)
else:
    ans = 0
    H1 = H[0]
    H2 = H[1]
    count = 1
    move = 0
    while count != (N):
        count += 1
        if H2 <= H1:
            move += 1
            ans = max(ans, move)
        else:
            move = 0
        if count != N:
            H1 = H2
            H2 = H[count]

print(ans)


### FIXED CODE ###

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

if N == 1:
    print(0)
else:
    ans = 0
    H1 = H[0]
    H2 = H[1]
    count = 1
    move = 0
    while count != N:
        count += 1
        if H2 <= H1:
            move += 1
            ans = max(ans, move)
        else:
            move = 0
        if count != N:
            H1 = H2
            H2 = H[count]

    print(ans)
x= list(map(int,input().split()))
k = int(input())
list.sort()
max = list[0] + lsit[1] + list[2] *2*k
 
print(max)
    

### FIXED CODE ###

x= list(map(int,input().split()))
k = int(input())
x.sort()
a = x[2]
for i in range(k):
    a = a *2
max = x[0] + x[1] + a
 
print(max)
import math
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(pt[i-1]/t*, pa[i-1]/a))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))      

### FIXED CODE ###

import math
from fractions import Fraction
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(Fraction(pt[i-1], t), Fraction(pa[i-1], a)))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))
def Exponential():
    X = int(input())
    res=1
    for b in range(1, X+1):
        for p in range(2, int(X/2)+1, 1): 
            if b**p >X: break
            else:
                res = max(b**p, res)
    print(res)
Exponential()

### FIXED CODE ###

def ColorfulTransceivers():
    
    def checker(number):
        return (number<1 or number>100)
    
    raw = input()
    input_list = raw.split(" ")
    try :
        [a,b,c,d] = [int(i) for i in input_list]
    except ValueError:
        return("Oops!  There is no int input.")
    if (sum([checker(i) for i in [a,b,c,d]])): 
        return("Oops!  There is no validate data.")
    elif abs(c-a)<=d:
        print("Yes")
    elif abs(b-a)<=d and abs(c-b)<=d:
        print("Yes")
    else:
        print("No")

ColorfulTransceivers()
n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]

d = 0
ans = 0
i = 0
while d <= x and i < n+1:
    ans += 1
    d = d + l[i]
    i += 1

print(ans)

### FIXED CODE ###

n, x = (int(i) for i in input().split())
l = [0] + [int(i) for i in input().split()]

d = 0
ans = 0
i = 1
while d <= x:
    ans += 1
    if ans == n+1:
        break
    d = d + l[i]
    i += 1

print(ans)
b=input()

if b=="A":
    print("T")
if b=="C":
    print("G")
if b=-G:
    print("C")
if b==T:
    print("A")

### FIXED CODE ###

b=input()

if b=="A":
    print("T")
if b=="C":
    print("G")
if b=="G":
    print("C")
if b=="T":
    print("A")
N=int(input());a=[0]*10_001;X=Y=Z=range(1,101)
for x in X:
    for y in Y:
        for z in Z:
            if (n:=x*x+y*y+z*z+x*y+y*z+z*x)<N+1:a[n-1]+=1
print(*a[:N],sep='\n')

### FIXED CODE ###

N = int(input())
ans = [0 for _ in range(1,10101)]

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n < N+1:
                ans[n-1] += 1

print(*ans[:N],sep='\n')
s, n = map(str, input().split())
n = int(n)
s = list(s)
s[n] = s[n].lower()
print(*s, sep="")

### FIXED CODE ###

hoge, n = map(int, input().split())
s = list(input())
s[n-1] = s[n-1].lower()
print(*s, sep="")
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

### FIXED CODE ###

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
import math
from functools import reduce
import numpy as np
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A = list(map(int, input().split()))
ans=0
for i in range(N):
    a = A[0]
    del A[0]
    
    b = gcd_list(A)
    if ans < b:
        ans = b
    A.append(a)

print(ans)

### FIXED CODE ###

def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y, x%y)

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

left_gcd = [A[0]]
a = A[0]
for i in range(1,N-1):
  a = gcd(a, A[i])
  left_gcd.append(a)

right_gcd = [A[N-1]]
b = A[N-1]
for k in range(N-2, 0, -1):
  b = gcd(b, A[k])
  right_gcd.append(b)

ans_gcd = [right_gcd[N-2], left_gcd[N-2]]

for p in range(N-2):
  ans_gcd.append(gcd(left_gcd[p], right_gcd[N-p-3]))

print(max(ans_gcd))