Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, W = NMI()
    grid = [input() for _ in range(H)]
    L = make_grid(H, W, 0)
    R = make_grid(H, W, 0)
    U = make_grid(H, W, 0)
    D = make_grid(H, W, 0)

    # left
    for h in range(H):
        for w in range(W):
            if grid[h][w] == "#":
                continue
            elif w == 0:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w-1] + 1

    # right
    for h in range(H):
        for w in range(W-1, -1, -1):
            if grid[h][w] == "#":
                continue
            elif w == W-1:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w+1] + 1

    # up
    for w in range(W):
        for h in range(H):
            if grid[h][w] == "#":
                continue
            elif h == 0:
                U[h][w] = 1
            else:
                U[h][w] = U[h-1][w] + 1

    # down
    for w in range(W):
        for h in range(H-1, -1, -1):
            if grid[h][w] == "#":
                continue
            elif h == H-1:
                D[h][w] = 1
            else:
                D[h][w] = D[h+1][w] + 1

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


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, W = NMI()
    grid = [input() for _ in range(H)]
    L = make_grid(H, W, 0)
    R = make_grid(H, W, 0)
    U = make_grid(H, W, 0)
    D = make_grid(H, W, 0)

    # left
    for h in range(H):
        for w in range(W):
            if grid[h][w] == "#":
                continue
            elif w == 0:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w-1] + 1

    # right
    for h in range(H):
        for w in range(W-1, -1, -1):
            if grid[h][w] == "#":
                continue
            elif w == W-1:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w+1] + 1

    # up
    for w in range(W):
        for h in range(H):
            if grid[h][w] == "#":
                continue
            elif h == 0:
                U[h][w] = 1
            else:
                U[h][w] = U[h-1][w] + 1

    # down
    for w in range(W):
        for h in range(H-1, -1, -1):
            if grid[h][w] == "#":
                continue
            elif h == H-1:
                D[h][w] = 1
            else:
                D[h][w] = D[h+1][w] + 1

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


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H, W = map(int, input().split())
grid = [[] for i in range(H)]
for i in range(H):
    s = input()
    for j in range(W):
        grid[i].append(1 if s[j] == '#' else 0)
#print(grid)
grid = np.array(grid)

def getRowContinue(s):
    num = [0]*len(s)
    cnt = 0
    for i in range(len(s)):
        if s[i] == 1:
            num[i] = 0
            cnt = 0
        else:
            cnt += 1
            num[i] = cnt
            for j in range(cnt):
                num[i - j] = num[i]
    return num

def getColContinue(g):
    num = [[] for _ in range(len(g))]
    for i in range(len(g)):
        for _ in range(len(g[i])):
            num[i].append(0)

    h = len(g)
    w = len(g[0])
    for j in range(w):
        cnt = 0
        for i in range(h):
            if g[i][j] == 1:
                cnt = 0
                num[i][j] = 0
            else:
                cnt += 1
                num[i][j] = cnt
                for k in range(cnt):
                    num[i - k][j] = num[i][j]
    return num


contRow = []
for i in range(H):
    contRow.append(getRowContinue(grid[i]))
contCol = getColContinue(grid)
contRow = np.array(contRow)
contCol = np.array(contCol)
cont = contRow + contCol
#print(cont.flatten())
print(np.max(cont.flatten()) - 1)

Fixed submission:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, W = NMI()
    grid = [input() for _ in range(H)]
    L = make_grid(H, W, 0)
    R = make_grid(H, W, 0)
    U = make_grid(H, W, 0)
    D = make_grid(H, W, 0)

    # left
    for h in range(H):
        for w in range(W):
            if grid[h][w] == "#":
                continue
            elif w == 0:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w-1] + 1

    # right
    for h in range(H):
        for w in range(W-1, -1, -1):
            if grid[h][w] == "#":
                continue
            elif w == W-1:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w+1] + 1

    # up
    for w in range(W):
        for h in range(H):
            if grid[h][w] == "#":
                continue
            elif h == 0:
                U[h][w] = 1
            else:
                U[h][w] = U[h-1][w] + 1

    # down
    for w in range(W):
        for h in range(H-1, -1, -1):
            if grid[h][w] == "#":
                continue
            elif h == H-1:
                D[h][w] = 1
            else:
                D[h][w] = D[h+1][w] + 1

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


if __name__ == "__main__":
    main()