Buggy python submission (verdict: Runtime Error):
import numpy as np

def main():
  H,W = map(int,input().split())
  maze = [list(input())for _ in range(H)]
  for i in range(H):
    for j in range(W):
      if maze[i][j]=="#":
        maze[i][j]=0
      else:
        maze[i][j]=float('INF')
  
  for i in range(1,H):
    maze[i,:]=np.minimum(maze[i,:],maze[i-1,:]+1)
  for i in range(H-2,-1,-1):
    maze[i,:]=np.minimum(maze[i,:],maze[i+1,:]+1)
  for i in range(1,W):
    maze[:,i]=np.minimum(maze[:,i],maze[:,i-1]+1)
  for i in range(W-2,-1,-1):
    maze[:,i]=np.minimum(maze[:,i],maze[:,i+1]+1)
  print(np.max(maze))
main()

Fixed submission:
import numpy as np
h,w=map(int,input().split())
maze = []
for i in range(h):
  maze.append([0 if x=="#" else float('INF') for x in list(input())])
maze = np.array(maze)

for i in range(1,h):
  maze[i,:] = np.minimum(maze[i,:],maze[i-1,:]+1)
for j in range(h-2,-1,-1):
  maze[j,:] = np.minimum(maze[j,:],maze[j+1,:]+1)
for k in range(1,w):
  maze[:,k] = np.minimum(maze[:,k],maze[:,k-1]+1)
for l in range(w-2,-1,-1):
  maze[:,l] = np.minimum(maze[:,l],maze[:,l+1]+1)


print(int(np.max(maze)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
 
H,W = map(int,input().split())
maze = [list(input())for i in range(H)]
que = deque([])
 
for i in range(H):
  for j in range(W):
    if maze[i][j] == "#":
      que.append([i,j])
      maze[i][j]=0      

patterns = [[1,0],[-1,0],[0,1],[0,-1]]
while que:
  now = que.popleft()
  nowY = now[0]
  nowX = now[1]
  nowStep = maze[nowY][nowX]
  for pattern in patterns:
    nextY = nowY + pattern[0]
    nextX = nowX + pattern[1]
    nextStep = nowStep + 1
    if 0 <= nextY < H and 0 <= nextX < W and maze[nextY][nextX]==".":
      maze[nextY][nextX]=nextStep
      que.append([nextY,nextX])
      
print(nowStep)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
maze = []
for i in range(h):
  maze.append([0 if x=="#" else float('INF') for x in list(input())])
maze = np.array(maze)

for i in range(1,h):
  maze[i,:] = np.minimum(maze[i,:],maze[i-1,:]+1)
for j in range(h-2,-1,-1):
  maze[j,:] = np.minimum(maze[j,:],maze[j+1,:]+1)
for k in range(1,w):
  maze[:,k] = np.minimum(maze[:,k],maze[:,k-1]+1)
for l in range(w-2,-1,-1):
  maze[:,l] = np.minimum(maze[:,l],maze[:,l+1]+1)


print(int(np.max(maze)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys

H,W = map(int,input().split())
maze = [list(input())for i in range(H)]
que = deque([])

"""
append corrdinates of blacktiles to que and change the tile to int
"""
for i in range(H):
  for j in range(W):
    if maze[i][j] == "#":
      que.append([i,j])
      maze[i][j]=0      
"""
with BFS, change the white tile to int which represents from the black tile
"""
patterns = [[1,0],[-1,0],[0,1],[0,-1]]
while que:
  now = que.popleft()
  nowY = now[0]
  nowX = now[1]
  nowStep = maze[nowY][nowX]
  for pattern in patterns:
    nextY = nowY + pattern[0]
    nextX = nowX + pattern[1]
    nextStep = nowStep + 1
    if 0 <= nextY < H and 0 <= nextX < W and maze[nextY][nextX]==".":
      maze[nextY][nextX]=nextStep
      que.append([nextY,nextX])
      
print(nowStep)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
maze = []
for i in range(h):
  maze.append([0 if x=="#" else float('INF') for x in list(input())])
maze = np.array(maze)

for i in range(1,h):
  maze[i,:] = np.minimum(maze[i,:],maze[i-1,:]+1)
for j in range(h-2,-1,-1):
  maze[j,:] = np.minimum(maze[j,:],maze[j+1,:]+1)
for k in range(1,w):
  maze[:,k] = np.minimum(maze[:,k],maze[:,k-1]+1)
for l in range(w-2,-1,-1):
  maze[:,l] = np.minimum(maze[:,l],maze[:,l+1]+1)


print(int(np.max(maze)))