Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      d[i][j]=0
      l[i][j]=0
    else:
      if i!=0:
        d[i][j]+=d[i-1][j]+1
      else:
        d[i][j]=1
      if j!=0:
        l[i][j]+=l[i][j-1]+1
      else:
        l[i][j]=1
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    if s[i][j]=='#':
      r[i][j]=0
      u[i][j]=0
    else:
      if i!=h-1:
        u[i][j]+=u[i+1][j]+1
      else:
        u[i][j]=1
      if j!=w-1:
        r[i][j]+=r[i][j+1]+1
      else:
        r[i][j]=1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      d[i][j]=0
      l[i][j]=0
    else:
      if i!=0:
        d[i][j]+=d[i-1][j]+1
      else:
        d[i][j]=1
      if j!=0:
        l[i][j]+=l[i][j-1]+1
      else:
        l[i][j]=1
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    if s[i][j]=='#':
      r[i][j]=0
      u[i][j]=0
    else:
      if i!=h-1:
        u[i][j]+=u[i+1][j]+1
      else:
        u[i][j]=1
      if j!=w-1:
        r[i][j]+=r[i][j+1]+1
      else:
        r[i][j]=1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(w):
  if s[0][i]=='.':
    u[0][i]=1
  for j in range(1,h):
    if s[j][i]=='.':
      u[j][i]+=u[j-1][i]+1
for i in range(w):
  if s[h-1][i]=='.':
    d[h-1][i]=1
  for j in range(h-2,-1,-1):
    if s[j][i]=='.':
      d[j][i]+=d[j+1][i]+1
for i in range(h):
  if s[i][0]=='.':
    l[i][0]=1
  for j in range(1,w):
    if s[i][j]=='.':
      l[i][j]+=l[i][j-1]+1
for i in range(h):
  if s[i][w-1]=='.':
    r[i][w-1]=1
  for j in range(w-2,-1,-1):
    if s[i][j]=='.':
      r[i][j]+=r[i][j+1]+1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      d[i][j]=0
      l[i][j]=0
    else:
      if i!=0:
        d[i][j]+=d[i-1][j]+1
      else:
        d[i][j]=1
      if j!=0:
        l[i][j]+=l[i][j-1]+1
      else:
        l[i][j]=1
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    if s[i][j]=='#':
      r[i][j]=0
      u[i][j]=0
    else:
      if i!=h-1:
        u[i][j]+=u[i+1][j]+1
      else:
        u[i][j]=1
      if j!=w-1:
        r[i][j]+=r[i][j+1]+1
      else:
        r[i][j]=1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(w):
  if s[0][i]=='.':
    u[0][i]=1
  for j in range(1,h):
    if s[j][i]=='.':
      u[j][i]+=u[j-1][i]+1
for i in range(w):
  if s[h-1][i]=='.':
    d[h-1][i]=1
  for j in range(h-2,-1,-1):
    if s[j][i]=='.':
      d[j][i]+=d[j+1][i]+1
for i in range(h):
  if s[i][0]=='.':
    l[i][0]=1
  for j in range(1,w):
    if s[i][j]=='.':
      l[i][j]+=l[i][j-1]+1
for i in range(h):
  if s[i][w-1]=='.':
    r[i][w-1]=1
  for j in range(w-2,-1,-1):
    if s[i][j]=='.':
      r[i][j]+=r[i][j+1]+1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      d[i][j]=0
      l[i][j]=0
    else:
      if i!=0:
        d[i][j]+=d[i-1][j]+1
      else:
        d[i][j]=1
      if j!=0:
        l[i][j]+=l[i][j-1]+1
      else:
        l[i][j]=1
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    if s[i][j]=='#':
      r[i][j]=0
      u[i][j]=0
    else:
      if i!=h-1:
        u[i][j]+=u[i+1][j]+1
      else:
        u[i][j]=1
      if j!=w-1:
        r[i][j]+=r[i][j+1]+1
      else:
        r[i][j]=1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(w):
  if s[0][i]=='.':
    u[0][i]=1
  for j in range(1,h):
    if s[j][i]=='.':
      u[j][i]+=u[j-1][i]+1
for i in range(w):
  if s[h-1][i]=='.':
    d[h-1][i]=1
  for j in range(h-2,-1,-1):
    if s[j][i]=='.':
      d[j][i]+=d[j+1][i]+1
for i in range(h):
  if s[i][0]=='.':
    l[i][0]=1
  for j in range(1,w):
    if s[i][j]=='.':
      l[i][j]+=l[i][j-1]+1
for i in range(h):
  if s[i][w-1]=='.':
    r[i][w-1]=1
  for j in range(w-2,-1,-1):
    if s[i][j]=='.':
      r[i][j]+=r[i][j+1]+1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      d[i][j]=0
      l[i][j]=0
    else:
      if i!=0:
        d[i][j]+=d[i-1][j]+1
      else:
        d[i][j]=1
      if j!=0:
        l[i][j]+=l[i][j-1]+1
      else:
        l[i][j]=1
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    if s[i][j]=='#':
      r[i][j]=0
      u[i][j]=0
    else:
      if i!=h-1:
        u[i][j]+=u[i+1][j]+1
      else:
        u[i][j]=1
      if j!=w-1:
        r[i][j]+=r[i][j+1]+1
      else:
        r[i][j]=1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)