Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int,input().split())
G = [input() for k in range(H)]
yoko = [[0 for k in range(W)] for k in range(H)]
tate = [[0 for k in range(W)] for k in range(H)]


for h in range(H):
    t = 0
    s = 0
    for w in range(W):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,w):
                    yoko[h][k] = t
            s = w+1
            t = 0
    if t > 0:
        for k in range(s,W):
            yoko[h][k] = t


for w in range(W):
    t = 0
    s = 0
    for h in range(H):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,h):
                    tate[k][w] = t
            s = h+1
            t = 0
    if t > 0:
        for k in range(s,H):
            tate[k][w] = t

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


Fixed submission:
H, W = map(int,input().split())
G = [input() for k in range(H)]
yoko = [[0 for k in range(W)] for k in range(H)]
tate = [[0 for k in range(W)] for k in range(H)]


for h in range(H):
    t = 0
    s = 0
    for w in range(W):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,w):
                    yoko[h][k] = t
            s = w+1
            t = 0
    if t > 0:
        for k in range(s,W):
            yoko[h][k] = t


for w in range(W):
    t = 0
    s = 0
    for h in range(H):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,h):
                    tate[k][w] = t
            s = h+1
            t = 0
    if t > 0:
        for k in range(s,H):
            tate[k][w] = t

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

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

def keisan(h,w):
    k = 0
    while h-k>=0:
        if G[h-k][w] == ".":
            k += 1
        else:
            break
    l = 0
    while h+l<H:
        if G[h+l][w] == ".":
            l += 1
        else:
            break
    m = 0
    while w-m>=0:
        if G[h][w-m] == ".":
            m += 1
        else:
            break
    n = 0
    while w+n < W:
        if G[h][w+n] == ".":
            n += 1
        else:
            break
    return k+l+m+n-3

ans = 0
for h in range(H):
    for w in range(W):
        if G[h][w] == ".":
                ans = max(ans,keisan(h,w))
                if ans == H+W-1:
                    print(ans)
                    exit(0)
print(ans)


Fixed submission:
H, W = map(int,input().split())
G = [input() for k in range(H)]
yoko = [[0 for k in range(W)] for k in range(H)]
tate = [[0 for k in range(W)] for k in range(H)]


for h in range(H):
    t = 0
    s = 0
    for w in range(W):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,w):
                    yoko[h][k] = t
            s = w+1
            t = 0
    if t > 0:
        for k in range(s,W):
            yoko[h][k] = t


for w in range(W):
    t = 0
    s = 0
    for h in range(H):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,h):
                    tate[k][w] = t
            s = h+1
            t = 0
    if t > 0:
        for k in range(s,H):
            tate[k][w] = t

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

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

def keisan(h,w):
    k = 0
    while h-k>=0:
        if G[h-k][w] == ".":
            k += 1
        else:
            break
    l = 0
    while h+l<H:
        if G[h+l][w] == ".":
            l += 1
        else:
            break
    m = 0
    while w-m>=0:
        if G[h][w-m] == ".":
            m += 1
        else:
            break
    n = 0
    while w+n < W:
        if G[h][w+n] == ".":
            n += 1
        else:
            break
    return k+l+m+n-3

ans = 0
for h in range(H):
    for w in range(W):
        if G[h][w] == ".":
                ans = max(ans,keisan(h,w))
print(ans)


Fixed submission:
H, W = map(int,input().split())
G = [input() for k in range(H)]
yoko = [[0 for k in range(W)] for k in range(H)]
tate = [[0 for k in range(W)] for k in range(H)]


for h in range(H):
    t = 0
    s = 0
    for w in range(W):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,w):
                    yoko[h][k] = t
            s = w+1
            t = 0
    if t > 0:
        for k in range(s,W):
            yoko[h][k] = t


for w in range(W):
    t = 0
    s = 0
    for h in range(H):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,h):
                    tate[k][w] = t
            s = h+1
            t = 0
    if t > 0:
        for k in range(s,H):
            tate[k][w] = t

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