Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

L.sort()
L.reverse()
#print(L)
count=0

for i in range(N-2):
  cond=0
  for j in range(i+1,N-1):
    if cond==1:
      break
    for k in range(j+1,N):
      if L[i]<L[j]+L[k]:
        if L[j]<L[i]+L[k]:
          if L[k]<L[i]+L[j]:
            count +=1
      else:
        cond=1
        break
            
print(count)
        


### FIXED CODE ###

import bisect

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

L.sort()
#print(L)
count=0

for i in reversed(range(2,N)):
  for j in reversed(range(1,i)):
    index=bisect.bisect_right(L,L[i]-L[j])
    #print(index,j,i)
    if index<j:
     count += j-index
            
print(count)
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
L = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]


def make_hash(a, b):
    a, b = min(a, b), max(a, b)
    return N*a+b


def un_hash(n):
    a = n//N
    b = n % N
    return a, b


from_to = defaultdict(lambda: set())
pointed = defaultdict(int)
pointing = defaultdict(int)

for i in range(N):
    for node_from, node_to in zip(L[i], L[i][1:]):
        #from_to[make_hash(i, node_to)].add(make_hash(i, node_from))
        from_to[make_hash(i, node_from)].add(make_hash(i, node_to))
        pointed[make_hash(i, node_to)] += 1
        pointing[make_hash(i, node_from)] += 1

START = set()
DST = set()
for i in range(N):
    for j in range(i+1, N):
        h = make_hash(i, j)
        pointed_i = pointed[h]
        pointing_i = pointing[h]
        if pointed_i == 0:
            START.add(h)
        if pointing_i == 0:
            DST.add(h)
if len(START) == 0 or len(DST) == 0:
    print(-1)

else:
    Q = [[v, 1] for v in START]
    visited = set()
    dist = 1
    while Q:
        tmp = []
        for n in Q:
            q = n[0]
            d = n[1]
            for nex in from_to[q]:
                tmp.append([nex, d+1])
                dist = d+1
                visited.add(nex)
        Q = tmp
    print(dist)


### FIXED CODE ###

from collections import deque

n = int(input())
matches = []
for _ in range(n):
    matches.append(list(map(lambda x: int(x)-1, input().split())))

q = deque(range(n))

days = [0]*n  # 各選手の現在の日付
pairs = [-1]*n  # 次の対戦相手を管理(wait的な)

while q:
    x = q.popleft()  # 試合する人
    if len(matches[x]) == 0:  # 試合が全て終わってる?
        continue
    y = matches[x].pop(0)  # xの次の対戦相手
    if pairs[y] == x:
        day = max(days[x], days[y])+1
        days[x] = day
        days[y] = day
        q.append(x)
        q.append(y)
    else:
        pairs[x] = y

if not any(matches):  # 全ての試合をしょうか
    print(max(days))
else:
    print(-1)
### BUGGY CODE ###

k,s=map(int,input().split())
count=0
for x in range(k+1):
    for y in range(k+1):
        for j in range(k+1):
            if x+y+j==s:
                count+=1
print(count)

### FIXED CODE ###

k,s=map(int,input().split())
count=0
for x in range(k+1):
    for y in range(x+1):
        if x+y>s:
            continue
        else:
            z=s-x-y
            if z>x or z>y:
              continue
            if x==y==z:
                count+=1
            elif x==y or y==z or z==x:
                count+=3
            else:
                count+=6
print(count)
### BUGGY CODE ###

import copy
n = int(input())
k = input().split()
for i in range(n):
    delk = k[i]
    del k[i]
    solk = copy.copy(k)
    solk.sort(reverse=False)
    ans = 0
    while len(solk)>1:
        cnt = 0
        while solk[0]==solk[1]:
            cnt += 1
            del solk[0]
            if len(solk)==1:
                break
        del solk[0]
        ans += cnt*(cnt+1)//2
    print(ans)
    k.insert(i,delk)

### FIXED CODE ###


import collections as c

n = int(input())

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

x = c.Counter(a)

cnt = {}

for k,v in x.items():
    cnt[k] = v*(v-1)//2
    
s = sum(cnt.values())
    
mcnt = {}

for k,v in x.items():
    mcnt[k] = cnt[k]-(v-2)*(v-1)//2
    
for i in a:
    print(s-mcnt[i])
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

AA = [a % p for a in A]
sum = 0
for i in range(0, N - 1):
  for j in range(i + 1, N):
    sum += (AA[i] * AA[j]) % p
print(sum % p)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

S = [A[0]] * N
for i in range(1, N):
  S[i] = S[i - 1] + A[i]

sum = 0
for i in range(0, N - 1):
	sum += (A[i] * (S[N - 1] - S[i])) % p
print(sum % p)
### BUGGY CODE ###

import math

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

for i in range(M):
    A.sort()
    A[-1] /= 2

print(sum(list(map(math.floor, A))))

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
neg_A = []
for a in A:
    neg_A.append(-a)
heapq.heapify(neg_A)

for i in range(M):
    n = heapq.heappop(neg_A)
    heapq.heappush(neg_A, -(-n//2))

print(sum(neg_A) * (-1))
### BUGGY CODE ###

import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
wv = [[0,0]]
for n in range(1,N+1):
    wv.append( list(map(int, input().split())))
    for w_lim in range(1,W+1):
        if w_lim - wv[n][0] >= 0 :
            dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
        else :
            dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])


### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])
### BUGGY CODE ###

from collections import deque
N, K = list(map(int, input().split()))

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

score = [0]*N
dq = []

for i in range(0, K):
    dq.append(A[i])
score_now = 1
for i in range(len(dq)):
    score_now *= dq[i]

for j in range(K-1, N-1):
    score[j] = score_now

    left = dq[0]
    del dq[0]
    score_now /= left
    dq.append(A[j+1])
    score_now *= A[j+1]
score[N-1] = score_now


for k in range(K, N):
    if score[k] > score[k-1]:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

N, K = list(map(int, input().split()))
K -= 1
A = list(map(int, input().split()))

index = 0
left = A[index]

for i in range(K+1, N):

    if A[index] < A[i]:
        print("Yes")
    else:
        print("No")

    index += 1
### BUGGY CODE ###

from math import floor

a,b,n = map(int, input().split())
mx = 0
for i in range(n+1):
  v = floor(a*i/b) - a*floor(i/b)
  if v < mx:
    break
  else:
    mx = v
print(mx)


### FIXED CODE ###

from math import floor

a,b,n = map(int, input().split())
i = min(n,b-1)
print(floor(a*i/b) - a*floor(i/b))
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

for row in range(N):
    row_value = values[row]
    max_value = max(value_count_map.keys())
    if row_value != max_value:
        print(max_value)
    elif value_count_map[row_value] != 1:
        print(max_value)
    else:
        # if row value is a unique max value
        value_count = value_count_map.pop(row_value)
        max_value = max(value_count_map.keys())
        print(max_value)
        value_count_map[row_value] = value_count




### FIXED CODE ###

# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

max_value = max(value_count_map.keys())
value_count = value_count_map.pop(max_value)
if value_count == 1:
    next_max_value = max(value_count_map.keys())
for row in range(N):
    if value_count > 1:
        print(max_value)
    elif values[row] == max_value:
        print(next_max_value)
    else:
        print(max_value)
### BUGGY CODE ###

n, m = (int(i) for i in input().split()) 
p, y = [], []
yd = [[] for i in range(n+1)]
for i in range(m):
  tmp = [int(i) for i in input().split()]
  p.append(tmp[0])
  y.append(tmp[1])
  yd[p[i]].append(y[i])
for i in range(n):
  yd[i+1].sort()
for i in range(m):
  l = str(p[i])
  r = str(yd[p[i]].index(y[i])+1)
  lzero = l.zfill(6)
  rzero = r.zfill(6)
  print(lzero + rzero)

### FIXED CODE ###

n, m = (int(i) for i in input().split()) 
py = [[int(i) for i in input().split()] for i in range(m)]
cnt = [0]*(n+1)
ids = {}
for p,y in sorted(py, key=lambda x: x[1]):
  cnt[p] += 1
  ids[y] = '%06d%06d' % (p, cnt[p])
for _, y in py:
  print(ids[y])
### BUGGY CODE ###

from collections import defaultdict
from queue import Queue

n, m = list(map(int, input().split()))
MX = int(1e6)
edge = defaultdict(set)
dist = [[MX, MX, MX] for i in range(n)]
reached = [[False, False, False] for i in range(n)]

for loop in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].add(b-1)

s, t = list(map(int, input().split()))
s = s-1
t = t-1
dist[s][0] = 0

q = Queue()
q.put((s, 0))
while not q.empty():
    node, step = q.get()
    next_step = (step + 1) % 3
    reached[node][step] = True
    for next_node in edge[node]:
        if not reached[next_node][next_step]: q.put((next_node, next_step))
        if step == 2:
            dist[next_node][next_step] = min(dist[next_node][next_step], dist[node][step] + 1)
        else:
            dist[next_node][next_step] = min(dist[next_node][next_step], dist[node][step])

if dist[t][0] == MX:
    print(-1)
else:
    print(dist[t][0])



### FIXED CODE ###

from collections import defaultdict
from queue import Queue

n, m = list(map(int, input().split()))
MX = int(1e6)
edge = defaultdict(set)
dist = [[MX, MX, MX] for i in range(n)]
reached = [[False, False, False] for i in range(n)]

for loop in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].add(b-1)

s, t = list(map(int, input().split()))
s = s-1
t = t-1
dist[s][0] = 0

q = Queue()
q.put((s, 0))
while not q.empty():
    node, step = q.get()
    next_step = (step + 1) % 3
    for next_node in edge[node]:
        if reached[next_node][next_step]: continue
        q.put((next_node, next_step))
        reached[next_node][next_step] = True
        if step == 2:
            dist[next_node][next_step] = min(dist[next_node][next_step], dist[node][step] + 1)
        else:
            dist[next_node][next_step] = min(dist[next_node][next_step], dist[node][step])

if dist[t][0] == MX:
    print(-1)
else:
    print(dist[t][0])
### BUGGY CODE ###

n,m = map(int, input().split())
d = m//n
if m==1000000000 and n==3:
    print(250000000)
    exit()

for i in range(0,d):
    if (m % (d-i) == 0):
        print(d-i)
        break

### FIXED CODE ###

n,m = map(int, input().split())
d = m//n
ans = []
for i in range(1,min(d+1,int(m**0.5)+1)):
    if (m % i == 0):
        ans.append(i)
        if (m//i<=d):
            ans.append(m//i)
print(max(ans))
### BUGGY CODE ###

A = [int(input()) for i in range(int(input()))]
max_A = max(A)
for i in A:
    if i == max_A:
        print(sorted(A)[-2])
    else:
        print(max_A)


### FIXED CODE ###

A = [int(input()) for i in range(int(input()))]
first = max(A)
second = sorted(A)[-2]
for i in A:
    if i == first:
        print(second)
    else:
        print(first)
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import connected_components
from collections import Counter
n,m = map(int,input().split())

l = np.array([[0]*n for _ in range(n)])

for i in range(m):
    a,b = map(int,input().split())
    l[a-1][b-1] = 1

x,labels= connected_components(l)
c = Counter(list(labels))
print(c.most_common()[0][1])

### FIXED CODE ###

from collections import defaultdict,deque
n,m = map(int,input().split())

d = defaultdict(list)

if m==0:
    print(1)
    exit()

visited = [-1] + [False]*n
for i in range(m):
    a,b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)
maxi = 1
for i in range(1,n+1):
    if visited[i]:
        continue
    cnt = 0
    que = deque([i])
    while que:
        v = que.pop()
        if not visited[v]:
            visited[v] = True
            cnt += 1
        for j in d[v]:
            if not visited[j]:
                que.append(j)
    maxi = max(maxi,cnt)
print(maxi)
### BUGGY CODE ###

N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K]*N

for i in range(Q):
    who_answered[i] = int(input()) - 1
    
for who in who_answered:
    for i in range(N):
        participants[i] -= 1
    participants[who] += 1

for i in range(N):
    if participants[i] > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K-Q]*N

for i in range(Q):
    who_answered[i] = int(input()) - 1
    participants[who_answered[i]] += 1

for i in range(N):
    if participants[i] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

charseq = raw_input()
start = -1
end = -1

for i in range(len(charseq)):
    for j in range(i+2, len(charseq)+1):
        part = charseq[i:j]
        chars = list(part)
        for char in chars:
            if chars.count(char) > (j-i)/2:
                start = i+1
                end = j
                break
        if not start == -1:
            break
    
print start, end 
    


### FIXED CODE ###

charseq = raw_input()
start = -1
end = -1

for i in range(len(charseq)-1):
    if charseq[i] == charseq[i+1]:
        start = i+1 
        end = i+2 
        break
if start == -1: 
    for i in range(len(charseq)-2):
        if charseq[i] == charseq[i+2]:
            start = i+1 
            end = i+3 
            break

print start, end
### BUGGY CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
for i in range(n):
    if min(p[:i+1]) == p[i]:
        ans += 1

print(ans)



### FIXED CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
min_ = 10**9
for i in range(n):
    if p[i] < min_:
        ans += 1
        min_ = p[i]

print(ans)
### BUGGY CODE ###

from collections import deque
n, m = map(int, input().split())
graph = [set([]) for _ in range(n+1)]
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].add(v)


graph3 = [set([]) for _ in range(n+1)]
for i, g in enumerate(graph):
    if i == 0:
        continue
        
    graph2 = set([])
    for r in g:
        graph2 |= graph[r]

    for r in graph2:
        graph3[i] |= graph[r]


s, t = map(int, input().split())
q = deque([s])
visited = [False] * (n+1)
visited[s] = True
dist = [-1] * (n+1)
dist[s] = 0
while q:
    now = q.popleft()
    for i in graph3[now]:
        if visited[i]:
            continue
        if i == now:
            continue
        q.append(i)
        visited[i] = True
        dist[i] = dist[now] + 1

print(dist[t])


### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
graph = [[[] for _ in range(3)] for _ in range(n+1)]
for _ in range(m):
    u, v = map(int, input().split())
    graph[u][0].append([v, 1])
    graph[u][1].append([v, 2])
    graph[u][2].append([v, 0])


s, t = map(int, input().split())
q = deque([[s, 0]])
visited = [[False] * 3 for _ in range(n+1)]
visited[s][0] = True
dist = [[-3] * 3 for _ in range(n+1)]
dist[s][0] = 0
while q:
    num, cnt = q.popleft()
    for i, j in graph[num][cnt]:
        if visited[i][j]:
            continue
        q.append([i, j])
        visited[i][j] = True
        dist[i][j] = dist[num][cnt] + 1

print(dist[t][0]//3)
### BUGGY CODE ###

import bisect

n = int(input())
s = list(map(int, input().split()))
a = [s[1]]
ans = s[2]
p = 0

for i in range(n-1):
    q = list(map(int,input().split()))
    if q[0]==1:
        ans += q[2]
        b = bisect.bisect_left(a, q[1])
        if len(a)%2==1:
            ans+=abs(a[p]-q[1])
            a=a[:b]+[q[1]]+a[b:]
        else:
            p+=1
            a=a[:b]+[q[1]]+a[b:]
            ans+=abs(a[p]-q[1])
    if q[0]==2:
        print(a[p], ans)

### FIXED CODE ###

import heapq

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

# 中央値より左・右の管理
l=[]
r=[]
heapq.heapify(l)
heapq.heapify(r)
lenl=0
lenr=0
# 中央値
x = s[1]

# b含めた答え
ans = s[2]

for i in range(n-1):
    q = list(map(int,input().split()))
    if q[0]==1:
        ans += q[2]
        if (lenl+lenr)%2==0:
            lenr+=1
            ans+=abs(x-q[1])
            if x<=q[1]:
                heapq.heappush(r,q[1])
            else:
                heapq.heappush(l,-q[1])
                heapq.heappush(r,x)
                x = -heapq.heappop(l)
        else:
            lenl+=1
            if x<q[1]:
                heapq.heappush(l,-x)
                heapq.heappush(r,q[1])
                x=heapq.heappop(r)
            else:
                heapq.heappush(l,-q[1])
            ans+=abs(x-q[1])
    if q[0]==2:
        print(x, ans)
### BUGGY CODE ###

N, K = map(int,input().split())
if K == 1 or N == 0 or N == K:
    print(0)
    exit()
elif K == 0:
    print(N)
    exit()
elif N == 1 or N == K-1 or K == N-1:
    print(1)
    exit()
else:
    l = []
    ans = N
    for i in range(max(N,K)):
        ans = abs(ans - K)
        l.append(ans)
        if i >= 10:
            if l[0] == l[2]:
                print(min(l))
                exit()
    print(min(l))

### FIXED CODE ###

N, K = map(int,input().split())
if K == 1 or N == 0 or N == K or N%K==0:
    print(0)
elif K == 0:
    print(N)
elif N == 1 or N == K-1 or K == N-1 or N%K==1:
    print(1)
elif N > K:
    res = abs(N - (K*(N//K)))
    if abs(res - K) < res:
        print(abs(res-K))
    else:
        print(res)
elif K > N:
    if abs(K-N) < N:
        print(abs(K-N))
    else:
        print(N)
### BUGGY CODE ###

from collections import defaultdict
d = defaultdict(list)
n = int(input())
l = sorted(list(map(int,input().split())))
for i,j in enumerate(l):
    d[j].append(i)

used = [0]*n
ans = 0
for i in range(n-1,-1,-1):
    if used[i]:
        continue
    x = 2**(l[i].bit_length())
    y = x-l[i]
    if y in d:
        for j in d[y]:
            if used[j] == 0 and j != i:
                used[j] = 1
                ans += 1
                used[i] = 1
                break
print(ans)

### FIXED CODE ###

from collections import defaultdict
d = defaultdict(int)
n = int(input())
l = sorted(list(map(int,input().split())))
for i in l:
    d[i] += 1

ans = 0
for i in range(n-1,-1,-1):
    if d[l[i]] == 0:
        continue
    x = 2**(l[i].bit_length())
    y = x-l[i]
    if y == l[i]:
        if d[y] >= 2:
            d[y] -= 2
            ans += 1
    else:
        if d[y] > 0:
            d[y] -= 1
            d[l[i]] -= 1
            ans += 1
            
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
count = A[0]
for i,v in enumerate(A):
    if i != 0:
        count = count * v
if 10 ** 18 < count:
    count = -1
print(count)


### FIXED CODE ###

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

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

count = 1
for i in A:
    count *= i
    if 10 ** 18 < count:
        break

if 10 ** 18 < count:
    count = -1

print(count)
### BUGGY CODE ###

def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = round(tasu(p[i]) / p[i] , 6)

    for i in range(n - k + 1):

        count = sum(kitai[i:i+k]) % mod
 #       for w in range(i , i + k):
#            count += kitai[w]
#            count += tasu(p[w]) / p[w]
        ans = max(ans , count)

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(n , k , p))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    kitaisum = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n):
        if i == 0:
            kitaisum[i] += kitai[i]
        else:
            kitaisum[i] += kitai[i] + kitaisum[i-1]

    for i in range(n - k + 1):

        ans = max(ans , (kitaisum[i + k - 1] - kitaisum[i-1]) if i != 0 else kitaisum[i + k - 1])

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(n , k , p))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

for i in range(n):
    if i%2: b.insert(0, a[i])
    else: b.append(a[i])
print(" ".join(map(str, b[::(-1)**(n%2)])))

### FIXED CODE ###

def main():
    n = int(input())
    a = input().split()
    if n%2: ans = a[n-1::-2] + a[1:n-1:2]
    else: ans = a[n-1:0:-2] + a[0:n-1:2]
    print(" ".join(ans))
if __name__=="__main__": main()
### BUGGY CODE ###

from collections import deque


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

    q = deque()

    arrived = [[True] * (w + 2)] + \
              [[True] + [False] * w + [True] for _ in range(h)] + \
              [[True] * (w + 2)]

    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                q.append([i+1, j+1])
                arrived[i+1][j+1] = True

    ans = 0
    while q:
        ans += 1
        pop_max = len(q)
        cnt = 0
        while cnt != pop_max:
            i, j = q.popleft()
            if not arrived[i-1][j]:
                arrived[i-1][j] = True
                q.append([i-1, j])

            if not arrived[i + 1][j]:
                arrived[i + 1][j] = True
                q.append([i + 1, j])

            if not arrived[i][j - 1]:
                arrived[i][j - 1] = True
                q.append([i, j - 1])

            if not arrived[i][j + 1]:
                arrived[i][j + 1] = True
                q.append([i, j + 1])

            cnt += 1

    ans -= 1
    print(ans)


def main():
    solve()


if __name__ == "__main__":
    main()


### FIXED CODE ###

from scipy.ndimage import distance_transform_cdt


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

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

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

    print(cnt.max())


if __name__ == "__main__":
    main()