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

import sys
from math import sqrt

def solve(a: list):
    length = len(a)
    if length <= 3:
        return min(sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in zip(a, a[1:]))

    med = length//2
    x_l, x_r = a[:med], a[med:]
    delta = min(solve(x_l), solve(x_r))
    median_x = a[med][0]
    m_a = []
        
    for p in x_l[::-1]:
        if p[0] < median_x-delta:
            break
        m_a.append(p)
    m_a.reverse()
    for p in x_r:
        if p[0] > median_x+delta:
            break
        m_a.append(p)

    for i, (x1, y1) in enumerate(m_a):
        to_y = y1 + delta
        for j, (x2, y2) in enumerate(m_a[i+1:]):
            if y2 > to_y:
                break
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = sorted([tuple(map(float, l.split())) for l in sys.stdin.readlines()])
    print("{:.10f}".format(solve(a)))


### FIXED CODE ###

import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt

def solve(a: list, sorted_axis: int = -1):
    length = len(a)
    if length <= 3:
        return sqrt(min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2)))

    x_set_len = len(set(x for x, _ in a))
    axis1 = 0 if x_set_len > length/2 else 1

    if sorted_axis != axis1:
        a.sort(key=itemgetter(axis1))

    mid_index = length//2
    left, right = a[:mid_index], a[mid_index:]
    delta = min(solve(left, axis1), solve(right, axis1))

    axis2 = not axis1
    median = a[mid_index][axis1]
    mid_a = sorted([p for _iter in (
        (takewhile(lambda p: median-delta < p[axis1], left[::-1])),
        (takewhile(lambda p: p[axis1] < median+delta, right))
    ) for p in _iter], key=itemgetter(axis2))

    for i, (x1, y1) in enumerate(mid_a):
        ub = (x1 if axis1 else y1) + delta
        for x2, y2 in takewhile(lambda p: p[axis2] < ub, mid_a[i+1:]):
            delta = min(delta, sqrt((x1-x2)**2+(y1-y2)**2))

    return delta

if __name__ == "__main__":
    N = int(input())
    a = [tuple(map(float, l.split())) for l in sys.stdin.readlines()]
    print("{:.10f}".format(solve(a)))
### BUGGY CODE ###

import itertools
n = int(input())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
l = []
for it in itertools.combinations_with_replacement(divisor(n),2):
    if it[0] * it[1] == n:
        l.append(it[0] + it[1] -2)
print(sorted(l)[0])

### FIXED CODE ###

import itertools
n = int(input())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
d = divisor(n)
l = float('inf')
for i in range(len(d)):
    l = min(n // d[i] + d[i] - 2,l)
print(l)
### BUGGY CODE ###

# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array(lr() + [0])
# ある回数から先は全ての電球にNを足す
for _ in range(min(K, 10 ** 3)):
    next = np.array([0] * (N+1))
    for i in range(N):
        x = A[i]
        next[max(0, i-x)] += 1
        next[min(N-1, i+x)+1] -= 1
    A = next.cumsum()

print(*A[:-1])

### FIXED CODE ###

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr() + [0]
# ある回数から先は全ての電球にNを足す
for _ in range(min(K, 41)):
    next = [0] * (N+1)
    for i in range(N):
        x = A[i]
        next[max(0, i-x)] += 1
        next[min(N-1, i+x)+1] -= 1
    for i in range(N):
        next[i+1] += next[i]
    A = next.copy()

print(*A[:-1])
### BUGGY CODE ###

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

Ans = 0
for i in range(N):
    xorA = A[i]
    orA = A[i]
    plusA = A[i]
    for j in range(i+1,N):
        if xorA ^ A[j] == plusA + A[j]:
            Ans += 1
        if orA & A[j] > 0:
            break
        xorA ^= A[j]
        plusA += A[j]
        orA |= A[j]

print(Ans+N)


### FIXED CODE ###

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

Ans = 0
j,xorA = 0,0
for i in range(N):
    while j < N and xorA&A[j] == 0:
        xorA |= A[j]
        j += 1
    Ans += j-i
    xorA ^= A[i]

print(Ans)
### BUGGY CODE ###

import random
import numpy as np

def is_prime(q,k=50):
    if q == 2: return 1
    if q < 2 or q&1 == 0: return 0

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return 0
    return 1
  
chk = np.array([0]*10**5)
for i in range(10**5):
  chk[i] = is_prime(i+1,10)
  
ans = np.array([0]*10**5)
for i in range(2,10**5):
  ans[i] = chk[i]&chk[(i+1)//2]
np.cumsum(ans,out=ans)

q = int(input())
for i in range(q):
  l,s = map(int,input().split())
  print(ans[s-1]-ans[max(0,l-2)])

### FIXED CODE ###

import random
import numpy as np

def is_prime(q,k=50):
    # q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return 1
    if q < 2 or q&1 == 0: return 0

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return 0
    return 1
  
chk = np.array([0]*10**5)
for i in range(10**5):
  chk[i] = is_prime(i+1,15)
  
ans = np.array([0]*10**5)
for i in range(2,10**5):
  ans[i] = chk[i]&chk[(i+1)//2]
np.cumsum(ans,out=ans)

import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
  l,s = map(int,input().split())
  print(ans[s-1]-ans[max(0,l-2)])
### BUGGY CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(20000000)
N, K = map(int, input().split())
heights = [int(h) for h in input().split()]


@lru_cache(None)
def dfs(i):
    if i == len(heights) - 1:
        return 0
    res = float("inf")
    for k in range(1, K + 1):
        if i + k < len(heights):
            res = min(res, abs(heights[i] - heights[i + k]) + dfs(i + k))
    return res


def helper():
    dp = [float("inf")] * len(heights)
    dp[0] = 0
    for i in range(1, len(heights)):
        dp[i] = min(dp[i],
                    min(dp[j] + abs(heights[j] - heights[i]) for j in range(max(i - K, 0), i))
                    )

    return dp[-1]


# print(dfs(0))
print(helper())

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
 
def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0
 
    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]
 
 
print(frog(n, k, h))
### BUGGY CODE ###

n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(m)] 
e = [list(range(i[0],i[1]+1)) for i in e]

x = set(e[0])
for i in e:
  x = x & set(i)
  
print(len(list(x)))

### FIXED CODE ###

n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(m)] 

start, end = e[0][0], e[0][1]
for i in e: 
  if start < i[0]:
    start = i[0]
  if end > i[1]:
    end = i[1]
  if start > end:
    break

if start > end:
  print(0)
else:
  print(end-start+1)
### BUGGY CODE ###

N, M = map(int, input().split())
numList=[[0]*2 for i in range(N)]


for i in range(N):
    A,B= map(int, input().split())
    numList[i][0]=A
    numList[i][1]=B

numList =  sorted(numList, key=lambda x: (x[1]),reverse=True)
numList =  sorted(numList, key=lambda x: (x[0]))

sum=0
count=0
k=0
t=-1
while True:
    if(k>=M):break
    k+=1
    for i in range(N):
        if(numList[i][0]<=k):
            if(count<numList[i][1]):
                count=numList[i][1]
                t=i
        else:
            sum+=count
            count=0
            if(t!=-1):
                numList[t][1]=0
                t=-1
            break
    else:
        sum+=count
        count=0
        if(t!=-1):
            numList[t][1]=0
            t=-1
print(sum)

### FIXED CODE ###

import heapq
N,M = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
AB.sort(key=lambda x:x[0])
index = 0
Works = []
ans = 0

for d in range(1,M+1):#d日後までの支払いのうち一番高いやつ
    while 1:
        if index>=N:break
        if AB[index][0]<=d:
            heapq.heappush(Works,-AB[index][1])
            index += 1
        else:
            break
    if Works:
        ans -= heapq.heappop(Works)
print(ans)
### BUGGY CODE ###

from collections import Counter
n = int(input())
l = []
check = []
count = 0
for i in range(n):
    a = list(input())
    b = Counter(a)
    b = sorted(b.items())
    if b in l:
        index = l.index(b)
        count += check[index]
        check[index] += 1
    else:
        l.append(b)
        check.append(1)


print(count)

### FIXED CODE ###

n = int(input())
dic = {}
for i in range(n):
    s = "".join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans = 0
for i in dic.values():
    if i > 1:
        ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

n=int(input())

l=10**9+7
numlist=[format(int(i),"060b") for i in input().split(" ")]
# print(numlist)


def xor(a,b):
    c=[]
    for i in range(60):
        if a[i]!=b[i]:
            c.append("1")
        else:
            c.append("0")
    c="".join(c)
    c=int(c, 2)
    return c
    
        

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=xor(numlist[i],numlist[j])
    ans=ans%l
print(ans)
        

### FIXED CODE ###

#D問題

#ビットごとに考えられる
k=10**9+7

anslist=[]

n=int(input())
a=[format(int(i), '060b') for i in input().split()]
d=[]

for i in range(60):
    b=[j[59-i] for j in a]
    c=b.count("0")*b.count("1")
    d.append(c*2**(i)%k)
ans=0

for i in d:
    ans+=i
print(ans%k)
### BUGGY CODE ###

from collections import deque
n=int(input())
lis=[[] for i in range(n*(n-1)//2)]
num=[-1]*(n**2)
cnt=-1
for x in range(n**2):
	if x//n<x%n:
		cnt+=1
		num[x]=cnt
for i in range(n):
	a=list(map(int,input().split()))
	for j in range(n-2):
		x=a[j]-1
		y=a[j+1]-1
		px=num[min(i*n+x,x*n+i)]
		py=num[min(i*n+y,y*n+i)]
		lis[px].append(py)
node_in=[0]*(n*(n-1)//2)
for i in range(n*(n-1)//2):
	for x in lis[i]:
		node_in[x]+=1
zero=deque([])
days=[10**9]*(n*(n-1)//2)
for i in range(n*(n-1)//2):
	if node_in[i]==0:
		zero.append(i)
		days[i]=1
while zero:
	r=zero.popleft()
	for x in lis[r]:
		node_in[x]-=1
		if node_in[x]==0:
			zero.append(x)
			days[x]=days[r]+1
if any([x==10**9 for x in days]):
	print(-1)
else:
	print(max(days))


### FIXED CODE ###

def main():
	from collections import deque
	n=int(input())
	battle=n*(n-1)//2
	lis=[[] for i in range(battle)]
	num=[-1]*(n**2)
	cnt=-1
	for x in range(n**2):
		if x//n<x%n:
			cnt+=1
			num[x]=cnt
	for i in range(n):
		a=list(map(int,input().split()))
		for j in range(n-2):
			x=a[j]-1
			y=a[j+1]-1
			px=num[min(i*n+x,x*n+i)]
			py=num[min(i*n+y,y*n+i)]
			lis[px].append(py)
	node_in=[0]*(battle)
	for i in range(battle):
		for x in lis[i]:
			node_in[x]+=1
	zero=deque([])
	days=[10**9]*(battle)
	for i in range(battle):
		if node_in[i]==0:
			zero.append(i)
			days[i]=1
	while zero:
		r=zero.popleft()
		for x in lis[r]:
			node_in[x]-=1
			if node_in[x]==0:
				zero.append(x)
				days[x]=days[r]+1
	if 10**9 in days:
		print(-1)
	else:
		print(max(days))
if __name__ == '__main__':
	main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
VW = [tuple(map(int,input().split())) for i in range(Q)]

ans = []
for v,w in VW:
    while v != w:
        if v > w: v,w = w,v
        w = (w+N-2)//N
    ans.append(v)
print(*ans, sep='\n')

### FIXED CODE ###

N,Q = map(int,input().split())
if N == 1:
    for i in range(Q):
        print(min(map(int,input().split())))
    exit()

def solve(s):
    a,b = map(int,s.split())
    while a != b:
        if a < b: a,b = b,a
        a = (a+N-2) // N
    return str(a)

print('\n'.join(map(solve, [input() for i in range(Q)])))
### BUGGY CODE ###

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

### FIXED CODE ###

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)
### BUGGY CODE ###

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

ba = []
for _ in [0]*n:
    a,b = map(int,input().split())
    if a >= h:
        a = h
    ba.append(b*dg + a)
ba.sort()

d = [10**9]*(h+1)
d[0] = 0

for i in range(1, h+1):
    for e in ba:
        a,b = e%dg, e//dg
        if i<=a:
            if d[i] > b:
                d[i] = b
        else:
            if d[i] > d[i-a]+b:
                d[i] = d[i-a]+b
print(d[-1])

### FIXED CODE ###

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

ba = []
for _ in [0]*n:
    a,b = map(int,input().split())
    if a >= h:
        a = h
    ba.append(b*dg + a)
ba.sort()

d = [10**9]*(h+1)
d[0] = 0

for i in range(1, h+1):
    for e in ba:
        a,b = e%dg, e//dg
        if i<=a:
            if d[i] > b:
                d[i] = b
        else:
            if d[i] > d[i-a]+b:
                d[i] = d[i-a]+b
print(d[-1])
### BUGGY CODE ###

N = int(input())

ans1 = 0

A = '1'
B = str(N)

if len(A)>=len(B):
    ans = len(A)
else:
    ans = len(B)
    
for i in range(2,N+1):
    A = i
    if N%A==0:
        B = int(N / A)
        A = str(A)
        B = str(B)
#        print(A, B)
        if len(A)>=len(B):
            ans1 = len(A)
        else:
            ans1 = len(B)
        if ans1 <= ans:
            ans = ans1
    if len(str(A))==len(str(B)):
        break
print(ans)


### FIXED CODE ###

import math

N = int(input())

ans1 = 0

A = '1'
B = str(N)

if len(A)>=len(B):
    ans = len(A)
else:
    ans = len(B)
    
for i in range(2,int(math.sqrt(N)+1)):
    A = i
    if N%A==0:
        B = int(N / A)
        A = str(A)
        B = str(B)
#        print(A, B)
        if len(A)>=len(B):
            ans1 = len(A)
        else:
            ans1 = len(B)
        if ans1 <= ans:
            ans = ans1
    if len(str(A))==len(str(B)):
        break
print(ans)
### BUGGY CODE ###

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

b = [a.count(x)-1 for x in a]
c = sum(b)//2

for i in range(n):
  print(c-b[i])

### FIXED CODE ###

import collections

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

c = collections.Counter(a)
for i in c:
  cnt += c[i]*(c[i]-1)//2



for i in range(n):
	print(cnt-c[a[i]]+1)
### BUGGY CODE ###

s = input().rstrip().split(' ')
L = int(s[0])
R = int(s[1])
cnt = (L*(L+1)) % 2019
 
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if ans < cnt:
            cnt = ans
            if cnt == 0:
        	    break
    if cnt == 0:
      break
 
print(cnt)

### FIXED CODE ###

s = input().rstrip().split(' ')
L = int(s[0])
R = int(s[1])
cnt = 2020
 
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if ans < cnt:
            cnt = ans
            if cnt == 0:
        	    break
    if cnt == 0:
      break
 
print(cnt)
### BUGGY CODE ###

n = int(input())
c = input()
c = [char for char in c]

def op1(l, id1, id2):
    temp = l[id1]
    l[id1] = l[id2]
    l[id2] = temp
    return l

r_idx, w_idx = [], []
for j in range(len(c)):
    if c[j] == "R":
        r_idx.append(j)
    elif c[j] == "W":
        w_idx.append(j)

ans = [0 for _ in range(min(len(r_idx), len(w_idx)))]
if len(ans) == 0:
    print(0)
else:
    for i in range(min(len(r_idx), len(w_idx))): # i is number of op1
        c_i = c[:]
        for j in range(i):
            c_i = op1(c_i, w_idx[j], r_idx[-j - 1])
            ans[i] += 1
        if "W" in "".join(c_i).rstrip("W"):
            ans[i] += "".join(c_i).rstrip("W").count("W")
    print(min(ans))

### FIXED CODE ###

n = int(input())
c = input()
c = [char for char in c]

ans = 0
for i in range(c.count("R")):
    if c[i] == "W":
        ans += 1

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

import sys
input = sys.stdin.readline
import itertools

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

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    se = set([(a,n)])
    m = n
    while m:
        bit = m & (-m)
        se |= set(B[n - bit])
        m -= bit
    B.append(sorted(se, reverse=True)[:2])

answer = itertools.accumulate([x+y for (x,i),(y,j) in B[1:]], max)
print('\n'.join(map(str,answer)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
from heapq import heappushpop

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

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    arr = [(0,0),(a,n)]
    m = n
    while m:
        bit = m & (-m)
        (x,i),(y,j) = B[n-bit]
        if (x,i) != arr[-1]:
            heappushpop(arr,(x,i))
        if (y,j) != arr[-1]:
            heappushpop(arr,(y,j))
        m -= bit
    B.append(arr)

answer = [0]
for (x,i),(y,j) in B[1:]:
    z = answer[-1]
    if z < x + y:
        z = x + y
    answer.append(z)
print('\n'.join(map(str,answer[1:])))
### BUGGY CODE ###

N = int(input())

def f(a,b):
    if len(str(a)) < len(str(b)):
        return len(str(b))
    else:
        return len(str(a))

ans = 100000000000
for i in range(1,N+1):
    if N % i == 0:
        ans = min(ans,f(i,N//i))
print(ans)
        
        

### FIXED CODE ###

import math

N = int(input())

def f(a,b):
    if len(str(a)) < len(str(b)):
        return len(str(b))
    else:
        return len(str(a))

ans = 100000000000
for i in range(1,int(math.sqrt(N)+1)):
    if N % i == 0:
        ans = min(ans,f(i,N//i))
print(ans)
### BUGGY CODE ###

n = int(input())
a = [0] * n
for i in range(n):
  a[i] = int(input())

for i in range(n):
  alt = a[i]
  a[i] = 0
  print(max(a))
  a[i] = alt

### FIXED CODE ###

n = int(input())
a = [0] * n
for i in range(n):
  a[i] = int(input())

asort = sorted(a,reverse=True)
for i in range(n):
  if a[i] == asort[0]:
    print(asort[1])
  else:
    print(asort[0])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ua=list(set(a))
d={}
total=0
for x in ua:
    c=a.count(x)
    d[x]=c
    total+=sum(range(c))
for x in a:
    print(total-d[x]+1)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
    if d.get(x) is None:
        d[x]=1
        continue
    d[x]+=1
total=0
for v in d.values():
    total+=(v-1)*v//2
for x in a:
    print(total-d[x]+1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(input())

import queue
todo = queue.Queue()
seen = [[False] * W for _ in range(H)]
route= [[0] * W for _ in range(H)]
for y in range(H):
    for x in range(W):
        if A[y][x] == '#':
            todo.put((x, y))
            seen[y][x] = True


seen = [[False] * W for _ in range(H)]
route= [[0] * W for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
last = 0
def bfs(el):
    global last
    x, y = el
    #print(x, y)
    for i in range(4):
        if 0 <= x + dx[i] < W and 0 <= y + dy[i] < H:
            if seen[y + dy[i]][x + dx[i]] == False:
                route[y + dy[i]][x + dx[i]] = route[y][x] + 1
                last = route[y + dy[i]][x + dx[i]]
                seen[y + dy[i]][x + dx[i]] = True
                todo.put((x + dx[i], y + dy[i]))
    if not todo.empty():
        bfs(todo.get())
    else:
        return None
bfs(todo.get())
#print(seen)
#print(route)
print(last)
# M = 0
# for y in range(W):
#     for x in range(H):
#         M = max(M, route[y][x])
# print(M)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
matrix = [["a" for _ in range(w+2)]] + [list("a" + input() + "a") for _ in range(h)] + [["a" for _ in range(w+2)]]

matrix_list1 = deque()
cnt = 0

#黒いタイルの位置情報を確認
for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j] == "#":
            matrix_list1.append([i,j])

#白いタイルが無くなるまで、黒いタイルを増やす
while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if matrix[x+1][y] == ".":
            matrix[x+1][y] = "#"
            matrix_list1.append([x+1,y])
        if matrix[x-1][y] == ".":
            matrix[x-1][y] = "#"
            matrix_list1.append([x-1,y])
        if matrix[x][y+1] == ".":
            matrix[x][y+1] = "#"
            matrix_list1.append([x,y+1])
        if matrix[x][y-1] == ".":
            matrix[x][y-1] = "#"
            matrix_list1.append([x,y-1])
    else:
        if len(matrix_list1) > 0:
            cnt += 1
    
print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())

ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(tmp)

checked = set()
count = 0

for i in range(n-1):
    if i in checked:
        continue
    same_str = set()
    for j in range(i+1, n):
        if ss[i] == ss[j]:
            count += 1

            for s in same_str:
                count += 1

            same_str.add(j)
            checked.add(j)

print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)