Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[]
for i in range(h):
	s.append(input().rstrip())
num=[[0]*w for _ in range(h)]
for i in range(h):
	p=0
	for j in range(w):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(h):
	p=0
	for j in range(w-1,-1,-1):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h-1,-1,-1):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
ans=0
for i in range(h):
	ans=max(ans,max(num[i])-3)
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[]
for i in range(h):
	s.append(input().rstrip())
num=[[0]*w for _ in range(h)]
for i in range(h):
	p=0
	for j in range(w):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(h):
	p=0
	for j in range(w-1,-1,-1):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h-1,-1,-1):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
ans=0
for i in range(h):
	ans=max(ans,max(num[i])-3)
print(ans)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
d=[]
field=[]
fie=[]
for _ in range(h):
	s=input()
	d.append(s)
	cnt=0
	yoko=[]
	for i in range(w):
		if s[i]=="#":
			yoko.append(cnt)
			cnt=0
		else:
			cnt+=1
	if cnt>0:
		yoko.append(cnt)
	yoko.append(0)
	yoko.append(0)
	field.append(yoko)
for i in range(w):
	tate=[]
	cnt=0
	for j in range(h):
		if d[j][i]=="#":
			tate.append(cnt)
			cnt=0
		else:
			cnt+=1
	if cnt>0:
		tate.append(cnt)
	tate.append(0)
	tate.append(0)
	fie.append(tate)
for i in range(h):
	for j in range(len(field[i])-2):
		if field[i][j]>0 and field[i][j+1]>0:
			field[i].insert(j+1,0)
		elif field[i][j]>=0 and field[i][j+1]==0 and field[i][j+2]==0:
			field[i].insert(j+1,0)
for i in range(w):
	for j in range(len(fie[i])-2):
		if fie[i][j]>0 and fie[i][j+1]>0:
			fie[i].insert(j+1,0)
		elif fie[i][j]>=0 and fie[i][j+1]==0 and fie[i][j+2]==0:
			fie[i].insert(j+1,0)
ans=[[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
	k=0
	cn=0
	for j in range(w):
		if field[i][k]==0:
			k+=1
			continue
		else:
			ans[i][j]+=field[i][k]
			cn+=1
		if cn==field[i][k]:
			cn=0
			k+=1
for i in range(w):
	k=0
	cn=0
	for j in range(h):
		if fie[i][k]==0:
			k+=1
			continue
		else:
			ans[j][i]+=fie[i][k]
			cn+=1
		if cn==fie[i][k]:
			cn=0
			k+=1
M=0
for i in range(h):
	for j in range(w):
		M=max(ans[i][j],M)
print(M-1)






Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[]
for i in range(h):
	s.append(input().rstrip())
num=[[0]*w for _ in range(h)]
for i in range(h):
	p=0
	for j in range(w):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(h):
	p=0
	for j in range(w-1,-1,-1):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h-1,-1,-1):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
ans=0
for i in range(h):
	ans=max(ans,max(num[i])-3)
print(ans)