Buggy python submission (verdict: Time Limit Exceeded):
# ABC129 D
H, W = map(int, input().split(' '))

H += 2
W += 2
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

grid = []
grid.append(list(('#'*W).strip()))
for i in range(H-2):
    grid.append(list(('#'+input()+'#').strip()))
grid.append(list(('#'*W).strip()))

for i in range(1, H-1):
    for j in range(1, W-1):
        if grid[i][j] == '.':
            L[i][j] = L[i][j-1] + 1

for i in range(1, H-1):
    for j in range(1, W-1):
        if grid[i][W - j-1]  == '.':
            R[i][W - j-1] = R[i][W - j-1 + 1] + 1

for j in range(1, W-1):
    for i in range(1, H-1):
        if grid[i][j] == '.':
            U[i][j] = U[i-1][j] + 1

for j in range(1, W-1):
    for i in range(1, H-1):
        if grid[H - i-1][j]  == '.':
            D[H - i-1][j] = D[H - i-1 + 1][j] + 1

total = [[0 for _ in range(W)] for _ in range(H)]
for i in range(1, H-1):
    for j in range(1,W-1):
        total[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3

ans = 0
for i in range(1,H-1):
    ans = max(ans, max(total[i]))
print (ans)

Fixed submission:
# ABC129 D
H, W = map(int, input().split(' '))

H += 2
W += 2
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

grid = []
grid.append(list(('#'*W).strip()))
for i in range(H-2):
    grid.append(list(('#'+input()+'#').strip()))
grid.append(list(('#'*W).strip()))

for i in range(1, H-1):
    for j in range(1, W-1):
        if grid[i][j] == '.':
            L[i][j] = L[i][j-1] + 1
        if grid[i][W - j-1]  == '.':
            R[i][W - j-1] = R[i][W - j-1 + 1] + 1

for j in range(1, W-1):
    for i in range(1, H-1):
        if grid[i][j] == '.':
            U[i][j] = U[i-1][j] + 1
        if grid[H - i-1][j]  == '.':
            D[H - i-1][j] = D[H - i-1 + 1][j] + 1

total = [[0 for _ in range(W)] for _ in range(H)]
for i in range(1, H-1):
    for j in range(1,W-1):
        total[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3

ans = 0
for i in range(1,H-1):
    ans = max(ans, max(total[i]))
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC129 D
H, W = map(int, input().split(' '))

H += 2
W += 2
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

grid = []
grid.append(list(('#'*W).strip()))
for i in range(H-2):
    grid.append(list(('#'+input()+'#').strip()))
grid.append(list(('#'*W).strip()))

for i in range(1, H-1):
    for j in range(1, W-1):
        if grid[i][j] == '.':
            L[i][j] = L[i][j-1] + 1

for i in range(1, H-1):
    for j in range(1, W-1):
        if grid[i][W - j-1]  == '.':
            R[i][W - j-1] = R[i][W - j-1 + 1] + 1

for j in range(1, W-1):
    for i in range(1, H-1):
        if grid[i][j] == '.':
            U[i][j] = U[i-1][j] + 1

for j in range(1, W-1):
    for i in range(1, H-1):
        if grid[H - i-1][j]  == '.':
            D[H - i-1][j] = D[H - i-1 + 1][j] + 1

total = [[0 for _ in range(W)] for _ in range(H)]
for i in range(1, H-1):
    for j in range(1,W-1):
        total[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3

ans = 0
for i in range(1,H-1):
    ans = max(ans, max(total[i]))
print (ans)

Fixed submission:
# ABC129 D
H, W = map(int, input().split(' '))

H += 2
W += 2
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

grid = []
grid.append(list(('#'*W).strip()))
for i in range(H-2):
    grid.append(list(('#'+input()+'#').strip()))
grid.append(list(('#'*W).strip()))

for i in range(1, H-1):
    for j in range(1, W-1):
        if grid[i][j] == '.':
            L[i][j] = L[i][j-1] + 1
        if grid[i][W - j-1]  == '.':
            R[i][W - j-1] = R[i][W - j-1 + 1] + 1

for j in range(1, W-1):
    for i in range(1, H-1):
        if grid[i][j] == '.':
            U[i][j] = U[i-1][j] + 1
        if grid[H - i-1][j]  == '.':
            D[H - i-1][j] = D[H - i-1 + 1][j] + 1

total = [[0 for _ in range(W)] for _ in range(H)]
for i in range(1, H-1):
    for j in range(1,W-1):
        total[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3

ans = 0
for i in range(1,H-1):
    ans = max(ans, max(total[i]))
print (ans)