Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import accumulate
import bisect
import numpy as np
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
H,W = inputs()
meiro = [tuple(input()) for i in range(H)]
#print(meiro)
imosw = [[0]*(W) for _ in range(H)]
imosh = [[0]*(W) for _ in range(H)]
for i in range(H):
    cnt=0
    for j in range(W):
        if meiro[i][j]=="#":
            if cnt!=0:
                imosw[i][j]-=cnt
                imosw[i][j-cnt]+=cnt
            cnt = 0
        else:
            cnt+=1
    if cnt!=0:
    	imosw[i][W-1-cnt+1]+=cnt
for j in range(W):
    cnt= 0
    for i in range(H):
        if meiro[i][j]=="#":
            if cnt!=0:
                imosh[i][j]-=cnt
                imosh[i-cnt][j]+=cnt
            cnt = 0
        else:
            cnt+=1
    if cnt!=0:
    	imosh[H-1-cnt+1][j]+=cnt
imosw = np.cumsum(imosw, axis=1)
imosh = np.cumsum(imosh, axis=0)
ans = np.max(imosw+imosh)-1
print(ans)

Fixed submission:
H, W = map(int, input().split())
meiro = [list(input()) for i in range(H)]
right = [[0 for _ in range(W)] for _ in range(H)]
left= [[0 for _ in range(W)] for _ in range(H)]
up = [[0 for _ in range(W)] for _ in range(H)]
down = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    cur=0
    for j in range(W):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        left[i][j]=cur
for i in range(H):
    cur=0
    for j in range(W-1,-1,-1):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        right[i][j]=cur
for i in range(W):
    cur=0
    for j in range(H):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        up[j][i]=cur
for i in range(W):
    cur=0
    for j in range(H-1,-1,-1):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        down[j][i]=cur
res = 0
for i in range(H):
    for j in range(W):
        res = max(res,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import accumulate
import bisect
import numpy as np
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
H,W = inputs()
meiro = [list(input()) for i in range(H)]
#print(meiro)
imosw = [[0]*(W) for _ in range(H)]
imosh = [[0]*(W) for _ in range(H)]
for i in range(H):
    cnt=0
    for j in range(W):
        if meiro[i][j]=="#":
            if cnt!=0:
                imosw[i][j]-=cnt
                imosw[i][j-cnt]+=cnt
            cnt = 0
        else:
            cnt+=1
    if cnt!=0:
    	imosw[i][W-1-cnt+1]+=cnt
for j in range(W):
    cnt= 0
    for i in range(H):
        if meiro[i][j]=="#":
            if cnt!=0:
                imosh[i][j]-=cnt
                imosh[i-cnt][j]+=cnt
            cnt = 0
        else:
            cnt+=1
    if cnt!=0:
    	imosh[H-1-cnt+1][j]+=cnt
imosw = np.cumsum(imosw, axis=1)
imosh = np.cumsum(imosh, axis=0)
ans = np.max(imosw+imosh)-1
print(ans)


Fixed submission:
H, W = map(int, input().split())
meiro = [list(input()) for i in range(H)]
right = [[0 for _ in range(W)] for _ in range(H)]
left= [[0 for _ in range(W)] for _ in range(H)]
up = [[0 for _ in range(W)] for _ in range(H)]
down = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    cur=0
    for j in range(W):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        left[i][j]=cur
for i in range(H):
    cur=0
    for j in range(W-1,-1,-1):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        right[i][j]=cur
for i in range(W):
    cur=0
    for j in range(H):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        up[j][i]=cur
for i in range(W):
    cur=0
    for j in range(H-1,-1,-1):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        down[j][i]=cur
res = 0
for i in range(H):
    for j in range(W):
        res = max(res,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(res)