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

def main():
    N,M = map(int,input().split())
    S = [list(str(input())) for _ in range(N)]
    
    up = [[0 for _ in range(M)] for _ in range(N)]
    down = [[0 for _ in range(M)] for _ in range(N)]
    left = [[0 for _ in range(M)] for _ in range(N)]
    right = [[0 for _ in range(M)] for _ in range(N)]
    
    for i in range(M):
        if S[0][i] == ".":
            up[0][i] = 1
        for j in range(N-1):
            if S[j+1][i] == "#":
                up[j+1][i] = 0
            else:
                up[j+1][i] = up[j][i] + 1

    for i in range(M):
        if S[-1][i] == ".":
            down[-1][i] = 1
        for j in range(N-1):
            if S[-2-j][i] == "#":
                down[-2-j][i] = 0
            else:
                down[-2-j][i] = down[-1-j][i] + 1

    for i in range(N):
        if S[i][0] == ".":
            left[i][0] = 1
        for j in range(M-1):
            if S[i][j+1] == "#":
                left[i][j+1] = 0
            else:
                left[i][j+1] = left[i][j] + 1
    
    for i in range(N):
        if S[i][-1] == ".":
            right[i][-1] = 1
        for j in range(M-1):
            if S[i][-2-j] == "#":
                right[i][-2-j] = 0
            else:
                right[i][-2-j] = right[i][-1-j] + 1
    
    ans = 0
    for i in range(N):
        for j in range(M):
            if S[i][j] == ".":
                num = up[i][j]+down[i][j]+left[i][j]+right[i][j]-3
                ans = max(ans,num)
    
    print(ans)
    
if __name__ == "__main__":
    main()

Fixed submission:
#import sys
#input = sys.stdin.buffer.readline
import numpy as np

def main():
    H,W = map(int,input().split())
    S = np.array([list(input()) for _ in range(H)]) == '.'

    up = np.zeros((H,W), dtype=int)
    down = np.zeros((H,W), dtype=int)
    left = np.zeros((H,W), dtype=int)
    right = np.zeros((H,W), dtype=int)
    
    for i in range(H-1):
        up[i+1,:] = (up[i,:] + 1) * S[i,:]
    for i in range(H-1):
        down[-i-2,:] = (down[-i-1,:] + 1) * S[-i-1,:]
    for i in range(W-1):
        left[:,i+1] = (left[:,i] + 1) * S[:,i]
    for i in range(W-1):
        right[:,-i-2] = (right[:,-i-1] + 1) * S[:,-i-1]
        
    print(((up+down+left+right)*S).max()+1)
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def main():
	H,W = map(int,input().split())
	dis_list1 = []
	dis_list2 = []
	for i in range(H):
		st = input()
		dis_list1.append([0 if i == "#" else 1 for i in list(st)])
		dis_list2.append([0 if i == "#" else 1 for i in list(st)])
	w_list = dis_list1
	h_list = dis_list2
	for i in range(H):
		for j in range(W-1):
			if w_list[i][j+1] != 0:
				w_list[i][j+1] = w_list[i][j]+1
	for i in range(H):
		for j in range(W-1):
			if w_list[i][-j-2] != 0 and w_list[i][-j-1] != 0:
				w_list[i][-j-2] = w_list[i][-j-1]

	for i in range(W):
		for j in range(H-1):
			if h_list[j+1][i] != 0:
				h_list[j+1][i] = h_list[j][i]+1
	for i in range(W):
		for j in range(H-1):
			if h_list[-j-2][i] != 0 and h_list[-j-1][i] != 0:
				h_list[-j-2][i] = h_list[-j-1][i]

	w_list = np.array(w_list)
	h_list = np.array(h_list)

	sum_list = w_list+h_list

	print(sum_list.max()-1)		

if __name__ == "__main__":
	main()

Fixed submission:
#import sys
#input = sys.stdin.buffer.readline
import numpy as np

def main():
    H,W = map(int,input().split())
    S = np.array([list(input()) for _ in range(H)]) == '.'

    up = np.zeros((H,W), dtype=int)
    down = np.zeros((H,W), dtype=int)
    left = np.zeros((H,W), dtype=int)
    right = np.zeros((H,W), dtype=int)
    
    for i in range(H-1):
        up[i+1,:] = (up[i,:] + 1) * S[i,:]
    for i in range(H-1):
        down[-i-2,:] = (down[-i-1,:] + 1) * S[-i-1,:]
    for i in range(W-1):
        left[:,i+1] = (left[:,i] + 1) * S[:,i]
    for i in range(W-1):
        right[:,-i-2] = (right[:,-i-1] + 1) * S[:,-i-1]
        
    print(((up+down+left+right)*S).max()+1)
    
if __name__ == "__main__":
    main()