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

h = []
v = []
for i in range(H):
    a = 0
    h.append([])
    v.append([])
    for j in range(W):
        if S[i][j] == '#':
            a = 0
        else:
            a += 1
        h[i].append(a)
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            a = 0
        else:
            if a == 0:
                a = h[i][j]
            h[i][j] = a

for i in range(W):
    a = 0
    for j in range(H):
        if S[j][i] == '#':
            a = 0
        else:
            a += 1
        v[j].append(a)
    for j in range(H - 1, -1, -1):
        if S[j][i] == '#':
            a = 0
        else:
            if a == 0:
                a = v[j][i]
            v[j][i] = a

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, h[i][j] + v[i][j])
print(ans - 1)
H, W = map(int, input().split())

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

h = []
v = []
for i in range(H):
    a = 0
    h.append([])
    v.append([])
    for j in range(W):
        if S[i][j] == '#':
            a = 0
        else:
            a += 1
        h[i].append(a)
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            a = 0
        else:
            if a == 0:
                a = h[i][j]
            h[i][j] = a

for i in range(W):
    a = 0
    for j in range(H):
        if S[j][i] == '#':
            a = 0
        else:
            a += 1
        v[j].append(a)
    for j in range(H - 1, -1, -1):
        if S[j][i] == '#':
            a = 0
        else:
            if a == 0:
                a = v[j][i]
            v[j][i] = a

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, h[i][j] + v[i][j])
print(ans - 1)

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

h = []
v = []
for i in range(H):
    a = 0
    h.append([])
    v.append([])
    for j in range(W):
        if S[i][j] == '#':
            a = 0
        else:
            a += 1
        h[i].append(a)
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            a = 0
        else:
            if a == 0:
                a = h[i][j]
            h[i][j] = a

for i in range(W):
    a = 0
    for j in range(H):
        if S[j][i] == '#':
            a = 0
        else:
            a += 1
        v[j].append(a)
    for j in range(H - 1, -1, -1):
        if S[j][i] == '#':
            a = 0
        else:
            if a == 0:
                a = v[j][i]
            v[j][i] = a

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, h[i][j] + v[i][j])
print(ans - 1)


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

h = []
v = []
for i in range(H):
    a = 0
    h.append([])
    v.append([])
    for j in range(W):
        if S[i][j] == '#':
            a = 0
        else:
            a += 1
        h[i].append(a)
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            a = 0
        else:
            if a == 0:
                a = h[i][j]
            h[i][j] = a

for i in range(W):
    a = 0
    for j in range(H):
        if S[j][i] == '#':
            a = 0
        else:
            a += 1
        v[j].append(a)
    for j in range(H - 1, -1, -1):
        if S[j][i] == '#':
            a = 0
        else:
            if a == 0:
                a = v[j][i]
            v[j][i] = a

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, h[i][j] + v[i][j])
print(ans - 1)