Harryxun/stf_run huggingface dataset:
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, rightSibling, *children):
        self.id = num
        self.parent = parent
        self.rightSibling = rightSibling
        self.children = list(children)
        self.depth = 0
    def showInfo(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print('{0}'.format(self.children))

def setNode(num, k, *children):
    if T[num]:
        T[num].children = list(children)
    else:
        node = Node(num, -1, None, *children)
        T[num] = node
    if children:
        for i, x in enumerate(children[:-1]):
            if T[x]:
                T[x].parent = num
                T[x].rightSibling = children[i + 1]
            else:
                node = Node(x, num, children[i + 1])
                T[x] = node
        lastChild = children[-1]
        if T[lastChild]:
            T[lastChild].parent = num
        else:
            node = Node(lastChild, num, None)
            T[lastChild] = node

def setDepth(u, p):
    T[u].depth = p
    if T[u].children:
        setDepth(T[u].children[0], p + 1)
    if T[u].rightSibling != None:
        setDepth(T[u].rightSibling, p)

def findRoot(r):
    if T[r].parent == -1:
        return r
    return findRoot(T[r].parent)


import sys

n = int(sys.stdin.readline())

T = [None for i in range(n)]

for x in sys.stdin.readlines():
    setNode(*list(map(int, x.split())))

r = findRoot(0)

setDepth(r, 0)

for x in T:
    x.showInfo()

### FIXED CODE ###

class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
        
    def show_info(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,
                                                                     self.parent,
                                                                     self.depth,
                                                                     self.type,
                                                                     self.children))


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pdt(T[-1], -1, 0)

T[T[-1]].type ='root'

for n in T[:-1]:
    n.show_info()
input()
ss = input()
loss = ss[1:].count("E")
min_loss = loss
ss_before = ss[:-1]
ss_after = ss[1:]
for b, a in zip(ss_before, ss_after):
    loss += b == "W"
	loss -= a == "E"
    if loss < min_loss:
        min_loss = loss
print("{}".format(min_loss))

### FIXED CODE ###

input()
ss = input()
loss = ss[1:].count("E")
min_loss = loss
ss_before = ss[:-1]
ss_after = ss[1:]
for b, a in zip(ss_before, ss_after):
    loss += b == "W"
    loss -= a == "E"
    if loss < min_loss:
        min_loss = loss
print("{}".format(min_loss))
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n = onem()
a = []
for i in range(n):
    a.append(l())
aa = []
for i in range(n-1):
    for j in range(i,n):
        if not (a[i][0] - a[j][0] == 0 and a[i][1] - a[j][1] == 0):
            aa.append([a[i][0] - a[j][0],a[i][1] - a[j][1]])
            aa.append([a[j][0] - a[i][0],a[j][1] - a[i][1]])
aa.sort()
c = 1
cc = 1
lp = aa[0]
for i in range(1,len(aa)):
    if lp == aa[i]:
        c += 1
    else:
        if c >= cc:
            cc = c
        lp = aa[i]
        c = 1
if c >= cc:
    cc = c


print(n - cc )


### FIXED CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n = onem()
if n == 1:
    l()
    print(1)
else:
    a = []
    for i in range(n):
        a.append(l())
    aa = []
    for i in range(n-1):
        for j in range(i,n):
            if not (a[i][0] - a[j][0] == 0 and a[i][1] - a[j][1] == 0):
                aa.append([a[i][0] - a[j][0],a[i][1] - a[j][1]])
                aa.append([a[j][0] - a[i][0],a[j][1] - a[i][1]])
    aa.sort()
    c = 1
    cc = 1
    lp = aa[0]
    for i in range(1,len(aa)):
        if lp == aa[i]:
            c += 1
        else:
            if c >= cc:
                cc = c
            lp = aa[i]
            c = 1
    if c >= cc:
        cc = c


    print(n - cc )
n, k, s = map(int, input().split())
a = []
for _ in range(k):
        a.append(str(s))
for _ in range(n-k):
  if s != 1000000000
        a.append(str(s+1))
  else:
    a.append(str(s-1))
ans = ' '.join(a)
print(ans)

### FIXED CODE ###

n, k, s = map(int, input().split())
a = []
for _ in range(k):
        a.append(str(s))
for _ in range(n-k):
  if s != 1000000000:
  	a.append(str(s+1))
  else:
    a.append(str(s-1))
ans = ' '.join(a)
print(ans)
a = [input() for i in range(3)]
a.sort()
print(int((a[2]+a[1])+a[0])

### FIXED CODE ###

a,b,c=sorted(map(int,input().split()))
print(10*c+b+a)
D = int(input())
if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve') 
elif D == 22:
  print('Christmas Eve Eve Eve')
 D = int(input())
if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve') 
elif D == 22:
  print('Christmas Eve Eve Eve')
 

### FIXED CODE ###

D = int(input())
if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve') 
elif D == 22:
  print('Christmas Eve Eve Eve')
#c.py
w,h,x,y = map(int,input().split())
min(w * y,(w*h)-w*y)
min(h * x,(w*h)-h*x)
if x > w//2 and y > h//2:
    m = 
if w//2 == x and h//2 == y:
    print(w*h/2,0)
else:
    ans = max(min(w*y,(w*h)-w*y),min(h*x,(w*h)-h*x))
    print(ans,1)



### FIXED CODE ###

#c.py
w,h,x,y = map(int,input().split())
if w/2 == x and h/2 == y:
    print(w*h/2,1)
else:
    print(w*h/2,0)
N, K = list(map(int, input().split()))
links = [list(map(int, input().split())) for _ in range(N-1)]

def perm(a, b):
    s = 1
    for i in range(a-b+1, a+1):
        s *= i
    return s

if N == 1:
    ans = K
else:
    perm_dict = {}
    mod = 1000000007
    d = {i: [] for i in range(1, N+1)}
    history = [True] * (N + 1)
    for i, j in links:
        d[i].append(j)
        d[j].append(i)
    b = len(d[1])
    if K - 1 < b:
        ans = 0
    else:
        ans = K * perm(K - 1, b)
        history[1] = False
        a = K - 2
        stack = d[1]
        while stack:
            node = stack.pop()
            history[node] = False
            b = len(d[node]) - 1
            if a < b:
                ans = 0
                break
            if b not in perm_dict:
                perm_dict[b] = perm(a, b)
            ans *= perm_dict[b]
            for i in d[node]:
                if history[i]:
                    stack.append(i)
            
print(ans % mod)

### FIXED CODE ###

N, K = list(map(int, input().split()))
l = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    l[a].append(b)
    l[b].append(a)

deg1 = [0] * (N + 1)
deg2 = [0] * (N + 1)
history = [True] * (N + 1)
stack = [1]
ans = 1

while stack:
    node = stack.pop()
    ans *= K - deg1[node] - deg2[node]
    ans %= 1000000007
    history[node] = False
    for child in l[node]:
        if history[child]:
            deg1[child] += 1
            deg2[child] += deg1[node]
            deg1[node] += 1
            stack.append(child)
            
print(ans)
N,K = map(int, input().split())
p = list(map(int, input().split()))
sump0=0
for i in range(N-2):
	sump=p[i]+p[i+1]+p[i+2]
	if sump>sump0:
	sump0=sump
    
print(sump0/2+K/2)

### FIXED CODE ###

import itertools
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
acc = [0] + list(itertools.accumulate([(x+1)/2 for x in p])) # 累積和を計算
 
ans = max(acc[i]-acc[i-k] for i in range(k, n+1)) # k番目からn番目まで計算
print(ans)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : a.py
# Author            : recurze
# Date              : 22:46 18.01.2019
# Last Modified Date: 22:46 18.01.2019

print int(raw_input()) + int(raw_input()) >> 1


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : a.py
# Author            : recurze
# Date              : 22:46 18.01.2019
# Last Modified Date: 22:49 18.01.2019

a, b = [int(x) for x in raw_input().split()]
print a + (b>>1)
import queue
h,w,n = map(int,input().split())
factrys = [None] * (n + 1)
ss = ["X" * (w + 2)]
for i in range(h):
  s = "X" + input() + "X"
  if "S" in s:
    factrys[0] = (i + 1, s.index("S"))
  for j in range(1,n + 1):
    if str(j) in s:
      factrys[j] = (i + 1, s.index(str(j)))
  ss.append(s)
ss.append("X" * (w + 2))
mp = []
que = queue.Queue()

def bfs(i):
  while True:
    (x,y) = que.get()
  #  print(i,x,y)
  #  print(mp[x][y])
    if (x,y) == factrys[i + 1]:
      return mp[x][y]
    count = mp[x][y]
    if ss[x + 1][y] != "X" and mp[x + 1][y] is None:
      mp[x + 1][y] = count + 1
      que.put((x + 1, y))
    if ss[x - 1][y] != "X" and mp[x - 1][y] is None:
      mp[x - 1][y] = count + 1
      que.put((x - 1, y))
    if ss[x][y + 1] != "X" and mp[x][y + 1] is None:
      mp[x][y + 1] = count + 1
      que.put((x, y + 1))
    if ss[x][y - 1] != "X" and mp[x][y - 1] is None:
      mp[x][y - 1] = count + 1
      que.put((x, y - 1))

ans = 0
for i in range(n):
  mp = [[None] * (w + 2) for j in range(h + 2)]
  x,y = factrys[i]
  que = queue.Queue()
  mp[x][y] = 0
  que.put((x,y))
  ret = bfs(i)
  if ret is None:
    ans += 0
  else:
    ans += (ret)
print(ans)


### FIXED CODE ###

from collections import deque

def main():
  h, w, n = map(int, input().split())
  mp = ["X" + input() + "X" for _ in range(h)]
  mp.insert(0, "X" * (w + 2))
  mp.append("X" * (w + 2))
  
  poss = [None] * (n + 1)
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y][x] == "S":
        poss[0] = (x, y)
      elif "1" <= mp[y][x] <= "9":
        poss[int(mp[y][x])] = (x, y)
  
  ans = 0
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  for i in range(n):
    sx, sy = poss[i]
    gx, gy = poss[i + 1]
    used = [[False] * (w + 2) for _ in range(h + 2)]
    used[sy][sx] = True
    que = deque()
    push = que.append
    pop = que.popleft
    push((0, sx, sy))
    while que:
      cnt, x, y = pop()
      if (x, y) == (gx, gy):
        ans += cnt
        break
      
      for dx, dy in vec:
        nx, ny = x + dx, y + dy
        if used[ny][nx] or mp[ny][nx] == "X":continue
        used[ny][nx] = True
        push((cnt + 1, nx, ny))
  
  print(ans)

main()
import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a-1, b-1])
    bridges = bridges[::-1]
    parent = [i for i in range(N)]
    count = collections.defaultdict(int)
    for i in range(N): count[i] = 1

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            parent[pj] = pi
            df += count[pi] * count[pj]
            count[pi] += count[pj]
        return df

    if N % 2 == 0:
        ans.append((N//2)*(N-1))
    else:
        ans.append(N*((N-1)//2))
    for a, b in bridges:
        d = union(a, b)
        ans.append(ans[-1] - d)
    return ans[:-1][::-1]

if __name__ == '__main__':
    output = main()
    for v in output:
        print(str(v))

### FIXED CODE ###

import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a, b])
    bridges = bridges[::-1]
    parent = [i for i in range(N+1)]
    count = dict()
    for i in range(N+1): count[i] = 1

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            if count[pi] > count[pj]:
                parent[pj] = pi
                df += count[pi] * count[pj]
                count[pi] += count[pj]
                del count[pj]
            else:
                parent[pi] = pj
                df += count[pi] * count[pj]
                count[pj] += count[pi]
                del count[pi]                
        return df

    ans = [N*(N-1)//2]
    for a, b in bridges[:-1]:
        d = union(a, b)
        ans.append(ans[-1]-d)
    return ans[::-1]

if __name__ == '__main__':
    output = main()
    for v in output:
        print(v)
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):
 i=str(i);print(f'node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, {list(map(int,t[i]))}')


### FIXED CODE ###

import sys
def q(a,h):
 d[a]=h
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
n=int(input())
for e in sys.stdin:
 e=e.split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,range(n))))
from fractions import factorial

n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

n1 = v.count(v[a - 1])
n2 = v[:a].count(v[:a][a - 1])

print(sum(v[:a]) / a)
if len(set(v[:a])) != 1:
	print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2))))
else:
	ans = 0
	for i in range(a, b + 1):
		ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i)))
	print(int(ans))

### FIXED CODE ###

from math import factorial

n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

n1 = v.count(v[a - 1])
n2 = v[:a].count(v[:a][a - 1])

print(sum(v[:a]) / a)
if len(set(v[:a])) != 1:
	if n1 == n2:
		print(1)
	else:
		print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2))))
else:
	ans = 0
	if n1 == 1:
		print(1)
	else:
		for i in range(a, min(n1 + 1, b + 1)):
			ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i)))
		print(int(ans))
import sys
import math
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


n = ni()
p = na()
q = na()
def check(pq):
    ans = factorial(n)
    a = list(range(1,n+1))
    for i in range(n):
        l = n - i
        pqi = pq[i]
        index = a.index(pqi)
        ans -= factorial(max(l-1, 0)) * max(l-index, 0)
        a.remove(pqi)
    return ans
print(abs(check(p) - check(q)))

### FIXED CODE ###

import sys
import math
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def factorial(n):
    if n == 1:
        return n
    elif n==0:
        return 0
    return n * factorial(n-1)

n = ni()

p = na()
q = na()
def check(pq):
    ans = factorial(n)
    a = list(range(1,n+1))
    for i in range(n):
        l = n - i
        pqi = pq[i]
        index = a.index(pqi)
        ans -= factorial(max(l-1, 0)) * max(l-index, 0)
        a.remove(pqi)
    return ans
print(abs(check(p) - check(q)))
s = int(input())
p = [1]*(s+1)
mod = 10**9 + 7

p[1] = 0
p[2] = 0
if s >= 3:
	for i in range(3,s+1):
		p[i] = (sum(p[:i-2]))%mod
print(p[s])

### FIXED CODE ###

s = int(input())
p = [0]*(s+1)
mod = 10**9 + 7
p[0] = 1

if s >= 3:
	for i in range(3,s+1):
		p[i] = (sum(p[:i-2]))%mod
print(p[s])
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
            j = j + 1
print(count)
 

### FIXED CODE ###

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    elif (x % 2 == 0):
        continue
    else:
        if (pow(2, x - 1, x) == 1):
            count += 1
print(count)
n,k = [int(i) for i in input().split()]
td = [[int(i) for i in input().split()] for _ in range(n)]

###dが大きい順にソート
td.sort(key = lambda x: x[0],reverse=True)
td.sort(key = lambda x: x[1],reverse=True)

###なるべくtの種類を多いなかで、dを最大化する
###まず各tでdが最大のものを1つずつ選ぶ
eated_kind = []
eated_kind_num = 0
eated = []
for t,d in td:
  if t not in eated_kind:
    eated_kind.append(t)
    eated_kind_num += 1
    eated.append([t,d])
    
    ###tがk種類存在したら、残りのtを扱うことはない
    ###またdも最大化されているため、これ以降のtdを使うことはない
    if eated_kind_num == k:
      td = td[:i+1]
      break

not_eated = [i for i in td if i not in eated]

###tがk種類存在しなかったら、k個になるまでtに関係なくdを最大化する
if eated_kind_num < k:
  eated += not_eated[:k-eated_kind_num]
  not_eated = not_eated[k-eated_kind_num:]
  #print(eated)
  eated.sort(key = lambda x: x[1],reverse=True)
  
t_point = eated_kind_num**2
d_point = sum([i[1] for i in eated])
point = t_point + d_point
###種類の寿司でdの最大化をする
for t,d in not_eated:
  eated_last_t, eated_last_d = eated[-1]
  t_point_sub = (eated_kind_num-1)**2 - eated_kind_num**2
  d_point_sub = d - eated_last_d
  eated = eated[:-1]
  point = max(point,point[-1]+t_point_sub+d_point_sub)
  eated_kind_num -= 1    
#print(eated)

print(point)

### FIXED CODE ###

n,k = [int(i) for i in input().split()]
td = [[int(i) for i in input().split()] for _ in range(n)]

###dが大きい順にソート
td.sort(key = lambda x: x[1],reverse=True)

###各tでdが最大のものを格納
fix_eated_d=[]
###各tでdが最大でないものを格納。tの種類を増やす際の削除候補
change_eated_d=[]

eated_t = set()
d_point = 0

###まずdを最大化
for t,d in td[:k]:
  
  ###すでにtが選ばれているなら最大のdではないのでchangeへ
  if t in eated_t:
    change_eated_d.append(d)
    
  ###まだtが選ばれていないなら最大のdだからfixへ
  else:
    fix_eated_d.append(d)
    eated_t.add(t)
    
  d_point += d
  
point = len(eated_t)**2 + d_point

###tの種類を増やす
for t,d in td[k:]:
  ###削除候補がなくなれば終了
  if not change_eated_d:
    break
  
  ###すでにtが選ばれているならskip
  if t in eated_t:
    continue
    
  ###まだtが選ばれていないなら追加、change中dが最小のものを削除
  eated_t.add(t)
  d_point += d - change_eated_d.pop()
  point = max(point, len(eated_t)**2 + d_point)
  
print(point)
from itertools import chain,repeat
K,N = map(int,input().split())

def dec(seq):
  if seq[-1] == 1:
    seq.pop()
  else:
    seq[-1] -= 1
    if len(seq) < N:
      seq += list(repeat(K,N-len(seq)))
  return seq

if K % 2 == 0:
  print(' '.join(chain((K-1,),repeat(K,N-1))))
else:
  seq = list(repeat(K//2+1,N))
  d = (N-1)//2
  for _ in range(d):
    seq = dec(seq)
  print(' '.join(map(str, seq)))


### FIXED CODE ###

from itertools import chain,repeat
K,N = map(int,input().split())

def solve():

  if K % 2 == 0:
    return ' '.join(map(str, chain((K//2,),repeat(K,N-1))))
  else:
    seq = [K//2+1]*N
    d = N//2
    for _ in range(d):
      if seq[-1] == 1:
        seq.pop()
      else:
        seq[-1] -= 1
        seq.extend(repeat(K,N-len(seq)))
    return ' '.join(map(str, seq))

def naive():
  from itertools import product
  s = sorted(chain.from_iterable(product(range(1,K+1),repeat=i) for i in range(1,N+1)))
  return ' '.join(map(str, s[(len(s)-1)//2]))

print(solve())
# print(naive())
from math import gcd

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

if n == 2:
    print(max(a))
else:
    # 最初の3個のうちの2個を選んで、最大の最大公約数
    # 最大公約数に選ばれなかったものを交換（rがaより大きいとき）
    r = max(gcd(A[0], A[1]), gcd(A[1], A[2]), gcd(A[2], A[0]))
    # リストaの最初3個の最大公約数
    a = gcd(A[0], gcd(A[1], A[2]))

    for i in range(3, n):
        r = max(gcd(A[i], r), a)
        a = gcd(A[i], a)

    print(r)

### FIXED CODE ###

from math import gcd

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

if n == 2:
    print(max(A))
else:
    # 最初の3個のうちの2個を選んで、最大の最大公約数
    # 最大公約数に選ばれなかったものを交換（rがaより大きいとき）
    r = max(gcd(A[0], A[1]), gcd(A[1], A[2]), gcd(A[2], A[0]))
    # リストaの最初3個の最大公約数
    a = gcd(A[0], gcd(A[1], A[2]))

    for i in range(3, n):
        r = max(gcd(A[i], r), a)
        a = gcd(A[i], a)

    print(r)
length = 0
ans = 0

def remove_data(data, ind_pre, ind_after):
    if ind_pre == 0:
        data_pre = ''
    else:
        data_pre = data[:ind_pre]
    if ind_after == len(data) - 1:
        data_after = ''
    else:
        data_after = data[ind_after + 1:]
    data_remove = data_pre + data_after
    return data_remove

def calc_ans(data):
    global length, ans
    ans_kari = length - len(data)
    if ans_kari > ans:
        ans = ans_kari


def calc_data(data):
    for i in range(len(data) - 1):
        if data[i] != data[i + 1]:
            data_remove = remove_data(data, i, i+1)
            calc_data(data_remove)
    calc_ans(data)

def main():
    global length, ans
    data = input()
    length = len(data)
    calc_data(data)
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###


def calc_data(data):
    count = 0
    c_0, c_1 = 0, 0
    for i in range(len(data)):
        if data[i] == '0':
            if c_1 > 0:
                count += 2
                c_1 -= 1
            else:
                c_0 += 1
        if data[i] == '1':
            if c_0 > 0:
                count += 2
                c_0 -= 1
            else:
                c_1 += 1
    print(count)

def main():
    data = input()
    calc_data(data)


if __name__ == '__main__':
    main()
import sys
_args = sys.argv
_A = _args[1]
_P = _args[2]

if _A > 0 :
    _P=_P+_A*3

_ANS =math.floor(_P/2)

print(_ANS)

### FIXED CODE ###

A, P = map(int, input().split())
print((A * 3 + P)//2)
N = int(input())
def triplets(n):
  	counter = 0
    lower = 1
    upper = round(n**0.5)
    for x in range(1, upper+1):
        y_upper = round(0.5*((4*n-3*x**2)**0.5-x))
        for y in range(1, y_upper+1):
            root = (4*n-3*x**2-3*y**2-2*x*y)**0.5
            z = 0.5*(root-x-y)
            if z%1==0 and z>0:
                counter += 1
    return counter
for m in range(1, N+1):
    print(triplets(m))

### FIXED CODE ###

N = int(input())
l = [0]*N
upper = round((N-1)**0.5-1)
for x in range(1, upper+1):
    for y in range(1, upper + 1):
        for z in range(1, upper + 1):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if tmp < N+1:
                l[tmp-1]+=1
for x in l:
    print(x)