Buggy python submission (verdict: Time Limit Exceeded):
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)           

Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
#lamp
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)           

Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
#lamp
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)           

Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
lists1=[0]*h
import sys
input=sys.stdin.readline
for i in range(h):
    s=list(input())
    lists1[i]=s
uselists1=[0]*h
judgelist=[]
for j in  range(h):
    some=lists1[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist.append(sublist)

reallist1=[[] for _ in range(h)]
for i in range(h):
  use=judgelist[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist1[i].append(use[j])
    else:
      reallist1[i].append(0)
#今度は横の方向について調べる
judgelist2=[]
for j in  range(w):
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(h):
        some=lists1[k][j]
        if some=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some==".":
            count+=1
            if k==h-1:
                sublist.append(count)
    judgelist2.append(sublist)

reallist2=[[] for _ in range(w)]
for i in range(w):
  use=judgelist2[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist2[i].append(use[j])
    else:
      reallist2[i].append(0)

answer=0
for i in range(h):
  for j in range(w):
    if reallist1[i][j]==0 or reallist2[j][i]==0:
      continue
    else:
      answer=max(answer,reallist1[i][j]+reallist2[j][i]-1)
      
print(answer)


Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
lists1=[0]*h
import sys
input=sys.stdin.readline
for i in range(h):
    s=list(input())
    lists1[i]=s

  
    
uselists1=[0]*h
judgelist=[]
for j in  range(h):
    some=lists1[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist.append(sublist)

reallist1=[[] for _ in range(h)]
for i in range(h):
  use=judgelist[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist1[i].append(use[j])
    else:
      reallist1[i].append(0)


lists2=[0]*w
for i in range(w):
  s=[0]*h
  for j in range(h):
    s[j]=lists1[j][i]
  lists2[i]=s


h,w=w,h
judgelist2=[]
for j in  range(h):
    some=lists2[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist2.append(sublist)
   
reallist2=[[] for _ in range(h)]
for i in range(h):
  use=judgelist2[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist2[i].append(use[j])
    else:
      reallist2[i].append(0)
               

answer=0
h,w=w,h
for i in range(h):
  for j in range(w):
    if reallist1[i][j]==0 or reallist2[j][i]==0:
      continue
    else:
      answer=max(answer,reallist1[i][j]+reallist2[j][i]-1)
      
print(answer)


Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
lists1=[0]*h
import sys
input=sys.stdin.readline
for i in range(h):
    s=list(input())
    lists1[i]=s

  
    
uselists1=[0]*h
judgelist=[]
for j in  range(h):
    some=lists1[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist.append(sublist)

reallist1=[[] for _ in range(h)]
for i in range(h):
  use=judgelist[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist1[i].append(use[j])
    else:
      reallist1[i].append(0)


lists2=[0]*w
for i in range(w):
  s=[0]*h
  for j in range(h):
    s[j]=lists1[j][i]
  lists2[i]=s


h,w=w,h
judgelist2=[]
for j in  range(h):
    some=lists2[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist2.append(sublist)
   
reallist2=[[] for _ in range(h)]
for i in range(h):
  use=judgelist2[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist2[i].append(use[j])
    else:
      reallist2[i].append(0)
               

answer=0
h,w=w,h
for i in range(h):
  for j in range(w):
    if reallist1[i][j]==0 or reallist2[j][i]==0:
      continue
    else:
      answer=max(answer,reallist1[i][j]+reallist2[j][i]-1)
      
print(answer)


Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):

h,w=map(int,input().split())
lists1=[0]*h
for i in range(h):
    s=list(input())
    lists1[i]=s

  
    
uselists1=[0]*h
judgelist=[]
for j in  range(h):
    some=lists1[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist.append(sublist)

reallist1=[[] for _ in range(h)]
for i in range(h):
  use=judgelist[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist1[i].append(use[j])
    else:
      reallist1[i].append(0)


lists2=[0]*w
for i in range(w):
  s=[0]*h
  for j in range(h):
    s[j]=lists1[j][i]
  lists2[i]=s


h,w=w,h
judgelist2=[]
for j in  range(h):
    some=lists2[j]
    count=0
    addlist=[0]*w
    sublist=[]
    for k in range(w):
        if some[k]=="#" and count==0:
            sublist.append(0)
            
            count=0
        elif some[k]=="#" and count>=1:
          sublist.append(count)
          sublist.append(0)
          count=0
          
        if some[k]==".":
            count+=1
            if k==w-1:
                sublist.append(count)
    judgelist2.append(sublist)
   
reallist2=[[] for _ in range(h)]
for i in range(h):
  use=judgelist2[i]
  for j in range(len(use)):
    if use[j]!=0:
    	for k in range(use[j]):
    		reallist2[i].append(use[j])
    else:
      reallist2[i].append(0)
               

answer=0
h,w=w,h
for i in range(h):
  for j in range(w):
    if reallist1[i][j]==0 or reallist2[j][i]==0:
      continue
    else:
      answer=max(answer,reallist1[i][j]+reallist2[j][i]-1)
      
print(answer)

Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
lists=[]
for i in range(h):
    s=input()
    lists.append(s)
ylists=[]
for some in lists:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(w+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    ylists.append(add)
    

            
lists1=[]
for i in range(w):
    for j in range(h):
        lists1[i][j]=lists[j][i]

    

tlists=[]
for some in lists1:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(h+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    tlists.append(add)


listss=[]
for i in range(h):
    for j in range(w):
        if ylists[i][j]==0 or  tlists[j][i]==0:
            continue
        else:
            listss.append(ylists[i][j]+tlists[j][i]-1)
print(max(listss))

Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
lists=[]
for i in range(h):
    s=input()
    lists.append(s)
ylists=[]
for some in lists:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(w+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    ylists.append(add)
lists1=[]
for i in range(w):
    adds=""
    for j in range(h):
        adds+=lists[j][i]
    lists1.append(adds)
    

tlists=[]
for some in lists1:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(h+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    tlists.append(add)


listss=[]
for i in range(h):
    for j in range(w):
        if ylists[i][j]==0 or  tlists[j][i]==0:
            continue
        else:
            listss.append(ylists[i][j]+tlists[j][i]-1)
print(max(listss))

            

Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
lists=[]
for i in range(h):
    s=input()
    lists.append(s)
ylists=[]
for some in lists:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(w+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    ylists.append(add)
    

            
lists1=[]
for i in range(w):
    adds=""
    for j in range(h):
        adds+=lists[j][i]
    lists1.append(adds)
    
tlists=[]
for some in lists1:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(h+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    tlists.append(add)


maximum=0
for i in range(h):
    for j in range(w):
        if ylists[i][j]==0 or tlists[j][i]==0:
            continue
        else:
            maximum=max(maximum,ylists[i][j]+tlists[j][i]-1)
print(maximum)    


Fixed submission:
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)