Buggy python submission (verdict: Time Limit Exceeded):
def main():
    h,w = map(int,input().split())
    ls = [list(input()) for _ in range(h)]
    r = [[0 for _ in range(w)]  for _ in range(h)]
    l = [[0 for _ in range(w)]  for _ in range(h)]
    o = [[0 for _ in range(w)]  for _ in range(h)]
    u = [[0 for _ in range(w)]  for _ in range(h)]

    for i in range(h):
        for j in reversed(range(w)):
            if j == w-1:
                if ls[i][j]=='#':
                    r[i][j] = 0   
                else:
                    r[i][j] = 1
                    
            else:
                if ls[i][j]=='#':
                    r[i][j] = 0
                else:
                    r[i][j] = r[i][j+1]+1

    for i in range(h):
        for j in range(w):
            if j == 0:
                if ls[i][j]=='#':
                    pass
                else:
                    l[i][j]=1
            else:
                if ls[i][j]=='#':
                    pass
                else:
                    l[i][j] = l[i][j-1]+1
    for j in range(w):
        for i in range(h):
            if i == 0:
                if ls[i][j]=='#':
                    pass
                else:
                    o[i][j]=1
            else:
                if ls[i][j]=="#":
                    pass
                else:
                    o[i][j] = o[i-1][j] + 1
    for j in range(w):
        for i in reversed(range(h)):
            if i == h-1:
                if ls[i][j]=='#':
                    pass
                else:
                    u[i][j]=1
            else:
                if ls[i][j]=='#':
                    pass
                else:
                    u[i][j] = u[i+1][j] + 1

    ans = 0
    for i in range(h):
        for j in range(w):
            can = r[i][j] + l[i][j] + o[i][j] + u[i][j]
            ans = max(ans,can)
    print(ans-3)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    h,w = map(int,input().split())
    ls = [list(input()) for _ in range(h)]
    r = [[0 for _ in range(w)]  for _ in range(h)]
    l = [[0 for _ in range(w)]  for _ in range(h)]
    o = [[0 for _ in range(w)]  for _ in range(h)]
    u = [[0 for _ in range(w)]  for _ in range(h)]

    for i in range(h):
        for j in reversed(range(w)):
            if j == w-1:
                if ls[i][j]=='#':
                    r[i][j] = 0   
                else:
                    r[i][j] = 1
                    
            else:
                if ls[i][j]=='#':
                    r[i][j] = 0
                else:
                    r[i][j] = r[i][j+1]+1

    for i in range(h):
        for j in range(w):
            if j == 0:
                if ls[i][j]=='#':
                    pass
                else:
                    l[i][j]=1
            else:
                if ls[i][j]=='#':
                    pass
                else:
                    l[i][j] = l[i][j-1]+1
    for j in range(w):
        for i in range(h):
            if i == 0:
                if ls[i][j]=='#':
                    pass
                else:
                    o[i][j]=1
            else:
                if ls[i][j]=="#":
                    pass
                else:
                    o[i][j] = o[i-1][j] + 1
    for j in range(w):
        for i in reversed(range(h)):
            if i == h-1:
                if ls[i][j]=='#':
                    pass
                else:
                    u[i][j]=1
            else:
                if ls[i][j]=='#':
                    pass
                else:
                    u[i][j] = u[i+1][j] + 1

    ans = 0
    for i in range(h):
        for j in range(w):
            can = r[i][j] + l[i][j] + o[i][j] + u[i][j]
            ans = max(ans,can)
    print(ans-3)
if __name__ == "__main__":
    main()