Buggy python submission (verdict: Time Limit Exceeded):
H,W = list(map(int,input().split()))
 
S=[input() for i in range(H)]
color1 = -1
color_list1 = [[-1 for j in range(W)] for i in range(H)]
color_num1 = [0 for i in range(H*W)]
flag=True
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            flag=True
        else:
            if j==0:
                flag=True
            if flag:
                color1+=1
                color_list1[i][j]=color1
                color_num1[color1]+=1
                flag=False
            else:
                color_list1[i][j]=color1
                color_num1[color1]+=1
 
color2 = -1
color_list2 = [[-1 for j in range(W)] for i in range(H)]
color_num2 = [0 for i in range(H*W)]
flag=True
for j in range(W):
    for i in range(H):
        if S[i][j]=="#":
            flag=True
        else:
            if i==0:
                flag=True
            if flag:
                color2+=1
                color_list2[i][j]=color2
                color_num2[color2]+=1
                flag=False
            else:
                color_list2[i][j]=color2
                color_num2[color2]+=1
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans=max(color_num1[color_list1[i][j]]+color_num2[color_list2[i][j]]-1,ans)
 
print(ans)

Fixed submission:
H,W = list(map(int,input().split()))

S=[input() for i in range(H)]
color1 = -1
color_list1 = [[-1 for j in range(W)] for i in range(H)]
color_num1 = [0 for i in range(H*W)]
flag=True
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            flag=True
        else:
            if j==0:
                flag=True
            if flag:
                color1+=1
                color_list1[i][j]=color1
                color_num1[color1]+=1
                flag=False
            else:
                color_list1[i][j]=color1
                color_num1[color1]+=1

color2 = -1
color_list2 = [[-1 for j in range(W)] for i in range(H)]
color_num2 = [0 for i in range(H*W)]
flag=True
for j in range(W):
    for i in range(H):
        if S[i][j]=="#":
            flag=True
        else:
            if i==0:
                flag=True
            if flag:
                color2+=1
                color_list2[i][j]=color2
                color_num2[color2]+=1
                flag=False
            else:
                color_list2[i][j]=color2
                color_num2[color2]+=1
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans=max(color_num1[color_list1[i][j]]+color_num2[color_list2[i][j]]-1,ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = list(map(int,input().split()))

S=[input() for i in range(H)]
e_list1 = [[] for i in range(H*W)]
e_list2 = [[] for i in range(H*W)]

for i in range(H):
    for j in range(W):
        if i!=H-1:
            if S[i][j]=="." and S[i+1][j]==".":
                e_list1[i*W+j].append((i+1)*W+j)
                e_list1[(i+1)*W+j].append(i*W+j)

for i in range(H):
    for j in range(W):
        if j!=W-1:
            if S[i][j]=="." and S[i][j+1]==".":
                e_list2[i*W+j].append(i*W+j+1)
                e_list2[i*W+j+1].append(i*W+j)

from collections import deque

def BFS(vi,color,color_list,color_num,checked_list,e_list):
    
    Q = deque([vi])
    checked_list[vi]=True
    color_list[vi]=color
    color_num[color]+=1
    while len(Q)>0:
        v = Q.pop()
        for v1 in e_list[v]:
            if not checked_list[v1]:
                checked_list[v1]=True
                Q.appendleft(v1)
                color_list[v1]=color
                color_num[color]+=1
    return checked_list,color_list,color_num

color1 = 0
color_list1 = [-1 for i in range(H*W)]
color_num1 = [0 for i in range(H*W)]
checked_list1 = [False for i in range(H*W)]

for i in range(H):
    for j in range(W):
        if S[i][j]=="." and color_list1[i*W+j]==-1:
            checked_list1,color_list1,color_num1=BFS(i*W+j,color1,color_list1,color_num1,checked_list1,e_list1)
            color1+=1


color2 = 0
color_list2 = [-1 for i in range(H*W)]
color_num2 = [0 for i in range(H*W)]
checked_list2 = [False for i in range(H*W)]


for i in range(H):
    for j in range(W):
        if S[i][j]=="." and color_list2[i*W+j]==-1:
            checked_list2,color_list2,color_num2=BFS(i*W+j,color2,color_list2,color_num2,checked_list2,e_list2)
            color2+=1

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans=max(color_num1[color_list1[i*W+j]]+color_num2[color_list2[i*W+j]]-1,ans)

print(ans)

Fixed submission:
H,W = list(map(int,input().split()))

S=[input() for i in range(H)]
color1 = -1
color_list1 = [[-1 for j in range(W)] for i in range(H)]
color_num1 = [0 for i in range(H*W)]
flag=True
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            flag=True
        else:
            if j==0:
                flag=True
            if flag:
                color1+=1
                color_list1[i][j]=color1
                color_num1[color1]+=1
                flag=False
            else:
                color_list1[i][j]=color1
                color_num1[color1]+=1

color2 = -1
color_list2 = [[-1 for j in range(W)] for i in range(H)]
color_num2 = [0 for i in range(H*W)]
flag=True
for j in range(W):
    for i in range(H):
        if S[i][j]=="#":
            flag=True
        else:
            if i==0:
                flag=True
            if flag:
                color2+=1
                color_list2[i][j]=color2
                color_num2[color2]+=1
                flag=False
            else:
                color_list2[i][j]=color2
                color_num2[color2]+=1
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans=max(color_num1[color_list1[i][j]]+color_num2[color_list2[i][j]]-1,ans)

print(ans)