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

G = []
for _ in range(H):
    g = []
    line = input()
    for i in range(W):
        g.append(line[i])
    G.append(g)

# 左に何マス行けるか
G_left = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W):
        if G[h][w] == "#":
            cnt = 0
            G_left[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_left[h][w] = cnt
# print(G_left)

# 右に何マス行けるか
G_right = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_right[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_right[h][w] = cnt
# print(G_right)

# 上に何マス行けるか
G_up = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H):
        if G[h][w] == "#":
            cnt = 0
            G_up[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_up[h][w] = cnt
# print(G_up)

# 下に何マス行けるか
G_down = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_down[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_down[h][w] = cnt
# print(G_down)
ans = 0
for h in range(H):
    for w in range(W):
        tmp = G_left[h][w] + G_right[h][w] + G_up[h][w] + G_down[h][w] - 3
        ans = max(ans, tmp)

print(ans)


Fixed submission:
H, W = map(int, input().split())

grid = []
for _ in range(H):
    line = input()
    # 後で都合が良いので末尾に足しておく
    line += "#"
    grid.append(line)

# 後で都合が良いので末尾に足しておく
grid.append("#" * W)
# print(grid)

G_h = []
for h in range(H):
    g = [-1] * W
    lamp_start = -1
    lamp = 0
    line = grid[h]
    for w in range(W):
        if line[w] == "#":
            g[w] = 0
        elif line[w] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = w
                # print("lampstart", w)
            if line[w + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, w + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_h.append(g)

# print(G_h)

G_v = []
for w in range(W):
    g = [-1] * H
    lamp_start = -1
    lamp = 0
    line = []
    for hi in range(H):
        line.append(grid[hi][w])
    line.append("#")
    # line = grid[w]
    for h in range(H):
        if line[h] == "#":
            g[h] = 0
        elif line[h] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = h
                # print("lampstart", w)
            if line[h + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, h + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_v.append(g)

# print(G_v)

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

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

grid = []
for _ in range(H):
    line = input()
    # 後で都合が良いので末尾に足しておく
    line += "#"
    grid.append(line)

# 後で都合が良いので末尾に足しておく
grid.append("#" * W)
# print(grid)

G_h = []
for h in range(H):
    g = [-1] * W
    lamp_start = -1
    lamp = 0
    line = grid[h]
    for w in range(W):
        if line[w] == "#":
            g[w] = 0
        elif line[w] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = w
                # print("lampstart", w)
            if line[w + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, w + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_h.append(g)

# print(G_h)

G_v = []
for w in range(W):
    g = [-1] * H
    lamp_start = -1
    lamp = 0
    line = []
    for hi in range(H):
        line.append(grid[hi][w])
    line.append("#")
    # line = grid[w]
    for h in range(H):
        if line[h] == "#":
            g[h] = 0
        elif line[h] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = h
                # print("lampstart", w)
            if line[h + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, h + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_v.append(g)

# print(G_v)

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


Fixed submission:
H, W = map(int, input().split())

grid = []
for _ in range(H):
    line = input()
    # 後で都合が良いので末尾に足しておく
    line += "#"
    grid.append(line)

# 後で都合が良いので末尾に足しておく
grid.append("#" * W)
# print(grid)

G_h = []
for h in range(H):
    g = [-1] * W
    lamp_start = -1
    lamp = 0
    line = grid[h]
    for w in range(W):
        if line[w] == "#":
            g[w] = 0
        elif line[w] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = w
                # print("lampstart", w)
            if line[w + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, w + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_h.append(g)

# print(G_h)

G_v = []
for w in range(W):
    g = [-1] * H
    lamp_start = -1
    lamp = 0
    line = []
    for hi in range(H):
        line.append(grid[hi][w])
    line.append("#")
    # line = grid[w]
    for h in range(H):
        if line[h] == "#":
            g[h] = 0
        elif line[h] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = h
                # print("lampstart", w)
            if line[h + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, h + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_v.append(g)

# print(G_v)

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