Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
h,w=map(int,input().split())
graph=[[0 if i=='#' else float('inf') for i in list(input())] for _ in range(h)]
graph=np.array(graph)

def bfs():
    for x in range(h):
        for y in range(w):
            for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
                if 0<=x+dx<h and 0<=y+dy<w:
                    graph[x+dx][y+dy]=np.minimum(graph[x][y]+1,graph[x+dx][y+dy])
while np.max(graph)==float('inf'):
    bfs()
print(int(np.max(graph)))


Fixed submission:
import numpy as np
h,w=map(int,input().split())
graph=[[0 if i=='#' else float('inf') for i in list(input())] for _ in range(h)]
graph=np.array(graph)
for x in range(w-1):
    graph[:,x+1]=np.minimum(graph[:,x]+1,graph[:,x+1])
for x in range(w-1,0,-1):
    graph[:,x-1]=np.minimum(graph[:,x]+1,graph[:,x-1])
for y in range(h-1):
    graph[y+1,:]=np.minimum(graph[y,:]+1,graph[y+1,:])
for y in range(h-1,0,-1):
    graph[y-1,:]=np.minimum(graph[y,:]+1,graph[y-1,:])

print(int(np.max(graph)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int,input().split())
field=[list(input()) for _ in range(h)]
graph=[[float('inf')]*w for _ in range(h)]
queue=deque()
for i in range(h):
    for j in range(w):
        if field[i][j]=='#':
            queue.append([i,j])
            graph[i][j]=0

def bfs():
    while queue:
        x,y=queue.popleft()
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            if 0<=x+dx<h and 0<=y+dy<w:
                if graph[x+dx][y+dy]==float('inf'):
                    graph[x+dx][y+dy]=graph[x][y]+1
                    queue.append([x+dx,y+dy])
bfs()
print(max(max(graph[s]) for s in range(h)))

Fixed submission:
import numpy as np
h,w=map(int,input().split())
graph=[[0 if i=='#' else float('inf') for i in list(input())] for _ in range(h)]
graph=np.array(graph)
for x in range(w-1):
    graph[:,x+1]=np.minimum(graph[:,x]+1,graph[:,x+1])
for x in range(w-1,0,-1):
    graph[:,x-1]=np.minimum(graph[:,x]+1,graph[:,x-1])
for y in range(h-1):
    graph[y+1,:]=np.minimum(graph[y,:]+1,graph[y+1,:])
for y in range(h-1,0,-1):
    graph[y-1,:]=np.minimum(graph[y,:]+1,graph[y-1,:])

print(int(np.max(graph)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int,input().split())
field=[list(input()) for _ in range(h)]
graph=[[float('inf')]*w for _ in range(h)]
queue=deque()
count=0
for i in range(h):
    for j in range(w):
        if field[i][j]=='#':
            queue.append([i,j])
            graph[i][j]=0

def bfs():
    x,y=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=x+dx<h and 0<=y+dy<w:
            if graph[x+dx][y+dy]==float('inf'):
                graph[x+dx][y+dy]=graph[x][y]+1
                queue.append([x+dx,y+dy])
while queue:
    bfs()
print(max(max(graph[s]) for s in range(h)))
    

Fixed submission:
import numpy as np
h,w=map(int,input().split())
graph=[[0 if i=='#' else float('inf') for i in list(input())] for _ in range(h)]
graph=np.array(graph)
for x in range(w-1):
    graph[:,x+1]=np.minimum(graph[:,x]+1,graph[:,x+1])
for x in range(w-1,0,-1):
    graph[:,x-1]=np.minimum(graph[:,x]+1,graph[:,x-1])
for y in range(h-1):
    graph[y+1,:]=np.minimum(graph[y,:]+1,graph[y+1,:])
for y in range(h-1,0,-1):
    graph[y-1,:]=np.minimum(graph[y,:]+1,graph[y-1,:])

print(int(np.max(graph)))