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

def main():
    H, W = map(int , readline().split())
    A = np.zeros((H+1, W+1), np.int64)
    A[:H, :] = (np.frombuffer(read(H*(W+1)), 'B') == ord('.')).reshape((H, W+1))
    for j in range(H):
        prev = 0
        start = 0
        for i in range(W+1):
            if A[j, i] > 0:
                if prev == 0:
                    start = i 
                    prev = 1
            else:
                if prev == 1:
                    n = i - start
                    for k in range(start, i):
                        A[j, k] = n
                    prev = 0 
    

    for i in range(W):
        prev = 0
        start = 0
        for j in range(H+1):
            if A[j, i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    n = j - start - 1
                    for k in range(start, j):
                        A[k, i] += n
                    prev = 0

    print(A.max())
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
def main():
    H, W = map(int , readline().split())
    A = []
    for i in range(H):
        A.append([1 if i == ord('.') else 0 for i in readline()])
    A.append([0 for _ in range(W+1)])

    for j in range(H):
        prev = 0
        start = 0
        for i in range(W+1):
            if A[j][i] > 0:
                if prev == 0:
                    start = i 
                    prev = 1
            else:
                if prev == 1:
                    n = i - start
                    for k in range(start, i):
                        A[j][k] = n
                    prev = 0 
    
    ans = 0
    for i in range(W):
        prev = 0
        start = 0
        for j in range(H+1):
            if A[j][i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    n = j - start - 1
                    for k in range(start, j):
                        A[k][i]+= n
                        ans = max(ans, A[k][i])
                    prev = 0
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
def main():
    H, W = map(int , readline().split())
    A = np.array([1 if i == ord('.') else 0 for i in read()], np.int16).reshape(H, W+1)
    A = np.vstack((A, np.zeros(W+1, np.int16)))

    for j in range(H):
        prev = 0
        start = 0
        for i in range(W+1):
            if A[j, i] > 0:
                if prev == 0:
                    start = i 
                    prev = 1
            else:
                if prev == 1:
                    n = i - start
                    for k in range(start, i):
                        A[j, k] = n
                    prev = 0 
    

    for i in range(W):
        prev = 0
        start = 0
        for j in range(H+1):
            if A[j, i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    n = j - start - 1
                    for k in range(start, j):
                        A[k, i] += n
                    prev = 0

    print(A.max())
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
def main():
    H, W = map(int , readline().split())
    A = np.array([1 if i == ord('.') else 0 for i in read()], np.int16).reshape(H, W+1)
    A = np.vstack((A, np.zeros(W+1, np.int16)))
    row = np.zeros((H+1, W+1), np.int16)
    clumn = np.copy(row)

    for j in range(H):
        prev = 0
        start = 0
        for i in range(W+1):
            if A[j, i] == 1:
                if prev == 0:
                    start = i 
                    prev = 1
            else:
                if prev == 1:
                    n = i - start
                    for k in range(start, i):
                        row[j, k] = n
                    prev = 0 
    

    for i in range(W):
        prev = 0
        start = 0
        for j in range(H+1):
            if A[j, i] == 1:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    n = j - start
                    for k in range(start, j):
                        clumn[k, i] = n
                    prev = 0

    print((row+clumn).max()-1)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
def main():
    H, W = map(int , readline().split())
    A = np.array([1 if i == ord('.') else 0 for i in read()], np.int16).reshape(H, W+1)
    A = np.vstack((A, np.zeros(W+1, np.int16)))
    row = np.zeros((H+1, W+1), np.int16)
    clumn = np.copy(row)

    for j in range(H):
        prev = 0
        start = 0
        for i in range(W+1):
            if A[j, i] == 1:
                if prev == 0:
                    start = i 
                    prev = 1
            else:
                if prev == 1:
                    n = i - start
                    for k in range(start, i):
                        row[j, k] = n
                    prev = 0 
    

    for i in range(W):
        prev = 0
        start = 0
        for j in range(H+1):
            if A[j, i] == 1:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    n = j - start
                    for k in range(start, j):
                        clumn[k, i] = n
                    prev = 0

    print((row+clumn).max()-1)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

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



def main():
    H, W = map(int, readline().split())
    g = []
    for _ in range(H):
        s = readline().rstrip().decode()
        g.append(s)

    def rowBeam(si, sj):
        cnt1 = 0
        cnt2 = 0
        for dj in range(W):
            x = sj+dj
            if x>=W:
                break
            if g[si][x] == '#':
                break
            cnt1 += 1
        for dj in range(W):
            x = sj-dj
            if x<0:
                break
            if g[si][x] == '#':
                break
            cnt2 += 1
        return cnt1+cnt2-1


    def clumnBeam(si, sj):
        cnt1 = 0
        cnt2 = 0
        for di in range(H):
            x = si+di
            if x>=H:
                break
            if g[x][sj] == '#':
                break
            cnt1 += 1
        for di in range(H):
            x = si-di
            if x<0:
                break
            if g[x][sj] == '#':
                break
            cnt2 += 1
        return cnt1+cnt2-1

    ans = 0
    for si in range(H):
        for sj in range(W):
            if g[si][sj] == '#':
                continue
            tmp = rowBeam(si, sj) + clumnBeam(si, sj)
            ans = max(ans, tmp)
    print(ans-1)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

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



def main():
    H, W = map(int, readline().split())
    g = []
    for _ in range(H):
        s = readline().rstrip().decode()
        g.append(s)

    def rowBeam(si, sj):
        cnt1 = 0
        cnt2 = 0
        for dj in range(W):
            x = sj+dj
            if x>=W:
                break
            if g[si][x] == '#':
                break
            cnt1 += 1
        for dj in range(W):
            x = sj-dj
            if x<0:
                break
            if g[si][x] == '#':
                break
            cnt2 += 1
        return cnt1+cnt2-1


    def clumnBeam(si, sj):
        cnt1 = 0
        cnt2 = 0
        for di in range(H):
            x = si+di
            if x>=H:
                break
            if g[x][sj] == '#':
                break
            cnt1 += 1
        for di in range(H):
            x = si-di
            if x<0:
                break
            if g[x][sj] == '#':
                break
            cnt2 += 1
        return cnt1+cnt2-1

    ans = 0
    for si in range(H):
        for sj in range(W):
            if g[si][sj] == '#':
                continue
            tmp = rowBeam(si, sj) + clumnBeam(si, sj)
            ans = max(ans, tmp)
    print(ans-1)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

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



def main():
    H, W = map(int, readline().split())
    g = []
    for _ in range(H):
        s = readline().rstrip().decode()
        g.append(s)

    def rowBeam(si, sj):
        cnt1 = 0
        cnt2 = 0
        for dj in range(W):
            x = sj+dj
            if x>=W:
                break
            if g[si][x] == '#':
                break
            cnt1 += 1
        for dj in range(W):
            x = sj-dj
            if x<0:
                break
            if g[si][x] == '#':
                break
            cnt2 += 1
        return cnt1+cnt2-1


    def clumnBeam(si, sj):
        cnt1 = 0
        cnt2 = 0
        for di in range(H):
            x = si+di
            if x>=H:
                break
            if g[x][sj] == '#':
                break
            cnt1 += 1
        for di in range(H):
            x = si-di
            if x<0:
                break
            if g[x][sj] == '#':
                break
            cnt2 += 1
        return cnt1+cnt2-1

    ans = 0
    for si in range(H):
        for sj in range(W):
            if g[si][sj] == '#':
                continue
            tmp = rowBeam(si, sj) + clumnBeam(si, sj)
            ans = max(ans, tmp)
    print(ans-1)
if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#python3

def main():
    h, w = map(int, input().split())
    ss = []
    for _ in range(h):
        s = input()
        ss.append(s)

    sumv = [[0 for _ in range(w)] for _ in range(h)]
    #横方向について連続で何マス続くかを求める
    for i in range(h):
        #doneは連続何マス続くかをすでに求めたかどうかを保持するリスト　
        done = [0 for _ in range(w)]
        for j in range(w):
            #i,jはぞれぞれ縦と横のマスの位置を表すインデックス
            if ss[i][j] == '#':
                continue
            if done[j] == 1:
                continue
            #seqは横に何マス続くかを記録する変数
            seq = 0
            while j + seq < w:
                if ss[i][j+seq] == '#':
                    break
                seq = seq + 1
            #ss[i][j]からss[i][j+seq]までのマスは連続してseqマスである
            for k in range(seq):
                sumv[i][j+k] = sumv[i][j+k] + seq
                #連続するマスが求め終わったマスを記録する
                done[j+k] = 1
    
    #縦方向について同様に
    for j in range(w):
        done = [0 for _ in range(h)]
        for i in range(h):
            if ss[i][j] == '#':
                continue
            if done[i] == 1:
                continue
            seq = 0
            while i + seq < h:
                if ss[i+seq][j] == '#':
                    break
                seq = seq + 1
            for k in range(seq):
                sumv[i+k][j] = sumv[i+k][j] +  seq
                done[i+k] = 1

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, sumv[i][j]-1)            
    print(ans)
main()




Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#python3

def main():
    h, w = map(int, input().split())
    ss = []
    for _ in range(h):
        s = input()
        ss.append(s)

    sumv = [[0 for _ in range(w)] for _ in range(h)]
    #横方向について連続で何マス続くかを求める
    for i in range(h):
        #doneは連続何マス続くかをすでに求めたかどうかを保持するリスト　
        done = [0 for _ in range(w)]
        for j in range(w):
            #i,jはぞれぞれ縦と横のマスの位置を表すインデックス
            if ss[i][j] == '#':
                continue
            if done[j] == 1:
                continue
            #seqは横に何マス続くかを記録する変数
            seq = 0
            while j + seq < w:
                if ss[i][j+seq] == '#':
                    break
                seq = seq + 1
            #ss[i][j]からss[i][j+seq]までのマスは連続してseqマスである
            for k in range(seq):
                sumv[i][j+k] += seq
                #連続するマスが求め終わったマスを記録する
                done[j+k] = 1
    
    #縦方向について同様に
    for j in range(w):
        done = [0 for _ in range(h)]
        for i in range(h):
            if ss[i][j] == '#':
                continue
            if done[i] == 1:
                continue
            seq = 0
            while i + seq < h:
                if ss[i+seq][j] == '#':
                    break
                seq = seq + 1
            for k in range(seq):
                sumv[i+k][j] += seq
                done[i+k] = 1

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, sumv[i][j]-1)            
    print(ans)
main()




Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#python3

def main():
    h, w = map(int, input().split())
    ss = []
    for _ in range(h):
        s = input()
        ss.append(s)

    sumh = [[0 for _ in range(w)] for _ in range(h)]
    #横方向について連続で何マス続くかを求める
    for i in range(h):
        for j in range(w):
            #i,jはぞれぞれ縦と横のマスの位置を表すインデックス
            #doneは連続何マス続くかをすでに求めたかどうかを保持するリスト　
            done = [0 for _ in range(w)]
            if ss[i][j] == '#':
                continue
            if done[j] == 1:
                continue
            #seqは横に何マス続くかを記録する変数
            seq = 0
            while j + seq < w:
                if ss[i][j+seq] == '#':
                    break
                seq = seq + 1
            #ss[i][j]からss[i][j+seq]までのマスは連続してseqマスである
            for k in range(seq):
                if sumh[i][j+k] != 0:
                    continue
                sumh[i][j+k] += seq
                #連続するマスが求め終わったマスを記録する
                done[j+k] = 1
    
    #縦方向について同様に
    sumv = [[0 for _ in range(w)] for _ in range(h)]
    for j in range(w):
            for i in range(h):
                done = [0 for _ in range(h)]
                if ss[i][j] == '#':
                    continue
                if done[i] == 1:
                    continue
                seq = 0
                while i + seq < h:
                    if ss[i+seq][j] == '#':
                        break
                    seq = seq + 1
                for k in range(seq):
                    if sumv[i+k][j] != 0:
                        continue
                    sumv[i+k][j] += seq
                    done[i+k] = 1

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, sumh[i][j]+sumv[i][j]-1)            
    print(ans)
main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#python3

def main():
    h, w = map(int, input().split())
    ss = []
    for _ in range(h):
        s = input()
        ss.append(s)

    sumh = [[0 for _ in range(w)] for _ in range(h)]
    #横方向について連続で何マス続くかを求める
    for i in range(h):
        for j in range(w):
            #i,jはぞれぞれ縦と横のマスの位置を表すインデックス
            #doneは連続何マス続くかをすでに求めたかどうかを保持するリスト　
            done = [0 for _ in range(w)]
            if ss[i][j] == '#':
                continue
            if done[j] == 1:
                continue
            #seqは横に何マス続くかを記録する変数
            seq = 0
            while j + seq < w:
                if ss[i][j+seq] == '#':
                    break
                seq = seq + 1
            #ss[i][j]からss[i][j+seq]までのマスは連続してseqマスである
            for k in range(seq):
                if sumh[i][j+k] != 0:
                    continue
                sumh[i][j+k] += seq
                #連続するマスが求め終わったマスを記録する
                done[j+k] = 1
    
    #縦方向について同様に
    sumv = [[0 for _ in range(w)] for _ in range(h)]
    for j in range(w):
            for i in range(h):
                done = [0 for _ in range(h)]
                if ss[i][j] == '#':
                    continue
                if done[i] == 1:
                    continue
                seq = 0
                while i + seq < h:
                    if ss[i+seq][j] == '#':
                        break
                    seq = seq + 1
                for k in range(seq):
                    if sumv[i+k][j] != 0:
                        continue
                    sumv[i+k][j] += seq
                    done[i+k] = 1

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, sumh[i][j]+sumv[i][j]-1)            
    print(ans)
main()




Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
import itertools as it
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()