Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
#    print("a2:",a)
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

#n=8
#a=[746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#ans=[19]
#n=2
#a=[1000000000, 1000000000]
#n=5
#a=[15, 18, 24, 36, 81]
#n=3
#a=[7, 6, 8]
n=int(input())
a=[]
for i in map(int,input().split()):
    a.append(i)

#print(a)
if n==2:
    print(max(a))
elif n<2**10:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=2**9
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==n-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)

    gcdv=0

    for mi in range(m):
        rgcd1=rgcd.copy()
        del rgcd1[mi]
        ms=ns*mi
        if mi==n-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        for i in range(len(am)):
            acpy=am.copy()
            del acpy[i]
            acpy=acpy+rgcd1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx

#    print(gcdv,a1)
    print(gcdv)


### FIXED CODE ###

def gcdf(a):
    a.sort()
#    print("a2:",a)
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
#    print("a2:",a)
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

#n=8
#a=[746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#ans=[19]
#n=2
#a=[1000000000, 1000000000]
#n=5
#a=[15, 18, 24, 36, 81]
#n=3
#a=[7, 6, 8]
n=int(input())
a=[]
for i in map(int,input().split()):
    a.append(i)
if n==2:
    print(max(a))
elif n<2**10:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n**(1/2))
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)
### BUGGY CODE ###

# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    # ai may be not a parent of bi. -> set a skip condition (p) in dfs
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()
### BUGGY CODE ###

# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def main():
    x,y,z,k=MI()
    A=sorted(LI(),reverse=True)
    B=sorted(LI(),reverse=True)
    C=sorted(LI(),reverse=True)
    Q=[[(A[0]+B[0]+C[0])*(-1),0,0,0]]
    heapify(Q)
    #print(Q)
    i=0
    ans=[]
    #print(heappop(Q))
    #al=[[[-1]*x for i in range(y)] for j in range(z)]
    #al[0][0][0]=0
    xl,yl,zl=0,0,0
    al=[]
    al=[[0,0,0]]
    while i<k:
        #print(Q)
        if not Q:
            sys.exit()
        a,u,v,w=heappop(Q)
        ans.append(-a)
        i+=1
        if u+1<x and (not ([u+1,v,w] in al)):
            heappush(Q,[-A[u+1]-B[v]-C[w],u+1,v,w])
            al.append([u+1,v,w])
            
            #al[u+1][v][w]=0
        if v+1<y and not([u,v+1,w] in al):
            heappush(Q,[-A[u]-B[v+1]-C[w],u,v+1,w])
            al.append([u,v+1,w])
            #al[u][v+1][w]=0
        if w+1<z and not([u,v,w+1] in al):
            heappush(Q,[-A[u]-B[v]-C[w+1],u,v,w+1])
            al.append([u,v,w+1])
    #print(len(ans))
    for i in range(k):
        print(ans[i])
if __name__=="__main__":
    main()
    

    
    


### FIXED CODE ###

# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,y,z,k=MI()
A=LI()
B=LI()
C=LI()
lis=[]
for i in range(x):
    for j in range(y):
        lis.append(A[i]+B[j])
lis.sort(reverse=True)
lisan=[]
for i in range(min(k,x*y)):
    for j in range(z):
        lisan.append(lis[i]+C[j])
lisan.sort(reverse=True)
for i in range(k):
    print(lisan[i])
### BUGGY CODE ###

def main():
  n,q=map(int,input().split())
  s=input()
  lr=[list(map(int,input().split())) for _ in [0]*q]
  for i in range(q):
    print(s[lr[i][0]-1:lr[i][1]].count('AC'))

if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n,q=map(int,input().split())
  s=input()
  t = [0] * (n + 1)
  for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
  for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

if __name__=='__main__':
  main()
### BUGGY CODE ###

N = int(input())

letter = []
num_letter = []
letter.append(input())
num_letter.append(1)
max_num_letter = 1

for i in range(1,N):
  S = input()
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S:
      num_letter[j]+=1
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

max_num_letter = max(num_letter)
max_letter = []

max_letter = [letter[i] for i in range(len(letter)) if num_letter[i] == max_num_letter]
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])


### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])
### BUGGY CODE ###

from operator import mul
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
re = reduce(mul,A)
#print(reduce(mul,A))
#for i in range(N):
#  re *= A[i]
if re > 10**18:
  re = -1
print(re)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
re = 1
if int(0 in A) == 1:
  re = 0
  N = 0
for i in range(N):
  re *= A[i]
  if re > 10**18:
    re = -1
    break
print(re)
### BUGGY CODE ###

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

mod = 1000000007

def cmb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
  
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

print(pow(2,n,mod)-1-(cmb(n,a,mod)+cmb(n,b,mod)))

### FIXED CODE ###

n, a, b = map(int, input().split())
mod = 7+10**9
def comb(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod
c_a = comb(n,a,mod)
c_b = comb(n,b,mod)
print((pow(2,n,mod)-1 -(c_a+c_b))%mod)
### BUGGY CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[-1 for _ in range(n+2)] for __ in range(n+2)] for ___ in range(n+2)]
"""

for i in range(n,-1,-1):
    for j in range(n,i-1,-1):
        for k in range(n,j-1,-1):
            dp[k][j][i] = (dp[k-1][j+1][i] + 1) * k/n +(dp[k][j-1][i+1] + 1) * i/n +  (dp[k][j][i] + 1) * j/n
こういうインデックスが面倒なことになるから1枚、2枚、3枚でなく1枚以上、2枚以上、3枚以上食べた種類の数で管理する
"""
"""
for i in range(n-1,-1,-1):
    for j in range(n-1,i-1,-1):
        for k in range(n-1,j-1,-1):
            
            ???
            dp[k][j][i] = (dp[k+1][j+1][i] + 1) * k/n +(dp[k+1][j+1][i+1] + 1) * j/n +  (dp[k][j][i] + 1) * i/n
            → dp[k][j][i] = ((dp[k+1][j+1][i] + 1) * k/(n-i) +(dp[k+1][j+1][i+1] + 1) * j/(n-i)) +   n/i
            """


#上の方針だと追えないのでやり直し。
#割り算が遅いと聞いてとりあえず試す
dp[n][n][n] = 0
def solve(x, y, z):
    if dp[x][y][z] != -1:
        return dp[x][y][z]
    else:
        
        hoge = 1.0 / (n - z)
        delta = n*hoge#3枚以上ある皿以外を引くまで
        dp[x][y][z] = 0
        try:
            if x != n:
                dp[x][y][z] += (solve(x+1,y,z) + delta) * (n-x)*hoge
            if y != x:
                dp[x][y][z] += (solve(x,y+1,z) + delta) * (x-y)*hoge#x+1,y+1ではない
            if z != y:
                dp[x][y][z] += (solve(x,y,z+1) + delta) * (y-z)*hoge#x+1,y+1,z+1ではない
        except:
            print(x,y,z)

        return dp[x][y][z]


print(solve(cnt[1]+cnt[2], cnt[2] ,0))




### FIXED CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[0 for _ in range(n+1)] for __ in range(n+1)] for ___ in range(n+1)]

dp[n][n][n] = 0
divT = [1/i for i in range(1,n+1)]

for x in range(n,cnt[1]+cnt[2]-1,-1):## -2だったのを-1に
    for y in range(x,cnt[2]-1,-1):##cnt[2]
        for z in range(y,-1,-1):
            delta = n*divT[n-z-1]#2枚以下を引くまで
            if x != n:
                dp[x][y][z] += (dp[x+1][y][z] + delta) * (n-x)
            if y != x:
                dp[x][y][z] += (dp[x][y+1][z] + delta) * (x-y)#x+1,y+1ではない
            if z != y:
                dp[x][y][z] += (dp[x][y][z+1] + delta)* (y-z)#x+1,y+1,z+1ではない
            dp[x][y][z] *=divT[n-z-1]

print(dp[cnt[1]+cnt[2]][cnt[2]][0])
### BUGGY CODE ###

import collections as cl,sys
input = sys.stdin.readline
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-1 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
cl = [1 for i in range(n)]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = [1 for i in range(n)]

    elif ppp[kkk[0]] != 0 and on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != 0 != 0 and ppp[kkk[0]] != 0 and on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][0],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][0],kkk[0]])


print(co)


### FIXED CODE ###

import collections as cl
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-1 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
ppppp = [1 for i in range(n)]
cl = ppppp[:]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = ppppp[:]

    elif ppp[kkk[0]] != 0 and on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != 0 != 0 and ppp[kkk[0]] != 0 and on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][0],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][0],kkk[0]])


print(co)
### BUGGY CODE ###

n = int(input())

l1 = []
for i in range(n // 2):
  q, mod = divmod(n , i + 1)
  if mod == 0:
    l1.append(q + i -1)
print(min(l1))

### FIXED CODE ###

n = int(input())
 
l1 = []
for i in range(1, int(n ** 0.5) + 1):
  q, mod = divmod(n , i)
  if mod == 0:
    l1.append(q + i -2)
print(min(l1))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
q=int(input())
dic=dict()
list_sum=sum(l)
for i in range(len(l)):
    if(l[i] not in dic.keys()):
        dic[l[i]]=1
    else:
        dic[l[i]]+=1
# print(dic)

for i in range(q):
    s=0
    b,c=map(int,input().split())
    if(b in dic and dic[b]!=0):
        # s=(c-b)*dic[b]+list_sum
        if(c in dic):
            dic[c]+=dic[b]
            dic[b]=0
        else:
            dic[c]=dic[b]
            dic[b]=0
    for x in dic:
        if(dic[x]!=0):
            s+=x*dic[x]
    print(s)





### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
q=int(input())
dic=dict()
list_sum=sum(l)
for i in range(len(l)):
    if(l[i] not in dic.keys()):
        dic[l[i]]=1
    else:
        dic[l[i]]+=1
# print(dic)
s=list_sum
for i in range(q):
    b,c=map(int,input().split())
    # print(dic)
    if(b in dic and dic[b]!=0):
        s+=(c-b)*dic[b]
        if(c in dic):
            dic[c]+=dic[b]
            dic[b]=0
        else:
            dic[c]=dic[b]
            dic[b]=0
    
    print(s)
    # print(dic)
### BUGGY CODE ###

N = int(input())

stairs = list(map(int, input().split(" ")))

for i in range(N):
    stair = stairs[i]
    if stair - 2 >= min(stairs[i:]):
        print("No")
        exit(0)

print("Yes")


### FIXED CODE ###

N = int(input())

stairs = list(map(int, input().split(" ")))
min = 0

for i in range(N):
    stair = stairs[i]
    if min > stair:
        print("No")
        exit(0)
    if stair - 1 > min:
        min = stair - 1

print("Yes")
### BUGGY CODE ###

n, a, b = map(int, input().split())
total = 0
out = 0
while True:
    total += a
    out += a
    if total >= n:
        out -= (total - n)
        break
    
    total += b
    if total >= n:
        break

print(out)

### FIXED CODE ###

n, a, b = map(int, input().split())
q = n // (a + b)
mod = n % (a + b)
if mod > a:
    remain = a
else:
    remain = mod
    
print(q * a + remain)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
f = 0
for i in A:
    if A.count(i) > 1:
        f = 1 
        
if f > 0:
    print("NO")
else:
 print("YES")
    


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
f = 0
A.sort()
for i in range(len(A)):
    if i != len(A)-1:
        if A[i] == A[i+1]:
            f = 1
            break
        
if f > 0:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

import math

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0

n, r = N-1, K-1 
C = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(N-K+1):
    ans += (A[-i-1] - A[i]) * C
    C *= N-i-K
    if N-i-1 != 0:
        C //= N-i-1

print(ans % 1000000007)

### FIXED CODE ###

N, K = map(int, input().split())
MOD = 10**9+7
A = [a % MOD for a in sorted(list(map(int, input().split())))]
MIN, MAX = 0, 0

def div_MOD(a):     # (a^{-1} mod MOD) をフェルマーの小定理より求める
    return pow(a, MOD - 2, MOD)     # a^{-1} = a^{p-2} (mod p)

C = [0]*(K-1) + [1]
for n in range(K, N):
    C.append((C[n-1] * n * div_MOD(n-(K-1))) % MOD)

for i in range(N-K+1):
    MIN = (MIN + (A[i] * C[N-i-1]) % MOD) %MOD
for i in range(N-K+1):
    MAX = (MAX + (A[N-1-i] * C[N-i-1]) % MOD) %MOD

print((MAX - MIN) % MOD)
### BUGGY CODE ###

import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()

H, W = map(int, input().split())

ch, cw = map(int, input().split())
dh, dw = map(int, input().split())

visited = {}

maze = []
for i in range(H):
    a = list(input())
    maze.append(a)

queue = deque([(ch-1, cw-1, 0)])
ans = float("inf")

visited[(ch-1, cw-1)] = 0
while queue:
    y, x, cnt = queue.popleft()

    if y == dh-1 and x == dw-1:
        ans = min(ans, cnt)

    for a, b in ([1, 0], [-1, 0], [0, 1], [0, -1]):
        new_y, new_x = y+a, x+b
        if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != '#':
            if (new_y, new_x) not in visited or visited[(new_y, new_x)] > cnt:
                queue.append((new_y, new_x, cnt))
                visited[(new_y, new_x)] = cnt

    for a in range(-2, 3):
        for b in range(-2, 3):
            new_y, new_x = y + a, x + b
            if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != '#':
                if (new_y, new_x) not in visited or visited[(new_y, new_x)] > cnt + 1:
                    queue.append((new_y, new_x, cnt+1))
                    visited[(new_y, new_x)] = cnt+1

print(-1 if ans == float("inf") else ans)

### FIXED CODE ###

import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()

H, W = map(int, input().split())

ch, cw = map(int, input().split())
ch -= 1
cw -= 1
dh, dw = map(int, input().split())
dh -= 1
dw -= 1

maze = []
for i in range(H):
    a = list(input())
    maze.append(a)

queue = deque([(ch, cw, 0)])

dist = [[float("inf") for _ in range(W)] for _ in range(H)]
dist[ch][cw] = 0

while queue:
    y, x, cnt= queue.popleft()

    for a, b in ([1, 0], [-1, 0], [0, 1], [0, -1]):
        new_y, new_x = y+a, x+b
        if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != '#':
            if dist[new_y][new_x] == float("inf") or dist[new_y][new_x] > cnt:
                queue.appendleft((new_y, new_x, cnt))
                dist[new_y][new_x] = cnt

    for a in range(-2, 3):
        for b in range(-2, 3):
            new_y, new_x = y + a, x + b
            if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != '#':
                if dist[new_y][new_x] == float("inf") or dist[new_y][new_x] > cnt + 1:
                    queue.append((new_y, new_x, cnt+1))
                    dist[new_y][new_x] = cnt + 1

print(-1 if dist[dh][dw] == float("inf") else dist[dh][dw])
### BUGGY CODE ###

def main():
    L = int(input())
    l = L
    ans = 0
    m = L * 10 ** 3
    for i in range(1, m):
        for j in range(1, m):
            w = m - i - j
            t = i/ 10 ** 3 * j/ 10 ** 3 * w/ 10 ** 3
            if w < 0:
                break
            ans = ans if ans > t else t
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    L = int(input())
    l = L
    ans = 0
    a = L / 3
    print(L ** 3 /27)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

Asum = sum(A)
ans = float('inf')
for i in range(len(A)-1):
    s = sum(A[:i+1])
    t = Asum - s
    ans = min(ans, abs(s-t))

print(ans)

### FIXED CODE ###

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

cum = [0]
for a in A:
    cum.append(cum[-1]+a)

ans = float('inf')
for i in range(n-1):
    s = cum[i+1]
    t = cum[-1] - s
    ans = min(ans, abs(s-t))

print(ans)
### BUGGY CODE ###

#!/usr/bin/python3
import copy

r = 998244353

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

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

# s => comb
itbl = {}
rtbl = {}

for i in range(n):
    ai = a[i]
    
    #itbl
    nitbl = copy.copy(itbl)
    if ai in nitbl:
        nitbl[ai] = (nitbl[ai] + i + 1) % r
    else:
        nitbl[ai] = i + 1

    for sk in itbl:
        if sk + ai in nitbl:
            nitbl[sk + ai] = (nitbl[sk + ai] + itbl[sk]) % r
        else:
            nitbl[sk + ai] = itbl[sk]

    #rtbl
    if ai in rtbl:
        rtbl[ai] += (i + 1) * (n - i)
    else:
        rtbl[ai] = (i + 1) * (n - i)

    for sk in itbl:
        if sk + ai in rtbl:
            rtbl[sk + ai] = (rtbl[sk + ai] + itbl[sk] * (n - i)) % r
        else:
            rtbl[sk + ai] = (itbl[sk] * (n - i)) % r
            
    itbl = nitbl
    
print(rtbl.get(s, 0))


### FIXED CODE ###

#!/usr/bin/python3
import copy

r = 998244353

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

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

# s => comb
itbl = {}
rtbl = {}

for i in range(n):
    ai = a[i]
    
    if ai <= s:
        nitbl = copy.copy(itbl)        
        if ai in nitbl:
            nitbl[ai] = (nitbl[ai] + i + 1) % r
        else:
            nitbl[ai] = i + 1

        if ai in rtbl:
            rtbl[ai] += (i + 1) * (n - i)
        else:
            rtbl[ai] = (i + 1) * (n - i)

        for sk in itbl:
            if sk + ai <= s:
                if sk + ai in nitbl:
                    nitbl[sk + ai] = (nitbl[sk + ai] + itbl[sk]) % r
                else:
                    nitbl[sk + ai] = itbl[sk]
                    
                if sk + ai in rtbl:
                    rtbl[sk + ai] = (rtbl[sk + ai] + itbl[sk] * (n - i)) % r
                else:
                    rtbl[sk + ai] = (itbl[sk] * (n - i)) % r
            
        itbl = nitbl
    
print(rtbl.get(s, 0))