Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h, w = li()
grid = [lc() for _ in range(h)]

# 左側の照らせるマス
left = [[0]*w for _ in range(h)]
for row in range(h):
    cur = 0
    for col in range(w-1, -1, -1):
        if grid[row][col] == ".":
            cur += 1
            left[row][col] = cur
        else:
            cur = 0

# 右側の照らせるマス
right = [[0]*w for _ in range(h)]
for row in range(h):
    cur = 0
    for col in range(w):
        if grid[row][col] == ".":
            cur += 1
            right[row][col] = cur
        else:
            cur = 0

# 上側の照らせるマス
up = [[0]*w for _ in range(h)]
for col in range(w):
    cur = 0
    for row in range(h-1, -1, -1):
        if grid[row][col] == ".":
            cur += 1
            up[row][col] = cur
        else:
            cur = 0

# 下側の照らせるマス
down = [[0]*w for _ in range(h)]
for col in range(w):
    cur = 0
    for row in range(h):
        if grid[row][col] == ".":
            cur += 1
            down[row][col] = cur
        else:
            cur = 0

# 最大値
ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, left[row][col] + right[row][col] + up[row][col] + down[row][col])

print(ans-3)


Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]


lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if col == 0:
            lr[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue

            else:
                lr[row][col] = lr[row][col-1] + 1

for row in range(h):
    for col in range(w-2, -1, -1):
        if lr[row][col] == 0:
            continue
        else:
            lr[row][col] = max(lr[row][col+1], lr[row][col])

for col in range(w):
    for row in range(h):
        if row == 0:
            tb[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue
            else:
                tb[row][col] = tb[row-1][col] + 1

for col in range(w):
    for row in range(h-2, -1, -1):
        if tb[row][col] == 0:
            continue
        else:
            tb[row][col] = max(tb[row+1][col], tb[row][col])

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(max(0, ans-1))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]

def left_right(grid, row, col, cnt, w):
    if col == w:
        return cnt

    elif grid[row][col] == "#":
        return cnt

    else:
        cnt = left_right(grid, row, col+1, cnt+1, w)

    lr[row][col] = cnt
    return cnt


def top_bottom(grid, row, col, cnt, h):
    if row == h:
        return cnt

    elif grid[row][col] == "#":
        return cnt

    else:
        cnt = top_bottom(grid, row+1, col, cnt+1, h)

    tb[row][col] = cnt
    return cnt

lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if grid[row][col] == "." and lr[row][col] == 0:
            left_right(grid, row, col, 0, w)

for col in range(w):
    for row in range(h):
        if grid[row][col] == "." and tb[row][col] == 0:
            top_bottom(grid, row, col, 0, h)

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(ans-1)

Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]


lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if col == 0:
            lr[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue

            else:
                lr[row][col] = lr[row][col-1] + 1

for row in range(h):
    for col in range(w-2, -1, -1):
        if lr[row][col] == 0:
            continue
        else:
            lr[row][col] = max(lr[row][col+1], lr[row][col])

for col in range(w):
    for row in range(h):
        if row == 0:
            tb[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue
            else:
                tb[row][col] = tb[row-1][col] + 1

for col in range(w):
    for row in range(h-2, -1, -1):
        if tb[row][col] == 0:
            continue
        else:
            tb[row][col] = max(tb[row+1][col], tb[row][col])

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(max(0, ans-1))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]

def left_right(grid, row, col, cnt, w):
    if col == w:
        return cnt

    elif grid[row][col] == "#":
        return cnt

    else:
        cnt = left_right(grid, row, col+1, cnt+1, w)

    lr[row][col] = cnt
    return cnt


def top_bottom(grid, row, col, cnt, h):
    if row == h:
        return cnt

    elif grid[row][col] == "#":
        return cnt

    else:
        cnt = top_bottom(grid, row+1, col, cnt+1, h)

    tb[row][col] = cnt
    return cnt

lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if grid[row][col] == "." and lr[row][col] == 0:
            left_right(grid, row, col, 0, w)

for col in range(w):
    for row in range(h):
        if grid[row][col] == "." and tb[row][col] == 0:
            top_bottom(grid, row, col, 0, h)

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(ans-1)

Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]


lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if col == 0:
            lr[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue

            else:
                lr[row][col] = lr[row][col-1] + 1

for row in range(h):
    for col in range(w-2, -1, -1):
        if lr[row][col] == 0:
            continue
        else:
            lr[row][col] = max(lr[row][col+1], lr[row][col])

for col in range(w):
    for row in range(h):
        if row == 0:
            tb[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue
            else:
                tb[row][col] = tb[row-1][col] + 1

for col in range(w):
    for row in range(h-2, -1, -1):
        if tb[row][col] == 0:
            continue
        else:
            tb[row][col] = max(tb[row+1][col], tb[row][col])

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(max(0, ans-1))

Buggy python submission (verdict: Runtime Error):
h, w = li()
grid = [lc() for _ in range(h)]

def left_right(grid, row, col, cnt, w):
    if col == w:
        return cnt

    elif grid[row][col] == "#":
        return cnt

    else:
        cnt = left_right(grid, row, col+1, cnt+1, w)

    lr[row][col] = cnt
    return cnt


def top_bottom(grid, row, col, cnt, h):
    if row == h:
        return cnt

    elif grid[row][col] == "#":
        return cnt

    else:
        cnt = top_bottom(grid, row+1, col, cnt+1, h)

    tb[row][col] = cnt
    return cnt

lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if grid[row][col] == "." and lr[row][col] == 0:
            left_right(grid, row, col, 0, w)

for col in range(w):
    for row in range(h):
        if grid[row][col] == "." and tb[row][col] == 0:
            top_bottom(grid, row, col, 0, h)

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(ans-1)

Fixed submission:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]


lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if col == 0:
            lr[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue

            else:
                lr[row][col] = lr[row][col-1] + 1

for row in range(h):
    for col in range(w-2, -1, -1):
        if lr[row][col] == 0:
            continue
        else:
            lr[row][col] = max(lr[row][col+1], lr[row][col])

for col in range(w):
    for row in range(h):
        if row == 0:
            tb[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue
            else:
                tb[row][col] = tb[row-1][col] + 1

for col in range(w):
    for row in range(h-2, -1, -1):
        if tb[row][col] == 0:
            continue
        else:
            tb[row][col] = max(tb[row+1][col], tb[row][col])

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(max(0, ans-1))