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

h, w = map(int, input().split(' '))
a = [input() for _ in range(h)]
d = [[float('inf') for _ in range(w)] for _ in range(h)]
move = [(1, 0), (-1, 0), (0, 1), (0, -1)]

que = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            d[i][j] = 0
            if (i + 1 < h and a[i+1][j] == '.') or (i - 1 >= 0 and a[i-1][j] == '.') or (j + 1 < w and a[i][j+1] == '.') or (j - 1 >= 0 and a[i][j-1] == '.'):
                que.append((i, j))


while len(que) > 0:
    y, x = que.pop(0)

    for dy, dx in move:
        ny = y + dy
        nx = x + dx

        if (ny >= 0 and ny < h) and (nx >= 0 and nx < w) and a[ny][nx] == '.' and d[ny][nx] == float('inf'):
            d[ny][nx] = d[y][x] + 1
            if (ny + 1 < h and a[ny + 1][nx] == '.') or (ny - 1 >= 0 and a[ny - 1][nx] == '.') or (nx + 1 < w and a[ny][nx + 1] == '.') or (nx - 1 >= 0 and a[ny][nx - 1] == '.'):
                que.append((ny, nx))

print(np.max(d))


Fixed submission:
import numpy as np


def solve():
    h, w = map(int, input().split(' '))
    max_value = h + w
    values = []
    for i in range(h):
        values.append([0 if i == '#' else max_value for i in list(input())])
    values = np.array(values)

    for x in range(w - 1):
        values[:, x+1] = np.minimum(values[:, x] + 1, values[:, x+1])
    for x in range(w - 1, 0 , -1):
        values[:, x-1] = np.minimum(values[:, x-1], values[:, x] + 1)
    for x in range(h - 1):
        values[x+1, :] = np.minimum(values[x, :] + 1,values[x+1, :])
    for x in range(h - 1, 0, -1):
        values[x-1, :] = np.minimum(values[x, :] + 1, values[x-1, :])
    print(np.max(values))


solve()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

h, w = map(int, input().split(' '))
a = [input() for _ in range(h)]
d = [[float('inf') for _ in range(w)] for _ in range(h)]
move = [(1, 0), (-1, 0), (0, 1), (0, -1)]

que = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            d[i][j] = 0
            if (i + 1 < h and a[i+1][j] == '.') or (i - 1 >= 0 and a[i-1][j] == '.') or (j + 1 < w and a[i][j+1] == '.') or (j - 1 >= 0 and a[i][j-1] == '.'):
                que.append((i, j))


while len(que) > 0:
    y, x = que.pop(0)

    for dy, dx in move:
        ny = y + dy
        nx = x + dx

        if (ny >= 0 and ny < h) and (nx >= 0 and nx < w) and a[ny][nx] == '.' and d[ny][nx] == float('inf'):
            d[ny][nx] = d[y][x] + 1
            if (ny + 1 < h and a[ny + 1][nx] == '.') or (ny - 1 >= 0 and a[ny - 1][nx] == '.') or (nx + 1 < w and a[ny][nx + 1] == '.') or (nx - 1 >= 0 and a[ny][nx - 1] == '.'):
                que.append((ny, nx))

print(np.max(d))


Fixed submission:
import numpy as np


def solve():
    h, w = map(int, input().split(' '))
    max_value = h + w
    values = []
    for i in range(h):
        values.append([0 if i == '#' else max_value for i in list(input())])
    values = np.array(values)

    for x in range(w - 1):
        values[:, x+1] = np.minimum(values[:, x] + 1, values[:, x+1])
    for x in range(w - 1, 0 , -1):
        values[:, x-1] = np.minimum(values[:, x-1], values[:, x] + 1)
    for x in range(h - 1):
        values[x+1, :] = np.minimum(values[x, :] + 1,values[x+1, :])
    for x in range(h - 1, 0, -1):
        values[x-1, :] = np.minimum(values[x, :] + 1, values[x-1, :])
    print(np.max(values))


solve()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

h, w = map(int, input().split(' '))
d = [[float('inf') for _ in range(w)] for _ in range(h)]

a = []
que = []
for i in range(h):
    aa = input()
    a.append(aa)
    for j, aaa in enumerate(aa):
        if aaa == '#':
            d[i][j] = 0
            que.append((i, j))

move = [(1, 0), (-1, 0), (0, 1), (0, -1)]

while len(que) > 0:
    y, x = que.pop(0)

    for dy, dx in move:
        ny = y + dy
        nx = x + dx

        if (ny >= 0 and ny < h) and (nx >= 0 and nx < w) and a[ny][nx] == '.' and d[ny][nx] == float('inf'):
            que.append((ny, nx))
            d[ny][nx] = d[y][x] + 1

print(np.max(d))


Fixed submission:
import numpy as np


def solve():
    h, w = map(int, input().split(' '))
    max_value = h + w
    values = []
    for i in range(h):
        values.append([0 if i == '#' else max_value for i in list(input())])
    values = np.array(values)

    for x in range(w - 1):
        values[:, x+1] = np.minimum(values[:, x] + 1, values[:, x+1])
    for x in range(w - 1, 0 , -1):
        values[:, x-1] = np.minimum(values[:, x-1], values[:, x] + 1)
    for x in range(h - 1):
        values[x+1, :] = np.minimum(values[x, :] + 1,values[x+1, :])
    for x in range(h - 1, 0, -1):
        values[x-1, :] = np.minimum(values[x, :] + 1, values[x-1, :])
    print(np.max(values))


solve()