Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

queue = deque()

left = [[0 for j in range(w)] for i in range(h)]
right = [[0 for j in range(w)] for i in range(h)]
up = [[0 for j in range(w)] for i in range(h)]
down = [[0 for j in range(w)] for i in range(h)]

cnt = 0

for i in range(h):
    cnt = 0
    for j in range(w):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            left[i][j] = cnt

    cnt = 0
    for j in reversed(range(w)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            right[i][j] = cnt


for j in range(w):
    cnt = 0
    for i in range(h):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            up[i][j] = cnt

    cnt = 0
    for i in reversed(range(h)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            down[i][j] = cnt

ans = 0
for i in range(h):
    for j in range(w):
        tmp = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
        ans = max(tmp, ans)

print(ans)


Fixed submission:

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

queue = deque()

left = [[0 for j in range(w)] for i in range(h)]
right = [[0 for j in range(w)] for i in range(h)]
up = [[0 for j in range(w)] for i in range(h)]
down = [[0 for j in range(w)] for i in range(h)]

cnt = 0

for i in range(h):
    cnt = 0
    for j in range(w):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            left[i][j] = cnt

    cnt = 0
    for j in reversed(range(w)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            right[i][j] = cnt


for j in range(w):
    cnt = 0
    for i in range(h):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            up[i][j] = cnt

    cnt = 0
    for i in reversed(range(h)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            down[i][j] = cnt

ans = 0
for i in range(h):
    for j in range(w):
        tmp = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
        ans = max(tmp, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)
import numpy as np

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

queue = deque()

vert = np.array([[0 for j in range(w)] for i in range(h)])
hori = np.array([[0 for j in range(w)] for i in range(h)])

h_start = 0
h_val = 0
v_start = 0
v_val = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            h_val += 1
            if j == w-1:
                hori[i,h_start:w] += h_val
                h_val = 0
                h_start = 0
        else:
            hori[i,h_start:j] += h_val
            h_val = 0
            h_start = (j+1)%(w)

for j in range(w):
    for i in range(h):
        if maze[i][j] == '.':
            v_val += 1
            if i == h-1:
                vert[v_start:h,j] += v_val
                v_val = 0
                v_start = 0
        else:
            vert[v_start:i,j] += v_val
            v_val = 0
            v_start = (i+1)%(h)


sum_ = hori + vert - 1

print(np.max(sum_))


Fixed submission:

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

queue = deque()

left = [[0 for j in range(w)] for i in range(h)]
right = [[0 for j in range(w)] for i in range(h)]
up = [[0 for j in range(w)] for i in range(h)]
down = [[0 for j in range(w)] for i in range(h)]

cnt = 0

for i in range(h):
    cnt = 0
    for j in range(w):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            left[i][j] = cnt

    cnt = 0
    for j in reversed(range(w)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            right[i][j] = cnt


for j in range(w):
    cnt = 0
    for i in range(h):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            up[i][j] = cnt

    cnt = 0
    for i in reversed(range(h)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            down[i][j] = cnt

ans = 0
for i in range(h):
    for j in range(w):
        tmp = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
        ans = max(tmp, ans)

print(ans)