Harryxun/stf_run huggingface dataset:
n  = int(input())
red = []
red_x = []
blue = []
blue_y = []
for i in range(n):
    a, b = map(int,input().split())
    red.append([a,b])
    red_x.append(x)
    
for i in range(n):
    c, d = map(int,input().split())
    blue.append([c,d])
    blue_y.append(d)

count = 0    
for i in range(n):
    p = max(red_x)
    red_x.remove(p)
    s = max(blue_y)
    blue_y.remove(s)
    q = 0
    r = 0
    for j in range(n):
        if red[j][0] == p:
            q = red[j][1]
            red[j][0] = -1
            red[j][1] = -1
    for k in range(n):
        if blue[k][1] == s:
            r = blue[k][0]
            blue[k][0] = -1
            blue[k][1] = -1
            
    if p < r and q < s:
        count = count + 1
    else:
        None
            
    
            


### FIXED CODE ###

n = int(input())
red = []
blue = []

for i in range(n):
    a, b = map(int,input().split())
    red.append([a,b])
    

for i in range(n):
    c, d = map(int,input().split())
    blue.append([c,d])
    
red_sort = list(reversed(sorted(red, key=lambda y: y[1])))
blue_sort = sorted(blue, key=lambda x: x[0])

# print(red_sort)
# [[1, 3], [2, 0], [3, 1]]
# print(blue_sort)
# [[4, 2], [0, 4], [5, 5]]

pair = []
for blue_point in blue_sort:
    x_blue = blue_point[0]
    y_blue = blue_point[1]
    
    for red_point in red_sort:
        x_red = red_point[0]
        y_red = red_point[1]
        
        if x_red<x_blue and y_red<y_blue:
            if not (red_point in pair) and not (blue_point in pair):
                pair.append(red_point)
                pair.append(blue_point)
    
print(len(pair) // 2)
n = int(input())
def get_h(pos,cx,cy,H):
  r= H - abs(pos[0]-cx) - abs(pos[1]-cy)

  return r

points = []
for i in range(n):
  x,y,h = map(int,input().split())
  if h == 0:
    continue
  points.append([x,y,h])
  
ans = []
if ans == []:
  for i in range(101):
    for j in range(101):
      d = get_h(points[0],i,j,0)- get_h(points[1],i,j,0)
      if points[0][2]- points[1][2] == d:
        ans.append([i,j])
for k in range(len(points)):
  for l in range(k+1,len(points)):
    for elem in ans[:]:
      i = elem[0]
      j = elem[1]
      if points[k][2] - points[l][2] != abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
        ans.remove(elem)
h = abs(points[0][0]-ans[0][0])+abs(points[0][1]-ans[0][1]) + points[0][2]
print('{} {} {}'.format(ans[0][0],ans[0][1],h))

### FIXED CODE ###

n = int(input())
hist = [tuple(map(int,input().split())) for _ in range(n)]
hist.sort(key=lambda x: x[2], reverse=1)

cands = []
x0,y0,h0 = hist[0]

for i in range(0,101):
  for j in range(0,101):
    if h0 == 0:
      cands.append((i,j,1))
    else:
      cands.append((i,j, h0+abs(i-x0)+abs(j-y0)))
    
for X,Y,H in cands:
  for x,y,h in hist:
    if max(H-abs(X-x)-abs(Y-y),0) == h:
      continue
    else:
      break
  else:
    print(X,Y,H)
    break
A, B, H, M =map(int, input().split())
Min = 60*H + M
long_v = 0.5
short_v = 6
diff = 5.5*Min%360
print((A**2 + B**2 - 2*A*B*math.cos(math.radians(diff)))**0.5)

### FIXED CODE ###

import math
A, B, H, M =map(int, input().split())
Min = 60*H + M
long_v = 0.5
short_v = 6
diff = 5.5*Min%360
print((A**2 + B**2 - 2*A*B*math.cos(math.radians(diff)))**0.5)
# CとDの最小公倍数を求める
# CとDのそれぞれの倍数の数を求めて最小公倍数で割る
import math

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


A,B,C,D = map(int,input().split())
E = lcm(C,D)
c = (A-1)//C + 1
d = (A-1)//D + 1
e = (A-1)//E + 1
cde = [[c,C], [d,D], [e,E]]
cnt_cde = []
for x,y in cde:
    if x*y < B:
        cnt_cde.append((B-x*y)//y+1)
    elif x*y == B:
        cnt_cde.append(1)
    else :
        cnt_cde.append(0)
answer = B-A+1-(cnt_cde[0]+cnt_cde[1]-cnt_cde[2])
print(cde,cnt_cde,answer)
            

### FIXED CODE ###

import fractions
A,B,C,D = map(int,input().split())
c = B//C - (A-1)//C
d = B//D - (A-1)//D
E = (C*D)//fractions.gcd(C,D)
e = B//E - (A-1)//E
answer = B-A+1-(c+d-e)
print(answer)
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a.sort()
a.reverse()
print('Yes' if (a[m] >= (sum(a) / (4 * m))) else 'No')


### FIXED CODE ###

n, m = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]

a_sum = sum(a_list)
a_list.sort()
a_list.reverse()
for i in range(m):
    a = a_list[i]
    if a < a_sum / (4 * m):
        print('No')
        exit()
else:
    print('Yes')
a,b=map(int,input().split())
if a*b%2==0:
    print("Odd")
else:
    print(#Even)

### FIXED CODE ###

a,b=map(int,input().split())
c=a*b
if c%2==0:
    print("Even")
else:
    print("Odd")
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
if m == 0:
   return True
if i >= n and m > sum(A)
   return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res

for m in M
   if res = solve(0,m):
      print 'yes'
   else:
      print 'no'

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
   if m == 0:
     return True
   if i >= n or m > sum(A):
     return False
   res = solve(i + 1, m) or solve(i + 1, m - A[i])
   return res

for m in M:
  if solve(0,m):
     print "yes"
  else:
     print "no"
#!python
# -*- coding: utf-8 -*-


S = input() + '_'
T_s = ["dream", "dreamer", "erase", "eraser"]

while True:
    S_ = S
    for T in T_s:
        S = S.replace(T + "_", "_")
        print(S)
    if S_ == S:
        break

if S == "_":
    print("YES")
else:
    print("NO")


### FIXED CODE ###

#!python
# -*- coding: utf-8 -*-


S = input()
T_s = ["dream", "dreamer", "erase", "eraser"]

while len(S):
    for T in T_s:
        if T == S[-len(T):]:
            S = S[:-len(T)]
            break
    else:
        print("NO")
        break
else:
    print("YES")
def swap(A,i,j):
    A[i],A[j] = A[j],A[i]
    return A

def partition(A,p=0, r=None):
    if r is None:
        r = len(A)-1
    x = A[r]
    i = p-1
    for j in range(p,r):
        while A[j] <= x:
            i += 1
            swap(A,i,j)
    swap(A,i+1,r)
    return i+1

if __name__ == "__main__":
    input()
    A = list(map(int, input().strip().split()))
    k = partition(A)
    B = list(map(str, A))
    B[k] = "[{}]".format(B[k])
    print(" ".join(B))

### FIXED CODE ###

def swap(A,i,j):
    A[i],A[j] = A[j],A[i]
    return A

def partition(A,p=0, r=None):
    if r is None:
        r = len(A)-1
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j] <= x:
            i += 1
            swap(A,i,j)
    swap(A,i+1,r)
    return i+1

if __name__ == "__main__":
    input()
    A = list(map(int, input().strip().split()))
    k = partition(A)
    B = list(map(str, A))
    B[k] = "[{}]".format(B[k])
    print(" ".join(B))
n,m=map(int,input().split())
ll=[input().split() for _ in range(m)]
la={p for p,s in ll if s=='AC'})
f,c=0,0
for p,s in ll:
  if s=='AC': 
  if 

### FIXED CODE ###

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

lac = [0] * n
lwa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if lac[p] == 0:
        if s == 'WA':
            lwa[p] += 1
        if s == 'AC':
            lac[p] = 1

lwa = [x * y for x, y in zip(lac, lwa)]
print(sum(lac), sum(lwa))
# コンテスト名の取得
S =　input()
 
# 入力されたコンテストではないものを出力
if S == "ABC":
  print("ARC")
elif　S == "ARC":
  print("ABC")

### FIXED CODE ###

# コンテスト名の要求
S = input()

# 入力されたコンテストではないものを出力
if S == "ABC":
    print("ARC")
elif S == "ARC":
    print("ABC")
else:
    print("入力内容が正しくありません。")
D, G = map(int, input().split())
p = []
c = []
for i in range(D):
    P, C = map(int, input().split())
    p.append(P)
    c.append(C)

getPoint = [[] for i in range(max(p))]
#getPoint = [0 for i in range(max(p))]
#print(c)
for i in range(max(p)):
    for j in range(D):
        if p[j] - 1> i:
            getPoint[i].append((i + 1) * 100 * (j + 1))
        else:
            getPoint[i].append(p[j] * (j + 1) * 100 + c[j])

#print(getPoint)

def sarch(G, keypoint):
    i = 0
    print(G, keypoint, 1111)
    if max(getPoint[-1]) >= G:
        i = 0
        while True:
            if max(getPoint[i]) >= G:
                print(keypoint + i + 1)
                break
            i += 1
    else:
        G -= max(getPoint[-1])
        keypoint += max(p)
        for i in range(len(getPoint[-1])):
            if getPoint[-1][i] == max(getPoint[-1]):
                key = i
        del p[i]
        del getPoint[max(p) + 1:]
        for i in range(len(getPoint)):
            del getPoint[i][key]
        sarch(G, keypoint)

def sarch2(G, keypoint):
    if G < 0:
        return print(keypoint)
    num = sorted(getPoint[0])[-1]
    for i in range(len(getPoint[0])):
        if getPoint[0][i] == max(getPoint[0]):
            num = i
    i = 0
    while True:
        if getPoint[i][num] < max(getPoint[i]):
            G -= getPoint[i][num]
            keypoint = keypoint + i + 1
            for j in range(len(getPoint)):
                if j < i:
                    #print(j, i)
                    getPoint[j][num] = getPoint[j + i + 1][num]
                else:
                    getPoint[j][num] = getPoint[-1][num]
            sarch2(G, keypoint)
            break
        i += 1
        if i >= len(getPoint):
            break
i = 0
#sarch(G, 0)
sarch2(G, 0)

### FIXED CODE ###

D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]

ans_cnt = 10 ** 20
for i in range(2 ** (D)):
    def make_p(i):
        p = bin(i)[2::]
        while len(p) != D:
            p = "0" + p
        key = D
        for j in range(D - 1, -1, -1):
            if int(p[j]) == 0:
                key = j
                break
        return p, key
    
    p_and_key = make_p(i)
    p = p_and_key[0]
    key = p_and_key[1]
    cnt = 0
    ansP = 0
    for j in range(len(p)):
        if p[j] == "1":
            ansP += pc[j][0] * 100 * (j + 1) + pc[j][1]
            cnt += pc[j][0]
    j = 0
    if int(key) != int(D):
        key = int(key)
        while ansP < G:
            j = int(j)
            if pc[key][0] <= j:
                break
            ansP += 100 * (key + 1)
            cnt += 1
            j += 1
    if ansP >= G:
        ans_cnt = min(ans_cnt, cnt)

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

import math

lcm = a * b / math.gcd(a, b)

print(int(lcm))

### FIXED CODE ###

import fractions
A, B = map(int, input().split())
print(A*B//fractions.gcd(A, B))
# -*- coding: utf-8 -*-

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

if(N = 0):
    min = 0
    
elif(N >= K):
    min = N % K

else:
    min = 1

print(abs(min))

### FIXED CODE ###

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

if N % K == 0:
  print(0)
  
else:
  print(1)
N=input()
if N%2 == 0:
  print(int(N/2))
else:
  print(int(((N+1)/2)))

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
  n = N / 2
else:
  n = int((N+1) / 2)
print(int(n))
import numpy as np

def iterate(mapdata, passed, curr, count):
    if curr == (passed.shape[0] - 1, passed.shape[1] - 1):
        return count

    if mapdata[curr[0]][curr[1]] == '#':
        return 100000 #passed[curr]
    
    if passed[curr] > 0:
        return 100000 #passed[curr]
    passed[curr] = 1
    
    ret = 100000
    if curr[0] < passed.shape[0] - 1:
        tmp = iterate(mapdata, passed, (curr[0] + 1, curr[1]), count + 1)
        ret = min(ret, tmp)
    if curr[1] < passed.shape[1] - 1:
        tmp = iterate(mapdata, passed, (curr[0], curr[1] + 1), count + 1)
        ret = min(ret, tmp)
    if curr[0] > 0:
        tmp = iterate(mapdata, passed, (curr[0] - 1, curr[1]), count + 1)
        ret = min(ret, tmp)
    if curr[1] > 0:
        tmp = iterate(mapdata, passed, (curr[0], curr[1] - 1), count + 1)
        ret = min(ret, tmp)

    return ret


h, w = map(int, input().split())
mapdata = [input() for y in range(h)]
dotsum = sum(mapdata[y].count('.') for y in range(h))

passed = np.zeros((h, w), np.int32)
#passed[:, :] = 100000
count = iterate(mapdata, passed, (0, 0), 0)
#print(count)
if count < 50 * 50:
    print(dotsum - count - 1)
else:
    print(-1)

### FIXED CODE ###

import numpy as np

def iterate2(mapdata, passed, start):
    queue = [(start, 0)]

    while len(queue) > 0:
        curr, count = queue[0]
        del queue[0]
        if curr == (passed.shape[0] - 1, passed.shape[1] - 1):
            return count
        if mapdata[curr[0]][curr[1]] == '#':
            continue
        if passed[curr] > 0:
            continue
        passed[curr] = 1

        if curr[0] < passed.shape[0] - 1:
            queue.append(((curr[0] + 1, curr[1]), count + 1))
        if curr[1] < passed.shape[1] - 1:
            queue.append(((curr[0], curr[1] + 1), count + 1))
        if curr[0] > 0:
            queue.append(((curr[0] - 1, curr[1]), count + 1))
        if curr[1] > 0:
            queue.append(((curr[0], curr[1] - 1), count + 1))
    
    return -1

h, w = map(int, input().split())
mapdata = [input() for y in range(h)]
dotsum = sum(mapdata[y].count('.') for y in range(h))

passed = np.zeros((h, w), np.int8)
count = iterate2(mapdata, passed, (0, 0))
#print(dotsum)
#print(count)
if count > 0:
    print(dotsum - count - 1)
else:
    print(-1)
import math
import sys
sys.setrecursionlimit(10**6)

n, k = input().split()
n = int(n)
k = int(k)
mincost = [None]*n
h = list(map(int, input().split()))

def cost(n):
  if (mincost[n-1] is not None):
    return mincost[n-1]
  elif (n == 1):
    mincost[n-1] = 0
  elif (n == 2):
    mincost[n-1] =  abs(h[1] - h[0])
  else:
    x = [10**5]*k
    for i in range(k):
        if (n-i-2 < 0):
            break
        x[i] = cost(n-i-1) + abs(h[n-1]-h[n-i-2])
    mincost[n-1] = min(x)
  return mincost[n-1]

print(cost(n))


### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10**6)

n = int(input())
mincost = [None]*n

def cost(n,h):
  if (mincost[n-1] is not None):
    return mincost[n-1]
  elif (n == 1):
    mincost[n-1] = 0
  elif (n == 2):
    mincost[n-1] =  abs(h[1] - h[0])
  else:
    mincost[n-1] = min(cost(n-1,h) + abs(h[n-1]-h[n-2]), cost(n-2,h) + abs(h[n-1]-h[n-3]))
  return mincost[n-1]

h = [None]*n

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

print(cost(n,h))
n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=set(n)
print(max(0,n.count(l[i])-m.count(l[i])) for i in range(l))


### FIXED CODE ###

n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
a,b = map(int,input().split())
from math import gcd
print(gcd(a,b))

### FIXED CODE ###

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

from itertools import combinations

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

gcd_n = gcd(a,b)

#L = [i for i in range(1,gcd_n+1) if gcd_n%i==0]

def div(num):
    l = [1]
    if(num==1):
        return [1]
    while(num%2==0):
        num //=2
        l.append(2)
    f = 3
    while(f*f<=num):
        if num%f==0:
            num //= f
            l.append(f)
        else:
            f += 2
    
    if num!=1:
        l.append(num)
    return l

l = div(gcd_n)
cnt = 0
pre = 0
for i in range(len(l)):
    if pre==l[i]:
        continue
    pre = l[i]
    cnt += 1
print(cnt)
a=imput()
print(a.count("o"))

### FIXED CODE ###

a=input()
print(700+100*int(a.count("o")))
n = int(input())
h = [int(x) for x in input().split()]
h.reverse()

flag = True

for i in range(1, n):
    print(h, i)

    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

print('Yes') if flag else print('No')


### FIXED CODE ###

n = int(input())
h = [int(x) for x in input().split()]
h.reverse()

flag = True

for i in range(1, n):
    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

print('Yes') if flag else print('No')
import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input())))
    for i in range(8):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input().rstrip("\n"))))
    
    for i in range(2**3):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
xyh =[0]*N
for i in range(N):
    xyh[i] = tuple(int(i) for i in input().split())

from collections import defaultdict
H =defaultdict(set)
for x,y,h in xyh:
    for cx in range(101):
        for cy in range(101):
            xx =x -cx
            yy =y -cy
            if cx <=x and cy <=y:
                H[(cx,cy)].add( (h +xx +yy) )
            elif cx >x and cy <=y:
                 H[(cx,cy)].add( (h -xx +yy) )
            elif cx <=x and cy >y:
                 H[(cx,cy)].add( (h +xx -yy) )
            elif cx >x and cy >y:
                 H[(cx,cy)].add( (h -xx -yy) )
            
#print(xyh)
#H.sort(key =lambda x:x[1])
for k,v in H.items():
    if len(v)==1:
        if 0 <= v[0] <=10**9:
            print(*k,*v)
        elif v[0] <0:
            print(*k,0)
        elif 10**9 <v[0]:
            print(*k,10**9)

### FIXED CODE ###

# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
xyh =[0]*N
h_list =[0]*N

for i in range(N):
    x,y,h= (int(i) for i in input().split())
    xyh[i] =x,y,h
    h_list[i] =h

from bisect import bisect_right
xyh.sort(key =lambda x:x[2])
h_list.sort()
ind =bisect_right(h_list,0)
from collections import defaultdict
H =defaultdict(set)

for x,y,h in xyh[ind:]:
    for cx in range(101):
        for cy in range(101):
            xx =x -cx
            yy =y -cy
            if cx <=x and cy <=y:
                H[(cx,cy)].add( (h +xx +yy) )
            elif cx >x and cy <=y:
                H[(cx,cy)].add( (h -xx +yy) )
            elif cx <=x and cy >y:
                H[(cx,cy)].add( (h +xx -yy) )
            elif cx >x and cy >y:
                H[(cx,cy)].add( (h -xx -yy) )
            
#print(xyh)
#H.sort(key =lambda x:x[1])
if len(xyh[ind:]) ==1:
    print(*xyh[-1])
else:
    for k,v in H.items():
    
        if len(v)==1:
            vv =v.pop()
            if 0 <= vv :
                print(*k,vv)
            elif vv <0:
                print(*k,0)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
if sum(sorted([int(x) for x in input().split()]) > 2*Llist[-1]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
Llist = [int(x) for x in input().split()]
Llist.sort()
Llist.reverse()
if sum(Llist) > 2*Llist[0]:
    print("Yes")
else:
    print("No")
import math

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

a = (n[0] * n[1]) // math.gcd(n[0], n[1])

### FIXED CODE ###

import fractions

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

a = (n[0] * n[1]) // fractions.gcd(n[0], n[1])
print(a)
d=int(input())
if d==25:
	print('Christmas')
elif d==24:
    print('Christmas Eve ')
elif d==23:
    print('Christmas Eve Eve')
else d==22:
    print('Christmas Eve Eve Eve ')

### FIXED CODE ###

d=int(input())
if d==25:
	print('Christmas')
elif d==24:
    print('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
N,H,W=map(int,input())
ans=0
for _ in range(N):
    a,b=map(int,input().split())
    if a>=H and b>=W:
        ans+=1
print(ans)

### FIXED CODE ###

N,H,W=map(int,input().split())
ans=0
for _ in range(N):
    a,b=map(int,input().split())
    if a>=H and b>=W:
        ans+=1
print(ans)
import math

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

aa=a*a
bb=b*b

hh=h*30
mm=m*6

cos = math.cos(math.radians(abs(hh-mm)))

cc=aa+bb-2*a*b*cos

c=math.sqrt(cc)

print(c)




### FIXED CODE ###

a=input()

if a[-1]=='3':
    print('bon')
elif a[-1]=='0' or a[-1]=='1' or a[-1]=='6' or a[-1]=='8':
    print('pon')
elif a[-1]=='2' or a[-1]=='4' or a[-1]=='5' or a[-1]=='7' or a[-1]=='9':
    print('hon')
import sys #追加
sys.setrecursionlimit(10**9)

n,m = map(int,input().split())
al = list(map(int,input().split()))

#a,bの最大公約数
def gcd(a, b):
   while b:
       a, b = b, a % b
   return a

#a,bの最小公倍数
def lcm(a, b):
   return a * b // gcd (a, b)


bl = [i//2 for i in al]
import numpy as np
ans = 1
for b in bl:
   ans = np.lcm(b, ans)

for a in al:
   if ans % a == 0:
      print(0)
      import sys
      sys.exit()

def ceil(a, b):
   return a // b + (a % b > 0)

print(ceil(m // ans, 2))


### FIXED CODE ###

import sys #追加
sys.setrecursionlimit(10**9)
import time
s = time.time()

n,m = map(int,input().split())
al = list(map(int,input().split()))

bl = [i//2 for i in al]
from fractions import gcd
ans = 1
for b in bl:
   if time.time() - s > 1.9:
      print(0)
      import sys
      sys.exit()
   ans = (ans * b) // gcd(ans, b)

for a in al:
   if time.time() - s > 1.9:
      print(0)
      import sys
      sys.exit()
   if ans % a == 0:
      print(0)
      import sys
      sys.exit()

def ceil(a, b):
   return a // b + (a % b > 0)

print(ceil(m // ans, 2))
def combination(n, r):
    r = min(r, n-r)
    nume = 1
    denomi = 1
    for i in range(1, r+1):
        denomi *= i
    for i in range(n-r+1, n+1):
        nume *= i
    return nume // denomi

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

sl = []
cnt = -1
ng = 0
for i in range(M):
    a = int(input())
    b = (a - 1) - (cnt + 1)
    if b == -1:
        ng = 1
    sl.append(max(b, 1))
    cnt = a

if ng:
    print(0)
else:
    sl.append(max(N - (a + 1), 1))
    ans = 1
    for s in sl:
        p = 0
        for i in range(s):
            j = s - i
            if (i <= j):
                p += combination(j, i)
            else:
                break
        ans *= p
    print(ans % 1000000007)

### FIXED CODE ###

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

print(min(*[abs(sum(wl[:a]) - sum(wl[a:])) for a in range(N)]))
from collections import deque
import numpy
H,W = list(map(int,input().split()))
A = [input().split() for i in range(H)]
place_h = [0,-1,0,1]
place_w = [1,0,-1,0]
black = 0
q = []
dist = [[-1 for i in range(W)] for j in range(H)]
for i in range(H):
    A[i] = list(A[i][0])
    for j in range(W):
        if A[i][j] == "#":
            black += 1
            q.append(deque([[i,j]]))
            dist[i][j] = 0

while len(q)>0:
    i = 0
    while i < black:
        if len(q[i]) == 0:
            q.pop(i)
            black -= 1
            continue
        vh,vw = q[i].popleft()
        for m in range(4):
            nvh = vh+place_h[m]
            nvw = vw+place_w[m]
            if 0<=nvh<H and 0<=nvw<W and dist[nvh][nvw] == -1:
                q[i].append([nvh,nvw])
                dist[nvh][nvw] = dist[vh][vw]+1
        i+=1
print(numpy.amax(dist))





### FIXED CODE ###

from collections import deque
import sys
def main():
    H,W = list(map(int,sys.stdin.readline().split()))
    place_h = [0,-1,0,1]
    place_w = [1,0,-1,0]
    black = 0
    q = deque([])
    dist = []
    A = []
    for i in range(H):
        a = sys.stdin.readline().split()
        a = list(a[0])
        dist_sub = []
        for j in range(W):
            if a[j] == "#":
                black += 1
                q.append([i,j])
                dist_sub.append(0)
            else:
                dist_sub.append(-1)
        A.append(a)
        dist.append(dist_sub)

    ans = 0
    
    while len(q) > 0:
        vh,vw = q.popleft()
        for m in range(4):
            nvh = vh+place_h[m]
            nvw = vw+place_w[m]
            if 0<=nvh<H and 0<=nvw<W and dist[nvh][nvw] == -1:
                q.append([nvh,nvw])
                dist[nvh][nvw] = dist[vh][vw]+1
                if ans < dist[nvh][nvw]:
                    ans = dist[nvh][nvw]

    print(ans)

if __name__ == "__main__":
    main()