Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int, input().split())
Data = [[[0,0,0,0] for i in range(w)] for j in range(h)]
S = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                Data[i][j][0] = Data[i][j-1][0] + 1
            else:
                Data[i][j][0] = 1
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                Data[i][j][1] = Data[i][j+1][1] + 1
            else:
                Data[i][j][1] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                Data[j][i][2] = Data[j-1][i][2] + 1
            else:
                Data[j][i][2] = 1
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                Data[j][i][3] = Data[j+1][i][3] + 1
            else:
                Data[j][i][3] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(sum(Data[i][j])-3,ans)
print(ans)

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

for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                L[i][j] = L[i][j-1] + 1
            else:
                L[i][j] = 1
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                R[i][j] = R[i][j+1] + 1
            else:
                R[i][j] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                D[j][i] = D[j-1][i] + 1
            else:
                D[j][i] = 1
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                U[j][i] = U[j+1][i] + 1
            else:
                U[j][i] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int, input().split())
Data = [[[0,0,0,0] for i in range(w)] for j in range(h)]
S = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                Data[i][j][0] = Data[i][j-1][0] + 1
            else:
                Data[i][j][0] = 1
for i in range(h):
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                Data[i][j][1] = Data[i][j+1][1] + 1
            else:
                Data[i][j][1] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                Data[j][i][2] = Data[j-1][i][2] + 1
            else:
                Data[j][i][2] = 1
for i in range(w):
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                Data[j][i][3] = Data[j+1][i][3] + 1
            else:
                Data[j][i][3] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(sum(Data[i][j])-3,ans)
print(ans)

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

for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                L[i][j] = L[i][j-1] + 1
            else:
                L[i][j] = 1
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                R[i][j] = R[i][j+1] + 1
            else:
                R[i][j] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                D[j][i] = D[j-1][i] + 1
            else:
                D[j][i] = 1
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                U[j][i] = U[j+1][i] + 1
            else:
                U[j][i] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int, input().split())
Data = [[[0,0,0,0] for i in range(w)] for j in range(h)]
S = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                Data[i][j][0] = Data[i][j-1][0] + 1
            else:
                Data[i][j][0] = 1
for i in range(h):
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                Data[i][j][1] = Data[i][j+1][1] + 1
            else:
                Data[i][j][1] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                Data[j][i][2] = Data[j-1][i][2] + 1
            else:
                Data[j][i][2] = 1
for i in range(w):
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                Data[j][i][3] = Data[j+1][i][3] + 1
            else:
                Data[j][i][3] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(sum(Data[i][j])-3,ans)
print(ans)

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

for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            if j > 0:
                L[i][j] = L[i][j-1] + 1
            else:
                L[i][j] = 1
    for j in range(w-1,-1,-1):
        if S[i][j] == ".":
            if j < w-1:
                R[i][j] = R[i][j+1] + 1
            else:
                R[i][j] = 1
for i in range(w):
    for j in range(h):
        if S[j][i] == ".":
            if j > 0:
                D[j][i] = D[j-1][i] + 1
            else:
                D[j][i] = 1
    for j in range(h-1,-1,-1):
        if S[j][i] == ".":
            if j < h-1:
                U[j][i] = U[j+1][i] + 1
            else:
                U[j][i] = 1
ans = 0
for i in range(h):
    for j in range(w):
       ans = max(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3,ans)
print(ans)