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


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

    #L,U
    for i in range(H):
        for j in range(W):
            if S[i][j] != "#":
                if j == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i][j-1] + 1
            
                if i == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i-1][j] + 1

    #R,D
    for i in reversed(range(H)):
        for j in reversed(range(W)):
            if S[i][j] != "#":
                if j == W-1:
                    R[i][j] = 1
                else:
                    R[i][j] = R[i][j+1] + 1
            
                if i == H-1:
                    D[i][j] = 1
                else:
                    D[i][j] = D[i+1][j] + 1

        
    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                continue

            tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
            ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
h,w = map(int, input().split())

grid = [input() for i 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 grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)

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


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

#L,U
for i in range(H):
    for j in range(W):
        if S[i][j] != "#":
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#R,D
for i in reversed(range(H)):
    for j in reversed(range(W)):
        if S[i][j] != "#":
            if j == W-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
        
            if i == H-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

    
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue

        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)

Fixed submission:
h,w = map(int, input().split())

grid = [input() for i 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 grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int, input().split())

grid = [input() for i 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 grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)

Fixed submission:
h,w = map(int, input().split())

grid = [input() for i 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 grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int, input().split())
S = [""] * (h+2)
s = "#"*(w+2)
S[0] = s
for i in range(1, h+1):
    s = input()
    S[i] = "#" + s + "#"

S[h+1] = "#"*(w+2)
ans = 0
for i in range((h)):
    for j in range((w)):
        cnt = 1
        if S[i+1][j+1] == ".":
        
            #ue
            idx = 1
            while S[i+1-idx][j+1] != "#":
                cnt += 1
                idx += 1
            #sita
            idx = 1
            while S[i+1+idx][j+1] != "#":
                cnt += 1
                idx += 1

            #hidari
            idx = 1
            while S[i+1][j+1-idx] != "#":
                cnt += 1
                idx += 1
            #migi
            idx = 1
            while S[i+1][j+1+idx] != "#":
                cnt += 1
                idx += 1

        ans = max(ans, cnt)

print(ans)

Fixed submission:
h,w = map(int, input().split())

grid = [input() for i 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 grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)