Harryxun/stf_run huggingface dataset:
from collections import deque
h,w,k = map(int,input().split())
a,b,c,d=map(int,input().split())
a -= 1
b -= 1
c -= 1
d -= 1
maze = [input() for _ in range(h)]
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
depth = [[float("inf") for _ in range(w)] for _ in range(h)]
dq = deque([(b,a)])
depth[a][b] = 0
while dq:
  x,y ==dq.popleft()
  if x == d and y == c:
    break
  for i in range(4):
    nx,ny,K = x,y,k
    while K:
      K -= 1
      nx += dx[i]
      ny += dy[i]
      if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[nx][ny] != "@" and depth[nx][ny] > depth[y][x]:
        if depth[ny][nx] == depth[y][x]+1:
          continue
        depth[ny][nx] = depth[y][x] +1
        dq.append((nx,ny))
      else:
        break
print(depth[c][d] if depth[c][d] != float("inf") else -1)




### FIXED CODE ###

from collections import deque
h,w,k = map(int,input().split())
a,b,c,d = map(int,input().split())
a -= 1
b -= 1
c -= 1
d -= 1
maze = [input() for _ in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
depth = [[float("inf") for _ in range(w)] for _ in range(h)]
dq = deque([(b,a)])
depth[a][b] = 0
while dq:
    x,y = dq.popleft()
    if x == d and y == c:
        break
    for i in range(4):
        nx,ny,K = x,y,k
        while K:
            K -= 1
            nx += dx[i]
            ny += dy[i]
            if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[ny][nx] != "@" and depth[ny][nx] > depth[y][x]:
                if depth[ny][nx] == depth[y][x]+1:
                    continue
                depth[ny][nx] = depth[y][x] +1
                dq.append((nx,ny))
            else:
                break
print(depth[c][d] if depth[c][d] != float("inf") else -1)
N, M, C = map(int, input().split())
a = []
for i in range(N+1):
    a.append(list(map(int, input().split())))

count = 0
sum = 0
for i in range(1, N+1):
    for j in range(M):
        sum += int(a[0][j]) * int(a[i][j])
    if sum + int(C) > 0:
        count += 1
        sum = 0
    else:
        sum = 0

print(count)


### FIXED CODE ###

s = [input().split() for i in range(2)]

a, b, c, d = int(s[0][0]), int(s[0][1]), int(s[1][0]), int(s[1][1])

sum_cells_count = a * b
row_cells_count = b * c
col_cells_count = (a - c) * d

filled_cells_count = row_cells_count + col_cells_count

blank_cells_count = sum_cells_count - filled_cells_count
print(blank_cells_count)
n=input()
p = list(map(int,input().split()))
result=[]
for i in range(n):
    s1 = sum(p[:i])
    s2 = sum(p[i:])
    result.append(abs(s1-s2))
resultd = sorted(result)
print(resultd[0])

### FIXED CODE ###

n=int(input())
p = list(map(int,input().split()))
result=sum(p)
for i in range(n-1):
    s1 = sum(p[:i+1])
    s2 = sum(p[i+1:])
    result = min(result,abs(s1-s2))
print(result)
N = int(input())
if(int(N == 1)):
  print('Hello World')
 
if(int(N == 2)):
  A, B = map( int, input().split())
  print( int(A + B))

### FIXED CODE ###

N = int(input())

if( N == 1):
  print('Hello World')
  
if( N ==2):
  A = int( input())
  B = int( input())
  print( int( A + B))
a=int(input())
b=int(input())
c=((a)*(a+1))%2019
print(c)

### FIXED CODE ###

def main():
    a,b = map(int,input().split())
    if a-b+1>=2019:
        print(0)
    else:
        mini = 2020
        for i in range(a,b+1):
            for j in range(a,i):
                joke = i*j%2019
                if joke<mini:
                    mini = joke
                    if mini == 0:
                        print(0)
                        return 0
        print(mini)
main()
A,B,C = map(int,input().split())

answer = C-A+B

if answer > 0:
print(answer)

else :
print(0)

### FIXED CODE ###

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

answer = C-A+B

if answer >= 0:
	print(answer)

else :
	print(0)
n = int(input())
a = list(map(int,input().split()))

for i in range(n):
  for range(len(a)):
    if i in a:
      count++
    print(count\n)
    


### FIXED CODE ###

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

lis = [0] * n
for i in A:
  lis[i-1] += 1

for j in range(len(lis)):
  print(lis[j])
import msvcrt

nm=input().split()
NM_list = list(map(int,nm))

A_list=[]
B_list=[]
for m in range(NM_list[1]):
	ab=input().split()
	AB_list = list(map(int,ab))
	A_list.append(AB_list[0])
	B_list.append(AB_list[1])

n_list=[]
for n in range(1,NM_list[0]+1):
	n_list.append(0)


for i in range(1,len(A_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == A_list[i-1]):
			n_list[n_len-1] += 1
			break

for i in range(1,len(B_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == B_list[i-1]):
			n_list[n_len-1] += 1
			break
			
for p in range(1,NM_list[0]+1):
	print(n_list[p-1])

### FIXED CODE ###

nm=input().split()
NM_list = list(map(int,nm))

A_list=[]
B_list=[]
for m in range(NM_list[1]):
	ab=input().split()
	AB_list = list(map(int,ab))
	A_list.append(AB_list[0])
	B_list.append(AB_list[1])

n_list=[]
for n in range(1,NM_list[0]+1):
	n_list.append(0)


for i in range(1,len(A_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == A_list[i-1]):
			n_list[n_len-1] += 1
			break

for i in range(1,len(B_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == B_list[i-1]):
			n_list[n_len-1] += 1
			break

for p in range(1,NM_list[0]+1):
	print(n_list[p-1])
X=int(input())
for x in range(X,2*X):
    for i in range(2,int(x**.5)+1):
      if X%i==0:
        break:
      else:
        print(x)
        exit()

### FIXED CODE ###

X=int(input())
for x in range(X,2*X):
    for i in range(2,int(x**.5)+1):
        if x%i==0:
            break
    else:
        print(x)
        break
[NO][YES]?k2?K[1-d0<G+]dsGx0k3|Rp

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
c = 0
for i in A:
  if i%2:
    c += 1
if c%2==0:
  print("YES")
else:
  print("NO")
import math
n=int(input())
arr=list(map(int,input().split()))
freq=[0]*(max(arr)+10)
for i in range(len(arr)):
	freq[arr[i]]+=1
for i in range(1,n+1):
	print(freq[i])

### FIXED CODE ###

import math
n=int(input())
arr=list(map(int,input().split()))
freq=[0]*(200020)
for i in range(len(arr)):
	freq[arr[i]]+=1
for i in range(1,n+1):
	print(freq[i])
def main():
  x, a = map(int, input().split())

  if (x-a) <= 0:
    print(0)
    return
  print(x-a)
  return

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  x = input()

  if x[0] == '9':
    print('Yes')
    return
  if x[1] == '9':
    print('Yes')
    return
  print('No')
  return

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

t=list(map(lambda h: t-h*0.006, hs))
t=list(enumerate(t,1))

def solve(best,a,t):
    if not t:
        return best[0]
    if abs(best[1] - a) < abs(t[0][1] - a):
        return solve(best, a, t[1:])
    else:
        return solve(t[0],a,t[1:])

print(solve(t[0],a,t[1:]))


### FIXED CODE ###


n=int(input())
temp,a=map(int,input().split())
hs=map(int,input().split())

t=list(map(lambda h: temp-h*0.006, hs))
t=list(enumerate(t,1))

def solve(best,a,t):
    if not t:
        return best[0]
    if abs(best[1] - a) < abs(t[0][1] - a):
        return solve(best, a, t[1:])
    else:
        return solve(t[0],a,t[1:])

min_diff = 100000000
res = 0
for i in range(len(t)):
    if min_diff > abs(t[i][1] - a):
        min_diff = abs(t[i][1] - a)
        res = i + 1


print(res)
5
4 5 3 5 4

### FIXED CODE ###

n = int(input())
m = list(map(int, input().split()))
maxH = m[0]
numH = 0
for i in range(n):
    if m[i] >= maxH:
        maxH = m[i]
        numH += 1
print(numH)
s=input()
k=int(input())

result=""
for ss in s:
    if ss=="a":
        result+="a"
    else:
        if k>= 123 - ord(ss):
            k-=123-ord(ss)
            result+="a"
        else:
            result+=ss


if k>0:
    k=k%(123-97)
    temp=chr((((ord(result[-1])-97)+k)%(123-97))+97)
    
print(result[:-1]+temp)

#print(ord("a")):97
#print(ord("b")):98
#print(ord("z")):122
#97ならそのまま
#aにするには123-ord()をすればいい

### FIXED CODE ###

s=input()
k=int(input())

result=""
for ss in s:
    if ss=="a":
        result+="a"
    else:
        if k>= 123 - ord(ss):
            k-=123-ord(ss)
            result+="a"
        else:
            result+=ss


if k>0:
    k=k%(123-97)
    temp=chr((((ord(result[-1])-97)+k)%(123-97))+97)
    print(result[:-1]+temp)
else:
    print(result)

#print(ord("a")):97
#print(ord("b")):98
#print(ord("z")):122
#97ならそのまま
#aにするには123-ord()をすればいい
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp={}
    for number in numbers:
        for n in number:
            if n not in dp:
                dp[n]=1
            else:
                dp[n]+=1
    
    for i in range(1,len(dp)+1):
        print(dp[i])

if __name__=="__main__":
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main2():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp=[0]*n
    for number in numbers:
        for n in number:
            dp[n-1]+=1
    for ans in dp:
        print(ans)

def main():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp={}
    for number in numbers:
        for n in number:
            if n not in dp:
                dp[n]=1
            else:
                dp[n]+=1
    print(dp)
    for i in range(1,len(dp)+1):
        print(dp[i])

if __name__=="__main__":
    main2()
def main():
  a = int(input())
  b = float(input())
  print(a*b)

main()

### FIXED CODE ###

a, b = map(str, input().split())
a = int(a)
b1, b2 = b.split('.')
b = int(b1) * 100 + int(b2)
ans = a * b
print(ans//100)
import math
l=[]
for i in range(5):
  l=l+[int(input())]

li=[i%10 for i in l]
minimum=min([i for i in li if i!=0])
ans=l.pop(li.index(minimum))
for i in l:
  ans+=math.ceil(i/10)*10

print(ans)

### FIXED CODE ###

import math
l=[]
for i in range(5):
  l=l+[int(input())]

li=[i%10 for i in l]
lil = [i for i in li if i!=0]
if lil:
  minimum=min([i for i in li if i!=0])
else:
  minimum=0
ans=l.pop(li.index(minimum))
for i in l:
  ans+=math.ceil(i/10)*10

print(ans)
from collections import defaultdict

s = input()
x, y = map(int, input().split())
a = 0
t = [[0], [0]]
n = 0
for i in range(len(s)):
    if s[i] == 'F':
        t[n][-1] += 1
    else:
        n = 1 - n
        t[n].append(0)
flag = [False, False]
z = [x, y]
for k in range(2):
    tt = t[k]
    zk = z[k]
    p = sum(tt)
    if zk > p or zk < -p:
        flag = False
        break
    dp = defaultdict(bool)
    i = 1
    if k == 0:
        dp[tt[0]] = True
    else:
        dp[tt[0]] = True
        dp[-tt[0]] = True
    if len(tt) > 1:
        dp2 = defaultdict(bool)
        for tj in tt[1:]:
            for xj in dp.keys():
                dp2[xj + tj] = True
                dp2[xj - tj] = True
            dp = dp2
    flag = dp[zk]
    if not flag:
        break
if flag:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

from collections import defaultdict

s = input()
x, y = map(int, input().split())
a = 0
t = [[0], []]
n = 0
for i in range(len(s)):
    if s[i] == 'F':
        t[n][-1] += 1
    else:
        n = 1 - n
        t[n].append(0)
flag = [False, False]
z = [x, y]
for k in range(2):
    tt = t[k]
    zk = z[k]
    if len(tt) == 0:
        if zk == 0:
            flag = True
            continue
        else:
            print(1, k)
            flag = False
            break
    p = sum(tt)
    dp = defaultdict(bool)
    i = 1
    if k == 0:
        dp[tt[0]] = True
    else:
        dp[tt[0]] = True
        dp[-tt[0]] = True
    if len(tt) > 1:
        for tj in tt[1:]:
            dp2 = defaultdict(bool)
            for xj in dp.keys():
                dp2[xj + tj] = True
                dp2[xj - tj] = True
            dp = dp2
    flag = dp[zk]
    if not flag:
        break
if flag:
    print('Yes')
else:
    print('No')
input_char = input()
a = int(input_char.split()[0])
b = int(input_char.split()[1])
unused_tap = 1
count = 0

if a > b:
    print(1)
    exit()

while(1):
    if unused_tap >= b:
        print(count)
        break
    
    unused_tap = unused_tap-1 + a 
    count += 1



### FIXED CODE ###

S = input()
T = input()
days = 0

for i in range(3):
    if S == T:
        days = 3
        break
    if S[i] == T[i]:
        days += 1
    
print(days)
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M = map(int,input().split())
A = [int(i) for i in input().split()]
change = [0 for i in range(M)]
for i in range(M):
    change[i] = [int(i) for i in input().split()]

A.sort()
change = sorted(change,key=lambda x:x[1])
change.reverse()

ans = 0
b,c = change[0]
for i in range(N):
    if A[i] > c:
        break
partA = A[:i]

ans += sum(A[i:])
# print(partA)
# print(ans)
for i in range(M):
    count,value = change[i]
    if partA[0] > value:
        break
    for j in range(count):
        if partA[j] < value:
            partA[j] = value
            ans += value
    partA = list(filter(lambda partA:partA != value,partA))
    partA.sort()


ans += sum(partA)
print(ans)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M = map(int,input().split())
A = [int(i) for i in input().split()]
change = [0 for i in range(M)]
for i in range(M):
    change[i] = [int(i) for i in input().split()]

D = []
change = sorted(change,key=lambda x:x[1],reverse=True)
for i in range(M):
    b,c = change[i]
    for j in range(b):
        D += [c]
    if len(D) > N:
        break

A += D
A.sort(reverse=True)
print(sum(A[:N]))
N = int(input())
H = list(map(int, input().split()))
a = [0] * N
start = 0

for i in range(N):
  if H[i] >= H[i+1]:
    a[start] += 1
  else:
    start += 1

      
print(max(a))

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
a = [0] * N
start = 0

for i in range(N - 1):
  if H[i] >= H[i+1]:
    a[start] += 1
  else:
    start += 1

      
print(max(a))
class Solution:
    def solve(self, x: int, y: int) -> int:

        if (2*x - y) % 3 != 0 or (-x + 2*y) % 3 != 0:
            return 0

        m = (2*x - y) // 3
        n = (-x + 2*y) // 3

        # calculate {m+n}C{n}

        mod = 10**9 + 7

        # power
        def fastPow(x: int, n: int) -> int:
            ans = 1
            while n > 0:
                if n & 1 == 1:
                    ans = ans * x % mod
                x = x * x % mod
                n >>= 1

            return ans

        # factorial and its inverse
        fact = [1]
        inv = [1]
        for i in range(1, m+n+1):
            fact.append(0)
            inv.append(0)
            fact[i] = fact[i-1] * i % mod
            inv[i] = fastPow(fact[i], mod - 2) % mod

        return fact[n+m] * inv[n] % mod * inv[m] % mod


if __name__ == '__main__':

    # standard input
    x, y = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(x, y))


### FIXED CODE ###

class Solution:
    def solve(self, x: int, y: int) -> int:

        if (2*x - y) % 3 != 0 or (-x + 2*y) % 3 != 0:
            return 0

        m = (2*x - y) // 3
        n = (-x + 2*y) // 3

        if m < 0 or n < 0:
            return 0

        # calculate {m+n}C{n}
        def egcd(a, b):
            if a == 0:
                return b, 0, 1
            else:
                g, y, x = egcd(b % a, a)
                return g, x - (b // a) * y, y

        def modinv(a, m):
            g, x, y = egcd(a, m)
            if g != 1:
                raise Exception('modular inverse does not exist')
            else:
                return x % m

        def convination(n: int, r: int, mod: int = 10**9+7) -> int:
            r = min(r, n-r)
            res = 1
            for i in range(r):
                res = res * (n-i) * modinv(i+1, mod) % mod
            return res

        return convination(n+m, m)


if __name__ == '__main__':

    # standard input
    x, y = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(x, y))
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
count = 0
for i in range(n+1):
  if a[i] >= b[i]:
    count += b[i]
  else:
    count += b[i]
    a[i+1] = a[i+1] - b[i] + a[i]
print(count) 

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
count = 0
for i in range(n+1):
  if a[i] >= b[i]:
    count += b[i]
  else:
    if a[i] + a[i+1] > b[i]:
      count += b[i]
      a[i+1] = a[i+1] - b[i] + a[i]
    else:
      count += a[i] + a[i+1]
      a[i+1] = 0
print(count)
h,w = map(int,input().split())
lis = [str(input()) for i in range(h)]
ans = 0
ch = [[0] * w for i in range(h)]

def firstcheck(x,y):
    if lis[x][y] != "#" or ch[x][y] != 0:
        return False
    if x > 0:
        if lis[x-1][y] == ".":
            return True
    if x < h-1:
        if lis[x+1][y] == ".":
            return True
    if y > 0:
        if lis[x][y-1] == ".":
            return True
    if y < w-1:
        if lis[x][y+1] == ".":
            return True
    return False

for sx in range(h):
    for sy in range(w):
        if firstcheck(sx,sy):
            cnt = 1
            nu = 0
            ch[sx][sy] = 1
            num = [[0] * w for i in range(h)]
            now = {(sx,sy,1)}
            while len(now) != 0:
                tmp = set()
                for x,y,iro in now:
                    if x > 0:
                        if lis[x-1][y] != lis[x][y] and num[x-1][y] == 0:
                            nu += iro
                            tmp.add((x-1,y,(iro+1)%2))
                            num[x-1][y] = 1
                            if lis[x-1][y] == "#" and ch[x-1][y] == 0:
                                cnt += 1
                                ch[x-1][y] = 1
                    if x < h-1:
                        if lis[x+1][y] != lis[x][y] and num[x+1][y] == 0:
                            nu += iro
                            tmp.add((x+1,y,(iro+1)%2))
                            num[x+1][y] = 1
                            if lis[x+1][y] == "#" and ch[x+1][y] == 0:
                                cnt += 1
                                ch[x+1][y] = 1
                    if y > 0:
                        if lis[x][y-1] != lis[x][y] and num[x][y-1] == 0:
                            nu += iro
                            tmp.add((x,y-1,(iro+1)%2))
                            num[x][y-1] = 1
                            if lis[x][y-1] == "#" and ch[x][y-1] == 0:
                                cnt += 1
                                ch[x][y-1] = 1
                    if y < w-1:
                        if lis[x][y+1] != lis[x][y] and num[x][y+1] == 0:
                            nu += iro
                            tmp.add((x,y+1,(iro+1)%2))
                            num[x][y+1] = 1
                            if lis[x][y+1] == "#" and ch[x][y+1] == 0:
                                cnt += 1
                                ch[x][y+1] = 1
                now = tmp
            ans += nu * cnt
print(ans)

### FIXED CODE ###

n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))
N,M = list(map(int,input().split()))
S = []
C = []
ans = [0 for i in range(N)]
fr = 0
for i in range(M):
    s = 0
    c = 0
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

for i in range(M):
    if C[i] != ans[S[i]-1] and ans[S[i]-1] != 0:
        fr = 1
    else:
        ans[S[i]-1] = C[i]

if ans[0] == 0:
    ans += 1

if fr != 0:
    print(-1)
else:
    if N == 3:
        print(ans[0]*100 + ans[1]*10 + ans[2])
    elif N == 2:
        print(ans[0]*10 + ans[1])
    else:
        print(ans[0])

### FIXED CODE ###

N,M = list(map(int,input().split()))
S = []
C = []
ans = [11 for i in range(N)]
fr = 0
for i in range(M):
    s = 0
    c = 0
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

for i in range(M):
    if C[i] != ans[S[i]-1] and ans[S[i]-1] != 11:
        fr = 1
    elif C[i] == 0 and S[i] == 1 and N > 1:
        fr = 1
    else:
        ans[S[i]-1] = C[i]

for i in range(N):
    if ans[i] == 11:
        ans[i] = 0

if ans[0] == 0 and N > 1:
    ans[0] = 1

if fr != 0:
    print(-1)
else:
    if N == 3:
        print(ans[0]*100 + ans[1]*10 + ans[2])
    elif N == 2:
        print(ans[0]*10 + ans[1])
    else:
        print(ans[0])
N = int(input())
a = int(input())
a <= N

if a % 2 == 1:
    print(a/N)
    

### FIXED CODE ###

N = int(input())

if N%2 == 0:
    print(N/2/N)

else:
    print(((N-1)/2 +1)/N)
import sys
sys.setrecursionlimit(10**9)
def bfs(v,G,queue,dist):
    dist[0] = 0
    seen[v] = True
    for vertex in G[v]:
        if seen[vertex]:
            continue
        elif vertex in queue:
            continue
        queue.append(vertex)
        dist[vertex] = dist[v] + 1
    for elements in queue:
        queue.remove(elements)
        bfs(elements,G,queue,dist)
N,M = map(int,input().split())
dist = [-1 for _ in range(N)]
seen = [False for _ in range(N)]
G = dict()
for i in range(M):
    G[i] = []   
for _ in range(M):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
queue = []
bfs(0,G,queue,dist)
print("Yes")
for v in range(1,N): 
    for el in G[v]:
        if dist[v] == dist[el] + 1:
            print(el+1)
            break


### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(10**9)
    from sys import stdin
    def input() : return stdin.readline().rstrip()
    N,M = map(int,input().split())
    dist = [-1] * N
    G = dict()
    for i in range(N):
        G[i] = []   
    for _ in range(M):
        a,b = map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    q = [0]
    pre = [0] * N
    dist[0] = 0
    while (q != []):
        v = q[0]
        q.remove(q[0])
        for vertex in G[v]:
            if dist[vertex] != -1:
                continue
            dist[vertex] = dist[v] + 1
            pre[vertex] = v
            q.append(vertex)
    print("Yes")
    for v in range(1,N): 
        print(pre[v]+1)
if __name__ == '__main__':
    main()
import functools
import math

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

gcd_all = functools.reduce(math.gcd, A)
#print(gcd_all)

for i in range(N):
    list = A[:i] + A[i+1:]
    #print(list)
    gcd_1 =  functools.reduce(math.gcd, list)
    #print(gcd_1)
    if gcd_1 >= gcd_all:
        index = i
        value = gcd_1
        gcd_all = gcd_1

A[index] = value

print(functools.reduce(math.gcd, A))




### FIXED CODE ###

from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 17 11:58:20 2019
DP_G
@author: maezawa
"""
memo = [-1] * (10**5+100)

def rec(nx):
    if memo[nx] > -1:
        return memo[nx]
    depth = 0
    for edge in edges[nx]:
        nrec = rec(edge) + 1
        if nrec > depth:
            depth = nrec
    memo[nx] = depth
    return depth

n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for i in range(m):
    x, y = list(map(int, input().split()))
    edges[x-1].append(y-1)
    
maxdepth = 0
for node in range(n):
    depth = rec(node)
    if maxdepth < depth:
        maxdepth = depth
        
print(maxdepth)



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 16:05:26 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**5)

n, m = list(map(int, input().split()))
v = [-1]*(n+1)
adj = [[] for _ in range(n+1)]
for _ in range(m):
    i, j = list(map(int, input().split()))
    adj[i].append(j)
    
def dfs(vi):
    if v[vi] != -1:
        return v[vi]
    res = 0
    for nb in adj[vi]:
        res0 = dfs(nb) +1
        if res < res0:
            res = res0
    v[vi] = res
    return res

ans = 0
for node in range(1, n+1):
    current = dfs(node)
    if current > ans:
        ans = current
print(ans)