Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = np.ones((H, W))
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for i in range(H):
        for j in range(1, W):
            if S[i][j]:
                L[i][j] = L[i][j-1] + 1
            if S[i][W-j-1]:
                R[i][W-j-1] = R[i][W-j] + 1

    for j in range(W):
        for i in range(1, H):
            if S[i][j]:
                U[i][j] = U[i-1][j] + 1
            if S[H-i-1][j]:
                D[H-i-1][j] = D[H-i][j] + 1

    ans = int(np.max(L+R+U+D)) - 3
    print(ans)


main()


Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = np.ones((H, W), dtype=int)
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for j in range(1, W):
        L[:, j] = (L[:, j-1] + 1)*S[:, j]
        R[:, W-j-1] = (R[:, W-j] + 1) * S[:, W-j-1]

    for i in range(1, H):
        U[i][:] = (U[i-1][:] + 1)*S[i][:]
        D[H-i-1][:] = (D[H-i][:] + 1)*S[H-i-1][:]

    ans = (L+R+U+D).max() - 3
    print(ans)


main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = [0 for _ in range(H)]
    A = [[[-1, -1] for _ in range(W)] for _ in range(H)]
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i] |= 1 << j
    ans = 1
    tate = 0
    yoko = 0
    for i in range(H):
        yoko = 0
        for j in range(W):
            if (S[i] >> j) & 1:
                yoko = 0
                continue
            if yoko == 0:
                for k in range(j+1, W):
                    if (S[i] >> k) & 1:
                        break
                    yoko += 1
                for k in range(j+1, W):
                    if (S[i] >> k) & 1:
                        break
                    A[i][k][0] = yoko
                A[i][j][0] = yoko
            tate = 0
            if A[i][j][1] == -1:
                for k in range(i+1, H):
                    if (S[k] >> j) & 1:
                        break
                    tate += 1
                for k in range(i+1, H):
                    if (S[k] >> j) & 1:
                        break
                    A[k][j][1] = tate
                A[i][j][1] = tate
            ans = max(ans, sum(A[i][j]) + 1)
    print(ans)


main()

Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = np.ones((H, W), dtype=int)
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for j in range(1, W):
        L[:, j] = (L[:, j-1] + 1)*S[:, j]
        R[:, W-j-1] = (R[:, W-j] + 1) * S[:, W-j-1]

    for i in range(1, H):
        U[i][:] = (U[i-1][:] + 1)*S[i][:]
        D[H-i-1][:] = (D[H-i][:] + 1)*S[H-i-1][:]

    ans = (L+R+U+D).max() - 3
    print(ans)


main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = [0 for _ in range(H)]
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i] |= 1 << j
    ans = 1
    tate = 0
    yoko = 0
    for i in range(H):
        yoko = 0
        for j in range(W):
            if (S[i] >> j) & 1:
                yoko = 0
                continue
            if yoko == 0:
                for k in range(j+1, W):
                    if (S[i] >> k) & 1:
                        break
                    yoko += 1
            tate = 0
            for k in range(i+1, H):
                if (S[k] >> j) & 1:
                    break
                tate += 1
            for k in range(i-1, -1, -1):
                if (S[k] >> j) & 1:
                    break
                tate += 1
            ans = max(ans, tate + yoko + 1)
    print(ans)


main()


Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = np.ones((H, W), dtype=int)
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for j in range(1, W):
        L[:, j] = (L[:, j-1] + 1)*S[:, j]
        R[:, W-j-1] = (R[:, W-j] + 1) * S[:, W-j-1]

    for i in range(1, H):
        U[i][:] = (U[i-1][:] + 1)*S[i][:]
        D[H-i-1][:] = (D[H-i][:] + 1)*S[H-i-1][:]

    ans = (L+R+U+D).max() - 3
    print(ans)


main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = [0 for _ in range(H)]
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i] |= 1 << j
    ans = 1
    now = 1
    for i in range(H):
        for j in range(W):
            now = 1
            if (S[i] >> j) & 1:
                continue
            for k in range(j+1, W):
                if (S[i] >> k) & 1:
                    break
                now += 1
            for k in range(j-1, -1, -1):
                if (S[i] >> k) & 1:
                    break
                now += 1
            for k in range(i+1, H):
                if (S[k] >> j) & 1:
                    break
                now += 1
            for k in range(i-1, -1, -1):
                if (S[k] >> j) & 1:
                    break
                now += 1
            ans = max(ans, now)
    print(ans)


main()


Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = np.ones((H, W), dtype=int)
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for j in range(1, W):
        L[:, j] = (L[:, j-1] + 1)*S[:, j]
        R[:, W-j-1] = (R[:, W-j] + 1) * S[:, W-j-1]

    for i in range(1, H):
        U[i][:] = (U[i-1][:] + 1)*S[i][:]
        D[H-i-1][:] = (D[H-i][:] + 1)*S[H-i-1][:]

    ans = (L+R+U+D).max() - 3
    print(ans)


main()