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

yoko = [[0]*W for _ in range(H)]
tate = [[0]*W for _ in range(H)]

def f(l):
    print("\n".join("".join(map(str, row)) for row in l))

for h in range(H):
    if S[h][0] == ".":
        yoko[h][0] = 1
    else:
        yoko[h][0] = 0

for h in range(H):
    for w in range(1, W):
        if S[h][w] == ".":
            yoko[h][w] = yoko[h][w-1]+1
        else:
            yoko[h][w] = 0

for h in range(H):
    for w in range(W-2, -1, -1):
        if S[h][w]=="." and S[h][w+1]==".":
            yoko[h][w] = yoko[h][w+1]

for w in range(W):
    if S[0][w] == ".":
        tate[0][w] = 1
    else:
        tate[0][w] = 0

for w in range(W):
    for h in range(1, H):
        if S[h][w] == ".":
            tate[h][w] = tate[h-1][w]+1
        else:
            tate[h][w] = 0

for w in range(W):
    for h in range(H-2, -1, -1):
        if S[h][w]=="." and S[h+1][w]==".":
            tate[h][w] = tate[h+1][w]

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(yoko[h][w]+tate[h][w]-1, ans)

print(ans)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

yoko = [[0]*W for _ in range(H)]
tate = [[0]*W for _ in range(H)]

def f(l):
    print("\n".join("".join(map(str, row)) for row in l))

for h in range(H):
    if S[h][0] == ".":
        yoko[h][0] = 1
    else:
        yoko[h][0] = 0

for h in range(H):
    for w in range(1, W):
        if S[h][w] == ".":
            yoko[h][w] = yoko[h][w-1]+1
        else:
            yoko[h][w] = 0

for h in range(H):
    for w in range(W-2, -1, -1):
        if S[h][w]=="." and S[h][w+1]==".":
            yoko[h][w] = yoko[h][w+1]

for w in range(W):
    if S[0][w] == ".":
        tate[0][w] = 1
    else:
        tate[0][w] = 0

for w in range(W):
    for h in range(1, H):
        if S[h][w] == ".":
            tate[h][w] = tate[h-1][w]+1
        else:
            tate[h][w] = 0

for w in range(W):
    for h in range(H-2, -1, -1):
        if S[h][w]=="." and S[h+1][w]==".":
            tate[h][w] = tate[h+1][w]

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(yoko[h][w]+tate[h][w]-1, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
b = ["#"*(W+2)]+["#"+input()+"#" for _ in range(H)]+["#"*(W+2)]

ans = 0

for rh in range(1, H+1):
    for rw in range(1, W+1):
        if b[rh][rw] == "#":
            continue

        x = 0

        i = 1
        while True:
            if b[rh-i][rw] == "#":
                x += i-1
                break
            i += 1
        
        i = 1
        while True:
            if b[rh+i][rw] == "#":
                x += i-1
                break
            i += 1
        
        i = 1
        while True:
            if b[rh][rw-i] == "#":
                x += i-1
                break
            i += 1
        
        i = 1
        while True:
            if b[rh][rw+i] == "#":
                x += i-1
                break
            i += 1
        
        ans = max(x, ans)

print(ans+1)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

yoko = [[0]*W for _ in range(H)]
tate = [[0]*W for _ in range(H)]

def f(l):
    print("\n".join("".join(map(str, row)) for row in l))

for h in range(H):
    if S[h][0] == ".":
        yoko[h][0] = 1
    else:
        yoko[h][0] = 0

for h in range(H):
    for w in range(1, W):
        if S[h][w] == ".":
            yoko[h][w] = yoko[h][w-1]+1
        else:
            yoko[h][w] = 0

for h in range(H):
    for w in range(W-2, -1, -1):
        if S[h][w]=="." and S[h][w+1]==".":
            yoko[h][w] = yoko[h][w+1]

for w in range(W):
    if S[0][w] == ".":
        tate[0][w] = 1
    else:
        tate[0][w] = 0

for w in range(W):
    for h in range(1, H):
        if S[h][w] == ".":
            tate[h][w] = tate[h-1][w]+1
        else:
            tate[h][w] = 0

for w in range(W):
    for h in range(H-2, -1, -1):
        if S[h][w]=="." and S[h+1][w]==".":
            tate[h][w] = tate[h+1][w]

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(yoko[h][w]+tate[h][w]-1, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
b = ["#"*(W+2)]+["#"+input()+"#" for _ in range(H)]+["#"*(W+2)]

ans = 0

for rh in range(1, H+1):
    for rw in range(1, W+1):
        if b[rh][rw] == "#":
            continue

        x = 0

        i = 1
        while True:
            if b[rh-i][rw] == "#":
                x += i-1
                break
            i += 1
        
        i = 1
        while True:
            if b[rh+i][rw] == "#":
                x += i-1
                break
            i += 1
        
        i = 1
        while True:
            if b[rh][rw-i] == "#":
                x += i-1
                break
            i += 1
        
        i = 1
        while True:
            if b[rh][rw+i] == "#":
                x += i-1
                break
            i += 1
        
        ans = max(x, ans)

print(ans+1)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

yoko = [[0]*W for _ in range(H)]
tate = [[0]*W for _ in range(H)]

def f(l):
    print("\n".join("".join(map(str, row)) for row in l))

for h in range(H):
    if S[h][0] == ".":
        yoko[h][0] = 1
    else:
        yoko[h][0] = 0

for h in range(H):
    for w in range(1, W):
        if S[h][w] == ".":
            yoko[h][w] = yoko[h][w-1]+1
        else:
            yoko[h][w] = 0

for h in range(H):
    for w in range(W-2, -1, -1):
        if S[h][w]=="." and S[h][w+1]==".":
            yoko[h][w] = yoko[h][w+1]

for w in range(W):
    if S[0][w] == ".":
        tate[0][w] = 1
    else:
        tate[0][w] = 0

for w in range(W):
    for h in range(1, H):
        if S[h][w] == ".":
            tate[h][w] = tate[h-1][w]+1
        else:
            tate[h][w] = 0

for w in range(W):
    for h in range(H-2, -1, -1):
        if S[h][w]=="." and S[h+1][w]==".":
            tate[h][w] = tate[h+1][w]

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(yoko[h][w]+tate[h][w]-1, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int,input().split())
S_ = ["#"]*(W+2)
S = [["#"]+list(input())+["#"] for i in range(H)]
S = [S_] + S + [S_]

L_cnt = [[0]*(W+2) for i in range(H+2)]
R_cnt = [[0]*(W+2) for i in range(H+2)]
U_cnt = [[0]*(W+2) for i in range(H+2)]
D_cnt = [[0]*(W+2) for i in range(H+2)]

for h in range(1,H+1):
    for w in range(W,0,-1):
        if S[h][w] == ".":
            L_cnt[h][w] = L_cnt[h][w+1]+1

for h in range(1,H+1):
    for w in range(1,W+1,1):
        if S[h][w] == ".":
            R_cnt[h][w] = R_cnt[h][w-1]+1

for w in range(1,W+1):
    for h in range(H,0,-1):
        if S[h][w] == ".":
            U_cnt[h][w] = U_cnt[h+1][w]+1

for w in range(1,W+1):
    for h in range(1,H+1,1):
        if S[h][w] == ".":
            D_cnt[h][w] = D_cnt[h-1][w]+1

ans = 0
for h in range(1,H+1):
    for w in range(1,W+1):
        ans = max(ans,L_cnt[h][w]+R_cnt[h][w]+U_cnt[h][w]+D_cnt[h][w])

print(ans-3)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

yoko = [[0]*W for _ in range(H)]
tate = [[0]*W for _ in range(H)]

def f(l):
    print("\n".join("".join(map(str, row)) for row in l))

for h in range(H):
    if S[h][0] == ".":
        yoko[h][0] = 1
    else:
        yoko[h][0] = 0

for h in range(H):
    for w in range(1, W):
        if S[h][w] == ".":
            yoko[h][w] = yoko[h][w-1]+1
        else:
            yoko[h][w] = 0

for h in range(H):
    for w in range(W-2, -1, -1):
        if S[h][w]=="." and S[h][w+1]==".":
            yoko[h][w] = yoko[h][w+1]

for w in range(W):
    if S[0][w] == ".":
        tate[0][w] = 1
    else:
        tate[0][w] = 0

for w in range(W):
    for h in range(1, H):
        if S[h][w] == ".":
            tate[h][w] = tate[h-1][w]+1
        else:
            tate[h][w] = 0

for w in range(W):
    for h in range(H-2, -1, -1):
        if S[h][w]=="." and S[h+1][w]==".":
            tate[h][w] = tate[h+1][w]

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(yoko[h][w]+tate[h][w]-1, ans)

print(ans)

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

h_cnt = [[0]*W for i in range(H)]
w_cnt = [[0]*W for i in range(H)]

cnt = 0
z = []

for h in range(H):
    for w in range(W):
        if S[h][w] == ".":
            cnt += 1
            z.append(w)
        else:
            for i in range(len(z)):
                w_cnt[h][z.pop()] = cnt
            cnt = 0

    if cnt > 0:
        for i in range(len(z)):
            w_cnt[h][z.pop()] = cnt
        cnt = 0


for w in range(W):
    for h in range(H):
        if S[h][w] == ".":
            cnt += 1
            z.append(h)
        else:
            for i in range(len(z)):
                h_cnt[z.pop()][w] = cnt
            cnt = 0

    if cnt > 0:
        for i in range(len(z)):
            h_cnt[z.pop()][w] = cnt
        cnt = 0

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(ans,h_cnt[h][w]+w_cnt[h][w])

print(ans-1)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

yoko = [[0]*W for _ in range(H)]
tate = [[0]*W for _ in range(H)]

def f(l):
    print("\n".join("".join(map(str, row)) for row in l))

for h in range(H):
    if S[h][0] == ".":
        yoko[h][0] = 1
    else:
        yoko[h][0] = 0

for h in range(H):
    for w in range(1, W):
        if S[h][w] == ".":
            yoko[h][w] = yoko[h][w-1]+1
        else:
            yoko[h][w] = 0

for h in range(H):
    for w in range(W-2, -1, -1):
        if S[h][w]=="." and S[h][w+1]==".":
            yoko[h][w] = yoko[h][w+1]

for w in range(W):
    if S[0][w] == ".":
        tate[0][w] = 1
    else:
        tate[0][w] = 0

for w in range(W):
    for h in range(1, H):
        if S[h][w] == ".":
            tate[h][w] = tate[h-1][w]+1
        else:
            tate[h][w] = 0

for w in range(W):
    for h in range(H-2, -1, -1):
        if S[h][w]=="." and S[h+1][w]==".":
            tate[h][w] = tate[h+1][w]

ans = 0

for h in range(H):
    for w in range(W):
        ans = max(yoko[h][w]+tate[h][w]-1, ans)

print(ans)