Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
A = []
C = []
for i in range(H):
	tmp = [s for s in input()]
	indexes = [k for k, x in enumerate(tmp) if x == "#"]
	A.append(tmp)
	for k in indexes:
		C.append((i,k))

c = 0
for i in range(H):
	for j in range(W):
		if A[i][j] == ".":
			tmp = H+W
			for x,y in C:
				if tmp > abs(x-i) + abs(y-j):
					tmp = abs(x-i)+abs(y-j)
					if tmp == 1:
						break
			A[i][j] = tmp
			if tmp > c:
				c = tmp
print(c)

Fixed submission:
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([0 if s == "#" else H+W for s in input()])

A = np.array(A)
for x in range(W - 1):
	A[:,x+1] = np.minimum(A[:, x]+1,A[:, x+1])
for x in range(W - 1, 0 , -1):
	A[:,x-1] = np.minimum(A[:, x-1],A[:, x]+1)
for y in range(H -1):
	A[y+1,:] = np.minimum(A[y, :]+1,A[y+1, :])
for y in range(H -1, 0, -1):
	A[y-1,:] = np.minimum(A[y-1, :],A[y, :]+1)

print(np.max(A))

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
A = []
C = []
for i in range(H):
	tmp = [s for s in input()]
	indexes = [k for k, x in enumerate(tmp) if x == "#"]
	A.append(tmp)
	for k in indexes:
		C.append((i,k))

for i in range(H):
	for j in range(W):
		if A[i][j] == ".":
			tmp = H+W
			for x,y in C:
				if tmp > abs(x-i) + abs(y-j):
					tmp = abs(x-i)+abs(y-j)
			A[i][j] = tmp

tmp = 0
for i in range(H):
	for j in range(W):
		if A[i][j] != "#" and A[i][j] > tmp:
			tmp = A[i][j]
print(tmp)

Fixed submission:
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([0 if s == "#" else H+W for s in input()])

A = np.array(A)
for x in range(W - 1):
	A[:,x+1] = np.minimum(A[:, x]+1,A[:, x+1])
for x in range(W - 1, 0 , -1):
	A[:,x-1] = np.minimum(A[:, x-1],A[:, x]+1)
for y in range(H -1):
	A[y+1,:] = np.minimum(A[y, :]+1,A[y+1, :])
for y in range(H -1, 0, -1):
	A[y-1,:] = np.minimum(A[y-1, :],A[y, :]+1)

print(np.max(A))

Buggy python submission (verdict: Time Limit Exceeded):
def check(A):
	c = 0
	for i in range(H):
		for j in range(W):
			if A[i][j] == ".":
				return 1
	return 0

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([s for s in input()])

c = 0
while check(A) != 0:
	for i in range(H):
		for j in range(W):
			if A[i][j] != "." and A[i][j] != c:
				if i != 0:
					if A[i-1][j] == ".":
						A[i-1][j] = c
				if i != H-1:
					if A[i+1][j] == ".":
						A[i+1][j] = c
				if j != 0:
					if A[i][j-1] == ".":
						A[i][j-1] = c
				if j != W-1:
					if A[i][j+1] == ".":
						A[i][j+1] = c
	c += 1
print(c)

Fixed submission:
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([0 if s == "#" else H+W for s in input()])

A = np.array(A)
for x in range(W - 1):
	A[:,x+1] = np.minimum(A[:, x]+1,A[:, x+1])
for x in range(W - 1, 0 , -1):
	A[:,x-1] = np.minimum(A[:, x-1],A[:, x]+1)
for y in range(H -1):
	A[y+1,:] = np.minimum(A[y, :]+1,A[y+1, :])
for y in range(H -1, 0, -1):
	A[y-1,:] = np.minimum(A[y-1, :],A[y, :]+1)

print(np.max(A))

Buggy python submission (verdict: Time Limit Exceeded):
def check(A):
	c = 0
	for i in range(H):
		for j in range(W):
			if A[i][j] == ".":
				return 1
	return 0

def change(A):
	for i in range(H):
		for j in range(W):
			if A[i][j] == "?":
				A[i][j] = "#"
	return A

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([s for s in input()])

c = 0
while check(A) != 0:
	for i in range(H):
		for j in range(W):
			if A[i][j] == "#":
				if i != 0:
					if A[i-1][j] != "#":
						A[i-1][j] = "?"
				if i != H-1:
					if A[i+1][j] != "#":
						A[i+1][j] = "?"
				if j != 0:
					if A[i][j-1] != "#":
						A[i][j-1] = "?"
				if j != W-1:
					if A[i][j+1] != "#":
						A[i][j+1] = "?"
	A = change(A)
	c += 1
print(c)

Fixed submission:
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
	A.append([0 if s == "#" else H+W for s in input()])

A = np.array(A)
for x in range(W - 1):
	A[:,x+1] = np.minimum(A[:, x]+1,A[:, x+1])
for x in range(W - 1, 0 , -1):
	A[:,x-1] = np.minimum(A[:, x-1],A[:, x]+1)
for y in range(H -1):
	A[y+1,:] = np.minimum(A[y, :]+1,A[y+1, :])
for y in range(H -1, 0, -1):
	A[y-1,:] = np.minimum(A[y-1, :],A[y, :]+1)

print(np.max(A))