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

h, w = map(int, input().split())
b = [[0] * w for _ in range(h)]
q = []

for i in range(h):
    for j, m in enumerate(input()):
        if m == "#":
            q.append((i, j))
            b[i][j] = 1

cnt = -1

while q:
    nq = []
    for y, x in q:
        if y > 0:
            if not b[y-1][x]:
                b[y-1][x] = 1
                nq.append((y-1, x))
        if y < h-1:
            if not b[y+1][x]:
                b[y+1][x] = 1
                nq.append((y+1, x))
        if x > 0:
            if not b[y][x-1]: 
                b[y][x-1] = 1
                nq.append((y, x-1))
        if x < w-1:
            if not b[y][x+1]: 
                b[y][x+1] = 1
                nq.append((y, x+1))
    
    q = nq    
    cnt += 1
    
print(cnt)


Fixed submission:
h, w = map(int, input().split())
b = [[0] * w for _ in range(h)]
q = []

for i in range(h):
    for j, m in enumerate(input()):
        if m == "#":
            q.append((i, j))
            b[i][j] = 1

cnt = -1

while q:
    nq = []
    for y, x in q:
        if y > 0:
            if not b[y-1][x]:
                b[y-1][x] = 1
                nq.append((y-1, x))
        if y < h-1:
            if not b[y+1][x]:
                b[y+1][x] = 1
                nq.append((y+1, x))
        if x > 0:
            if not b[y][x-1]: 
                b[y][x-1] = 1
                nq.append((y, x-1))
        if x < w-1:
            if not b[y][x+1]: 
                b[y][x+1] = 1
                nq.append((y, x+1))
    
    q = nq    
    cnt += 1
    
print(cnt)

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

h, w = map(int, input().split())
b = [[0] * w for _ in range(h)]
iq = []

for i in range(h):
    for j, m in enumerate(input()):
        if m == "#":
            iq.append((i, j))
            b[i][j] = 1

def bfs(q, cnt):
    nq = []
    for y, x in q:
        if y > 0:
            if not b[y-1][x]:
                b[y-1][x] = 1
                nq.append((y-1, x))
        if y < h-1:
            if not b[y+1][x]:
                b[y+1][x] = 1
                nq.append((y+1, x))
        if x > 0:
            if not b[y][x-1]: 
                b[y][x-1] = 1
                nq.append((y, x-1))
        if x < w-1:
            if not b[y][x+1]: 
                b[y][x+1] = 1
                nq.append((y, x+1))
                
    if nq: return bfs(nq, cnt + 1)
    return cnt
    
print(bfs(iq, 0))


Fixed submission:
h, w = map(int, input().split())
b = [[0] * w for _ in range(h)]
q = []

for i in range(h):
    for j, m in enumerate(input()):
        if m == "#":
            q.append((i, j))
            b[i][j] = 1

cnt = -1

while q:
    nq = []
    for y, x in q:
        if y > 0:
            if not b[y-1][x]:
                b[y-1][x] = 1
                nq.append((y-1, x))
        if y < h-1:
            if not b[y+1][x]:
                b[y+1][x] = 1
                nq.append((y+1, x))
        if x > 0:
            if not b[y][x-1]: 
                b[y][x-1] = 1
                nq.append((y, x-1))
        if x < w-1:
            if not b[y][x+1]: 
                b[y][x+1] = 1
                nq.append((y, x+1))
    
    q = nq    
    cnt += 1
    
print(cnt)