Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
H, W = map(int, input().split())
rows = [input() for i in range(H)]
cols = []
for i in range(W):
    col = ''
    for row in rows:
        col += row[i]
    cols.append(col)

def create_light_list(tdl, reverse):
    ret = []
    lenl = len(tdl[0])
    tl = range(lenl)[::-1] if reverse else range(lenl)
    for l in tdl:
        d = deque()
        cur = 0
        for i in tl:
            if l[i] == '#':
                cur = 0
            else:
                cur += 1
            if reverse:
                d.appendleft(cur)
            else:
                d.append(cur)
        ret.append(d)
    return ret

# 上下左右の照らされる数だけをあらかじめ計算
L = create_light_list(rows, False)
R = create_light_list(rows, True)
U = create_light_list(cols, False)
D = create_light_list(cols, True)

ans = 0
for i in range(H):
    for j in range(W):
        light = L[i][j] + R[i][j] + U[j][i] + D[j][i] - 3
        ans = max(ans, light)

print(ans)


Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]
L, R, U, D = [[[0]*W for _ in range(H)] for i in range(4)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            L[h][w] = L[h][w-1]+1
            U[h][w] = U[h-1][w]+1
        if S[h][W-1-w] == '.':
            R[h][-w-1] = R[h][-w]+1
        if S[H-1-h][w] == '.':
            D[-h-1][w] = D[-h][w]+1

ans = 0
for i in range(H):
    for j in range(W):
        light = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, light)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
rows = [input() for i in range(H)]
cols = []
for i in range(W):
    col = ''
    for row in rows:
        col += row[i]
    cols.append(col)

def create_light_list(tdl, reverse):
    ret = []
    for l in tdl:
        lenl = len(l)
        items = []
        cur = 0
        if reverse:
            tl = range(lenl)[::-1]
        else:
            tl = range(lenl)
        for i in tl:
            if l[i] == '#':
                cur = 0
                items.append(cur)
            else:
                cur += 1
                items.append(cur)
        if reverse:
            ret.append(items[::-1])
        else:
            ret.append(items)
    return ret

# 上下左右の照らされる数だけをあらかじめ計算
L = create_light_list(rows, False)
R = create_light_list(rows, True)
U = create_light_list(cols, False)
D = create_light_list(cols, True)

ans = 0
for i in range(H):
    for j in range(W):
        light = L[i][j] + R[i][j] + U[j][i] + D[j][i] - 3
        ans = max(ans, light)

print(ans)


Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]
L, R, U, D = [[[0]*W for _ in range(H)] for i in range(4)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            L[h][w] = L[h][w-1]+1
            U[h][w] = U[h-1][w]+1
        if S[h][W-1-w] == '.':
            R[h][-w-1] = R[h][-w]+1
        if S[H-1-h][w] == '.':
            D[-h-1][w] = D[-h][w]+1

ans = 0
for i in range(H):
    for j in range(W):
        light = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, light)

print(ans)