Buggy python submission (verdict: Time Limit Exceeded):
#ABC129 D
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]
 
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] = 1
        elif L[i][j - 1] == 0:
            L[i][j] = 1            
        else:
            L[i][j] = L[i][j - 1] + 1
 
for i in range(H):
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif j == W - 1:
            R[i][j] = 1
        elif L[i][j + 1] == 0:
            R[i][j] = 1            
        else:
            R[i][j] = R[i][j + 1] + 1
            
for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            continue
        elif i == 0:
            D[i][j] = 1
        elif L[i - 1][j] == 0:
            D[i][j] = 1            
        else:
            D[i][j] = D[i - 1][j] + 1
            
for j in range(W):
    for i in range(H - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif i == H - 1:
            U[i][j] = 1
        elif L[i + 1][j] == 0:
            U[i][j] = 1            
        else:
            U[i][j] = U[i + 1][j] + 1
            
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, (L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3))
print(ans)

Fixed submission:
#ABC129 D
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]
 
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] = 1
        elif L[i][j - 1] == 0:
            L[i][j] = 1            
        else:
            L[i][j] = L[i][j - 1] + 1
            
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif j == W - 1:
            R[i][j] = 1
        elif L[i][j + 1] == 0:
            R[i][j] = 1            
        else:
            R[i][j] = R[i][j + 1] + 1

for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            continue
        elif i == 0:
            D[i][j] = 1
        elif L[i - 1][j] == 0:
            D[i][j] = 1            
        else:
            D[i][j] = D[i - 1][j] + 1
            
    for i in range(H - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif i == H - 1:
            U[i][j] = 1
        elif L[i + 1][j] == 0:
            U[i][j] = 1            
        else:
            U[i][j] = U[i + 1][j] + 1
            
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, (L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC129 D
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] = 1
        elif L[i][j - 1] == 0:
            L[i][j] = 1            
        else:
            L[i][j] = L[i][j - 1] + 1

for i in range(H):
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif j == W - 1:
            R[i][j] = 1
        elif L[i][j + 1] == 0:
            R[i][j] = 1            
        else:
            R[i][j] = R[i][j + 1] + 1
            
for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            continue
        elif i == 0:
            D[i][j] = 1
        elif L[i - 1][j] == 0:
            D[i][j] = 1            
        else:
            D[i][j] = D[i - 1][j] + 1
            
for j in range(W):
    for i in range(H - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif i == H - 1:
            U[i][j] = 1
        elif L[i + 1][j] == 0:
            U[i][j] = 1            
        else:
            U[i][j] = U[i + 1][j] + 1
            
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, (L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3))
print(ans)

Fixed submission:
#ABC129 D
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]
 
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] = 1
        elif L[i][j - 1] == 0:
            L[i][j] = 1            
        else:
            L[i][j] = L[i][j - 1] + 1
            
    for j in range(W - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif j == W - 1:
            R[i][j] = 1
        elif L[i][j + 1] == 0:
            R[i][j] = 1            
        else:
            R[i][j] = R[i][j + 1] + 1

for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            continue
        elif i == 0:
            D[i][j] = 1
        elif L[i - 1][j] == 0:
            D[i][j] = 1            
        else:
            D[i][j] = D[i - 1][j] + 1
            
    for i in range(H - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif i == H - 1:
            U[i][j] = 1
        elif L[i + 1][j] == 0:
            U[i][j] = 1            
        else:
            U[i][j] = U[i + 1][j] + 1
            
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, (L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3))
print(ans)