Harryxun/stf_run huggingface dataset:
N = int(input())
*A, = map(int,input().split())

if N%3:
    ans = True
    for a in A:
        if a:ans=False;break
else:
    B = set(A)
    l = len(B)
    ans = True
    if l>3 or l==2:ans = False
    elif l==1:
        for b in B:
            if b:ans=False;break
    else:
        a,b,c = B
        ans = ans and (A.count(a)==A.count(b)==A.count(c)==N//3) and (a^b==c)
        1/0
        
if ans:print("Yes")
else:print("No")

### FIXED CODE ###

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

if N%3:
    ans = True
    for a in A:
        if a:ans=False;break
else:
    B = set(A)
    l = len(B)
    ans = True
    if l>3:
        ans = False
    elif l==1:
        for b in B:
            if b:ans=False;break
    else:
        if l==3:
            a,b,c = B
            l,m,n = (A.count(x) for x in (a,b,c))
        if l==2:
            a,b = B
            l,m = (A.count(x) for x in (a,b))
            if l>=m:
                c=a
                n=l//2
                l-=n
            else:
                c=b
                n=m//2
                m-=n
        ans = ans and (l==m==n==N//3) and (a^b==c)
        
if ans:print("Yes")
else:print("No")
a.append("1000000001")
b.append("1000000001")
a[n]=int(a[n])
b[m]=int(b[m])

x=0
y=0
ans=0
time=0

for i in range(n+m):
    if a[x]<=b[y]:
        time+=a[x]
        if time>k:
            time-=a[x]
            print(ans)
            sys.exit()
        x+=1
        ans+=1
    else:
        time+=b[y]
        if time>k:
            time-=b[y]
            print(ans)
            sys.exit()   
        y+=1
        ans+=1
print(ans)

    

### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0 for i in range(n)]
B=[0 for i in range(m)]
A[0]=a[0]
B[0]=b[0]
for i in range(n-1):
    A[i+1]=a[i+1]+A[i]

for i in range(m-1):
    B[i+1]=b[i+1]+B[i]

ans=0
A.insert(0,0)
B.insert(0,0)

for i in range(n+1):
    x=0
    y=m
    j=(x+y)//2
    if A[i]+B[m]<=k:
        ans=max(ans,i+m)
    elif not A[i]+B[0]>k:
        
        
        while y-x>1:
            if A[i]+B[j]<=k:
                x=j
            else:
                y=j
            j=(x+y)//2
        ans=max(ans,i+x)
    
print(ans)
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

# スタート＋
if a[0] <= 0:
    A1 = 1
    ans1 += abs(a[0]) + 1
else:
    A1 = a[0]
for i in range(1, n):
    nextA = A1 + a[i]
    if (A1 > 0 and nextA < 0) or (A1 < 0 and nextA > 0):
        A1 = nextA
    elif nextA == 0 and A1 > 0:
        ans1 += 1
        A1 = -1
    elif nextA == 0 and A1 < 0:
        ans1 += 1
        A1 = 1
    elif A1 > 0:
        ans1 += abs(nextA) + 1
        A1 = -1
    else:
        ans1 += abs(nextA) + 1
        A1 = 1

# スタート-
if a[0] >= 0:
    ans2 = abs(a[0]) + 1
    A2 = -1
else:
    A2 = a[0]

for i in range(1, n):
    nextA = A2 + a[i]
    if (A2 > 0 and nextA < 0) or (A2 < 0 and nextA > 0):
        A2 = nextA
    elif nextA == 0 and A2 > 0:
        ans2 += 1
        A2 = -1
    elif nextA == 0 and A2 < 0:
        ans2 += 1
        A2 = 1
    elif A2 > 0:
        ans2 += abs(nextA) + 1
        A2 = -1
    else:
        ans2 += abs(nextA) + 1
        A2 = 1

print(min(ans1, ans2))




### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

# スタート＋
if a[0] <= 0:
    A1 = 1
    ans1 = abs(a[0]) + 1
else:
    A1 = a[0]
    ans1 = 0
for i in range(1, n):
    nextA = A1 + a[i]
    if (A1 > 0 and nextA < 0) or (A1 < 0 and nextA > 0):
        A1 = nextA
    elif nextA == 0 and A1 > 0:
        ans1 += 1
        A1 = -1
    elif nextA == 0 and A1 < 0:
        ans1 += 1
        A1 = 1
    elif A1 > 0:
        ans1 += abs(nextA) + 1
        A1 = -1
    else:
        ans1 += abs(nextA) + 1
        A1 = 1

# スタート-
if a[0] >= 0:
    ans2 = abs(a[0]) + 1
    A2 = -1
else:
    A2 = a[0]
    ans2 = 0
for i in range(1, n):
    nextA = A2 + a[i]
    if (A2 > 0 and nextA < 0) or (A2 < 0 and nextA > 0):
        A2 = nextA
    elif nextA == 0 and A2 > 0:
        ans2 += 1
        A2 = -1
    elif nextA == 0 and A2 < 0:
        ans2 += 1
        A2 = 1
    elif A2 > 0:
        ans2 += abs(nextA) + 1
        A2 = -1
    else:
        ans2 += abs(nextA) + 1
        A2 = 1

print(min(ans1, ans2))
# C - Snack
from math import gcd
A, B = map(int, input().split())
i = 1 
ans = A
while ans % B != 0:
    i += 1
    ans = A * i
print(ans)

### FIXED CODE ###

from fractions import *
a, b=map(int, input().split())
print(a * b // gcd(a, b))
a, b = int(input())
print(max(a+b,a-b,a*b))


### FIXED CODE ###

a, b = map(int,input().split())
print(max(a+b,a-b,a*b))
s=int(input())
n=len(str(s))
a=[0]*2019
a[0]=1
ans=0
k=s%2019
a[k]+=1
for i in range(n):
  s=int(s*0.1)
  k=s%2019
  a[k]+=1
for i in range(2019):
  ans+=a[i]*(a[i]-1)/2

print(int(ans))

### FIXED CODE ###

s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
mod=1
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*mod)%2019
  mod=(mod*10)%2019
  a[k]+=1
for i in a:
  ans+=i*(i-1)*0.5

print(int(ans))
X,Y,A,B,C=map(int,input().split())
p=sorted(list(map(int,input().split())))
q=sorted(list(map(int,input().split())))
r=sorted(list(map(int,input().split())))
for i in range(min(X,Y)):
  if p[A-X+i] > q[B-Y+i]:
    if r[-1] >= q[B-Y+i]:
      del q[B-Y+i]
      q.insert(B-Y+i,r[-1])
      del r[-1]
      r.insert(0,0)
      if r[-1] > p[A-X+i]:
        del p[A-X+i]
        p.insert(A-X+i,r[-1])
        del r[-1]
        r.insert(0,0)
  else:
    if r[-1] > p[A-X+i]:
      del p[A-X+i]
      p.insert(A-X+i,r[-1])
      del r[-1]
      r.insert(0,0)
      if r[-1] > q[B-Y+i]:
        del q[B-Y+i]
        q.insert(B-Y+i,r[-1])
        del r[-1]
        r.insert(0,0)
if X>Y:
  for j in range(X-Y):
    if p[A-X+Y+j] < r[-1]:
      del p[A-X+Y+j]
      p.insert(A-X+Y+j,r[-1])
      del r[-1]
      r.insert(0,0)
if X<Y:
  for j in range(Y-X):
    if q[B-Y+X+j] < r[-1]:
      del q[B-Y+X+j]
      q.insert(B-Y+X+j,r[-1])
      del r[-1]
      r.insert(0,0)
P=sorted(p)
Q=sorted(q)
sc=0
for k in range(X):
  sc+=P[A-X+k]
for l in range(Y):
  sc+=Q[B-Y+l]
print(sc)


### FIXED CODE ###

S=input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
import math

N ,M, K = map(int,input().split())
MOD = 998244353
SUM = 0

fact = [1]
fact_inv = [1]
for i in range(1,N+1):
    fact.append(fact[-1] * i)
    if i <= max(N-K,K)+1:
        fact_inv.append(pow(fact[-1],MOD-2,MOD))

def combinations_count(n, r):
    return (((fact[n] * fact_inv[n-r])%MOD) * fact_inv[r])%MOD

for i in range(K+1):
    if N -1 - i >= 0:
        SUM += M * pow(M-1,N-1-i,MOD) * combinations_count(N-1,i)
        SUM %= MOD

print(SUM)

### FIXED CODE ###

import math

N ,M, K = map(int,input().split())
MOD = 998244353

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs
invs = getInvs(N+3, MOD)

num = M
nums = []
for i in reversed(range(1,N)):
    nums.append(num)
    num *= i*(M-1)
    num *= invs[N-i]
    num %= MOD
nums.append(num)
nums.reverse()

ans = sum(nums[:K+1])
ans %= MOD
print(ans)
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

n = int(input())
S = input()
ans = 0
l = 0
while l < n and S[l] == '.':
    l += 1
for r in range(l, n-1):
    if S[r:r+2] == '#.':
        m = r
    if S[r:r+2] == '.#':
        ans += min(r-m, m-l)+1
        l = r+1
if S[-1] == '.':
    ans += min(r-m, m-l)+1
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

n = int(input())
S = input()
f = [0] * (n+1)
for i in range(n):
    f[i+1] = f[i] + (S[i] == '#')
g = [0] * (n+1)
for i in range(n):
    g[i+1] = g[i] + (S[i] == '.')
k = S.index('#') if '#' in S else 0
ans = min(f[n], g[n]-g[k])
lst = []
for i in range(n-1):
    if S[i:i+2] == '#.':
        lst.append(i)
for i, j in zip(lst, lst[1:]):
    ans = min(ans, f[i+1]+g[n]-g[j])
print(ans)


# N, M, K = map(int, input().split())
# A = list(map(int, input().split()))
H,W = map(int,input().split())
L = []
for i in range(H) :
    L.append(list(input()))

dxy = [(1,0),(-1,0),(0,1),(0,-1)]

flag = 0
for x in range(W) :
    for y in range(H) :
        if L[x][y] == "#" :
            for dx,dy in dxy :
                nx = x+dx
                ny = y+dy
                if (0 <= nx <= W-1) and (0 <= ny <= H-1) :
                    if L[nx][ny] == "#" :
                        flag = 0
                        
                        break
                    flag = 1
                else :
                    continue

if flag != 1 :
    print("Yes")
else :
    print("No")
    

### FIXED CODE ###

H,W = map(int,input().split())
L = [input() for i in range(H)]
dxy = [[1,0],[-1,0],[0,1],[0,-1]]
flag = 1

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" and flag == 1 :
            for dx,dy in dxy :
                nx = x+dx
                ny = y+dy
                if (0 <= nx <= W-1) and (0 <= ny <= H-1) :
                    if L[ny][nx] == "#" :
                        flag = 1
                        break
                    else :
                        flag = 0
if flag == 1 :
    print("Yes")
else :
    print("No")
h=int(input())
count=0
while  h>1:
	h = h // 2
	conut += 1
print(2 ** (count+1) - 1)

### FIXED CODE ###

h,a=map(int,input().split())
if h % a ==0:
	print(h // a)
else:
	print((h // a ) + 1)
S = input()
T = input()

print(sum([s == t for s, t in zip(S, T)])

### FIXED CODE ###

S = input()
T = input()

print(sum([s == t for s, t in zip(S, T)]))
def fib(W):
    a, b = 1, 1
    n = [a, b]
    while W > len(n):
        a, b = b, b + a
        n.append(b)
    return n
H, W, K = map(int, input().split())
f = fib(W)
r = [1] + [0] * (W - 1)
for i in range(H):
    tmp = [0] * W
    for j in range(W):
        if j == 0:
            tmp[j] = r[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2]
        elif j == W - 1:
            tmp[j] = r[j] * f[j] + r[j - 1] * f[j - 1]
        else:
            tmp[j] = r[j] * f[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] * f[j] + r[j - 1] * f[W - j - 1] * f[j - 1]
    r = tmp
print(r[K - 1] % 1000000007)

### FIXED CODE ###

def fib(W):
    a, b = 1, 1
    n = [a, b]
    while W > len(n):
        a, b = b, b + a
        n.append(b)
    return n
H, W, K = map(int, input().split())
f = fib(W)
r = [1] + [0] * (W - 1)
for i in range(H):
    tmp = [0] * W
    for j in range(W):
        if j == 0:
            tmp[j] = r[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] if W != 1 else 1
        elif j == W - 1:
            tmp[j] = r[j] * f[j] + r[j - 1] * f[j - 1]
        else:
            tmp[j] = r[j] * f[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] * f[j] + r[j - 1] * f[W - j - 1] * f[j - 1]
    r = tmp
print(r[K - 1] % 1000000007)
import itertools
n = int(input())
xy = [0 for _ in range(n)]
for i in range(n):
    ai = int(input())
    xy[i] = [list(map(int , input().split())) for _ in range(ai)]

#print(xy)
#print(xy[0])
#print(xy[0][0])
ans = 0
for i in itertools.product([0, 1], repeat=n):
    ok = True
    cnt = sum(i)
    for j in range(n):
        xyj = xy[j]
        for xyk in xyj:
            if xyk[1] == 0:
                if i[xyk[0]] == 1:
                    ok = False
            elif xyk[1] == 1:
                if i[xyk[0]] == 0:
                    ok = False
    if ok:
        ans = max(ans, cnt)

print(ans)


### FIXED CODE ###

import itertools
n = int(input())
xy = [0 for _ in range(n)]
for i in range(n):
    ai = int(input())
    xy[i] = [list(map(int , input().split())) for _ in range(ai)]

#print(xy)
#print(xy[0])
#print(xy[0][0])
ans = 0
for i in itertools.product([0, 1], repeat=n):
    ok = True
    cnt = sum(i)
    for j in range(n):
        xyj = xy[j]
        if i[j] == 1:
            for xyk in xyj:
                if xyk[1] == 1:
                    if i[xyk[0]-1] == 0:
                        ok = False
                elif xyk[1] == 0:
                    if i[xyk[0]-1] == 1:
                        ok = False
    #print(ok, i)
    if ok:
        ans = max(ans, cnt)

print(ans)
x = raw_input()
print("{0}".format(x^3))

### FIXED CODE ###

n=int(input())**3
print("{0}".format(n))
n,k = map(int,input().split())
a = list(map(int,input().split()))

memo = [1]
setm = set(memo)
cnt = 1
to = 1
while cnt <= k:
    to = a[to-1]
    if to not in setm:
        memo.append(to)
        setm.add(to)
        cnt += 1
    else:
        break
        
idx = memo.index(to)
kidx = ((k - len(memo))%(len(memo)-idx))
if len(memo)>k:
    print(memo[-2])
else:
    print(memo[-1] if kidx==0 else: memo[idx:][kidx])

### FIXED CODE ###

import numpy as np

def main():
    N,K = map(int,input().split())
    A = [0]
    A += list(map(int,input().split()))
    A = np.array(A)
    
    i = 1
    pas = np.zeros(N)
    pas[0] = i
    k = 1
    pass_set = set(pas)
    while k <= K:
        if A[i] in pass_set:
            rps = np.where(pas==(A[i]))[0]
            ans = A[i]
            break
        pas[k] = A[i]
        pass_set.add(A[i])
        ans = A[i]
        i = A[i]
        k += 1

    if k >= K:
        print(ans)
    else:
        rpnum = (K-rps[0])%(k-rps)
        print(int(pas[rps[0]+rpnum]))

main()
N, K = map(int, input().split())
A, B = [0]*N, [0]*N
s = ""
for i in range(N):
  A[i], B[i] = input().split()
  s += A[i] * int(B[i])
print(s[K-1])

### FIXED CODE ###

from collections import defaultdict
N, K = map(int, input().split())
d = defaultdict(int)
for _ in range(N):
  a, b = map(int, input().split())
  d[a] += b
d = sorted(d.items(), key=lambda x:x[0])
s = 0
for i in range(len(d)):
  s += d[i][1]
  if K <= s:
    print(d[i][0])
    exit()
N, M = map( int, input().split(' '))

tree_list = []
sort_list = []
for x in range(N):
    tree_list.append(int(input()))

sort_list = sorted(tree_list)

min_heigt = sort_list[2] - sort_list[0]

for x in range(N-M+1):
    nagasa =sort_list[x+2] - sort_list[x] 
    if min_heigt > nagasa:
        min_heigt = nagasa

print(min_heigt)

### FIXED CODE ###

N, M = map( int, input().split(' '))

tree_list = []
sort_list = []
for x in range(N):
    tree_list.append(int(input()))

sort_list = sorted(tree_list)

min_heigt = sort_list[M-1] - sort_list[0]

for x in range(N-M+1):
    nagasa =sort_list[x+M-1] - sort_list[x] 
    if min_heigt > nagasa:
        min_heigt = nagasa

print(min_heigt)
a, b = map(int, input().split())
int c
c　= (a * b) % 2
if c == 0:
  print('Even')
else:
  print('Odd')


### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = (a * b) % 2
if c == 0:
  print("Even")
else :
  print("Odd")
N,M = map(int,input().split())
A = list(map(int,input().split()))
L = []
for i in range(M) :
    b,c = map(int,input().split())
    L.append(b,c)

L = sorted(L,key=lambda x: x[1], reverse=True)
for i in range(len(L)) :
    b,c = L[i]
    b = min(b,10**9-len(A))
    A.extend([c]*b)
ans = sum(sorted(A,reverse=True)[:N])

print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
L = [list(map(int,input().split())) for i in range(M)]

P = sorted(([[1,A[i]] for i in range(N)] + L),key=lambda x: x[1],reverse=True)

ans = 0
rest = N

for cost,value in P :
    K = min(cost, rest)
    K = max(0,K)
    ans += K * value
    rest -= cost

print(ans)
r = int(input())

print(R ** 2)

### FIXED CODE ###

r = int(input())

print(int(r ** 2))
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


S = sys.stdin.buffer.readline().decode().rstrip()
K = int(sys.stdin.buffer.readline())

i = 0
while S[i] == '1':
    i += 1
if K <= i:
    print('1')
else:
    print(S[i])


### FIXED CODE ###

S = input()
K = int(input())


count1 = 0
for c in S:
    if c == '1':
        count1 += 1
    else:
        break
next_c = c

if K <= count1:
    print('1')
else:
    print(next_c)
a,b,c = map(int,input().split())
if a+b+c = 22:
		print("bust")
		
else:
		print("win")

### FIXED CODE ###

a,b,c = map(int,input().split())
if a+b+c >= 22:
		print("bust")
		
else:
		print("win")
A, B, C = map(int, input().split())
if len(set(A, B, C)) == 2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B, C = map(int, input().split())
if len({A, B, C}) == 2:
    print("Yes")
else:
    print("No")
X = int(input())

d = {}
k = {}
for i in range(-100,101):
    d[i] = pow(i,5)
    k[d[i]] = i
i = -100

while True:
    if X + d[i] in d.values():
        b = i
        a = k[X + d[i]]
        break
    i += 1

print(a, b)

### FIXED CODE ###

X = int(input())

d = {}
k = {}
for i in range(-1000,1001):
    d[i] = pow(i,5)
    k[d[i]] = i
i = 1000

while True:
    if X + d[i] in d.values():
        b = i
        a = k[X + d[i]]
        break
    i -= 1

print(a, b)
def main(N):
	a = list(map(int, input().split()))
	if a.count(0) == N:
		print("Yes")
		return
	if N%3 != 0:
		print("No")
		return
	d={}
	for i in a:
		if i in d:
			d[i] = d[i] + 1
		else:
			d[i] = 1
	if 0 in d.keys():
		if d[0] == N//3:
			for i in d.keys():
				if i == 0:
					continue
				elif d[i] % 2 != 0:
					print("No")
					return
			print("Yes")
		else:
			print("No")
	else:
		for i in d.values():
			if i != N//3:
				print("No")
				return
		lst = d.keys()
		if (lst[0]^lst[2]!=lst[1]) or (lst[0] != lst[1]^lst[2]) or(lst[2]!=lst[1]^lst[0]):
			print("No")
			return
		print("Yes")
	return
		
	return

main(int(input()))

### FIXED CODE ###

def main(N):
	a = list(map(int, input().split()))
	if a.count(0) == N:
		print("Yes")
		return
	if N%3 != 0:
		print("No")
		return
	d={}
	for i in a:
		if i in d:
			d[i] = d[i] + 1
		else:
			d[i] = 1
	if 0 in d.keys():
		if d[0] == N//3:
			for i in d.keys():
				if i == 0:
					continue
				elif d[i] % 2 != 0:
					print("No")
					return
			print("Yes")
		else:
			print("No")
	else:
		for i in d.values():
			if i != N//3:
				print("No")
				return
		lst = list(d.keys())
		if (lst[0]^lst[2]!=lst[1]) or (lst[0] != lst[1]^lst[2]) or(lst[2]!=lst[1]^lst[0]):
			print("No")
			return
		print("Yes")
	return
		
	return

main(int(input()))
sum=0
for i in range(3):
  sum+=sum([map(int,input().split())])
print("Yes" if sum%3==0 else "No")

### FIXED CODE ###

c_list=[]
for i in range(3):
    c_list.append([int(i) for i in input().split()])

for a1 in range(101):
    b1 = c_list[0][0] - a1
    a2 = c_list[1][0] - b1
    a3 = c_list[2][0] - b1
    b2 = c_list[0][1] - a1
    b3 = c_list[0][2] - a1
    if a2 + b2 == c_list[1][1] and a2 + b3 == c_list[1][2] and a3 + b2 == c_list[2][1] and a3 + b3 == c_list[2][2]:
        print('Yes')
        exit()
print('No')
x, y = map(int, input().split(" "))
print(x * y, (x + y) * 2)

### FIXED CODE ###

a, b = map(int, raw_input().split())
print(str(a * b) + " " + str((a + b) * 2))
from collections import deque

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

d = [[-1] * w for _ in range(h)]


def bfs(s):
    q = deque()
    for sx, sy in s:
        q.append([sx, sy])
        d[sy][sx] = 0
    dxy = [[1, 0], [-1, 0], [0, 1], [0, -1]]

    while q:
        ux, uy = q.popleft()
        for dx, dy in dxy:
            vx = ux + dx
            vy = uy + dy
            if 0 <= vx <= w - 1 and 0 <= vy <= h - 1 and\
                    a[vy][vx] == "." and d[vy][vx] == -1:
                d[vy][vx] = d[uy][ux] + 1
                q.append([vx, vy])


s = []
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            s.append([i, j])

bfs(s)

ans = 0
for row in d:
    for e in row:
        ans = max(ans, e)

print(ans)


### FIXED CODE ###

from scipy.ndimage import distance_transform_cdt


def main():
    h, w = map(int, input().split())
    a = [list(input()) for _ in range(h)]

    sq = [[1 if e == "." else 0 for e in row] for row in a]

    cnt = distance_transform_cdt(sq, metric="taxicab")

    print(cnt.max())


if __name__ == "__main__":
    main()
N = input()
atc = ["A","T","C","G"]
ans = []
cnt = 0
for i in range(len(N)):
    if N[i] in atc:
        cnt += 1 
    else:
        ans.append(cnt)
print(max(ans))

### FIXED CODE ###

N = input()
atc = ["A","T","C","G"]
ans = []
cnt = 0
for i in range(len(N)):
    if N[i] in atc:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt != 0:
    ans.append(cnt)
if ans == []:
    if N in atc:
        print(1)
    else:
        print(0)
else:
    print(max(ans))
#coding: UTF-8

l = raw_input()


r = int(l)

import math
S = math.pi * r**2

C = 2 * math.pi * r

print "%f %f" %(S, C)

### FIXED CODE ###

#coding: UTF-8

l = raw_input()


r = float(l)

import math
S = math.pi * r**2

C = 2 * math.pi * r

print "%f %f" %(S, C)
inf = input().split()
X = int(inf[0])
Y = int(inf[1])
Z = int(inf[2])
K = int(inf[3])

A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ab = []
for a in A:
  for b in B:
    ab +=[a+b]
ab.sort(reverse=True)
C.sort(reverse=True)
state = [ab[0]+i for i in C]
count  = 0
while count<K:
  x = max(state)
  print(x)
  count += 1
  i = state.index(x)
  j = ab.index(x-C[i])
  if j<X*Y-1:
    state[i] = ab[j+1]+C[i]
  else:
    state[i]=-1

### FIXED CODE ###

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ls = [A,B,C,D,E]
X = min((A,B,C,D,E))
s=N//X
if N%X==0:
  s-=1
print(s+5)
n=int(input())
a=list(map(int,input().split()))
a.sort()
x,y=[0,0]
for i in range(n):
    if(i%2==0):
        x+=a[i]
    else:
        y+=a[i]
print(sum(x)-sum(y))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x,y=[0,0]
for i in range(n):
    if(i%2==0):
        x+=a[i]
    else:
        y+=a[i]
print(x-y)
s,t = map(input().split())
print(t + s)

### FIXED CODE ###

a, b  = map(str, input().split())
print(b + a)
n = int(input())
count = [0]*5
d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}

for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    count[d[s[0]]] += 1

ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += count[i] * count[j] * count[k]]
print(ans)

### FIXED CODE ###

n = int(input())
count = [0]*5
d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}

for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    count[d[s[0]]] += 1

ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += count[i] * count[j] * count[k]
print(ans)
import math
n=int(input())
mod=1000000007
sum=0
s=[int(n) for n in input().split()]
ans=1
for i in s:
    ans*=i//math.gcd(ans,i)
for i in s:
    sum=(sum+ans//i)%mod
print(sum)


### FIXED CODE ###

n=int(input())
a=[int(j) for j in input().split()]
t=1
mod=10**9+7
from fractions import*
for i in a:
    t*=i//gcd(t,i)
print(sum(t//i for i in a)%mod)