Buggy python submission (verdict: Runtime Error):
from scipy import array, ndimage
H, _ = map(int, input().split())
print(ndimage.distance_transform_cdt(array([[c == "." for c in input()] for _ in range(H)], dtype=bool), metric="taxicab").max())


Fixed submission:
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            queue.append([j,i])

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = -1
def bfs(map_input,queue,ans):
    while queue:
        queue2 = deque([])
        ans+=1
        for x,y in queue:
            for i in range(4):
                nx = x+mx[i]
                ny = y+my[i]
                if 0<=nx<w and 0<=ny<h:
                    if map_input[ny][nx]=='#':
                        continue
                    map_input[ny][nx]='#'
                    queue2.append([nx,ny])

        queue = queue2
    return ans

ans = bfs(map_input,queue,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            queue.append([j,i])

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = -1
def bfs(map_input,queue,ans):
    while queue:
        queue2 = deque([])
        ans+=1
        for x,y in queue:
            for i in range(4):
                nx = x+mx[i]
                ny = y+my[i]
                if 0<=nx<w and 0<=ny<h:
                    if map_input[ny][nx]=='#':
                        continue
                    map_input[ny][nx]='#'
                    queue2.append([nx,ny])

        queue = queue2
    return ans

ans = bfs(map_input,queue,ans)
print(ans)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            queue.append([j,i])

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = -1
def bfs(map_input,queue,ans):
    while queue:
        queue2 = deque([])
        ans+=1
        for x,y in queue:
            for i in range(4):
                nx = x+mx[i]
                ny = y+my[i]
                if 0<=nx<w and 0<=ny<h:
                    if map_input[ny][nx]=='#':
                        continue
                    map_input[ny][nx]='#'
                    queue2.append([nx,ny])

        queue = queue2
    return ans

ans = bfs(map_input,queue,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            queue.append([j,i])

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = 0
def bfs(map_input,queue):
    queue2 = deque([])
    while queue:
        x,y = queue.popleft()
        for i in range(4):
            nx = x+mx[i]
            ny = y+my[i]
            if 0<=nx<w and 0<=ny<h:
                if map_input[ny][nx]=='#':
                    continue
                map_input[ny][nx]='#'
                queue2.append([nx,ny])

    return queue2

while True:
    queue = bfs(map_input,queue)
    if len(queue)==0:
        break
    ans+=1

print(ans)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            queue.append([j,i])

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = -1
def bfs(map_input,queue,ans):
    while queue:
        queue2 = deque([])
        ans+=1
        for x,y in queue:
            for i in range(4):
                nx = x+mx[i]
                ny = y+my[i]
                if 0<=nx<w and 0<=ny<h:
                    if map_input[ny][nx]=='#':
                        continue
                    map_input[ny][nx]='#'
                    queue2.append([nx,ny])

        queue = queue2
    return ans

ans = bfs(map_input,queue,ans)
print(ans)