Harryxun/stf_run huggingface dataset:
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        # print(ope)
        ps = [(0, 0)]
        tmp_board = copy.deepcopy(board)
        for color in itertools.chain(ope, (C - 1,)):
            now_c = tmp_board[0][0]
            if now_c == color:
                continue

            for r, c in ps:
                tmp_board[r][c] = color
            stack = ps[:]
            while stack:
                r, c = stack.pop()
                for dr, dc in drc:
                    nr, nc = r + dr, c + dc
                    if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
                        tmp_board[nr][nc] = color
                        stack.append((nr, nc))
                        ps.append((nr, nc))
        for r, c in ps:
            tmp_board[r][c] = -1
        stack = ps[:]
        while stack:
            r, c = stack.pop()
            for dr, dc in drc:
                nr, nc = r + dr, c + dc
                if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == C - 1:
                    tmp_board[nr][nc] = -1
                    stack.append((nr, nc))
        ans = max(ans, sum(row.count(-1) for row in tmp_board))
    print(ans)

### FIXED CODE ###

import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6


def dfs(r, c, now_c, next_c):
    tmp_board[r][c] = next_c
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
            dfs(nr, nc, now_c, next_c)


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        if ope[0] == board[0][0] or ope[-1] == C - 1 or any(ope[i] == ope[i + 1] for i in range(3)):
            continue
        tmp_board = copy.deepcopy(board)
        for color in ope:
            dfs(0, 0, tmp_board[0][0], color)
        dfs(0, 0, tmp_board[0][0], C - 1)
        dfs(0, 0, tmp_board[0][0], -1)
        cand = sum(row.count(-1) for row in tmp_board)
        if cand > ans:
            ans = cand
    print(ans)
import collections as col
N=int(input())
counts=[]
A=[]
S=[]
T=[]
U=[]
for _ in range(N):
    S.append(input())
T=sorted(S)
s=col.Counter(T)
values, counts = zip(*s.most_common())

print(values[0])
t=1

while t<=len(values) and counts[t]==counts[t-1]:
    print(values[t])
    t+=1

 

### FIXED CODE ###

N=int(input())
S=[input() for _ in range(N)]

S_d={}
A=[]

for i in range(N):
    if S[i] not in S_d.keys():
        S_d[S[i]]=1
    else:
        S_d[S[i]]+=1

max_co=max(S_d.values())

for j in S_d.keys():
    if S_d[j]==max_co:
        A.append(j)

B=sorted(A)

for k in B:
    print(k)
n = input()
n = int(n)
list = []

i = 0
while(i<n):
	x = input()
	list[i] = x
	i = i + 1

maxv = -20000000
minv = list[0]
i = 1
while(i<n):
	maxv = max(maxv, list[i]-minv)
	minv = min(minv, list[i])
	i = i + 1

print(maxv)


### FIXED CODE ###

n = input()
n = int(n)
list = []

i = 0
while(i<n):
	x = input()
	x = int(x)
	list.append(x)
	i = i + 1

maxv = -2000000000
minv = list[0]
i = 1
while(i<n):
        maxv = max(maxv, list[i]-minv)
        minv = min(minv, list[i])
        i = i + 1
	
print(maxv)
import math
##(A,B,C,D)=map(int,input().split())

N=int(input())
##c=list(map(int, input().split()))

a=[]
b=[]


for i in range(N):
    a.append(int(input()))
    b.append(int(input()))
k=float(0)
for i in range(N-1):
    for j in range(i,N):
        k=k+float(((a[i]-a[j])**2+(b[i]+b[j])**2)**0.5)

k=float(k*2/N)
print(k)




### FIXED CODE ###

N=int(input())
##c=list(map(int, input().split()))

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

k=0
for i in range(N):
    for j in range(N):
        if(i!=j):
            k=k+((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))**0.5

print(k/N)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.reverse()
B.reverse()

ans = 0
total_time = 0
while A or B:
    if not A:
        t = B.pop()
    elif not B:
        t = A.pop()
    else:
        if A[-1] < B[-1]:
            t = A.pop()
        elif B[-1] < A[-1]:
            t = B.pop()
        else:
            if A[-2] < B[-2]:
                t = A.pop()
            else:
                t = B.pop()
    total_time += t
    if total_time <= K:
        ans += 1
    else:
        break
print(ans)

### FIXED CODE ###

import bisect
N, M, K = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

Asums = [0] * (N + 1)
for i, a in enumerate(A):
    Asums[i+1] = Asums[i] + a

Bsums = [0] * (M + 1)
for i, b in enumerate(B):
    Bsums[i+1] = Bsums[i] + b

ans = 0
for anum in range(N + 1):
    t = Asums[anum]
    if K < t:
        break
    bnum = bisect.bisect_right(Bsums, K - t) - 1
    ans = max(ans, anum + bnum)
print(ans)
A = int(input())
B = int(input())
print(A*B)

### FIXED CODE ###

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

print(A*B)
N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
maxi=max(a)
mini=min(a)
num=[0]*100000000
maxi=max(a)
for i in range(N):
  w.append(1+i+a[i])
  s.append(1+i-a[i])
  num[1+i+a[i]]+=1
for i in range(N):
  count+=num[s[i]]
print(count)

### FIXED CODE ###

N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(1+i-a[i])
  if 1+i+a[i]<N:
    num[1+i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)
import sys
import numpy as np

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))
array = np.array(list_input)

a = array.prod()

if a > pow(10, 18):
    print(-1)
else:
    print(a)

### FIXED CODE ###

import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

if 0 in list_input:
    print(0)
    exit()

a = 1
for i in list_input:
    a *= i
    if a > pow(10, 18):
        break


if a > pow(10, 18):
    print(-1)
else:
    print(a)
import sys

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

s= [0]*(M-1)
for i in range(M-1):
    s[i] = X[i+1] - X[i]
s.sort(reverse=True)
res = sum(s)
if M == 1:
    res = 0
else:
    for i in range(N-1):
        res -= s[i]
print(res)

### FIXED CODE ###

import sys

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

if N >= M:
    print(0)
    sys.exit()
    
s= [0]*(M-1)
for i in range(M-1):
    s[i] = X[i+1] - X[i]
s.sort(reverse=True)
res = sum(s)
if M == 1:
    res = 0
else:
    for i in range(N-1):
        res -= s[i]
print(res)
def mx(i):
    if i == 0: return 0
    else     : return (i+1)*i + mx(i-1)

def cns(ls,m,sm):
    global n, s
    count = 0
    if m == n:
        if sm == s: return 1
        else      : return 0
    elif s-mx(n-m+1)-5 <= sm <= s:
        for i in range(9-m+1):
            rls = ls[:]
            k = rls.pop(i)
            count += cns(rls,m+1,sm+(m+1)*k)
        return count
    else: return 0

ls = [0,1,2,3,4,5,6,7,8,9]
while True:
    n, s = map(int, raw_input().split())
    if s > mx(n): print 0
    else        : print cns(ls,0,0)

### FIXED CODE ###

def mxmn(ls,m):
	global n
	s1,s2 = 0, 0
	for i in range(m):
		s1 += (n-i)*ls[-i-1]
		s2 += (n-i)*ls[i]
	return s1,s2

def f(ls,m,s):
	global n
	count = 0
	if m > 0:
		mx,mn = mxmn(ls,m)
		if mx < s or mn > s: return 0
		elif mx == s or mn == s: return 1
		for i in range(len(ls)):
			lls = ls[:]
			a = (n-m+1)*lls.pop(i)
			if s-a < 0:	break
			else: count += f(lls,m-1,s-a)
		return count
	else:
		return 1 if s == 0 else 0
			
ls = [i for i in range(10)]
while True:
	try:
		n,s = map(int, raw_input().split())
		print f(ls,n,s)
	except:
		break
#a,b=map(int,input().split())
a=map(int,input())
if a<2800:
	print("ABC")
else:
	print("ARC")

### FIXED CODE ###

a=int(input())
if a<1200:
	print("ABC")
elif a<2800:
	print("ARC")
else:
	print("AGC")
class UnionFind:
    def __init__(self,N):
        self.par = [i for i in range(N)]

    def root(self,x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        if self.rx == self.ry:
            return
        self.par[self.rx] = self.ry

    def same(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        return self.rx == self.ry

N,M = [int(i) for i in input().split()]
uf = UnionFind(N)

for _ in range(M):
    x,y,_ = [int(i)-1 for i in input().split()]
    uf.unite(x,y)

ans = set()
for i in range(N):
    ans.add(uf.root(i))

print(len(ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

class UnionFind:
    def __init__(self,N):
        self.par = [i for i in range(N)]

    def root(self,x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        if self.rx == self.ry:
            return
        self.par[self.rx] = self.ry

    def same(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        return self.rx == self.ry

N,M = [int(i) for i in input().split()]
uf = UnionFind(N)

for _ in range(M):
    x,y,_ = [int(i)-1 for i in input().split()]
    uf.unite(x,y)

ans = set()
for i in range(N):
    ans.add(uf.root(i))
print(len(ans))
#coding:utf-8
x=input()
x=x**3
print(x) 

### FIXED CODE ###

import sys

x = int( sys.stdin.readline() )
print( "{}".format( x**3 ) )
a = int(input())
b = [int(input()) for _ in range(a)]
b = sorted(b, key=lambda, x: x[0], reverse=True)
c = 0
for i in range(a):
  if i == 0:
    c += b[i] // 2
  else:
    c += b[i]
print(c)


### FIXED CODE ###

a = int(input())
b = [int(input()) for _ in range(a)]
b = sorted(b, reverse=True)
c  = 0
for i in range(a):
    if i == 0:
        c += b[i] // 2
    else:
        c += b[i]
print(c)
n,a,b = map(int,input().split())
mod=10**9+7

def sig(n):
    #return 2**n
    if n==1:
        return 2
    elif n%2==0:
        return (sig(n//2)**2)%mod
    else:
        return (2*sig((n-1)//2)**2)%mod
    
s = sig(n) - 1

MAX = 10**5*3

facts = [1 for i in range(n)]
invs = [1 for i in range(n)]

def inv(x):
	return pow(x,mod-2,mod)
 
for i in range(1,MAX):
		facts[i] = (facts[i-1] * i)% mod
		invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n]*invs[r] * invs[n-r] % mod

x = nCr(n,a)%mod
y = nCr(n,b)%mod

if s-(x+y) < 0:
    print(s-(x+y)+mod)
else:
    print(s-(x+y)%mod)

### FIXED CODE ###

n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1

comb1 = 1
for i in range(n-a+1, n+1):
    comb1 *= i
    comb1 %=  mod
for i in range(1, a+1):
    comb1 *= pow(i, mod-2, mod)
    comb1 %=  mod

comb2 = 1
for i in range(n-b+1, n+1):
    comb2 *= i
    comb2 %=  mod
for i in range(1, b+1):
    comb2 *= pow(i, mod-2, mod)
    comb2 %=  mod
ans -= (comb1 + comb2)
print(ans % mod)
n = int(input())
a = [int(input()) for i in range(n)]
if 0 in a:
  total = 0
else:
  total=1
  for i in a:
    total *= i
    if total > 10**8:
      total = -1
      break
print(total)


### FIXED CODE ###

n = int(input())
cnt = 1
l = list(map(int, input().split()))
if 0 in l:
    print(0)
else:
    for i in l:
        cnt *= i
        if cnt > 10 ** 18:
            print(-1)
            exit()
        else:
            pass
    print(cnt)
hthth

### FIXED CODE ###

w = list(input())
w_set = set(w)
for s in w_set:
    count_2 = w.count(s)
    if count_2 % 2 == 0:
        result = "Yes"
    else:
        result = "No"
        break
print(result)
import math
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
  print(cmb(k-1,i-1)*cmb(n-k+1,i)%mod)

### FIXED CODE ###

import math
from operator import mul
from functools import reduce

def cmb(n,r):
  if n>=r:
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return max(0,over//under)
  else:
    return 0

n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
  print(cmb(k-1,i-1)*cmb(n-k+1,i)%mod)
N,K,L=map(int,input().split())
PQ=[list(map(int,input().split())) for i in range(K)]
RS=[list(map(int,input().split())) for i in range(L)]

def find_root(root,x):
    y = root[x]
    if x == y:
        return x
    z = find_root(root,y)
    root[x] = z
    return z
 
def merge(root,size,x,y):
    x = find_root(root,x)
    y = find_root(root,y)
    if x == y:
        return
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    size[x] += sy
    
def UF_make(graph,n):
    Root=list(range(n+1))
    Size=[1] * (n+1)
    for i in range(len(graph)):
        merge(Root,Size,graph[i][0],graph[i][1])
    for i in range(n+1):
        Root[i] = find_root(Root,i)
    Root.pop(0)  #
    return Root

PQN=UF_make(PQ,N)
RSN=UF_make(RS,N)
PQRS=[[PQN[i]*10**6+RSN[i],i,0] for i in range(N)]
PQRS.sort()

p=0
while p<N:
    i=1
    c=0
    if p+i>=N-1:
        break
    while PQRS[p][0]==PQRS[p+i][0]:
        c+=1
        i+=1
    for j in range(p,p+i):
        PQRS[j][2]=c
    p+=i

PQRS.sort(key=lambda x:x[1])
for i in range(N):
    print(PQRS[i][2]+1,end=' ')

### FIXED CODE ###

N,K,L=map(int,input().split())
PQ=[list(map(int,input().split())) for i in range(K)]
RS=[list(map(int,input().split())) for i in range(L)]

def find_root(root,x):
    y = root[x]
    if x == y:
        return x
    z = find_root(root,y)
    root[x] = z
    return z
 
def merge(root,size,x,y):
    x = find_root(root,x)
    y = find_root(root,y)
    if x == y:
        return
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    size[x] += sy
    
def UF_make(graph,n):
    Root=list(range(n+1))
    Size=[1] * (n+1)
    for i in range(len(graph)):
        merge(Root,Size,graph[i][0],graph[i][1])
    for i in range(n+1):
        Root[i] = find_root(Root,i)
    Root.pop(0)  #
    return Root

PQN=UF_make(PQ,N)
RSN=UF_make(RS,N)
PQRS=[PQN[i]*10**6+RSN[i] for i in range(N)]
D=len(set(PQRS))
PQRS=[[PQRS[i],i,0] for i in range(N)]
PQRS.sort()

p=0
while p<N:
    i=1
    c=0
    if p+i>N-1:
        break
    while PQRS[p][0]==PQRS[p+i][0]:
        c+=1
        i+=1
        if p+i>N-1:
            break
    for j in range(p,p+i):
        PQRS[j][2]=c
    p+=i
PQRS.sort(key=lambda x:x[1])
for i in range(N):
    print(PQRS[i][2]+1,end=' ')
import math
a, b, h, m = map(int, input().split())
hrad = h * 30 + m * 0.5
mrad = m * 6
rad = hrad - mrad
if rad < 0:
    rad = -rad
else:
    if rad > 180:
        rad = 360 - rad
    else:
        pass
c = float((a**2 + b**2 - 2 * a * b * math.cos(math.radians(rad))) ** (0.5))
print(c)


### FIXED CODE ###

n = input()
slist = list(n)
number = int(slist[len(slist) - 1])

if number == 3:
  print('bon')
elif number == 0 or number == 1 or number == 6 or number == 8:
  print('pon')
else:
  print('hon')
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)


def popcount(n):
    return bin(n).count("1")

cache = [-1] * (2 * 10 ** 5 + 1)


def f(n):
    if cache[n] != -1:
        return cache[n]
    if n == 0:
        return 0
    t = n % popcount(n)
    if t == 0:
        cache[n] = 1
    else:
        cache[n] = f(t) + 1
    return cache[n]

def g(n, m):
    if n < 60:
        return (1 << n) % m
    else:
        t = n // 2
        return g(t, m) * g(n - t, m) % m


N = int(input())
X = input()

c = X.count('1')
t1 = [0] * N
t2 = [0] * N
for i in range(N):
    n = N - 1 - i
    t1[i] = g(n, c - 1)
    t2[i] = g(n, c + 1)

x1, x2 = 0, 0
for i in range(N):
    if X[i] == '1':
        x1 += t1[i]
        x2 += t2[i]

result = []
for i in range(N):
    if X[i] == '1':
        n = x1 - t1[i]
        n %= c - 1
    elif X[i] == '0':
        n = x2 + t2[i]
        n %= c + 1
    result.append(f(n) + 1)
print(*result, sep='\n')


### FIXED CODE ###

def popcount(n):
    return bin(n).count("1")


def f(n):
    if n == 0:
        return 0
    return 1 + f(n % popcount(n))


N = int(input())
X = input()

c = X.count('1')
t1 = [0] * N
t1[0] = 1 % (c + 1)
for i in range(1, N):
    t1[i] = (t1[i - 1] << 1) % (c + 1)
x1 = 0
for i in range(N):
    if X[i] == '0':
        continue
    x1 += t1[N - 1 - i]

if c - 1 != 0:
    t2 = [0] * N
    t2[0] = 1 % (c - 1)
    for i in range(1, N):
        t2[i] = (t2[i - 1] << 1) % (c - 1)
    x2 = 0
    for i in range(N):
        if X[i] == '0':
            continue
        x2 += t2[N - 1 - i]

result = []
for i in range(N):
    if X[i] == '0':
        n = (x1 + t1[N - 1 - i]) % (c + 1)
    elif X[i] == '1':
        if c - 1 == 0:
            result.append(0)
            continue
        n = (x2 - t2[N - 1 - i]) % (c - 1)
    result.append(1 + f(n))
print(*result, sep='\n')
# ABC042B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)
def main():
    N, L, A = map(int, open(0).read().split())
    A.sort()
    print("".join(map(str, A)))


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC042B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)
n, l = list(map(int, input().rstrip().split()))
lst = sorted([input().rstrip() for _ in range(n)])
for i in lst:
    print(i, end="")
a = int(input())

if (a/10 == 9 || a%10 == 9):
    print("yes")
else:
    print("No")

### FIXED CODE ###

a = int(input())
 
if (a//10 == 9 or a%10 == 9):
    print("Yes")
else:
    print("No")
m = map(int,raw_input().split())
for i in range(len(m)):
 if(m[i]==0):
  break
 print"Case %s* %s",%((i+1),m[i])

### FIXED CODE ###

i=0

while True:
    a = int(input())
    if(a==0):
      break
    i = i+1
    print "Case %d: %d" %  (i,a)
a, b = map(int,input().split())
[a,b] = [a,b].sort()
if a == 1:
    if b==1:
        print(b)
    else:
        print(b-2)
else:
    print((a-2) * (b-2))

### FIXED CODE ###

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

print(a[0]+b[1]+c[2])
n=int(input())
x=list(map(int,input().split()))
f=False
for i in range(n):
  if x[i]%2==0:
    if x%3==0 or x%5==0:
      pass
    else:
      f=True
      break
      
if f==False:
  print('APPROVED")
else:
        print('DENIED')


### FIXED CODE ###

n=int(input())
x=list(map(int,input().split()))
f=False
for i in range(n):
  if x[i]%2==0:
    if x[i]%3==0 or x[i]%5==0:
      pass
    else:
      f=True
      break
      
if f==False:
  
  print('APPROVED')
else:
        print('DENIED')
S = input().strip()
x = sum(c == '0' for c in S)
y = len(n) - x
print(2 * min(x, y))

### FIXED CODE ###

S = input().strip()
x = sum(c == '0' for c in S)
y = len(S) - x
print(2 * min(x, y))
import numpy as sp
xy = sp.reshape(sp.array(list(map(int, xy.split()))), (n, 2))
x = xy[:, 0]
y = xy[:, 1]
Min = sp.inf
for x1 in range(n-1):
    for x2 in range(x1+1, n):
        minx = min(x[x1], x[x2])
        maxx = max(x[x1], x[x2])
        for y1 in range(n-1):
            for y2 in range(y1+1, n):
                count = 0
                for i in range(n):
                    if minx <= x[i] <= maxx and min(y[y1], y[y2]) <= y[i] <= max(y[y1], y[y2]):
                        count += 1
                if count == k:
                    Min = min(Min, abs((x[x1]-x[x2])*(y[y1]-y[y2])))
print(Min)


### FIXED CODE ###

n,k=map(int,input().split())
x,y=[[0,0] for i in range(n)],[[0,0] for i in range(n)]
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    x_sub,y_sub=xy[i]
    x[i][0]=x_sub
    x[i][1]=i
    y[i][0]=y_sub
    y[i][1]=i
x.sort()
y.sort()
ans=(10**18)*5
for i1 in range(n):
    for l1 in range(n-i1,1,-1):
        for i2 in range(n):
            for l2 in range(n-i2,1,-1):
                x_sub1=x[i1][0]
                x_sub2=x[i1+l1-1][0]
                y_sub1=y[i2][0]
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                        z[i]=1
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
                else:
                    break
print(ans)
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
print(a+e+i)

### FIXED CODE ###

a=input()
b=input()
c=input()
print(a[0]+b[1]+c[2])
n,m,k = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

sum = 0
ans = 0


while sum < k:
    if k < a[0] and k < b[0] :
        break
    if len(a) == 0 and len(b) == 0:
        break
    elif len(a) == 0 :
        sum = sum + b.pop(0)
        ans += 1
    elif len(b) == 0:
        sum = sum + a.pop(0)
        ans += 1
    elif a[0] < b[0]:
        sum = sum + a.pop(0)
        ans += 1
    elif b[0] < a[0] :
        sum = sum + b.pop(0)
        ans += 1
if sum > k:
    ans -= 1

print(ans)

### FIXED CODE ###

import bisect

def cumsum(a):
   r = [0]
   for v in a:
      r.append(r[-1] + v)
   return r

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

# 累積和をとる
a_cumsum = cumsum(a)
b_cumsum = cumsum(b)

ans = 0

# a_numはindex、vの部分aの値（中味）
for a_num, v in enumerate(a_cumsum):
    tmp = 0
    if k >= v:
        b_num = bisect.bisect_right(b_cumsum, k-v) -1
        # -1は「0」先頭に入れてるからね
        tmp = a_num + b_num
    ans = max(ans,tmp)

print(ans)
h, w = map(int, input().split())
L = ['.'*(w+1)]
for i in range(h):
  L.append('.'+input()+'.')
L.append('.'*(w+1))  

out = 1
for i in range(1, h+1):
  for j in range(1, h+1):
    if L[i][j] == '#':
      if L[i][j+1] == '#' or L[i][j-1] == '#' or L[i-1][j] == '#' or L[i+1][j] == '#':
        out *= 1
      else:
        out *= 0

if out == 1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

h, w = map(int, input().split())
L = ['.'*(w+1)]
for i in range(h):
  L.append('.'+input()+'.')
L.append('.'*(w+1))  

out = 1
for i in range(1, h+1):
  for j in range(1, w+1):
    if L[i][j] == '#':
      if L[i][j+1] == '#' or L[i][j-1] == '#' or L[i-1][j] == '#' or L[i+1][j] == '#':
        out *= 1
      else:
        out *= 0

if out == 1:
  print('Yes')
else:
  print('No')
n,w = map(int,input().split())
lis = []
s = [str(input()) for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      lis.append([i,j])
ans = 0
for i in range(h):
  for j in range(w):
    num = 10 ** 7
    for x,y in lis:
      num = min(num,abs(i-x)+abs(j-y))
    ans = max(ans,num)
print(ans)
      

### FIXED CODE ###

import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]

  black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])

  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not M[bi - 1][bj]:
        M[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not M[bi][bj - 1]:
        M[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not M[bi + 1][bj]:
        M[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not M[bi][bj + 1]:
        M[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()