Harryxun/stf_run huggingface dataset:
from sys import stdin
import numpy as np
input = stdin.readline

N = int(input())
A_list = list(map(int, input().split()))
ans_list =np.ones(N)
A_list = np.array(A_list)

for i in range(N):
    for j in range(i+1,N):
        if A_list[i] %  A_list[j] == 0:
            ans_list[i] = 0
            if (A_list[j] %  A_list[i] == 0):
                ans_list[j] = 0
        elif A_list[i] ==  A_list[j]:
                ans_list[i] = 0
                ans_list[j] = 0
        elif(A_list[j] %  A_list[i] == 0):
            ans_list[j] = 0
print(int(np.sum(ans_list)))

### FIXED CODE ###

from sys import stdin
import numpy as np
input = stdin.readline

N = int(input())
A_list = list(map(int, input().split()))
# ans_list =np.ones(N)
# A_list = np.array(A_list)

# for i in range(N-1):
#     for j in range(i+1,N):
#         if A_list[i] %  A_list[j] == 0:
#             ans_list[i] = 0
#             if (A_list[j] %  A_list[i] == 0):
#                 ans_list[j] = 0
#         elif(A_list[j] %  A_list[i] == 0):
#             ans_list[j] = 0
# print(int(np.sum(ans_list)))
A_set = list(set(A_list))
maxA =  A_set[-1]
dp = [1] * (( 10 ** 6) + 1)

cntli = [0] * (( 10 ** 6) + 1)
unique =[]
for i in A_list:
    cntli[i] += 1
for i in range((( 10 ** 6) + 1)):
    if cntli[i] == 1:
        unique.append(i)

for elem in A_set:
    for i in range(2 * elem,  10 ** 6 + 1, elem):
        dp[i] = 0

ans = 0
for i in unique:
    if not (dp[i] == 0):
        ans += 1

print(ans)
import copy
n = int(input())
b = list(map(int,input().split()))
ans = 0
ls = copy.copy(b)

for i in range(n-1):
    if i > (n-2):
        break
    if b[i] == 0:
        ls.remove(0)
        ans -= b[i+1]
    else:
        ans += b[i]

if n == 2:
    print(min(b)*2)
else:
    print(ans+min(ls))

### FIXED CODE ###

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

for i in range(n-2):
    ans += min(b[i],b[i+1])  

print(ans+b[-1]+b[0])
num = input()
le = len(num)
sum=0
for i in range(le):
  sum += int(num[i])
if sum%9==0:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

import math
n,x,t = map(int,input().split())
c = t*math.ceil(n/x)
print(c)
# -*- coding: utf-8 -*-
#import numpy as np
n,m = map(int, input().split())
i=0
lst = []
while i < m: 
    l = map(int, input().split())
    lst.append(list(l))
    i+=1

sort_lst = sorted(lst)
i=1
res=[]
for i in range(1,n+1):
    j=1
    for k in sort_lst:
        if i == k[0]:
            res.append([str(k[0])+str(k[1]),str(res[0]).rjust(6,'0') + str(res[2]).rjust(6,'0')])
            j+=1

#ans
for ans in lst:
    for res in sort_lst:
        if str(ans[0])+str(ans[1]) == res[0]:
            print(res[1])


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,m = map(int, input().split())
i=0
lst = []
while i < m: 
    lst.append(list(map(int, input().split())) + [i])
    i+=1
lst = sorted(lst)
j=0
i=1
for k in lst:
    if i != k[0]:
        i=k[0]
        j=1
        k[1]=i*1000000+j
    else:
        j+=1
        k[1]=i*1000000+j

#ans
for ans in sorted(lst, key=lambda x:x[2]):
    print('{0:012d}'.format(ans[1]))
n = int(input())a = list(map(int, input().split(" ")))i = 0list = []for a_s in a:list.insert(0, (a.index(n - i) + 1))i += 1print(*list)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
dic = {}
i = 0
for a_s in a:
    dic.setdefault(i, a_s)
    i += 1
for k, v in sorted(dic.items(), key=lambda x: x[1]):
    print(k + 1)
*A = map(int,input().split())
A.sort()
print(A[0]+A[1])

### FIXED CODE ###

*A, = map(int,input().split())
A.sort()
print(A[0]+A[1])
N,K = map(int, input().split())
print(min(N%K,abs(N%K-K)))


### FIXED CODE ###

x,y,z = map(int, input().split())
print(z,x,y)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll result = 1;
    for(int i=0;i<N;i++) {
        cin >> A.at(i);
    }

    if(find(A.begin(),A.end(),0) != A.end()) {
        cout << "0" << endl;
        exit(0);
    }
    for(int i=0;i<N;i++) {
        result = result * A.at(i);
        if (result > (ll)pow(10,18)) {
            cout << "-1" << endl;
            exit(0);
        }
    }
    cout << result << endl;
}

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]

if 0 in A :
    print("0")
    exit()
result = 1
for i in range(N) :
    result *= A[i]
    if result > 10**18 :
        print("-1")
        exit()

print(result)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dishes = [a,b,c,d,e]
ans = 0
for i in range(5):
  if dishes[i]%10=0:
    ans += dishes[i]//10
  else:
    ans += dishes[i]//10+1
print(ans*10)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dishes = [a,b,c,d,e]
n = []
ans = 0
for i in range(5):
  if dishes[i]%10==0:
    ans += dishes[i]//10
  else:
    ans += dishes[i]//10+1
    n.append(dishes[i]%10)
if len(n)==0:
  print(ans*10)
else:
  ans = ans*10-10+min(n)
  print(ans)
K = int(input())
S = input()
if len(S) > K:
  S = S[:k] + "..."
  print(S)
else:
  print(S)

### FIXED CODE ###

K = int(input())
S = input()
if len(S) > K:
  S = S[:K] + "..."
  print(S)
else:
  print(S)
import numpy as np
A=a=int(input())
count=2
samenumcount=0
y=[]

if A==1:
    print(0)
    sys.exit()

while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
y.sort()

count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1

if count2==0:
    print(1)
else:
    print(count2)

### FIXED CODE ###

import numpy as np
import sys
A=a=int(input())
count=2
samenumcount=0
y=[]
 
if A==1:
    print(0)
    sys.exit()
 
while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
if A!=1:
    y.append(A)
y.sort()
count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1
 
if count2==0:
    count2+=1

print(count2)
# coding: utf-8
# Your code here!

n = int(input())
wsv = [[0,0,0]] + [[int(i) for i in input().split()] for _ in range(n)]
wsv.sort(key = lambda x: x[1]+x[0]) #sでソート
#print(wsv)

smax = 10000
dp = [0]*(smax)
for i, (w,s,v) in enumerate(wsv):
    for i in range(s,-1,-1):
        if i+w <= smax:
            if dp[i] != 0:
                dp[i+w] = max(dp[i+w],dp[i]+v)
    if w <= smax:
        dp[w] = max(dp[w],v)


#    print(dp)

print(max(dp))
    

### FIXED CODE ###

# coding: utf-8
# Your code here!

n = int(input())
#wsv = [[0,0,0]] + [[int(i) for i in input().split()] for _ in range(n)]
wsv = [[int(i) for i in input().split()] for _ in range(n)]
wsv.sort(key = lambda x: x[0]+x[1]) #sでソート
#print(wsv)

smax = 10000
dp = [0]*(smax*2+1)
for i, (w,s,v) in enumerate(wsv):
    for i in range(s,-1,-1):
        if dp[i] != 0 or i == 0:
                dp[i+w] = max(dp[i+w], dp[i]+v)

print(max(dp))
N = int(input())
A = [int(input()) for i in range(N)]

Alice = []
Bob = []

for i in range(N):
    if len(A) != 0:
        Alice.append(max(A))
        A.remove(max(A))
    else:
        break
    if len(A) != 0:
        Bob.append(max(A))
        A.remove(max(A))
    else:
        break
print(sum(Alice) - sum(Bob))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
Alice = sum(A[::2])
Bob = sum(A[1::2])
print(Alice-Bob)
n=input()
a=[]
m=[]

for i in range(n):
    a.append(input())
for i in range(n):
    c=0
    for j in range(n):
        if(a[i]>a[j]):
            c+=1
        else:
            break
    m.append(c)

print(max(m))    

### FIXED CODE ###

import sys

n = int(input())
a = []
b = input().split(" ")
for i in range(n):
	a.append(int(b[i]))

if n == 1:
	print(0)
	sys.exit()

mx = 0
cnt = 0
for i in range(n-2, -1, -1):
	if a[i] >= a[i+1]:
		cnt += 1
		mx = max(mx, cnt)
	else:
		cnt = 0

print(mx)
N, K = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()], reverse=True)

for v in A:
    if K==v:
        print("POSSIBLE")
        quit()
if K > A[0]:
    print("IMPOSSIBLE")
    quit()

d = []
for i in range(N-1):
    d.append(A[i]-A[i+1])

for v in d:
    K %= v

if K:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

### FIXED CODE ###

N, K = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()], reverse=True)

for v in A:
    if K==v:
        print("POSSIBLE")
        quit()
if K > A[0]:
    print("IMPOSSIBLE")
    quit()

d = []
for i in range(N-1):
    d.append(A[i]-A[i+1])

for v in d:
    if v:
        K %= v

if K:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
import bisect
from collections import defaultdict as dd

def factorize(n):
    b = 2
    fct = []

    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    
    if n > 1:
        fct.append(n)
    
    return fct

N = int(input())
f = factorize(N)
dic = dd(int)

for val in f:
    if val != 1:
        dic[val] += 1
res = 0

ls = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]

for val in dic.values():
    tmp = bisect.bisect_right(ls, val)
    res += tmp

print(res)

### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
a=int(input())
sum=0
s=''
'''if a<0:
    b = abs(a)
    if b%2==1:
        b=b+1
        print(str(bin(b))[2:-1]+'1')
    else:
        print(str(bin(b))[2:-1])''
if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)


### FIXED CODE ###

a=int(input())
sum=0
s=''

if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)
from copy import copy
n = int(input())
a = list(map(int, input().split()))

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	#d = defaultdict(int)
	d = dict()
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		dels = []
		if a[i] < a[i+1]:
			last = a[i+1]

		else:
			for k in d.keys():
				if last < k:
					dels.append(k)

			j = a[i+1]
			while j > 0:
				if j in d and d[j] == x-1:
					d[j] = 0
					dels.append(j)
					j -= 1
				else:
					break

			if j in d:
				d[j] += 1
			else:
				d[j] = 1

		for k in dels:
			del d[k]

		if 0 in d:
			valid = False
			break

	if valid:
		ok = x
	else:
		ng = x
print(ok)

### FIXED CODE ###

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

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	#d = defaultdict(int)
	d = dict()
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		dels = []
		if a[i] < a[i+1]:
			last = a[i+1]
			continue

		j = a[i+1]
		for k in d.keys():
			if j < k:
				dels.append(k)

		while j > 0:
			if j in d and d[j] == x-1:
				#d[j] = 0
				dels.append(j)
				j -= 1
			else:
				break

		if j in d:
			d[j] += 1
		else:
			d[j] = 1

		for k in dels:
			del d[k]

		if 0 in d:
			valid = False
			break
		last = j

	if valid:
		ok = x
	else:
		ng = x
print(ok)
card = []       #リスト型の変数カードを定義する。
for i in range(3):      #変数カードに三列のリスト型の数字を三行文加える。
    card.append(list(map(int,input().split())))

N = int(input())        #呼ばれる数字の数を指定する。

result = [[0,0,0],[0,0,0],[0,0,0]]      #変数resultを定義する。
for _ in range(N):      #以下の動作をN回繰り返す。
    b = int(input())        #数字を読み上げる。
    for i in range(3):      #bがAijと対応していた場合、変数resultのAijと同じ位置に1を代入する。
        for j in range(3):
            if b == card[i][j]:
                result[i][j] = 1

judge = "No"        #以下の条件に当てはまらなければNoと表示する

for i in range(3):      #横のビンゴの確認
    if result[i][0] * result[i][1] * result[i][2] == 1:
        judge = "Yes"

for i in range(3):      #縦のビンゴの確認
    if result[0][i] * result[1][i]*result[2][i] == 1:
        judge = "Yes"

if result[0][0] * result[1][1] * result[2][2] == 1:     #斜めのビンゴの確認
    judge = "Yes"

if result[0][2] * result[1][1] * result[2][1] == 1:     #斜めのビンゴの確認
    judge = "Yes"

print(judge)    
 

### FIXED CODE ###

n=int(input())

ans=int(n/2)

if n%2==0:
    print(ans)
else:
    print(ans+1)
A, B = map(int, input().split())
       if (A + B) % 2 != 0:
           print("IMPOSSIBLE")
       else:
               print(int((A+B)/2))


### FIXED CODE ###

n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')
print(int(not int(input()))

### FIXED CODE ###

print(int(not int(input())))
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j,if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

### FIXED CODE ###

n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))
N,Ma,Mb=map(int,input().split())
Med=[]
cnt_a=0
cnt_b=0
for i in range(N):
  a=[int(x) for x in input().split()]
  Med.append(a)
  cnt_a+=a[0]
  cnt_b+=a[1]
  
#[i]まででMa=[j],Mb=[k]を作る場合の最小のコストdp
#dp[i+1][j+Ma][k+Mb]=min(dp[i][j+Ma][k+Mb],dp[i][j][k]+Cost)
#リストをinfで初期化。inf=作れない配合なので、continue。初期値はdp[0][0][0]=0
dp=[[[float('inf') for j in range(cnt_b+1)] for k in range(cnt_a+1)] for i in range(N+1)]
dp[0][0][0]=0

for i in range(N):
  for j in range(cnt_a+1):
    for k in range(cnt_b+1):
      if dp[i][j][k]==float('inf'):
        continue
      dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k])
      dp[i+1][j+Med[i][0]][k+Med[i][1]]=min(dp[i][j+Med[i][0]][k+Med[i][1]],dp[i][j][k]+Med[i][2])

ans=float('inf')
for i in range(1,N+1):
  if i*Ma<401 and i*Mb<401:
    ans=min(ans,dp[N][i*Ma][i*Mb])
if ans==float('inf'):
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N,Ma,Mb=map(int,input().split())
Med=[]
cnt_a=0
cnt_b=0
for i in range(N):
  a=[int(x) for x in input().split()]
  Med.append(a)
  cnt_a+=a[0]
  cnt_b+=a[1]
R=max(cnt_a,cnt_b)
#[i]まででMa=[j],Mb=[k]を作る場合の最小のコストdp
#dp[i+1][j+Ma][k+Mb]=min(dp[i][j+Ma][k+Mb],dp[i][j][k]+Cost)
#リストをinfで初期化。inf=作れない配合なので、continue。初期値はdp[0][0][0]=0
dp=[[[float('inf') for j in range(R+1)] for k in range(R+1)] for i in range(N+1)]
dp[0][0][0]=0

for i in range(N):
  for j in range(R+1):
    for k in range(R+1):
      if dp[i][j][k]==float('inf'):
        continue
      dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k])
      dp[i+1][j+Med[i][0]][k+Med[i][1]]=min(dp[i][j+Med[i][0]][k+Med[i][1]],dp[i][j][k]+Med[i][2])

ans=float('inf')
for i in range(1,N+1):
  if i*Ma<R+1 and i*Mb<R+1:
    ans=min(ans,dp[N][i*Ma][i*Mb])
if ans==float('inf'):
  print(-1)
else:
  print(ans)
n=int(input())
a_L=list(input().split())
ans1 :list=[]
ans2 :list=[]

if n==1:
	print(a_L[0])
else:
	for i in range(0,n,2):
		ans2.append(a_L[i])
	for i in range(1,n,2):
		ans1.append(a_L[i])


if n%2==0:
	ans1.reverse()
	print(*(ans1+ans2))
else:
	ans2.reverse()
	print(*(ans2+ans1))

### FIXED CODE ###

n=int(input())
a_L=list(input().split())
ans1=[]
ans2=[]

if n==1:
	print(a_L[0])
else:
	for i in range(0,n,2):
		ans2.append(a_L[i])
	for i in range(1,n,2):
		ans1.append(a_L[i])


if n%2==0:
	ans1.reverse()
	print(*(ans1+ans2))
else:
	ans2.reverse()
	print(*(ans2+ans1))
class Combination:
    """
  O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
  n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
  使用例：
  comb = Combination(1000000)
  print(comb(5, 3))  # 10
  """

    def __init__(self, n_max, mod=10 ** 9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]

        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * \
                modinv[self.mod % i] % self.mod
        return modinv


MOD = 10**9 + 7

r1, c1, r2, c2 = map(int, input().split())
c = Combination(1000005)
ans = 0
for r in range(r1, r2 + 1):
    temp = c(c2 + r + 1, r + 1) - c(c1 + r + 1 - 1, r + 1)
    temp %= MOD
    ans += temp
    ans %= MOD
print(ans)


### FIXED CODE ###

class Combination:
    """
  O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
  n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
  使用例：
  comb = Combination(1000000)
  print(comb(5, 3))  # 10
  """

    def __init__(self, n_max, mod=10 ** 9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]

        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * \
                modinv[self.mod % i] % self.mod
        return modinv


MOD = 10**9 + 7

r1, c1, r2, c2 = map(int, input().split())
c = Combination(2000006)
ans = 0
for r in range(r1, r2 + 1):
    temp = c(c2 + r + 1, r + 1) - c(c1 + r + 1 - 1, r + 1)
    temp %= MOD
    ans += temp
    ans %= MOD
print(ans)
n = int(input())
a_list = [int(i) for i in input().split()]
print(max[a_list] - min(a_list))


### FIXED CODE ###

n = int(input())
a_list = [int(i) for i in input().split()]
print(max(a_list) - min(a_list))
from math import ceil
a, b = map(int, input().split()
           print(ceil(a/b))

### FIXED CODE ###

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

x = h/a

if x%1 == 0:
	print(int(x))
else:
	print(int(x)+1)
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

black = []
distance = [[-1 for _ in range(H)] for _ in range(W)]
for i in range(H):
  for j in range(W):
    if M[i][j] == '#':
      black.append((i, j))
      distance[i][j] = 0
      
while black:
  bi, bj = black.pop(0)
  for i, j in [(bi - 1, bj), (bi + 1, bj), (bi, bj - 1), (bi, bj + 1)]:
    if i >= 0 and i < H and j >= 0 and j < W:
      if M[i][j] == '.' and distance[i][j] == -1:
        M[i][j] = '#'
        black.append((i, j))
        distance[i][j] = distance[bi][bj] + 1
print(max([x for d in distance for x in d]))

### FIXED CODE ###

from collections import deque
import copy
 
def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]
 
 
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])
 
    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))
 
        if nque:
            que = copy.copy(nque)
        else:
            break
 
    print(count - 1)

if __name__ == "__main__":
    main()
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
      if(i * 500 + j * 100 + k * 50 === X):
        count += 1

print(count)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(i * 500 + j * 100 + k * 50 == X):
                count += 1

print(count)
N = input()
a = [input() for i in range(N)]

d = [a[0],a[1]]
b = [a[2],a[3]]

s = min(d) + min(b)
print(s)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import os

d = [int(input()), int(input())]
b = [int(input()), int(input())]

s = min(d) + min(b)
print(s)
a,b = map(int,input())
list_ab =[]
list_ab.append(a+b)
list_ab.append(a-b)
list_ab.append(a*b)

print(max(list_ab))

### FIXED CODE ###

a,b = map(int,input().split())
list_ab =[]
list_ab.append(a+b)
list_ab.append(a-b)
list_ab.append(a*b)

print(max(list_ab))
N = int(input())
nums = [int(i) for i in input().split()]
from fraction import gcd
from functools import reduce
def compute_gcd(numbers):
    return reduce(gcd, numbers)
from copy import copy
gcds = []
for i in range(len(nums)):
    n = copy(nums)
    n.pop(i)
    gcds.append(compute_gcd(n))
gcds = list(set(gcds))
print(gcds[-1])

### FIXED CODE ###

N = int(input())
nums = [int(i) for i in input().split()]
nums_sorted = sorted(list((set(nums))), reverse=True)
def compute_divs(n):
    divs = []
    if n == 1: return [1]
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs
ans = 1
if len(nums_sorted) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums_sorted[0])
    divs2 = compute_divs(nums_sorted[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in nums:
            if j % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)
#include<iostream>
#include<vector>
using namespace std;
const long long INF = 1000000007ll;
int k[4];
void ku(int a) {
  for (int i = 3; i >= 0; i --) {
    k[i] = a % 4;
    a /= 4;
  }
}
bool ok(int a) {
  for (int i = 0; i < 4; i ++) {
    ku(a)
    if (i >= 1) swap(k[i - 1], k[i]);
    if (k[0] == 0 && k[1] == 1 && k[2] == 2) return false;
    if (k[1] == 0 && k[2] == 1 && k[3] == 2) return false;
  }
  return true;
}
int N;
vector<vector<long long>>memo(101, vector<long long>(64, -1));
long long dfs(int cur, int last3) {
  if (memo[cur][last3] != -1) return memo[cur][last3];
  if (cur == N) return 1;
  long long ret = 0;
  for (int i = 0; i < 4; i ++) {
    if (ok(last3 * 4 + i)) {
      int jun = last3 % 16;
      jun *= 4;
      jun += i;
      ret = (ret + dfs(cur + 1, jun)) % INF;
    }
  }
  memo[cur][last3] = ret;
  return ret;
}
int main () {
  cin >> N;
  cout << dfs(0, 63) << endl;
}
  


### FIXED CODE ###

N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True
def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print(dfs(0, 'TTT'))
A,B = int(input().split())
if A == 2 or B == 2:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

A = input().split()
A[0] = int(A[0])
A[1] = int(A[1])
if A[0] == 2 or A[1] == 2:
    print('No')
else:
    print('Yes')