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


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    T = [[0] * W for _ in range(H)]
    B = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                R[h][w] = 0
            elif w == 0:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h][w] == "#":
                L[h][w] = 0
            elif w == W - 1:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h][w] == "#":
                B[h][w] = 0
            elif h == 0:
                B[h][w] = 1
            else:
                B[h][w] = B[h-1][w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h][w] == "#":
                T[h][w] = 0
            elif h == H - 1:
                T[h][w] = 1
            else:
                T[h][w] = T[h + 1][w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h][w] + L[h][w] + B[h][w] + T[h][w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    T = [[0] * W for _ in range(H)]
    B = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                R[h][w] = 0
            elif w == 0:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h][w] == "#":
                L[h][w] = 0
            elif w == W - 1:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h][w] == "#":
                B[h][w] = 0
            elif h == 0:
                B[h][w] = 1
            else:
                B[h][w] = B[h-1][w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h][w] == "#":
                T[h][w] = 0
            elif h == H - 1:
                T[h][w] = 1
            else:
                T[h][w] = T[h + 1][w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h][w] + L[h][w] + B[h][w] + T[h][w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    s = np.array(s)
    L = np.zeros((H, W))
    R = np.zeros((H, W))
    T = np.zeros((H, W))
    B = np.zeros((H, W))
    for h in range(H):
        for w in range(W):
            if s[h, w] == "#":
                R[h, w] = 0
            elif w == 0:
                R[h, w] = 1
            else:
                R[h, w] = R[h, w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h, w] == "#":
                L[h, w] = 0
            elif w == W - 1:
                L[h, w] = 1
            else:
                L[h, w] = L[h, w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h, w] == "#":
                B[h, w] = 0
            elif h == 0:
                B[h, w] = 1
            else:
                B[h, w] = B[h-1, w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h, w] == "#":
                T[h, w] = 0
            elif h == H - 1:
                T[h, w] = 1
            else:
                T[h, w] = T[h + 1, w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h, w] + L[h, w] + B[h, w] + T[h, w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    T = [[0] * W for _ in range(H)]
    B = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                R[h][w] = 0
            elif w == 0:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h][w] == "#":
                L[h][w] = 0
            elif w == W - 1:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h][w] == "#":
                B[h][w] = 0
            elif h == 0:
                B[h][w] = 1
            else:
                B[h][w] = B[h-1][w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h][w] == "#":
                T[h][w] = 0
            elif h == H - 1:
                T[h][w] = 1
            else:
                T[h][w] = T[h + 1][w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h][w] + L[h][w] + B[h][w] + T[h][w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    s = np.array(s)
    L = np.zeros((H, W))
    R = np.zeros((H, W))
    T = np.zeros((H, W))
    B = np.zeros((H, W))
    for h in range(H):
        for w in range(W):
            if s[h, w] == "#":
                R[h, w] = 0
            elif w == 0:
                R[h, w] = 1
            else:
                R[h, w] = R[h, w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h, w] == "#":
                L[h, w] = 0
            elif w == W - 1:
                L[h, w] = 1
            else:
                L[h, w] = L[h, w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h, w] == "#":
                B[h, w] = 0
            elif h == 0:
                B[h, w] = 1
            else:
                B[h, w] = B[h-1, w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h, w] == "#":
                T[h, w] = 0
            elif h == H - 1:
                T[h, w] = 1
            else:
                T[h, w] = T[h + 1, w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h, w] + L[h, w] + B[h, w] + T[h, w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    T = [[0] * W for _ in range(H)]
    B = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                R[h][w] = 0
            elif w == 0:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h][w] == "#":
                L[h][w] = 0
            elif w == W - 1:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h][w] == "#":
                B[h][w] = 0
            elif h == 0:
                B[h][w] = 1
            else:
                B[h][w] = B[h-1][w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h][w] == "#":
                T[h][w] = 0
            elif h == H - 1:
                T[h][w] = 1
            else:
                T[h][w] = T[h + 1][w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h][w] + L[h][w] + B[h][w] + T[h][w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    s = np.array(s)
    L = np.zeros((H, W))
    R = np.zeros((H, W))
    T = np.zeros((H, W))
    B = np.zeros((H, W))
    for h in range(H):
        for w in range(W):
            cnt = 0
            for v in s[h, w:]:
                if v == "#":
                    break
                cnt += 1
            R[h, w] = cnt
    for h in range(H):
        for w in range(W):
            cnt = 0
            for v in reversed(s[h, :w + 1]):
                if v == "#":
                    break
                cnt += 1
            L[h, w] = cnt
    for h in range(H):
        for w in range(W):
            cnt = 0
            for v in s[h:, w]:
                if v == "#":
                    break
                cnt += 1
            B[h, w] = cnt
    for h in range(H):
        for w in range(W):
            cnt = 0
            for v in reversed(s[:h + 1, w]):
                if v == "#":
                    break
                cnt += 1
            T[h, w] = cnt
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h, w] + L[h, w] + B[h, w] + T[h, w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    T = [[0] * W for _ in range(H)]
    B = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                R[h][w] = 0
            elif w == 0:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w - 1] + 1
    for h in range(H):
        for w in reversed(range(W)):
            if s[h][w] == "#":
                L[h][w] = 0
            elif w == W - 1:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w + 1] + 1
    for w in range(W):
        for h in range(H):
            if s[h][w] == "#":
                B[h][w] = 0
            elif h == 0:
                B[h][w] = 1
            else:
                B[h][w] = B[h-1][w] + 1
    for w in range(W):
        for h in reversed(range(H)):
            if s[h][w] == "#":
                T[h][w] = 0
            elif h == H - 1:
                T[h][w] = 1
            else:
                T[h][w] = T[h + 1][w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            res = R[h][w] + L[h][w] + B[h][w] + T[h][w] - 3
            ans = max(ans, res)
    print(int(ans))


if __name__ == "__main__":
    main()