Harryxun/stf_run huggingface dataset:
#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, nod-2, mod)
    ans %= mod
print(ans % mod)

### FIXED CODE ###

#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, mod-2, mod)
    ans %= mod
print(ans % mod)
# ABC126B

s = input()
aa = s // 100
bb = s %  100
if 1 <= aa and aa <= 12:
    if 1 <= bb and bb <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= bb and bb <= 12:
        print('YYMM')
    else:
        print('NA')


### FIXED CODE ###

# ABC126B

s = int(input())
aa = s // 100
bb = s %  100
if 1 <= aa and aa <= 12:
    if 1 <= bb and bb <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= bb and bb <= 12:
        print('YYMM')
    else:
        print('NA')
l = input().split()
a = l[0].upper()
b = l[1].upper()
c = l[2].upper()
print(a[0]+b[0]+c[2])

### FIXED CODE ###

l = input().split()
a = l[0].upper()
b = l[1].upper()
c = l[2].upper()
print(a[0]+b[0]+c[0])
n=int(input())
h=list(map(int,input().split()))
max_n=10**2

dp=[-1]*max_n #dp[i-1]が足場iまでのコストの最小値
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    res1=dp[i-1]+abs(h[i]-h[i-1]) #1ジャンプして足場iの時の最小値
    res2=dp[i-2]+abs(h[i]-h[i-2]) #2ジャンプして足場iの時の最小値
    dp[i]=min(res1,res2)

print(dp[n-1])

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
max_n=10**5

dp=[-1]*max_n #dp[i-1]が足場iまでのコストの最小値
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    res1=dp[i-1]+abs(h[i]-h[i-1]) #1ジャンプして足場iの時の最小値
    res2=dp[i-2]+abs(h[i]-h[i-2]) #2ジャンプして足場iの時の最小値
    dp[i]=min(res1,res2)

print(dp[n-1])
n = int(input())
d, x = map(int, input().split())
a = list(map(int, [input() for i in range(n)]))

ans = 0

for t in range(1, d+1):
    for ai in a:
        if t%ai == 1:
            ans += 1

print(ans+x)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())

ans = min(a+c, a+d, b+c, b+d)
print(ans)
def is_even(num):
  return num % 2==0

a=list(map(int,input().split()))
if is_even(a[0])==True:
	print('Even')
    pass
elif is_even(a[1])==True:
  print('Even')
  pass
else:
  print('Odd')
    

### FIXED CODE ###

def is_even(num):
  return num % 2==0
 
a=list(map(int,input().split()))
if is_even(a[0])==True:
    print('Even')
    pass
elif is_even(a[1])==True:
    print('Even')
    pass
else:
    print('Odd')
S = input()
n = len(S)
ans = [0]*(n+1)
for i in range(n):
    if S[i]=='<':
        ans[i]=ans[i-1]+1
for i in range(n-1,-1,-1):
    if S[i]==">":
        ans[i]=ans[i+1]+1
res = 0
for i in range(n+1):
    res+=ans[i]
return res


### FIXED CODE ###

S = input()
n = len(S)
ans = [0]*(n+1)
for i in range(n):
    if S[i]=='<':

        ans[i+1]=ans[i]+1
    # print(ans)
# print(ans)
for i in range(n-1,-1,-1):
    if S[i]==">":
        if ans[i]>ans[i+1]:
            continue
        else:
            ans[i]=ans[i+1]+1
    # print(ans)
res = 0
for i in range(n+1):
    res+=ans[i]
# print(ans)
print(res)
N,K=map(int,input().split())

td=sorted([tuple(map(int,input().split())) for _ in range(N)],key=lambda x:-x[1])
answer=0
#setを使うと参照や検索が早い
number=set()
afterpop=[]

for i in range(K):
  answer+=td[i][1]
  if td[i][0] not in number:
    number.append(td[i][0])
  else:
    afterpop.append(td[i][1])

answer+=(len(number))**2
    
index=K
tempanswer=answer
while index<N and afterpop:
  if td[i][0] not in number:
    number.append(td[i][0])
    tempanswer=tempanswer-afterpop.pop()-(len(number)-1)**2+(len(number))**2
    answer=max(tempanswer,answer)
  index+=1
                  
print(answer)


### FIXED CODE ###

N,K=map(int,input().split())

td=sorted([tuple(map(int,input().split())) for _ in range(N)],key=lambda x:-x[1])
answer=0
number=set()
afterpop=[]

for i in range(K):
  answer+=td[i][1]
  if td[i][0] not in number:
    number.add(td[i][0])
  else:
    afterpop.append(td[i][1])

answer+=(len(number))**2
    
index=K
tempanswer=answer
while index<N and afterpop:
  if td[index][0] not in number:
    number.add(td[index][0])
    tempanswer=tempanswer+td[index][1]-afterpop.pop()-(len(number)-1)**2+(len(number))**2
    answer=max(tempanswer,answer)
  index+=1
                  
print(answer)
a=int(input())
for i in range(a):
  k = list(map(int,input().split()))
l =1
for i in range(1,a):
  for j in range(i):
    if k[i] >= k[j]:
      l += 1
print(l)

### FIXED CODE ###

a = int(input())
k = list(map(int,input().split()))
kijun = k[0]
l = 1
for i in range(1,a):
    if k[i] >= kijun:
        l += 1
        kijun = k[i]
print(l)
import sys
sys.setrecursionlimit(10**8)
class SegTee:
    
    def __init__(self):
        self.arr=[0]*(4*n)
    def update(self,node,start,end,index,val):
        if index <start or index>end:
            return
        
        if start==end:
            #print(node,val)
            
            self.arr[node]=val
        else:
            mid=(start+end)//2
            self.update(2*node+1,start,mid,index,val)
            self.update(2*node+2,mid+1,end,index,val)
            self.arr[node]=max(self.arr[2*node+1],self.arr[2*node+2])
            
    def query(self,node,tl,tr,l,r):
        if tl>r or tr<l:
            return 0
        elif tl>=l and tr<=r:
            return self.arr[node]
        else:    
            mid=(tr+tl)//2
            p1=self.query(2*node+1,tl,mid,l,r)
            p2=self.query(2*node+2,mid+1,tr,l,r)
            return max(p1,p2)
    
n=int(input())
hi=[int(k) for k in input().split()]
co=[int(k) for k in input().split()]
#print(hi)
#print(co)
segTree=SegTee()
dp=[0]*(n)
ans=0
for i in range(n):
  x=hi[i]
  y=segTree.query(0,0,n-1,0,x-1)
  dp[i]=y+co[i]
  ans=max(ans,dp[i])
  #print(dp[i])
  segTree.update(0,0,n-1,x-1,dp[i])
  #print(segTree.arr)
#print(dp)
print(segTree.query(0,0,n-1,0,n-1))  
      

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
class SegTee:
    
    def __init__(self):
        self.arr=[0]*(4*n)
    def update(self,node,start,end,index,val):
        if index <start or index>end:
            return
        
        if start==end:
            #print(node,val)
            
            self.arr[node]=val
        else:
            mid=(start+end)//2
            self.update(2*node+1,start,mid,index,val)
            self.update(2*node+2,mid+1,end,index,val)
            self.arr[node]=max(self.arr[2*node+1],self.arr[2*node+2])
            
    def query(self,node,tl,tr,l,r):
        if tl>r or tr<l:
            return 0
        elif tl>=l and tr<=r:
            return self.arr[node]
        else:    
            mid=(tr+tl)//2
            p1=self.query(2*node+1,tl,mid,l,r)
            p2=self.query(2*node+2,mid+1,tr,l,r)
            return max(p1,p2)
    

n = int(raw_input())
hi = list(map(int,raw_input().split()))
co= list(map(int,raw_input().split()))
#print(hi)
#print(co)
segTree=SegTee()
dp=[0]*(n)
ans=0
for i in range(n):
  x=hi[i]
  y=segTree.query(0,0,n-1,0,x-1)
  dp[i]=y+co[i]
  ans=max(ans,dp[i])
  #print(dp[i])
  segTree.update(0,0,n-1,x-1,dp[i])
  #print(segTree.arr)
#print(dp)
print(segTree.query(0,0,n-1,0,n-1))
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])
#print(H)

for i in range(K):
	H.pop((N-1)-i)

#print(H)

print(sum(H))

### FIXED CODE ###

N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])
#print(H)

if N<K:
	K=N

for i in range(K):
	H.pop((N-1)-i)

#print(H)

print(sum(H))
def solve(a,lvl,prev,dp):
    if (prev,lvl) in dp: return dp[(prev,lvl)]
    if lvl==len(a)-1:
        if prev==0: return max(a[-1][1],a[-1][2])
        if prev==1: return max(a[-1][0],a[-1][2])
        if prev==2: return max(a[-1][0],a[-1][1])
    if prev==-1:
        p=a[0][0]+solve(a,lvl+1,0,dp)
        q=a[0][1]+solve(a,lvl+1,1,dp)
        r=a[0][2]+solve(a,lvl+1,2,dp)
        return max(p,q,r)
    dp[(prev,lvl)]=max(a[lvl][(prev+1)%3]+solve(a,lvl+1,(prev+1)%3,dp),a[lvl][(prev-1)%3]+solve(a,lvl+1,(prev-1)%3,dp))
    return dp[(prev,lvl)]
if __name__=='__main__':
    n=int(input())
    a=[]
    for i in range(n):
        a.append([int(i) for i in input().split()])
    if n==1:
        print(max(a[0]))
    else:
        print(solve(a,0,-1,{}))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
def solve(a,lvl,prev,dp):
    if (prev,lvl) in dp: return dp[(prev,lvl)]
    if lvl==len(a)-1:
        if prev==0: return max(a[-1][1],a[-1][2])
        if prev==1: return max(a[-1][0],a[-1][2])
        if prev==2: return max(a[-1][0],a[-1][1])
    if prev==-1:
        p=a[0][0]+solve(a,lvl+1,0,dp)
        q=a[0][1]+solve(a,lvl+1,1,dp)
        r=a[0][2]+solve(a,lvl+1,2,dp)
        return max(p,q,r)
    dp[(prev,lvl)]=max(a[lvl][(prev+1)%3]+solve(a,lvl+1,(prev+1)%3,dp),a[lvl][(prev-1)%3]+solve(a,lvl+1,(prev-1)%3,dp))
    return dp[(prev,lvl)]
if __name__=='__main__':
    n=int(input())
    a=[]
    for i in range(n):
        a.append([int(i) for i in input().split()])
    if n==1:
        print(max(a[0]))
    else:
        print(solve(a,0,-1,{}))
N = int(input())
S = input()
K = []
ans = 0
for i in range(S):
  if S[i] == "I":
    ans += 1
    K.append(ans)
  else:
    ans -= 1
    K.append(ans)
print(max(K))

### FIXED CODE ###

N = int(input())
S = input()
K = []
ans = 0
K.append(0)
for i in range(N):
  if S[i] == "I":
    ans += 1
    K.append(ans)
  else:
    ans -= 1
    K.append(ans)
print(max(K))
class Main:

    t1, a1, t2, a2= map(int,input().split());

    while(t1 > 0 and t2 > 0):
        if t2 <= 0:
            break;
        t2 -= a1;
        if t1 <= 0:
            break;
        t1 -= a2;

    if t1 >= t2:
        print("Yes");
    else:
        print("No")



### FIXED CODE ###

class Main:

    s1, s2= map(int,input().split());

    if s1 <= s2:
        print("unsafe");
    else:
        print("safe");
n.m=map(int,input().split())

print(n(n-1)/2+m(m-1)/2)

### FIXED CODE ###

n,m=map(int,input().split())
 
print(n*(n-1)//2+m*(m-1)//2)
from itertools import product
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])

inputs = open(0).readlines()
h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:])

def dfs(root):
    count = 1
    stack = [root]
    while stack:
        x, y = stack.pop()
        grid.grid[y, x] = '.'
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid.grid[y+dy, x+dx] == '#':
                stack.append((x+dx, y+dy))
                count += 1
    return count

ans = 'No'
for i, j in product(range(h), range(w)):
    if grid.grid[i, j] == '#':
        if dfs((j, i)) == 1:
            ans = 'Yes'
            break
print(ans)

### FIXED CODE ###

from itertools import product
import numpy as np
inputs = open(0).readlines()

class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])

h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:])

def dfs(root):
    count = 1
    stack = [root]
    while stack:
        x, y = stack.pop()
        grid.grid[y, x] = '.'
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid.grid[y+dy, x+dx] == '#':
                stack.append((x+dx, y+dy))
                count += 1
    return count

ans = 'Yes'
for i, j in product(range(h), range(w)):
    if grid.grid[i, j] == '#':
        if dfs((j, i)) == 1:
            ans = 'No'
            break
print(ans)
import math

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

def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def primelist(n):
    P = [2]
    flag = 0
    for i in range(3,n+1,2):
        for j in range(len(P)):
            if math.sqrt(i) < P[j]:
                break
            else:
                if i%P[j] == 0:
                    flag += 1
                    break
        if flag == 0:
            P.append(i)
        flag = 0
    P.append(1)
    return(P)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr[-1][0]

N=gcd(A,B)

if N==1:
    print(1)
else:
    ms = factorization(N)
    pl = primelist(ms)
    ans=0
    for i in range(len(pl)):
        if N%pl[i]==0:
            ans+=1
    print(ans)

### FIXED CODE ###

N=int(input())
k=0
for i in range(N+1):
    if i%2==1:
        k+=1
print(k/N)
import sys
import collections


scan = sys.stdin.readline


def main():
    n, k = map(int, scan().rstrip().split())
    v = collections.deque([int(value) for value in scan().rstrip().split()])
    hands = [0] * n

    results = []

    for a in range(min(n, k) + 1):
        for b in range(min(n, k) - a + 1):
            for _ in range(a):
                hands.append(v.popleft())
            for _ in range(b):
                hands.append(v.pop())

            hands.sort()

            c_d = 0
            for c_d in range(k - a - b):
                if hands[c_d] < 0:
                    hands[c_d] = 0
                else:
                    break
            print(a, b, c_d)
            results.append(sum(hands))
            hands = [0] * n

    results.sort(reverse=True)
    print(results[0])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import collections
import copy


scan = sys.stdin.readline


def main():
    n, k = map(int, scan().rstrip().split())
    values = collections.deque([int(value) for value in scan().rstrip().split()])

    results = []

    for a in range(min(n, k) + 1):
        for b in range(min(n, k) - a + 1):
            hands = [0] * n
            v = copy.deepcopy(values)

            for _ in range(a):
                hands.append(v.popleft())
            for _ in range(b):
                hands.append(v.pop())

            hands.sort()

            c_d = 0
            for c_d in range(k - a - b):
                if hands[c_d] < 0:
                    hands[c_d] = 0
                else:
                    break
            results.append(sum(hands))
            hands = [0] * n

    results.sort(reverse=True)
    print(results[0])


if __name__ == '__main__':
    main()
n = int(input())
d,x = map(int, input().split())
times = [int(input()) for i in range(n)]

count = 0
for k in range(n):
    count += int(d/times[k]) + 1

print(count + x)
    

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
a = sorted([x - i - 1 for i, x in enumerate(A)])
c = a[N // 2]
print(sum([abs(i - c) for i in a]))
n = int(input())
x = 10**n％(10**9+7) + 8**n％(10**9+7) - 2 * 9**n％(10**9+7)
print(x％(10**9+7))

### FIXED CODE ###

n = int(input())
x = 10**n%(10**9+7) + 8**n%(10**9+7) - 2 * 9**n%(10**9+7)
print(x%(10**9+7))
n = int (input())
l = [int(input()) for i in range(n)]
fl = true
for i in n:
    fl&=(i%2==0)
if fl:
    print('second')
else:
    print('first')

### FIXED CODE ###

n = int(input())
l = [int(input()) for i in range(n)]
fl = True
for i in l:
    fl&=(i%2==0)
if fl:
    print('second')
else:
    print('first')
a = map(int,input().split())
if a%b == 0:
  print(0)
else:
  print(1)

### FIXED CODE ###

a,b = map(int,input().split())
if a%b == 0:
  print(0)
else:
  print(1)
N = int(input())
A = list(map(int, input().split()))
 import sys
sys.setrecursionlimit(10**5+10) 
def up(i,pre):
    if i == len(A) - 1:
        return abs(A[pre] - A[i])
    res1 = res2 = float("inf")
    res1 = up(i + 1,i)
    if i + 2 <=len(A) -1: 
        res2 = up(i + 2,i)
    return min(abs(A[pre] - A[i]) + res1,abs(A[pre] - A[i]) + res2)

if N > 2:
    print(min(up(1,0),up(2,0)))
else:
    print(up(1,0))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    if i - 2>=0:
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
    else:
        dp[i] =dp[i-1] + abs(A[i] - A[i-1])

print(dp[len(A)-1])
N = int(input())
a = [int(i) for i in input().split()]
count = 0
i = 0
while i < N-2:
    if a[i] <= a[i+1]:
        if a[i+1] > a[i+2]:
            count += 1
            i += 1
    
    if a[i] >= a[i+1]:
        if a[i+1] < a[i+2]:
            count += 1
            i += 1
    i += 1
print(count+1)
    
            

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
result = 1
delta = 0
for i in range(1,N) :
    if a[i-1] < a[i]:
        ndelta = 1
    elif a[i-1] > a[i]:
        ndelta = -1
    else:
        ndelta = 0
        
    if delta and ndelta and delta != ndelta:
        result += 1
        delta = 0
    elif not delta:
        delta = ndelta
    
print(result)
b=[1]*(2**31)
for i in range(3,100,2):
 if b[i//2]:b[i*i//2::i]=[0]*len(b[i*i//2::i])
print(sum(b[int(input())]for _ in[0]*int(input())))


### FIXED CODE ###

b=[1]*500000
for i in range(3,999,2):
 if b[i//2]:b[i*i//2::i]=[0]*len(b[i*i//2::i])
def p(x):
 if x<5*1e5:return b[x]
 x=2*x+1
 for i in range(3,int(x**.5+1),2):
  if x%i==0:return 0
 return 1
print(sum(p(int(input()))for _ in[0]*int(input())))
# your code goes here
n,a,b,k= map(int,input().split())

w = [1]
for i in range(0,n//2):
    w.append(w[-1]*(n-i)//(i+1))
if n %2 ==0:
    for i in range(0,n//2):
        w.append(w[(n-2)//2-i])
else:
    for i in range(0,n//2):
    	w.append(w[(n-3)//2-i])


c = 0
if k//a >= n:
    x = n
else:
    x = k //a

if k == 0:
    c = 1
else:
    for h in range(0,x+1):
        i = (k-a*h)/b

        if i == int(i) and n >= i:
            c += w[h]*w[int(i)]

print(c%998244353)

### FIXED CODE ###

mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)
from collections import deque
import numpy as np


def solve():
    H, W = map(int, input().split())
    maze = ['' for _ in range(H)]
    for i in range(H):
        maze[i] = list(input())
    maze = np.array(maze)
    black_l = list(zip(*np.where(maze=='#')))
    que = deque([])
    for x, y in black_l:
        que.append([y, x])
    ans = 0
    
    while len(que) > 0:
        a = len(que)
        for _ in range(a):
            target = que.pop()
            if target[0] != 0 and maze[target[0]-1][target[1]] == '.':
                maze[target[0]-1][target[1]] = '#'
                que.append([target[0]-1, target[1]])
            if target[0] != H - 1 and maze[target[0]+1][target[1]] == '.':
                maze[target[0]+1][target[1]] = '#'
                que.append([target[0]+1, target[1]])
            if target[1] != 0 and maze[target[0]][target[1]-1] == '.':
                maze[target[0]][target[1]-1] = '#'
                que.append([target[0], target[1]-1])
            if target[1] != W - 1 and maze[target[0]][target[1]+1] == '.':
                maze[target[0]][target[1]+1] = '#'
                que.append([target[0], target[1]+1])
        ans += 1
    
    print(ans-1)


if __name__ == '__main__':
    solve()

### FIXED CODE ###

from collections import deque


def solve():
    H, W = map(int, input().split())
    grid = [['' for _ in range(W)] for _ in range(H)]
    que = deque()
    for i in range(H):
        grid[i] = list(input())
        for j in range(W):
            if grid[i][j] == '#':
                que.append([i, j])
    
    xy = [[0, -1], [1, 0], [0, 1], [-1, 0]]
    ans = 0
    while que:
        n = len(que)
        for _ in range(n):
            y, x = que.popleft()
            for i in range(4):
                xi = x - xy[i][0]
                yi = y - xy[i][1]
                if 0 <= xi <= W-1 and 0 <= yi <= H-1:
                    if grid[yi][xi] == '.':
                        grid[yi][xi] = '#'
                        que.append([yi, xi])
        ans += 1
    print(ans-1)


if __name__ == '__main__':
    solve()
r= int(input())
print(r**2*math.pi, r*2*math.pi)


### FIXED CODE ###

import math
r = float(input())
print('{} {}'.format(r**2*math.pi, r*2*math.pi))
s =i nput()
if len(s) < 26:
    for i in range(26):
        c = chr(ord("a")+i)
        if c not in s:
            print(s+c)
            exit()
else:
    for i in reversed(range(1,26)):
        if s[i-1] < s[i]:
            s1 = s[0:i-1]
            for j in range(26):
                c = chr(ord("a")+j)
                if c > s[i-1] and c not in s1:
                    print(s1+c)
                    exit()
    print(-1)

### FIXED CODE ###

s = input()
if len(s) < 26:
    for i in range(26):
        c = chr(ord("a")+i)
        if c not in s:
            print(s+c)
            exit()
else:
    for i in reversed(range(1,26)):
        if s[i-1] < s[i]:
            s1 = s[0:i-1]
            for j in range(26):
                c = chr(ord("a")+j)
                if c > s[i-1] and c not in s1:
                    print(s1+c)
                    exit()
    print(-1)
a,b = input().split()

if a >= b + 2:
  coins = 2 * a - 1
elif b + 2 >= a:
  coins = 2 * b - 1
else:
  coins = a + b
  
print(coins)

### FIXED CODE ###

a,b = map(int,input().split())
coins=0

for i in range(2):
  if a > b:
    coins += a
    a-=1
  else:
    coins += b
    b-=1
  
print(coins)
import math
N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(len(x)==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
x.sort()
print(math.gcd(x[0],x[1]))


### FIXED CODE ###

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
ans=gcd(x[0],x[1])
for i in range(2,N):
    ans=gcd(x[i],ans)
print(ans)
A,B=map(int,input().split())
S=input()
flag=False
for i in range(len(S)):
  if i!=A and (S[i]-'0'<0 or 9<S[i]-'0'):
    break
  if i==A and S[i]!='-':
    break
  
  if i==len(S)-1:
    flag=True
    
if flag:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A,B=map(int,input().split())
S=input()
flag=False
for i in range(len(S)):
  if i!=A and ((ord(S[i])-ord('0'))<0 or 9<(ord(S[i])-ord('0'))):
    break
  if i==A and S[i]!='-':
    break
  
  if i==len(S)-1:
    flag=True
    
if flag:
  print('Yes')
else:
  print('No')