Buggy python submission (verdict: Time Limit Exceeded):
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W=map(int,input().split())
S=[0]*H
for i in range(H):
    S[i]=list(input())


MAP=[[[0,0,0,0] for i in range(W)]for i in range(H)]
MAX=0
#ue

for i in range(W):
    c=0
    d=0
    for j in range(H):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0
        if(S[H-j-1][W-i-1]=="."):
            d+=1
            MAP[H-j-1][W-i-1][0]+=d
        else:
            d=0

#hidari
for j in range(H):
    c=0
    d=0
    for i in range(W):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
            MAX=max(MAX,MAP[j][i][0]-3)
        else:
            c=0
        if(S[H-j-1][W-i-1]=="."):
            d+=1
            MAP[H-j-1][W-i-1][0]+=d
            MAX=max(MAX,MAP[H-j-1][W-i-1][0]-3)
        else:
            d=0

print(MAX)

Fixed submission:
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W=map(int,input().split())
S=[0]*H
for i in range(H):
    S[i]=list(input())


MAP=[[[0,0,0,0] for i in range(W)]for i in range(H)]
MAX=0
#ue

for i in range(W):
    c=0
    d=0
    for j in range(H):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0
        if(S[H-j-1][W-i-1]=="."):
            d+=1
            MAP[H-j-1][W-i-1][0]+=d
        else:
            d=0

#hidari
for j in range(H):
    c=0
    d=0
    for i in range(W):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
            MAX=max(MAX,MAP[j][i][0]-3)
        else:
            c=0
        if(S[H-j-1][W-i-1]=="."):
            d+=1
            MAP[H-j-1][W-i-1][0]+=d
            MAX=max(MAX,MAP[H-j-1][W-i-1][0]-3)
        else:
            d=0

print(MAX)

Fixed submission:
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W=map(int,input().split())
S=[0]*H
for i in range(H):
    S[i]=list(input())


MAP=[[[0,0,0,0] for i in range(W)]for i in range(H)]
#MAP[H][W]

#ue
for i in range(W):
    c=0
    d=0
    for j in range(H):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0
        if(S[H-j-1][W-i-1]=="."):
            d+=1
            MAP[H-j-1][W-i-1][0]+=d
        else:
            d=0

#hidari
for j in range(H):
    c=0
    d=0
    for i in range(W):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0
        if(S[H-j-1][W-i-1]=="."):
            d+=1
            MAP[H-j-1][W-i-1][0]+=d
        else:
            d=0

#migi
MAX=0
for j in range(H):
    for i in range(W-1,-1,-1):
        MAX=max(MAX,MAP[j][i][0]-3)

print(MAX)

Fixed submission:
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W=map(int,input().split())
S=[0]*H
for i in range(H):
    S[i]=list(input())


MAP=[[[0,0,0,0] for i in range(W)]for i in range(H)]
#MAP[H][W]

#ue
for i in range(W):
    c=0
    for j in range(H):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0

#shita
for i in range(W):
    c=0
    for j in range(H-1,-1,-1):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0

#hidari
for j in range(H):
    c=0
    for i in range(W):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0

#migi
MAX=0
for j in range(H):
    c=0
    for i in range(W-1,-1,-1):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]+=c
        else:
            c=0
        MAX=max(MAX,MAP[j][i][0]-3)

print(MAX)

Fixed submission:
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W=map(int,input().split())
S=[0]*H
for i in range(H):
    S[i]=list(input())


MAP=[[[0,0,0,0] for i in range(W)]for i in range(H)]
#MAP[H][W]

#ue
for i in range(W):
    c=0
    for j in range(H):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]=c
        else:
            c=0
            MAP[j][i][0]=c

#shita
for i in range(W):
    c=0
    for j in range(H-1,-1,-1):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][1]=c
        else:
            c=0
            MAP[j][i][1]=c

#hidari
for j in range(H):
    c=0
    for i in range(W):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][2]=c
        else:
            c=0
            MAP[j][i][2]=c

#migi
for j in range(H):
    c=0
    for i in range(W-1,-1,-1):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][3]=c
        else:
            c=0
            MAP[j][i][3]=c

MAX=0
for i in range(W):
    for j in range(H):
        t=0
        t+=MAP[j][i][0]
        t+=MAP[j][i][1]
        t+=MAP[j][i][2]
        t+=MAP[j][i][3]  
        t-=3              
        MAX=max(MAX,t)
print(MAX)

Fixed submission:
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W=map(int,input().split())
S=[0]*H
for i in range(H):
    S[i]=list(input())


MAP=[[[0,0,0,0] for i in range(W)]for i in range(H)]
#MAP[H][W]

#ue
for i in range(W):
    c=0
    for j in range(H):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][0]=c
        else:
            c=0
            MAP[j][i][0]=c

#shita
for i in range(W):
    c=0
    for j in range(H-1,-1,-1):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][1]=c
        else:
            c=0
            MAP[j][i][1]=c

#hidari
for j in range(H):
    c=0
    for i in range(W):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][2]=c
        else:
            c=0
            MAP[j][i][2]=c

#migi
for j in range(H):
    c=0
    for i in range(W-1,-1,-1):
        if(S[j][i]=="."):
            c+=1
            MAP[j][i][3]=c
        else:
            c=0
            MAP[j][i][3]=c

MAX=0
for i in range(W):
    for j in range(H):
        t=0
        t+=MAP[j][i][0]
        t+=MAP[j][i][1]
        t+=MAP[j][i][2]
        t+=MAP[j][i][3]  
        t-=3              
        MAX=max(MAX,t)
print(MAX)

Fixed submission:
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)