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

U = [[0 for _ in range(w)] for _  in range(h)]
D = [[0 for _ in range(w)] for _  in range(h)]
L = [[0 for _ in range(w)] for _  in range(h)]
R = [[0 for _ in range(w)] for _  in range(h)]

for y in range(h):
    for x in range(w):
        if maps[y][x] == "#":
            U[y][x],L[y][x] = 0,0
        else:
            if y == 0 and x >= 1:
                U[0][x] = 1
                L[y][x] += 1 + L[y][x-1]
            elif x == 0 and y >= 1: 
                U[y][x] += 1 + U[y-1][x]
                L[y][0] = 1
            elif x == 0 and y == 0:
                U[y][x] = 1
                L[y][x] = 1
            else:
                U[y][x] += 1 + U[y-1][x]
                L[y][x] += 1 + L[y][x-1]

for y in range(h-1,-1,-1):
    for x in range(w-1,-1,-1):
        if maps[y][x] == "#":
            D[y][x],R[y][x] = 0,0
        else:
            if y == h-1 and x < w-1:
                D[y][x] = 1
                R[y][x] += 1 + R[y][x+1]
            elif x == w-1 and y < h-1:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] = 1
            elif  x == w-1 and y == h-1:
                D[y][x] = 1
                R[y][x] = 1
            else:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] += 1 + R[y][x+1]

ans = 0
#AnsMap = [[0 for _ in range(w)] for _  in range(h)]
for i in range(h):
    for j in range(w):
        #AnsMap[i][j] = L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3)
print(ans)

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

U = [[0 for _ in range(w)] for _  in range(h)]
D = [[0 for _ in range(w)] for _  in range(h)]
L = [[0 for _ in range(w)] for _  in range(h)]
R = [[0 for _ in range(w)] for _  in range(h)]

for y in range(h):
    for x in range(w):
        if maps[y][x] == "#":
            U[y][x],L[y][x] = 0,0
        else:
            if y == 0 and x >= 1:
                U[0][x] = 1
                L[y][x] += 1 + L[y][x-1]
            elif x == 0 and y >= 1: 
                U[y][x] += 1 + U[y-1][x]
                L[y][0] = 1
            elif x == 0 and y == 0:
                U[y][x] = 1
                L[y][x] = 1
            else:
                U[y][x] += 1 + U[y-1][x]
                L[y][x] += 1 + L[y][x-1]

for y in range(h-1,-1,-1):
    for x in range(w-1,-1,-1):
        if maps[y][x] == "#":
            D[y][x],R[y][x] = 0,0
        else:
            if y == h-1 and x < w-1:
                D[y][x] = 1
                R[y][x] += 1 + R[y][x+1]
            elif x == w-1 and y < h-1:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] = 1
            elif  x == w-1 and y == h-1:
                D[y][x] = 1
                R[y][x] = 1
            else:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] += 1 + R[y][x+1]

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
maps = [ input() for _ in range(h)]
ans = 0
for x in range(w):
    for y in range(h):
        if maps[y][x] == "#":
            continue
        else:
            tmpans = 0
            for u in range(y,-1,-1):
                if maps[u][x] == "#":
                    break
                else:
                    tmpans += 1
            for d in range(y+1, h):
                if maps[d][x] == "#":
                    break
                else:
                    tmpans += 1
            
            for l in range(x,-1,-1):
                if maps[y][l] == "#":
                    break
                else:
                    tmpans += 1
            for r in range(x+1,w):
                if maps[y][r] == "#":
                        break
                else:
                    tmpans += 1
                    
            ans = max(tmpans,ans)
print(ans-1)

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

U = [[0 for _ in range(w)] for _  in range(h)]
D = [[0 for _ in range(w)] for _  in range(h)]
L = [[0 for _ in range(w)] for _  in range(h)]
R = [[0 for _ in range(w)] for _  in range(h)]

for y in range(h):
    for x in range(w):
        if maps[y][x] == "#":
            U[y][x],L[y][x] = 0,0
        else:
            if y == 0 and x >= 1:
                U[0][x] = 1
                L[y][x] += 1 + L[y][x-1]
            elif x == 0 and y >= 1: 
                U[y][x] += 1 + U[y-1][x]
                L[y][0] = 1
            elif x == 0 and y == 0:
                U[y][x] = 1
                L[y][x] = 1
            else:
                U[y][x] += 1 + U[y-1][x]
                L[y][x] += 1 + L[y][x-1]

for y in range(h-1,-1,-1):
    for x in range(w-1,-1,-1):
        if maps[y][x] == "#":
            D[y][x],R[y][x] = 0,0
        else:
            if y == h-1 and x < w-1:
                D[y][x] = 1
                R[y][x] += 1 + R[y][x+1]
            elif x == w-1 and y < h-1:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] = 1
            elif  x == w-1 and y == h-1:
                D[y][x] = 1
                R[y][x] = 1
            else:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] += 1 + R[y][x+1]

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
maps = [ input() for _ in range(h)]
ans = 0
for x in range(w):
    for y in range(h):
        if maps[y][x] == "#":
            continue
        else:
            tmpans = 0
            for u in range(y,-1,-1):
                if maps[u][x] == "#":
                    break
                else:
                    tmpans += 1
            for d in range(y+1, h):
                if maps[d][x] == "#":
                    break
                else:
                    tmpans += 1
            
            for l in range(x,-1,-1):
                if maps[y][l] == "#":
                    break
                else:
                    tmpans += 1
            for r in range(x+1,w):
                if maps[y][r] == "#":
                        break
                else:
                    tmpans += 1
                    
            ans = max(tmpans,ans)
print(ans-1)

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

U = [[0 for _ in range(w)] for _  in range(h)]
D = [[0 for _ in range(w)] for _  in range(h)]
L = [[0 for _ in range(w)] for _  in range(h)]
R = [[0 for _ in range(w)] for _  in range(h)]

for y in range(h):
    for x in range(w):
        if maps[y][x] == "#":
            U[y][x],L[y][x] = 0,0
        else:
            if y == 0 and x >= 1:
                U[0][x] = 1
                L[y][x] += 1 + L[y][x-1]
            elif x == 0 and y >= 1: 
                U[y][x] += 1 + U[y-1][x]
                L[y][0] = 1
            elif x == 0 and y == 0:
                U[y][x] = 1
                L[y][x] = 1
            else:
                U[y][x] += 1 + U[y-1][x]
                L[y][x] += 1 + L[y][x-1]

for y in range(h-1,-1,-1):
    for x in range(w-1,-1,-1):
        if maps[y][x] == "#":
            D[y][x],R[y][x] = 0,0
        else:
            if y == h-1 and x < w-1:
                D[y][x] = 1
                R[y][x] += 1 + R[y][x+1]
            elif x == w-1 and y < h-1:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] = 1
            elif  x == w-1 and y == h-1:
                D[y][x] = 1
                R[y][x] = 1
            else:
                D[y][x] += 1 + D[y+1][x]
                R[y][x] += 1 + R[y][x+1]

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j] - 3)
print(ans)