Harryxun/stf_run huggingface dataset:
import sys
import math
input = sys.stdin.readline

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

A.sort()

ans = A[0]
for i in range(1, N):
    ans = math.gcd(ans, A[i])
print(ans)



### FIXED CODE ###

import sys

input = sys.stdin.readline

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

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

A.sort()
ans = A[0]
for i in range(1, N):
    ans = gcd(ans, A[i])
print(ans)
N, P = map(int, input().split())

if N == 1:
    print(P)
else:
    ans = 1
    for x in range(1, P):
        k = x**N
        if k > P:
            break
        if P % k == 0:
            ans = max(ans, x)
    print(ans)

### FIXED CODE ###

from collections import Counter

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

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

c = Counter(prime_factors(P))
ans = 1

for x in c.keys():
    ans *= pow(x, int(c[x]//N))

print(ans)
n=int(input())
a=[n]
count=0

for i in range(n):
    i = int(input())
    a.append(i)

for i in a:
    x = i%2
    if x != 0:
        count += 1
    else:
        continue

if count==n:
    print(0)
else:
    print(n)

### FIXED CODE ###

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

for i in range(n):
    while a[i]%2 == 0:
        a[i] = a[i]//2
        ans += 1
print(ans)
if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)

### FIXED CODE ###

def gcd(x,y):
    if x==0:return y
    else:return gcd(y%x,x)
def lcm(x,y):
    return x*y//gcd(x,y)
 
a,b,c,d = map(int,input().split())
a -= 1
# print(gcd(c,d),lcm(c,d))
ba = b - b//c - b//d + b//lcm(c,d)
aa = a - a//c - a//d + a//lcm(c,d)
print(ba - aa)
S = input()
print("No" if (s.count("N") == 0 and s.count("S") > 0)\
		or (s.count("S") == 0 and s.count("N") > 0)\
		or (s.count("W") == 0 and s.count("E") > 0)\
		or (s.count("E") == 0 and s.count("W") > 0)\
		else "Yes")


### FIXED CODE ###

s = input()
print("No" if (s.count("N") == 0 and s.count("S") > 0)\
		   or (s.count("S") == 0 and s.count("N") > 0)\
	       or (s.count("W") == 0 and s.count("E") > 0)\
		   or (s.count("E") == 0 and s.count("W") > 0)\
		   else "Yes")
h, w = map(int, input().split())
src = [input() for i in range(h)]

ans = []
for row in src:
        ans.append(list(row))

flag = 0
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for x in range(h):
        for y in range(w):
                if src[x][y] == ".":
                        continue
                else:
                        for dx, dy in dxy:
                                if x + dx < 0 or x + dx > h -1 or y + dy < 0 or y + dy > w - 1:
                                        continue
                                if src[x + dx][y + dx] == "#":
                                        flag = 1
                                        break
                        if flag == 0:
                                print("No")
                                exit()

print("Yes")

### FIXED CODE ###

h, w = map(int, input().split())
src = [input() for i in range(h)]

ans = []
for row in src:
        ans.append(list(row))

dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for x in range(h):
        for y in range(w):
                if src[x][y] == ".":
                        continue
                if src[x][y] == "#":
                        flag = 0
                        for dx, dy in dxy:
                                if x + dx < 0 or x + dx > h -1 or y + dy < 0 or y + dy > w - 1:
                                        continue
                                if src[x + dx][y + dy] == "#":
                                        flag = 1
                                        break
                        if flag == 0:
                                print("No")
                                exit()

print("Yes")
N,K = list(map(int,input().split()))
edges = [[] for _ in range(N+1)]

import operator as op
from functools import reduce

MOD = 1000000007

for _ in range(N-1):
    (e1, e2) = tuple(map(int, input().split()))
    edges[e1].append(e2)
    edges[e2].append(e1)

children = [[] for _ in range(N+1)]
seen = set()
stack = []

stack.append(1)
seen.add(1)

while stack:
    node = stack[-1]
    stack.pop()
    for edge in edges[node]:
        if edge not in seen:
            seen.add(edge)
            children[node].append(edge)
            stack.append(edge)

def solve(node, siblings, depth):
    num_children = len(children[node])

    has_grandparent = depth >= 2
    has_parent = depth >= 1

    ans = max(0, K-(siblings)-int(has_parent)-int(has_grandparent))
    if ans == 0:
        return 0

    child_siblings = 0
    for child in children[node]:
        ans *=  solve(child, child_siblings, depth+1)
        ans %= MOD
        child_siblings += 1
    return ans

if N == 1:
    print(K)
elif N == 2:
    print(K*(K-1)//2)
else:
    print(solve(1, 0, 0) % MOD)



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N,K = list(map(int,input().split()))
edges = [[] for _ in range(N+1)]

MOD = 1000000007

for _ in range(N-1):
    (e1, e2) = tuple(map(int, input().split()))
    edges[e1].append(e2)
    edges[e2].append(e1)

children = [[] for _ in range(N+1)]
seen = set()
stack = []

stack.append(1)
seen.add(1)

while stack:
    node = stack[-1]
    stack.pop()
    for edge in edges[node]:
        if edge not in seen:
            seen.add(edge)
            children[node].append(edge)
            stack.append(edge)

def solve(node, siblings, depth):
    num_children = len(children[node])

    has_grandparent = depth >= 2
    has_parent = depth >= 1

    ans = max(0, K-(siblings)-int(has_parent)-int(has_grandparent))
    child_siblings = 0
    for child in children[node]:
        ans *=  solve(child, child_siblings, depth+1)
        ans %= MOD
        child_siblings += 1
    return ans


print(solve(1, 0, 0) % MOD)
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = [1000000000000]
x = list(itertools.combinations(p, K))
counts = len(list(x))
  for l in range(1,x+1):
    sums = sum(list(x[counts - 1]))
  	if sums <= lists[l-1]:
    	lists.append(sums)
    else:
        continue

print(min(lists))


### FIXED CODE ###

S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = []
for l in range(K):
  lists.append(min(p))
  p.remove(min(p))
  
print(sum(lists))
N = int(input())
A = list(map(int, input().split()))

ans = A[0]

for i in range(1, N + 1):
  ans *= A[i]
  
  if ans > 10**(18):
    print(-1)
    
print(ans)

### FIXED CODE ###

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

ans = 1

for i in range(N):
  ans *= A[i]
  
  if ans > 10**18:
    print(-1)
    exit()
    
print(ans)
import math
W, H, x, y = map(int, input().split(' '))

f_x, i_x = math.modf(W / x)
f_y, i_y = math.modf(H / y)

if f_x == 0 and f_y == 0:
    print(float(W * y), 1)
elif f_x == 0:
    print(float(H * x), 0)
elif f_y == 0:
    print(float(H * x), 0)


### FIXED CODE ###

def main(W: int, H: int, x: int, y: int):
    area = W * H
    count = 0

    if x * 2 == W and y * 2 == H:
        count = 1

    print("{:.6f}".format(area / 2), count)


if __name__ == "__main__":
    W, H, x, y = map(int, input().split())

    main(W, H, x, y)
N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
i = 0
while True:
  if i+1 <= N:
    Alice += Ai[i]
    Bob = Alice[i+1]
  if i == N:
    Alice += Ai[i]
  if i > N:
    break
  i = i + 2

print(Alice - Bob)
    

### FIXED CODE ###

N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
i = 0
while True:
  if i+1 <= N-1:
    Alice += Ai[i]
    Bob += Ai[i+1]
  if i == N-1:
    Alice += Ai[i]
  if i > N-1:
    break
  i = i + 2

print(Alice - Bob)
from collections import deque
import numpy as np
H,W = map(int,input().split())
Maze=[list(input()) for i in range(H)]
for hi in range(0,H):
    for wi in range(0,W):
        if Maze[hi][wi]=="#":
            continue
        maze1=[[0]*W for _ in range(H)]
        stack=deque([[hi,wi]])
        while stack:
            h,w=stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h,new_w=h+i,w+j
                if new_h <0 or new_w <0 or new_h >=H or new_w >=W:
                    continue
                elif Maze[new_h][new_w]!="#" and maze1[new_h][new_w]==0:
                    maze1[new_h][new_w]=maze1[h][w]+1
                    stack.append([new_h,new_w])
        
        maze1[hi][wi]=0
        ans=max(ans,np.max(maze1))
print(ans)

### FIXED CODE ###

from collections import deque
import numpy as np
H,W = map(int,input().split())
Maze=[list(input()) for i in range(H)]
ans=0
for hi in range(0,H):
    for wi in range(0,W):
        if Maze[hi][wi]=="#":
            continue
        maze1=[[0]*W for _ in range(H)]
        stack=deque([[hi,wi]])
        while stack:
            h,w=stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h,new_w=h+i,w+j
                if new_h <0 or new_w <0 or new_h >=H or new_w >=W:
                    continue
                elif Maze[new_h][new_w]!="#" and maze1[new_h][new_w]==0:
                    maze1[new_h][new_w]=maze1[h][w]+1
                    stack.append([new_h,new_w])
        
        maze1[hi][wi]=0
        ans=max(ans,np.max(maze1))
print(ans)
X,K,D = map(int,input().split())

X = abs(X)

if X == D :
  print (X)
elif X < D :
  pirnt( D- X)
elif X > K * D:
  print (X - K * D)
elif X // D < K:
  print (X % D)
else:
  print(X)

### FIXED CODE ###

X,K,D = map(int,input().split())

X = abs(X)

if X == D :
  if K == 0:
    print (X)
  elif K % 2 == 0:
    print(X)
  else:
    print(0)
elif X < D :
  if K == 0 :
    print(X)
  elif K % 2 ==0:
    print(X)
  else:
    print( abs(D - X))
elif X > K * D:
  print (X - K * D)

elif X // D < K:
  K = K - X // D
  if K % 2 == 0:
    print (X % D)
  else:
    print (abs(D - X % D))
else:
  print(X)
a=int(input())

if(a<1200):
    print("ABC")
else:
    print("ARC)


### FIXED CODE ###

a=int(input())

if(a<1200):
    print("ABC")
else:
    print("ARC")
memo = [1, 1]

def fib(n):
    if (n in memo):
        return memo[n]
    ans = fib(n-1) + fib(n-2)
    memo.append(ans)
    return ans

n = int(input())
print(fib(n))


### FIXED CODE ###

memo = [1, 1]

def fib(n):
    if (n < len(memo)):
        return memo[n]

    memo.append(fib(n-1) + fib(n-2))
    return memo[n]

N = int(input())
print(fib(N))
N,K=map(int,input().split())
X=list(map(int,input().split()))
if X[0]>0:
    b=X[K]
elif X[0]==0:
    b=X[K-1]
elif 0 in X:
    a=0
    b=10**9
    for i in range(N):
        if X[i]==0:
            a=i
            break
    for j in range(max(0,K-1-a),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
else:
    a=0
    b=10**9
    for i in range(N):
        if X[i]>0:
            a=i
            break
    for j in range(max(-1,K-a-1),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
print(b)

### FIXED CODE ###

N,K=map(int,input().split())
X=list(map(int,input().split()))
if X[0]>=0:
    b=X[K-1]
elif X[-1]<=0:
    b=abs(X[-K])
elif 0 in X:
    a=0
    b=10**9
    for i in range(N):
        if X[i]==0:
            a=i
            break
    for j in range(max(0,K-1-a),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
else:
    a=0
    b=10**9
    for i in range(N):
        if X[i]>0:
            a=i
            break
    for j in range(max(-1,K-a-1),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
print(b)
n=int(input())
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
ans=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans+=gcd(i,gdc(j,k))
print(ans)



### FIXED CODE ###

K=int(input())
def gcd(a,b):
    res=0
    while b!=0:
        res=a%b
        a=b
        b=res
    return a

ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            t=gcd(i,gcd(j,k))
            ans+=t
print(ans)
K, X = input().split()

if 500 * int(K) >= X:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

K, X = input().split()

total = int(K) * 500

if total >= int(X):
  print("Yes")
else:
  print("No")
x,y=input().split()
x=int(x)
y=int(y)
a=[input() for i in range(x)]
c=""
for i in range(y):
  c=c+"#"
print(c)
for i in range(y):
  print("#"+a[i]+"#")
print(c)

### FIXED CODE ###

x,y=input().split()
x=int(x)
y=int(y)
a=[input() for i in range(x)]
c=""
for i in range(y+2):
  c=c+"#"
print(c)
for i in range(x):
  print("#"+a[i]+"#")
print(c)
n=int(input())
ans=0

for i in range(2**n):
    m=bin(i)[2:].rjust(n, "0")
    cnt=0
    flag=0
    for j in range(n):
        A=int(input())
        if m[j]=="0":
            for k in range(A):
                b, c =input().split()

        elif m[j]=="1":
            for k in range(A):
                b ,c =input().split()
                b=int(b)
                if m[b-1]!=int(c):
                    flag=1
                elif m[b-1]==int(c) and c=="1":
                    cnt+=1
    
    if flag==0 and cnt>ans:
        ans=cnt

print(ans)

### FIXED CODE ###

n=int(input())
word=[]

for i in range(n):
    a=int(input())
    l=[list(map(int, input().split())) for j in range(a)]
    word.append(l)

ans=0

for i in range(2**n):
    flag=0
    cnt=0
    for j in range(n):
        if((i>>j)&1)==1 and flag==0:
            for k in range(len(word[j])):
                if ((i>>word[j][k][0]-1)&1) != word[j][k][1]:
                    flag=1
                    break
    
    if flag==0:
        cnt=bin(i).count("1")
        ans=max(ans, cnt)

print(ans)
n, l = map(int, input().split())

total = (l - 1) * n + n * (n + 1) // 2
min_diff = abs(total)
for i in range(n):
  apple = l + i
  apple_pie = total - apple
  diff = abs(apple)
  if diff < min_diff:
    min_diff = diff
    min_apple_pie = apple_pie
print(min_apple_pie)

### FIXED CODE ###

n, l = map(int, input().split())

total = (l - 1) * n + n * (n + 1) // 2
min_diff = 1e20
for i in range(n):
  apple = l + i
  apple_pie = total - apple
  diff = abs(apple)
  if diff < min_diff:
    min_diff = diff
    min_apple_pie = apple_pie
print(min_apple_pie)
N=int(input())
p=list(map(int, input().split()))

cnt=0
min=p[0]
for i in range(N):
	if p[i]<=min:
		min=p[i]
        cnt+=1
	
print(cnt)

### FIXED CODE ###

N=int(input())
p=list(map(int, input().split()))
 
cnt=0
min=p[0]
for i in range(N):
	if p[i]<=min:
		min=p[i]
		cnt+=1
	
print(cnt)
inp = input()
inp = int(float(inp))
aaa = 0
bbb = 0
yyy = 0

if 0 <= inp and inp <= 10**9:
  if 500 <= inp:
    big = inp // 500
    aaa = big * 1000
    amari = inp % 500
    if 5 <= amari:
      smo = amari //5
      bbb = smo *5
    print(aaa+bbb)
  else if 5 <= inp:
    hhh = inp // 5
    yyy = hhh * 5
    print(yyy)
else:
  print(0)

### FIXED CODE ###

inp = input()
inp = int(float(inp))
aaa = 0
bbb = 0
yyy = 0

if 0 < inp and inp <= 10**9:
  if 500 <= inp:
    big = inp // 500
    aaa = big * 1000
    amari = inp % 500
    if 5 <= amari:
      smo = amari //5
      bbb = smo *5
    print(aaa+bbb)
  elif 5 <= inp:
    hhh = inp // 5
    yyy = hhh * 5
    print(yyy)
else:
  print(0)
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
totl=0
for i in range(n-1):
  if a[i]+a[i+1]<b[i]:
    totl+=a[i]+a[i+1]
    a[i]=0
    a[i+1]=0
  else:
    totl+=b[i]
    if a[i]<b[i]:
      a[i]=0
      a[i+1]-=b[i]-a[i]
    else:
      a[i]-=b[i]
    

print(totl)
  


### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
  if p[i]!=i+1:
    cnt+=1
if cnt>2:
  print('NO')
else:
  print('YES')
#N = int(input()).split()
n = 12141.split()
print(n[0])

### FIXED CODE ###

N = int(input())
n = str(N)
a = list(n)

count = 0

for i in range(len(a)):
  count = count + int(a[i])

if count % 9 == 0:
  print("Yes")
else:
  print("No")
a=max(list(map(int,input().split()));print(':('if a>8 else'Yay!')

### FIXED CODE ###

a=max(list(map(int,input().split())));print(':('if a>8 else'Yay!')
n,m=map(int,input().split())
ab=[list(map(int,input().split()))]
ab.sort()
medium = []
flag = 0
for i in range(m):
  if ab[i][0] == 1:
    medium.append(ab[i][1])
for j in range(m):
  if ab[j][0] in medium and ab[j][1] == n:
    flag = 1
if flag == 1:
  print("POSSIBLE")
else：
  print("IMPOSSIBLE")


### FIXED CODE ###

n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)])
relaypoint = []
for i in range(m):
  if ab[i][0] == 1:
    relaypoint.append(ab[i][1])
  else:
    break
ab.sort(key = lambda ab:ab[1],reverse = True)
relaypoint = set(relaypoint)
x = len(relaypoint)
j = 0
flag = 0
while(ab[j][1] == n):
  if ab[j][0] in relaypoint:
    flag = 1
  j += 1
if flag == 1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
a = list(map(int,input().split()))
wa = 0
for i in range(n):
	a[i] = a[i] - (i + 1)
	wa += a[i]
b = round(wa/n)
ans = 0
for i in range(n):
	ans += abs(a[i] - b)
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a2 = [a[x] - (x + 1) for x in range(n)]
a2.sort()
c = n // 2
b = a2[c]
ans = 0
for i in range(n):
	ans += abs(a2[i] - b)
print(ans)
n = int(input())
tree = [None for i in range(n +1)]
list_pre = list(map(int, input().split()))
list_in = list(map(int, input().split()))
 
 
def reconstruct(tree_pre, tree_in):
    if not tree_pre:
        return -1
    root = tree_pre[0]
    idx = tree_in.index(root)
    tree[root] = (reconstruct(tree_pre[1:i + 1], tree_in[:i]), 
                  reconstruct(tree_pre[i + 1:],  tree_in[i + 1:]))
    return root


def post_order_search(i):
    if i == -1:
        return
    l, r = tree[i]
    for j in post_order_search(l):
        yield j
    for j in post_order_search(r):
        yield j
    yield i


solve(list_pre, list_in)

print(*postorder(list_pre[0]))

### FIXED CODE ###

n = int(input())
tree = [None for i in range(n +1)]
list_pre = list(map(int, input().split()))
list_in = list(map(int, input().split()))
 
 
def solve(tree_pre, tree_in):
    if not tree_pre:
        return -1
    root = tree_pre[0]
    idx = tree_in.index(root)
    tree[root] = (solve(tree_pre[1:idx + 1], tree_in[:idx]), 
                  solve(tree_pre[idx + 1:],  tree_in[idx + 1:]))
    return root


def post_order_search(i):
    if i == -1:
        return
    l, r = tree[i]
    for j in post_order_search(l):
        yield j
    for j in post_order_search(r):
        yield j
    yield i


solve(list_pre, list_in)

print(*post_order_search(list_pre[0]))
a,b = map(int,input().split())
num1 = (a//2)*(b//2)

if a == 1 :
    print(b)
else if b==1:
  	print(a)
else:
    
    # print(num1)
    p = b//2
    q = a//2
    num2 = (b - p )*(a - q)
    ans = num1+num2
    print(num1+num2)

### FIXED CODE ###

a,b = map(int,input().split())
num1 = (a//2)*(b//2)

if a == 1 or b==1:
    print(1)
else:
    
    # print(num1)
    p = b//2
    q = a//2
    num2 = (b - p )*(a - q)
    ans = num1+num2
    print(num1+num2)
def main():
    N,M = map(int(input().split()))

    print((1900*M+100*(N-M))*2**M)

if __name__ == '__main__':
    main()

### FIXED CODE ###


def main():
    N,M = map(int,input().split())

    print((1900*M+100*(N-M))*2**M)

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

ans=99999999
for i in range(1,101):
  d=0
  for x in a:
    d+=(a-i)*(a-i)
  ans=min(ans,d)
print(ans)
    
  

### FIXED CODE ###

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

ans=99999999
for i in range(1,101):
  d=0
  for x in a:
    d+=(x-i)*(x-i)
  ans=min(ans,d)
print(ans)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def check(node_hash_list, edge_color_hash, next_node, node, color):
    edge_color_hash[str(node) + " " + str(next_node)] = color
    new_color = 1
    max_color = color
    if next_node in node_hash_list:
        for new_next_node in node_hash_list[next_node]:
            if color == new_color:
                new_color += 1
            if max_color < new_color:
                max_color = new_color
            temp_color = check(node_hash_list, edge_color_hash, new_next_node, next_node, new_color)
            new_color += 1
            if max_color < temp_color:
                max_color = temp_color
    return max_color
n = int(input())
node_hash_list = {}
print_list = []
for i in range(1, n):
    input_string = input()
    print_list.append(input_string)
    a, b = map(int, input_string.split())
    if a not in node_hash_list:
        node_hash_list[a] = []
    node_hash_list[a].append(b)
edge_color_hash = {}
node = 1
color = 0
max_color = 1
for next_node in node_hash_list[node]:
    color += 1
    if max_color < color:
        max_color = color
    temp_color = check(node_hash_list, edge_color_hash, next_node, node, color)
    if max_color < temp_color:
        max_color = temp_color

print(max_color)
for key in print_list:
    print(edge_color_hash[key])

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def check(node_hash_list, edge_color_hash, next_node, node, color):
    edge_color_hash[str(node) + " " + str(next_node)] = color
    edge_color_hash[str(next_node) + " " + str(node)] = color
    new_color = 1
    max_color = color
    for new_next_node in node_hash_list[next_node]:
        if new_next_node == node:
            continue
        if color == new_color:
            new_color += 1
        if max_color < new_color:
            max_color = new_color
        temp_color = check(node_hash_list, edge_color_hash, new_next_node, next_node, new_color)
        new_color += 1
        if max_color < temp_color:
            max_color = temp_color
    return max_color
n = int(input())
sys.setrecursionlimit(n * 10)
node_hash_list = {}
print_list = []
for i in range(1, n):
    input_string = input()
    print_list.append(input_string)
    a, b = map(int, input_string.split())
    if a not in node_hash_list:
        node_hash_list[a] = []
    if b not in node_hash_list:
        node_hash_list[b] = []
    node_hash_list[a].append(b)
    node_hash_list[b].append(a)
edge_color_hash = {}
node = 1
color = 0
max_color = 1
for next_node in node_hash_list[node]:
    color += 1
    if max_color < color:
        max_color = color
    temp_color = check(node_hash_list, edge_color_hash, next_node, node, color)
    if max_color < temp_color:
        max_color = temp_color

print(max_color)
for key in print_list:
    print(edge_color_hash[key])
n,m = map(int,input().split())
x =[]
c = 0
for i in range(n):
  a = list(map(int,input().split()))
  a.pap(0)
  x.extend(a)
  
for j in range(1,m+1):
  if x.count(j) ==n:
    c +=1
    
print(c)

### FIXED CODE ###

n,m = map(int,input().split())
x = []
c = 0
for i in range(n):
    a = list(map(int,input().split()))
    a.pop(0)
    x.extend(a)

for j in range(1,m+1):
    if x.count(j) == n:
        c += 1

print(c)
import math

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

l=[0]*(n)
for i in range(n-1):
    l[i+1] = math.gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = math.gcd(r[i+1],a[i+1])

print(max([math.gcd(r[i],l[i]) for i in range(n)]))


### FIXED CODE ###

from fractions import gcd

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

l=[0]*(n)
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = gcd(r[i+1],a[i+1])

print(max([gcd(r[i],l[i]) for i in range(n)]))