Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
lst = [input() for _ in range(h)]

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]

for i in range(h):
    cnt_L = 1
    for j in range(w):
        if (lst[i][j] == '#'):
            cnt_L =1
        else:
            L[i][j] = cnt_L
            cnt_L += 1
            
    cnt_R = 1
    for k in range(w)[::-1]:
        if (lst[i][k] == '#'):
            cnt_R = 1
        else:
            R[i][k] = cnt_R
            cnt_R += 1

for i in range(w):
    cnt_U = 1
    for j in range(h):
        if (lst[j][i] == '#'):
            cnt_U = 1
        else:
            U[j][i] = cnt_U
            cnt_U += 1
    
    cnt_D = 1
    for k in range(h)[::-1]:
        if (lst[k][i] == '#'):
            cnt_D = 1
        else:
            D[k][i] = cnt_D
            cnt_D += 1

ans = 0
for i in range(h):
    for j in range(w):
        tmp = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        if tmp > ans:
            ans = tmp
print(ans)

Fixed submission:
h,w = map(int,input().split())
lst = [input() for _ in range(h)]

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]

for i in range(h):
    cnt_L = 1
    for j in range(w):
        if (lst[i][j] == '#'):
            cnt_L =1
        else:
            L[i][j] = cnt_L
            cnt_L += 1
            
    cnt_R = 1
    for k in range(w)[::-1]:
        if (lst[i][k] == '#'):
            cnt_R = 1
        else:
            R[i][k] = cnt_R
            cnt_R += 1

for i in range(w):
    cnt_U = 1
    for j in range(h):
        if (lst[j][i] == '#'):
            cnt_U = 1
        else:
            U[j][i] = cnt_U
            cnt_U += 1
    
    cnt_D = 1
    for k in range(h)[::-1]:
        if (lst[k][i] == '#'):
            cnt_D = 1
        else:
            D[k][i] = cnt_D
            cnt_D += 1

ans = 0
for i in range(h):
    for j in range(w):
        tmp = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        if tmp > ans:
            ans = tmp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
lst = [input() for _ in range(h)]

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]

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

for i in range(h):
    cnt = 1
    for j in range(w)[::-1]:
        if (lst[i][j] == '#'):
            cnt =1
        else:
            R[i][j] = cnt
            cnt += 1

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

for i in range(w):
    cnt = 1
    for j in range(h)[::-1]:
        if (lst[j][i] == '#'):
            cnt = 1
        else:
            D[j][i] = cnt
            cnt += 1

ans = 0
for i in range(h):
    for j in range(w):
        tmp = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        if tmp > ans:
            ans = tmp
print(ans)

Fixed submission:
h,w = map(int,input().split())
lst = [input() for _ in range(h)]

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]

for i in range(h):
    cnt_L = 1
    for j in range(w):
        if (lst[i][j] == '#'):
            cnt_L =1
        else:
            L[i][j] = cnt_L
            cnt_L += 1
            
    cnt_R = 1
    for k in range(w)[::-1]:
        if (lst[i][k] == '#'):
            cnt_R = 1
        else:
            R[i][k] = cnt_R
            cnt_R += 1

for i in range(w):
    cnt_U = 1
    for j in range(h):
        if (lst[j][i] == '#'):
            cnt_U = 1
        else:
            U[j][i] = cnt_U
            cnt_U += 1
    
    cnt_D = 1
    for k in range(h)[::-1]:
        if (lst[k][i] == '#'):
            cnt_D = 1
        else:
            D[k][i] = cnt_D
            cnt_D += 1

ans = 0
for i in range(h):
    for j in range(w):
        tmp = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        if tmp > ans:
            ans = tmp
print(ans)