Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


h, w = map(int, input().split())

GRID = []
for _ in range(h):
    s = input().strip()
    R = [0 if c == "#" else 1 for c in s]
    GRID.append(R)

LEFT = [R.copy() for R in GRID]
for i in range(h):
    for j in range(1, w):
        if LEFT[i][j] == 0:
            continue
        LEFT[i][j] += LEFT[i][j - 1]

RIGHT = [R.copy() for R in GRID]
for i in range(h):
    for j in range(w - 2, -1, -1):
        if RIGHT[i][j] == 0:
            continue
        RIGHT[i][j] += RIGHT[i][j + 1]

TOP = [R.copy() for R in GRID]
for j in range(w):
    for i in range(1, h):
        if TOP[i][j] == 0:
            continue
        TOP[i][j] += TOP[i - 1][j]

BOTTOM = [R.copy() for R in GRID]
for j in range(w):
    for i in range(h - 2, -1, -1):
        if BOTTOM[i][j] == 0:
            continue
        BOTTOM[i][j] += BOTTOM[i + 1][j]

LIGHTED = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        LIGHTED[i][j] = LEFT[i][j] + RIGHT[i][j] + TOP[i][j] + BOTTOM[i][j] - 3

answer = 0
for i in range(h):
    for j in range(w):
        if LIGHTED[i][j] > answer:
            answer = LIGHTED[i][j]

print(answer)


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np


h, w = map(int, input().split())

GRID = []
for _ in range(h):
    S = [0] + [0 if c == "#" else 1 for c in input().strip()] + [0]
    GRID.append(S)
GRID.insert(0, [0] * (w + 2))
GRID.append([0] * (w + 2))
grid = np.array(GRID)

top = np.zeros((h + 2, w + 2), dtype = np.int)
bottom = np.zeros((h + 2, w + 2), dtype = np.int)
left = np.zeros((h + 2, w + 2), dtype = np.int)
right = np.zeros((h + 2, w + 2), dtype = np.int)

for i in range(1, h + 1):
    top[i] = (top[i - 1] + 1) * grid[i]
for i in range(h, 0, -1):
    bottom[i] = (bottom[i + 1] + 1) * grid[i]
for j in range(1, w + 1):
    left[:, j] = (left[:, j - 1] + 1) * grid[:, j]
for j in range(w, 0, -1):
    right[:, j] = (right[:, j + 1] + 1) * grid[:, j]

column = (top + bottom - 1) * grid
row = (left + right - 1) * grid
lighted = (column + row - 1) * grid

ans = lighted.max()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
GRID = [input() for _ in range(h)]

HORIZONTAL = [[0] * w for _ in range(h)]
for i in range(h):
    COUNTS = []
    count = 0
    for j in range(w):
        if GRID[i][j] == ".":
            count += 1
        else:
            COUNTS.append(count)
            count = 0
    COUNTS.append(count)
    k = 0
    for j in range(w):
        if GRID[i][j] == ".":
            HORIZONTAL[i][j] = COUNTS[k]
        else:
            k += 1

VERTICAL = [[0] * w for _ in range(h)]
for j in range(w):
    COUNTS = []
    count = 0
    for i in range(h):
        if GRID[i][j] == ".":
            count += 1
        else:
            COUNTS.append(count)
            count = 0
    COUNTS.append(count)
    k = 0
    for i in range(h):
        if GRID[i][j] == ".":
            VERTICAL[i][j] = COUNTS[k]
        else:
            k += 1

LIGHTED = []
for i in range(h):
    for j in range(w):
        LIGHTED.append(HORIZONTAL[i][j] + VERTICAL[i][j] - 1)

ans = max(LIGHTED)
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np


h, w = map(int, input().split())

GRID = []
for _ in range(h):
    S = [0] + [0 if c == "#" else 1 for c in input().strip()] + [0]
    GRID.append(S)
GRID.insert(0, [0] * (w + 2))
GRID.append([0] * (w + 2))
grid = np.array(GRID)

top = np.zeros((h + 2, w + 2), dtype = np.int)
bottom = np.zeros((h + 2, w + 2), dtype = np.int)
left = np.zeros((h + 2, w + 2), dtype = np.int)
right = np.zeros((h + 2, w + 2), dtype = np.int)

for i in range(1, h + 1):
    top[i] = (top[i - 1] + 1) * grid[i]
for i in range(h, 0, -1):
    bottom[i] = (bottom[i + 1] + 1) * grid[i]
for j in range(1, w + 1):
    left[:, j] = (left[:, j - 1] + 1) * grid[:, j]
for j in range(w, 0, -1):
    right[:, j] = (right[:, j + 1] + 1) * grid[:, j]

column = (top + bottom - 1) * grid
row = (left + right - 1) * grid
lighted = (column + row - 1) * grid

ans = lighted.max()
print(ans)