Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
s = [ input() for _ in range(h) ]

l = [ [0]*w for _ in range(h) ] 
r = [ [0]*w for _ in range(h) ] 
u = [ [0]*w for _ in range(h) ] 
d = [ [0]*w for _ in range(h) ] 

for i in range(h):
    for j in range(w):
        # l
        if s[i][j]=="#":
            l[i][j] = 0
        elif j==0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1
        # u
        if s[i][j]=="#":
            u[i][j] = 0
        elif i==0:
            u[i][j] = 1
        else:
            u[i][j] = u[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        # r
        if s[i][j]=="#":
            r[i][j] = 0
        elif j==(w-1):
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
        # d
        if s[i][j]=="#":
            d[i][j] = 0
        elif i==(h-1):
            d[i][j] = 1
        else:
            d[i][j] = d[i+1][j] + 1

# print(l)
# print(r)
# print(u)
# print(d)

M = 0
for i in range(h):
    for j in range(w):
        lamp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        M = max(M,lamp)

print(M)

Fixed submission:
h,w = map(int,input().split())
s = [ input() for _ in range(h) ]

l = [ [0]*w for _ in range(h) ] 
r = [ [0]*w for _ in range(h) ] 
u = [ [0]*w for _ in range(h) ] 
d = [ [0]*w for _ in range(h) ] 

for i in range(h):
    for j in range(w):
        # l
        if s[i][j]=="#":
            l[i][j] = 0
        elif j==0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1
        # u
        if s[i][j]=="#":
            u[i][j] = 0
        elif i==0:
            u[i][j] = 1
        else:
            u[i][j] = u[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        # r
        if s[i][j]=="#":
            r[i][j] = 0
        elif j==(w-1):
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
        # d
        if s[i][j]=="#":
            d[i][j] = 0
        elif i==(h-1):
            d[i][j] = 1
        else:
            d[i][j] = d[i+1][j] + 1

# print(l)
# print(r)
# print(u)
# print(d)

M = 0
for i in range(h):
    for j in range(w):
        lamp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        M = max(M,lamp)

print(M)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
s = [ input() for _ in range(h) ]

l = [ [0]*w for _ in range(h) ] 
r = [ [0]*w for _ in range(h) ] 
u = [ [0]*w for _ in range(h) ] 
d = [ [0]*w for _ in range(h) ] 

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            l[i][j] = 0
        elif j==0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1

for i in range(h):
    for j in reversed(range(w)):
        if s[i][j]=="#":
            r[i][j] = 0
        elif j==(w-1):
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
    
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            u[i][j] = 0
        elif i==0:
            u[i][j] = 1
        else:
            u[i][j] = u[i-1][j] + 1

for i in reversed(range(h)):
    for j in range(w):
        if s[i][j]=="#":
            d[i][j] = 0
        elif i==(h-1):
            d[i][j] = 1
        else:
            d[i][j] = d[i+1][j] + 1

# print(l)
# print(r)
# print(u)
# print(d)

M = 0
for i in range(h):
    for j in range(w):
        lamp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        M = max(M,lamp)

print(M)

Fixed submission:
h,w = map(int,input().split())
s = [ input() for _ in range(h) ]

l = [ [0]*w for _ in range(h) ] 
r = [ [0]*w for _ in range(h) ] 
u = [ [0]*w for _ in range(h) ] 
d = [ [0]*w for _ in range(h) ] 

for i in range(h):
    for j in range(w):
        # l
        if s[i][j]=="#":
            l[i][j] = 0
        elif j==0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1
        # u
        if s[i][j]=="#":
            u[i][j] = 0
        elif i==0:
            u[i][j] = 1
        else:
            u[i][j] = u[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        # r
        if s[i][j]=="#":
            r[i][j] = 0
        elif j==(w-1):
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
        # d
        if s[i][j]=="#":
            d[i][j] = 0
        elif i==(h-1):
            d[i][j] = 1
        else:
            d[i][j] = d[i+1][j] + 1

# print(l)
# print(r)
# print(u)
# print(d)

M = 0
for i in range(h):
    for j in range(w):
        lamp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        M = max(M,lamp)

print(M)