Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        for j, k in enumerate(SI()):
            if k == '#':
                S[i, j] = 1
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        l = 0
        r = 0
        for j in range(W):
            if S[i, j] == 1:
                l = 0
            else:
                l += 1
            L[i, j] = l
            if S[i, -1 - j] == 1:
                r = 0
            else:
                r += 1
            R[i, -1 - j] = r
    for j in range(W):
        t = 0
        b = 0
        for i in range(H):
            if S[i, j] == 1:
                t = 0
            else:
                t += 1
            T[i, j] = t
            if S[-1 - i, j] == 1:
                b = 0
            else:
                b += 1
            B[-1 - i, j] = b
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = []
    for i in range(H):
        S.append(list(SI()))
    S = (numpy.array(S) == '.')
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        L[i] = (L[i - 1] + 1) * S[i]
        R[-1 - i] = (R[-i] + 1) * S[-1 - i]
    for i in range(W):
        T[:, i] = (T[:, i - 1] + 1) * S[:, i]
        B[:, -1 - i] = (B[:, -i] + 1) * S[:, -1 - i]
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    H, W = LI()
    hs = [[-1] for _ in range(H)]
    ws = [[-1] for _ in range(W)]
    for h in range(H):
        s = SI()
        for w, ss in enumerate(s):
            if ss == '#':
                hs[h].append(w)
                ws[w].append(h)
    for h in range(H):
        hs[h].append(W)
    for w in range(W):
        ws[w].append(H)
    ah = [[0] * W for _ in range(H)]
    aw = [[0] * H for _ in range(W)]
    for hh, h in enumerate(hs):
        for wi in range(len(h) - 1):
            l, u = h[wi] + 1, h[wi + 1]
            cnt = u - l
            for i in range(l, u):
                ah[hh][i] = cnt
    for ww, w in enumerate(ws):
        for hi in range(len(w) - 1):
            l, u = w[hi] + 1, w[hi + 1]
            cnt = u - l
            for i in range(l, u):
                aw[ww][i] = cnt
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, aw[w][h] + ah[h][w] - 1)
    return ans

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = []
    for i in range(H):
        S.append(list(SI()))
    S = (numpy.array(S) == '.')
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        L[i] = (L[i - 1] + 1) * S[i]
        R[-1 - i] = (R[-i] + 1) * S[-1 - i]
    for i in range(W):
        T[:, i] = (T[:, i - 1] + 1) * S[:, i]
        B[:, -1 - i] = (B[:, -i] + 1) * S[:, -1 - i]
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    H, W = LI()
    hs = [[-1] for _ in range(H)]
    ws = [[-1] for _ in range(W)]
    for h in range(H):
        s = SI()
        for w, ss in enumerate(s):
            if ss == '#':
                hs[h].append(w)
                ws[w].append(h)
    for h in range(H):
        hs[h].append(W)
    for w in range(W):
        ws[w].append(H)
    ans = 0
    for h in range(H):
        for w in range(W):
            i = bisect_left(hs[h], w)
            j = bisect_left(ws[w], h)
            ans = max(ans, hs[h][i] - hs[h][i - 1] + ws[w][j] - ws[w][j - 1] - 3)
    return ans

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
import numpy

def main():
    H, W = LI()
    S = []
    for i in range(H):
        S.append(list(SI()))
    S = (numpy.array(S) == '.')
    L = numpy.zeros((H, W), dtype=int)
    R = numpy.zeros((H, W), dtype=int)
    T = numpy.zeros((H, W), dtype=int)
    B = numpy.zeros((H, W), dtype=int)
    for i in range(H):
        L[i] = (L[i - 1] + 1) * S[i]
        R[-1 - i] = (R[-i] + 1) * S[-1 - i]
    for i in range(W):
        T[:, i] = (T[:, i - 1] + 1) * S[:, i]
        B[:, -1 - i] = (B[:, -i] + 1) * S[:, -1 - i]
    ans = numpy.max(L + R + T + B) - 3
    return ans

print(main())