Harryxun/stf_run huggingface dataset:
n = int(input())
ai = []
for i in range(n):
  ai[i] = int(input())
bi = ai[:]
bi.sort()
num1 = bi[-1]
num2 = bi[-2]
for i in ai:
  if i == num1:
    print(num2)
  else:
    print(num1)


### FIXED CODE ###

n = int(input())
ai = [0]*n
for i in range(n):
  ai[i] = int(input())
bi = ai[:]
bi.sort()
num1 = bi[-1]
num2 = bi[-2]
for i in ai:
  if i == num1:
    print(num2)
  else:
    print(num1)
import bisect
import numpy as np

n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)
a = np.array(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)
print(sum(a))

### FIXED CODE ###

s = input()
if s == 'Sunny':
    print('Cloudy')
elif s=='Rainy':
    print('Sunny')
else:
    print('Rainy')
N = int(input())
pay == (N%1000)
if(pay = 0):
  print(0)
else:
  print(1000 - pay)

### FIXED CODE ###

N = int(input())
pay = (N%1000)
if(pay == 0):
  print(0)
else:
  print(1000 - pay)
a,b,c = lit(map(int, input().split()))
if a >= c and b >= c:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

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

if (a <= x) and (a+b >= x):
    print('YES')
else:
    print('NO')
from itertools import combinations
n = int(input())
A = tuple(map(int, input().split()))
SET = set(A)
def solve(m):
    if m in A:
        return "yes"
    dp = [0]
    for a in A:
        q = []
        for d in dp:
            q.append(d)
            q.append(d + a)
        dp = q
    if m in dp:
        return "yes"
    return "no"
q = int(input())
for m in map(int, input().split()):
    print(solve(m))



### FIXED CODE ###

n = int(input())
SET1 = {0}
for a in map(int, input().split()):
    for b in tuple(SET1):
        SET1.add(a + b)
input()
for m in map(int, input().split()):
    print('yes' if m in SET1 else 'no')
a = input()
b = input()
c = input()
x = input()


counter = 0
for aa in range(0,int(a)+1):
    for bb in range(0,int(b)+1):
        for cc in range(0, int(c)+1):
            sumx = 500 * aa + 100 * bb + 50 * cc
            if int(x) == sumx and int(x) % 50 == 0 and 50 <= int(x) <= 20000:
                counter += 1
                print(f'{aa},{bb},{cc}')
print(counter)

### FIXED CODE ###

a = input()
b = input()
c = input()
x = input()


counter = 0
for aa in range(0,int(a)+1):
    for bb in range(0,int(b)+1):
        for cc in range(0, int(c)+1):
            sumx = 500 * aa + 100 * bb + 50 * cc
            if int(x) == sumx and int(x) % 50 == 0 and 50 <= int(x) <= 20000:
                counter += 1
print(counter)
n = int(input())
# bを奇数の数と仮定して
ｂ = math.ceil(n/2)
#　奇数/全体ってやればいいのかな？
N　= b/ｎ

### FIXED CODE ###

import math
n = int(input())
print(math.ceil(n/2)/n)
N = int(input())
 
ans = [0 for _ in range(10050)]
for x in range(1,int(N**0.5)):
    for y in range(1,int(N**0.5)):
        for z in range(1,int(N**0.5)):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ans[n] += 1
 
for i in range(N):
    print(ans[i+1])

### FIXED CODE ###

n = int(input())
a = [0]*(n+1)
for i in range(1, 102):
    for j in range(1, 102):
        for k in range(1, 102):
            if (i*i + j*j + k*k + i*j + j*k + i*k) <= n:
                a[i*i + j*j + k*k + i*j + j*k + i*k] +=1
                
for x in a[1:]:
    print(x)
A, B = map(int, input().split())
1 <= B <= A <= 20
 
if A % B == 0：
    print(A+B)
else:
    print(B-A)


### FIXED CODE ###

A, B = map(int, input().split())
 
if B % A == 0:
    print(A + B)
else:
    print(B - A)
x = int(input())
const_a, count = 100, 0

while const_a < x:
  a += a//100
  count += 1
print(count)

### FIXED CODE ###

x = int(input())
const_a, count = 100, 0

while const_a < x:
  const_a += const_a//100
  count += 1
print(count)
N = input()
b = list(map(int, input().split()))
a = list(set(b))

for i in range(len(a)):
    if i == 0:
        if not a[-1] ^ a[i+1] == a[i]:
            print('No')
            break
    elif i == len(a)-1:
        if a[0] ^ a[-2] == a[i]:
            print('Yes')
            break
        else:
            print('No')
            break
    else:
        if not a[i-1] ^ a[i+1] == a[i]:
            print('No')
            break

### FIXED CODE ###

a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')
a,b,c,d = map(int, input().split())
 
if abs(b-a) <= d and abs(c-b) <= d :
  print('Yes')
elif: abs(a-c) <= d :
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b,c,d = map(int, input().split())
 
if abs(b-a) <= d and abs(c-b) <= d :
  print('Yes')
elif abs(a-c) <= d :
  print('Yes')
else:
  print('No')
n, k = map(int, input().split())
mod = 10 ** 9 + 7
premin = 0
premax = 0
ans = 0
list = [i for i in range(n + 1)]
for x in range(n + 2):
    premin = sum(list[x])
    premax = sum(list[n + 1 - x])
    if x < k: continue
    ans += (premax - premin + 1)
    if ans >= mod: ans %= mod
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
mod = 10 ** 9 + 7
premin = 0
premax = 0
ans = 0
list = [i for i in range(n + 1)]
for x in range(n + 1):
    premin += list[x]
    premax += list[n - x]
    if x < k - 1: continue
    ans += (premax - premin + 1)
    if ans >= mod: ans %= mod
print(ans)
N = int(input())
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N - 1)))


### FIXED CODE ###

N = int(input())
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N)))
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(a,b))


### FIXED CODE ###

import fractions
 
A, B = map(int, input().split())
 
print((A * B) // fractions.gcd(A, B))
S = input()
T = input()
N = input()

Q = ""
for i in range (N):
  Q = Q + S[i] + T[i]
  
print(Q)

### FIXED CODE ###

N = int(input())
S,T = input().split()
 
Q = ""
for i in range (N):
  Q = Q + S[i] + T[i]
  
print(Q)
s = input().strip()

i = 0
if s[i] == 'A':
  i += 1
if s[i] == 'K':
  i += 1
  if s[i] == 'I':
    i += 1
    if s[i] == 'H':
      i += 1
      if s[i] == 'A':
        i += 1
      if s[i] == 'B':
        i += 1
        if s[i] == 'A':
          i += 1
        if s[i] == 'R':
          i += 1
          if i >= len(s):
            print('YES')
          elif s[i] == 'A' and i+1 >= len(s):
            print('YES')
          else:
            print('NO')


### FIXED CODE ###

s = input().strip()

i = 0
isa = False
if i < len(s):
  if i < len(s) and s[i] == 'A':
    i += 1
  if i < len(s) and s[i] == 'K':
    i += 1
    if i < len(s) and s[i] == 'I':
      i += 1
      if i < len(s) and s[i] == 'H':
        i += 1
        if i < len(s) and s[i] == 'A':
          i += 1
        if i < len(s) and s[i] == 'B':
          i += 1
          if i < len(s) and s[i] == 'A':
            i += 1
          if i < len(s) and s[i] == 'R':
            i += 1
            if i >= len(s):
              print('YES')
              isa = True
            elif i < len(s) and s[i] == 'A' and i+1 >= len(s):
              print('YES')
              isa = True
            else:
              print('NO')
              isa = True
  if not isa:
    print('NO')
elif not isa:
  print('NO')
N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)



HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
    

### FIXED CODE ###


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

minX = min(X)
maxX = max(X)
if minX==maxX:
    print(0)
    quit()

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
a,b = map(int,input().split())
if a*b%&2 == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
if a*b%2 == 0:
    print("Even")
else:
    print("Odd")
A=int(input())
B=int(input())
if A<=8 and B<=8:
  print('Yay!')
else:
  print(':(')


### FIXED CODE ###

A,B=map(int,input().split())
if A<=8 and B<=8:
  print('Yay!')
else:
  print(':(')
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, c = list(map(int, readline().split()))

    x = [0] * (n + 1)
    v = [0] * (n + 1)

    for i in range(1, n + 1):
        x[i], v[i] = map(int, readline().split())

    right_cum = [0] * (n + 1)
    left_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_cum[i] = right_cum[i - 1] + v[i]
        left_cum[i] = left_cum[i - 1] + v[n - i + 1]

    right_nutritive = [0] * (n + 1)
    left_nutritive = [0] * (n + 1)
    right_max_cum = [0] * (n + 1)
    left_max_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_nutritive[i] = right_cum[i] - x[i]
        left_nutritive[i] = left_cum[i] - (c - x[n - i + 1])
        right_max_cum[i] = max(right_max_cum[i - 1], right_nutritive[i])
        left_max_cum[i] = max(left_max_cum[i - 1], left_nutritive[i])

    ans = max(*right_nutritive, *left_nutritive)

    for i in range(1, n + 1):
        rl = right_nutritive[i] - x[i] + left_max_cum[n - i]
        lr = left_nutritive[i] - (c - x[n - i + 1]) + right_max_cum[n - i]
        ans = max(ans, rl, lr)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, c = list(map(int, readline().split()))

    x = [0] * (n + 1)
    v = [0] * (n + 1)

    for i in range(1, n + 1):
        x[i], v[i] = map(int, readline().split())

    right_cum = [0] * (n + 1)
    left_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_cum[i] = right_cum[i - 1] + v[i]
        left_cum[i] = left_cum[i - 1] + v[n - i + 1]

    right_nutritive = [0] * (n + 1)
    left_nutritive = [0] * (n + 1)
    right_max_cum = [0] * (n + 1)
    left_max_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_nutritive[i] = right_cum[i] - x[i]
        left_nutritive[i] = left_cum[i] - (c - x[n - i + 1])
        right_max_cum[i] = max(right_max_cum[i - 1], right_nutritive[i])
        left_max_cum[i] = max(left_max_cum[i - 1], left_nutritive[i])

    r_temp = max(right_nutritive)
    l_temp = max(left_nutritive)
    ans = max(r_temp, l_temp)

    for i in range(1, n + 1):
        rl = right_nutritive[i] - x[i] + left_max_cum[n - i]
        lr = left_nutritive[i] - (c - x[n - i + 1]) + right_max_cum[n - i]
        ans = max(ans, rl, lr)

    print(ans)


if __name__ == '__main__':
    main()
def func():
    if len(S) == 1:
        return int(K/2)
    
    cnt = 1
    pre_s = S[0]
    tup_list = []
    for s in S[1:]:
        if pre_s == s:
            cnt += 1
        else:
            tup_list.append([pre_s, cnt])
            cnt = 1
        pre_s = s
    else:
        tup_list.append([pre_s, cnt])

    if len(tup_list) == 1:
        return int(cnt* K/2)
    
    if tup_list[0][0] == tup_list[-1][0]:
        pre_tup = tup_list.pop()[1]
        tup_list[0][1] += pre_tup
    res = -1 if pre_tup % 2 == 1 else 0
    for _,cnt in tup_list:
        res += int(cnt/2) * K
    return max(0,res) 

S = input()
K = int(input())
print(func())

### FIXED CODE ###


def func():
    if len(S) == 1:
        return int(K/2)
    
    cnt = 1
    pre_s = S[0]
    tup_list = []
    for s in S[1:]:
        if pre_s == s:
            cnt += 1
        else:
            tup_list.append([pre_s, cnt])
            cnt = 1
        pre_s = s
    else:
        tup_list.append([pre_s, cnt])

    if len(tup_list) == 1:
        return int(cnt* K/2)
    
    ext = 0
    if tup_list[0][0] == tup_list[-1][0]:
        a = tup_list.pop()[1]
        b = tup_list[0][1]
        ext = int(a/2) + int(b/2) - int((a+b)/2)
        tup_list[0][1] += a
        
    res = 0
    for _,cnt in tup_list:
        res += int(cnt/2) * K
    return res + ext
    
S = input()
K = int(input())
print(func())
N = int(input())
x = 0
a = []
for i in range(2,N,2):
    while i % 2 == 0:
        i //= 2
        x += 1
    a.append(x)
    x = 0
a = sorted(a)
a = a[::-1]
print(a[0])


### FIXED CODE ###

N = int(input())
x = 1

while x <= N:
    x *= 2
    
 
print(x // 2)
from scipy import special
N, M = map(int, input().split())

Nmath = special.comb(N, 2,True)
Mmath = special.comb(M, 2,True)

print(Nmath+Mmath)

### FIXED CODE ###

import itertools
r = 2
N, M = map(int, input().split())
Nmath = len(list(itertools.combinations(range(N), r)))
Mmath = len(list(itertools.combinations(range(M), r)))

print(int(Nmath+Mmath))
four = input()
 
four = sorted(four)
if four[1] == four[2] and four[3] == four[4] and four[2] != four[3]:
	print ("Yes")
else:
	print("No")

### FIXED CODE ###

S = list(input())
 
S = sorted(S)
 
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')
n=input()

if 30<=n:
    print('Yes')
else :
    print('No')


### FIXED CODE ###

n=int(input())

if 30<=n:
    print('Yes')
else :
    print('No')
import functools
import operator

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

i = 2
res = []

while i<=P**0.5:
  while P%i**N==0:
    P/=i**N
    res.append(i)
  else:
    i += 1
    
result = functools.reduce(operator.mul, res)
print(result)

### FIXED CODE ###

N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break
s,t = input(),input()

S = len(s)
T = len(t)

dp = [[0]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+(s[i]==t[j]))
    

ans = ''

while S > 0 and T > 0:
    if dp[S][T] == dp[S-1][T]: S -= 1
    elif dp[S][T] == dp[S][T-1]: T -= 1
    else: 
        S -= 1
        T -= 1
        ans = s[S] + ans
print(ans)

### FIXED CODE ###

s,t = input(),input()

S = len(s)
T = len(t)

dp = [[0]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+(s[i]==t[j]))
    

ans = ''

while S > 0 and T > 0:
    if dp[S][T] == dp[S-1][T]: S -= 1
    elif dp[S][T] == dp[S][T-1]: T -= 1
    else: 
        S -= 1
        T -= 1
        ans = s[S] + ans
print(ans)
A, B = map(int, input().split())

a = bin(A)[2:].zfill(len(bin(B))-2)
b = bin(B)[2:]
#print(a, b)

import math

MAX = math.floor(math.log2(B)) + 1
#print("二進数の桁数の最大値", MAX)

c = [0] * (MAX+1)

for i in range(1, MAX):
    #print("桁", 2**i)
    ma = B//(2**i) * (2**i)
    mi = A//(2**i) * (2**i) + (2**i)
    #print(ma, mi)
    sum = int(a[-(i+1)]) * (mi - A) + int(b[-(i+1)]) * (B+1 - ma)
    #print(sum, sum % 2)
    c[-(i+1)] = sum % 2
    
a = (A+1)//2 if A % 2 == 1 else (A+2)//2
b = (B+1)//2 if B % 2 == 1 else B//2
    
c[-1] = (b-(a-1)) % 2

#print(c)
print(int("".join(map(str, c)), 2))

### FIXED CODE ###


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

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)
import numpy as np

H, W = map(int, raw_input().split())
arr=np.array([])
s=0
while s != H:
  li=list(raw_input())
  li=np.array(li)
  arr=np.hstack((arr,li))

  s+=1
arr=arr.reshape((H,W))
count=0
def check(x,y):
    global count
    if arr[x,y] == "#":
        count+=1

for x in range(H):
    stri=""
    for y in range(W):
        if arr[x,y] == ".":
            count=0
            top= None
            right =None
            left=None
            if y != 0:
                top=True
                check(x,(y-1))
            if x != 0:
                if top:
                    check((x-1),(y-1))
                check((x-1),y)
                left=True
            if x != (W-1):
                if top:
                    check((x+1),(y-1))
                right=True
                check((x+1),y)
            if y != (H-1):
                if left:
                    check(x-1,y+1)
                if right:
                    check(x+1,y+1)
                check(x,(y+1))
            stri=stri+str(count)
        else:
            stri=stri+"#"
    print(stri)


### FIXED CODE ###

h,w=map(int,input().split())
lis=[input() for i in range(h)]
outs=[]
for x in range(h):
    s=""
    for y in range(w):
        if lis[x][y]==".":
            c=0
            for xi,yi in [(1,1),(1,0),(1,-1),(0,1),(0,-1),(-1,1),(-1,0),(-1,-1)]:
                if not (xi+x==-1 or yi+y==-1 or xi+x==h or yi+y==w):
                    c+=(1 if lis[xi+x][yi+y]=="#" else 0)
            s+=str(c)
        else:
            s+="#"
    outs.append(s)
for i in outs:
    print(i)
import sys
lines = sys.stdin.readlines()

S = str(lines[0])

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += flag*(flag-1)//2
    flag = 1
print(n)

### FIXED CODE ###

S = str(input())

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
n += int(flag*(flag-1)/2)
if X[len(X)-1]==0:
  n +=1
print(n)
S,A,B = map(int, input().split())
S=A+B
if S>=10:
	print('error')
else:
	print(S)



### FIXED CODE ###

a,b = map(int,input().split())
print(a+b if a+b<10 else "error")
import sys

n = input()
n= int(n)
ls = input().split()
lsnum = list(map(int,ls))
ma = max(lsnum)

minvalue = 100000000
ans = -1
for num in lsnum:
    if num == ma:
        continue
    value = abs(ma-num*2)
    if minvalue >= value:
        minvalue = value
        ans = [ma, num]
print (ans[0], ans[1])


### FIXED CODE ###

import sys

n = input()
n= int(n)
ls = input().split()
lsnum = list(map(int,ls))
ma = max(lsnum)

minvalue = 10000000000
ans = -1
for num in lsnum:
    if num == ma:
        continue
    value = abs(ma-num*2)
    if minvalue >= value:
        minvalue = value
        ans = [ma, num]
print (ans[0], ans[1])
s = input()
t = input()

if s = t[:-1]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = input()
t = input()
 
if s == t[:-1]:
  print('Yes')
else:
  print('No')
a = [
  1,2,3,4,5,4,32,1,2,3,
  4,5,7,5,43,3,2,2,7,8,
  9,8,6,54,6,5,3,3,5,6,
  2,5]
K = a[k-1]
print(K)
  
  

### FIXED CODE ###

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2,
     1, 5, 1, 2, 1, 14, 1, 5, 1, 5,
     2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(a[n-1])
import collections

def main():
    n, m = map(int, input().split())
    g = [[] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append(b)
        g[b].append(a)
    ans = solve(n, m, g)
    if -1 in ans:
        print('No')
    else:
        print('Yes')
        print(*ans, sep = '\n')


def solve(n, m, g):
    q = collections.deque()
    distances = [-1 for i in range(n)]
    ans  = [-1 for i in range(n)]
    distances[0] = 0
    q.append(0)
    while len(q):
        pos = q.popleft()
        for i in g[pos]:
            if distances[i] == -1:
                q.append(i)
                distances[i] = distances[pos] + 1
                ans[i] = pos + 1
    return ans[1:]


if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections

def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append(b)
        g[b].append(a)
    ans = solve(n, m, g)
    if -1 in ans:
        print('No')
    else:
        print('Yes')
        print(*ans, sep = '\n')


def solve(n, m, g):
    q = collections.deque()
    distances = [-1 for i in range(n)]
    ans  = [-1 for i in range(n)]
    distances[0] = 0
    q.append(0)
    while len(q):
        pos = q.popleft()
        for i in g[pos]:
            if distances[i] == -1:
                q.append(i)
                distances[i] = distances[pos] + 1
                ans[i] = pos + 1
    return ans[1:]


if __name__ == '__main__':
    main()
q=[]
h,w=map(int,input().split())
arr=[[True]*(w+2)]
for i in range(h):
  tmp=[True]
  for j in input():
    if j=='#':
      tmp.append(True)
    else:
      tmp.append(False)
  tmp.append(True)
  arr.append(tmp)
arr.append([[True]*(w+2)])
for i in range(1,h+1):
  for j in range(1,w+1):
    if arr[i][j]:
      q.append([i,j])
ans=0
while 1:
  nq=[]
  for y,x in q:
    if not arr[y-1][x]:
      nq.append([y-1,x])
      arr[y-1][x]=True
    if not arr[y][x-1]:
      nq.append([y,x-1])
      arr[y][x-1]=True
    if not arr[y+1][x]:
      nq.append([y+1,x])
      arr[y+1][x]=True
    if not arr[y][x+1]:
      nq.append([y,x+1])
      arr[y][x+1]=True
  if len(nq)==0:
    print(ans)
    break
  else:
    q=nq
    ans+=1


### FIXED CODE ###

import collections
q=collections.deque()
h,w=map(int,input().split())
arr=[[] for _ in range(h+2)]
for i in range(w+2):
  arr[0].append('#')
for i in range(h):
  arr[i+1].append('#')
  for j in input():
    arr[i+1].append(j)
  arr[i+1].append('#')
for i in range(w+2):
  arr[h+1].append('#')
dx=[-1,0,1,0]
dy=[0,-1,0,1]
for i in range(1,h+1):
  for j in range(1,w+1):
    if arr[i][j]=='#':
      q.append([i,j,0])
while 1:
  y,x,cnt=q.popleft()
  for i in range(4):
    if arr[y+dy[i]][x+dx[i]]=='.':
      q.append([y+dy[i],x+dx[i],cnt+1])
      arr[y+dy[i]][x+dx[i]]='#'
  if len(q)==0:
    print(cnt)
    break
w, h, n=map(int,input().split())

mat = [list(map(int, input().split())) for _ in range(n)]

w1 = 0
w2 = w
h1 = 0
h2 = h

for i in range(n):
    if(mat[i][2] == 1 and w1 < mat[i][0]):
        w1 = mat[i][0]
    elif(mat[i][2] == 2 and w2 > mat[i][0]):
        w2 = mat[i][0]
    elif(mat[i][2] == 3 and w3 < mat[i][1]):
        h1 = mat[i][1]
    elif(mat[i][2] == 4 and w4 > mat[i][1]):
        h2 = mat[i][1]
        
print((w2-w1)*(h2-h1) if w2 >= w1 and h2 >= h1 else 0)

### FIXED CODE ###

w, h, n=map(int,input().split())

mat = [list(map(int, input().split())) for _ in range(n)]

w1 = 0
w2 = w
h1 = 0
h2 = h

for i in range(n):
    if(mat[i][2] == 1 and w1 < mat[i][0]):
        w1 = mat[i][0]
    elif(mat[i][2] == 2 and w2 > mat[i][0]):
        w2 = mat[i][0]
    elif(mat[i][2] == 3 and h1 < mat[i][1]):
        h1 = mat[i][1]
    elif(mat[i][2] == 4 and h2 > mat[i][1]):
        h2 = mat[i][1]
        
print((w2-w1)*(h2-h1) if w2 >= w1 and h2 >= h1 else 0)
a, b = input()
a, b = int(a), int(b)
if b % a == 0:
  print(a+b)
else:
  print(b-a)

### FIXED CODE ###

a, b = input().split()
a, b = int(a), int(b)
if b % a == 0:
  print(a+b)
else:
  print(b-a)
N=int(input())
a=list(map(int,input().split()))
m=max(a)
mm=min(a)
p=[0]*(m-mm)

for i in range(mm,m-1):
  p[i]=a.count(i)+a.count(i+1)+a.count(i+2)
  
print(max(p))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)
x=[0]*(M-m+3)
for i in a:
  x[i-m]+=1
  x[i-m+1]+=1
  x[i-m+2]+=1
print(max(x))