Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = (W + 1) * h + 4 * w
            light[(W + 1) * (h + 1) + 4 * w + 1] = light[here + 1] + 1
            light[(W + 1) * h + 4 * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = (W + 1) * h + 4 * w
            light[(W + 1) * (h - 1) + 4 * w + 0] = light[here + 0] + 1
            light[(W + 1) * h + 4 * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, light[here: here + 4])

print(ans)


Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

row = 4 * (W + 1)
col = 4

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h + 1) + col * w + 1] = light[here + 1] + 1
            light[row * h + col * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h - 1) + col * w + 0] = light[here + 0] + 1
            light[row * h + col * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, sum(light[here: here + 4]) + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [[[0, 0, 0, 0] for _ in range(W + 1)] for _ in range(H + 1)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = light[h][w]
            light[h + 1][w][1] = here[1] + 1
            light[h][w + 1][3] = here[3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = light[h][w]
            light[h - 1][w][0] = here[0] + 1
            light[h][w - 1][2] = here[2] + 1
            ans = max(ans, sum(here) + 1)

print(ans)


Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

row = 4 * (W + 1)
col = 4

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h + 1) + col * w + 1] = light[here + 1] + 1
            light[row * h + col * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h - 1) + col * w + 0] = light[here + 0] + 1
            light[row * h + col * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, sum(light[here: here + 4]) + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [[[0, 0, 0, 0] for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = light[h][w]
            if h + 1 < H and grid[h + 1][w] == '.':
                light[h + 1][w][1] = here[1] + 1
            if w + 1 < W and grid[h][w + 1] == '.':
                light[h][w + 1][3] = here[3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = light[h][w]
            if h - 1 >= 0 and grid[h - 1][w] == '.':
                light[h - 1][w][0] = here[0] + 1
            if w - 1 >= 0 and grid[h][w - 1] == '.':
                light[h][w - 1][2] = here[2] + 1
            ans = max(ans, sum(here) + 1)

print(ans)


Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

row = 4 * (W + 1)
col = 4

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h + 1) + col * w + 1] = light[here + 1] + 1
            light[row * h + col * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h - 1) + col * w + 0] = light[here + 0] + 1
            light[row * h + col * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, sum(light[here: here + 4]) + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [[[0, 0, 0, 0] for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = light[h][w]
            if h + 1 < H and grid[h + 1][w] == '.':
                light[h + 1][w][1] = here[1] + 1
            if w + 1 < W and grid[h][w + 1] == '.':
                light[h][w + 1][3] = here[3] + 1

for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = light[h][w]
            if h - 1 >= 0 and grid[h - 1][w] == '.':
                light[h - 1][w][0] = here[0] + 1
            if w - 1 >= 0 and grid[h][w - 1] == '.':
                light[h][w - 1][2] = here[2] + 1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, sum(light[h][w]) + 1)

print(ans)


Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

row = 4 * (W + 1)
col = 4

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h + 1) + col * w + 1] = light[here + 1] + 1
            light[row * h + col * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h - 1) + col * w + 0] = light[here + 0] + 1
            light[row * h + col * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, sum(light[here: here + 4]) + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [[[0, 0, 0, 0] for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = light[h][w]
            if h + 1 < H and grid[h + 1][w] == '.':
                light[h + 1][w][1] = here[1] + 1
            if w + 1 < W and grid[h][w + 1] == '.':
                light[h][w + 1][3] = here[3] + 1

for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = light[h][w]
            if h - 1 >= 0 and grid[h - 1][w] == '.':
                light[h - 1][w][0] = here[0] + 1
            if w - 1 >= 0 and grid[h][w - 1] == '.':
                light[h][w - 1][2] = here[2] + 1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, sum(light[h][w]) + 1)

print(ans)


Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

row = 4 * (W + 1)
col = 4

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h + 1) + col * w + 1] = light[here + 1] + 1
            light[row * h + col * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h - 1) + col * w + 0] = light[here + 0] + 1
            light[row * h + col * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, sum(light[here: here + 4]) + 1)

print(ans)