Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]
queue=[]
check=[[True for i in range(w)]for j in range(h)]
for i in range(h):
  for j in range(w):
    if field[i][j]=='#':
      check[i][j]=False
      queue.append([i,j])
p=[[0,1],[0,-1],[1,0],[-1,0]]
ans=0
while len(queue)>0:
  ans+=1
  manu=queue.copy()
  queue.clear()
  save=True
  for now in manu:
    for i in range(4):
      x=now[0]+p[i][0]
      y=now[1]+p[i][1]
      if x>-1 and x<h and y>-1 and y<w and check[x][y]:
        field[x][y]='#'
        queue.append([x,y])
        save=False
        check[x][y]=False
  if save:
    ans-=1
print(ans)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]
field=[[0 if field[j][i]=='#' else h+w for i in range(w)]for j in range(h)]
field=np.array(field)
for i in range(1,h):
  field[i,:]=np.minimum(field[i,:],field[i-1,:]+1)
for i in range(h-1,0,-1):
  field[i-1,:]=np.minimum(field[i,:]+1,field[i-1,:])
for i in range(1,w):
  field[:,i]=np.minimum(field[:,i],field[:,i-1]+1)
for i in range(w-1,0,-1):
  field[:,i-1]=np.minimum(field[:,i]+1,field[:,i-1])
print(np.max(field))

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]
queue=[]
for i in range(h):
  for j in range(w):
    if field[i][j]=='#':
      queue.append([i,j])
p=[[0,1],[0,-1],[1,0],[-1,0]]
ans=0
check=[[True for i in range(w)]for j in range(h)]
while len(queue)>0:
  ans+=1
  manu=queue.copy()
  queue.clear()
  save=True
  for now in manu:
    for i in range(4):
      x=now[0]+p[i][0]
      y=now[1]+p[i][1]
      if x>-1 and x<h and y>-1 and y<w and check[x][y] and field[x][y]=='.':
        field[x][y]='#'
        queue.append([x,y])
        save=False
        check[x][y]=False
  if save:
    ans-=1
print(ans)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]
field=[[0 if field[j][i]=='#' else h+w for i in range(w)]for j in range(h)]
field=np.array(field)
for i in range(1,h):
  field[i,:]=np.minimum(field[i,:],field[i-1,:]+1)
for i in range(h-1,0,-1):
  field[i-1,:]=np.minimum(field[i,:]+1,field[i-1,:])
for i in range(1,w):
  field[:,i]=np.minimum(field[:,i],field[:,i-1]+1)
for i in range(w-1,0,-1):
  field[:,i-1]=np.minimum(field[:,i]+1,field[:,i-1])
print(np.max(field))

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]
queue=[]
for i in range(h):
  for j in range(w):
    if field[i][j]=='#':
      queue.append([i,j])
p=[[0,1],[0,-1],[1,0],[-1,0]]
ans=0
while len(queue)>0:
  ans+=1
  manu=queue.copy()
  queue.clear()
  save=True
  for now in manu:
    for i in range(4):
      x=now[0]+p[i][0]
      y=now[1]+p[i][1]
      if x>-1 and x<h and y>-1 and y<w and field[x][y]=='.':
        field[x][y]='#'
        queue.append([x,y])
        save=False
  if save:
    ans-=1
print(ans)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]
field=[[0 if field[j][i]=='#' else h+w for i in range(w)]for j in range(h)]
field=np.array(field)
for i in range(1,h):
  field[i,:]=np.minimum(field[i,:],field[i-1,:]+1)
for i in range(h-1,0,-1):
  field[i-1,:]=np.minimum(field[i,:]+1,field[i-1,:])
for i in range(1,w):
  field[:,i]=np.minimum(field[:,i],field[:,i-1]+1)
for i in range(w-1,0,-1):
  field[:,i-1]=np.minimum(field[:,i]+1,field[:,i-1])
print(np.max(field))