Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


for i in range(H) :
    flg = 0
    for j in range(W) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == 0 :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    flg = 0
    for j in range(W-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == W-1 :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    flg = 0
    for i in range(H) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == 0 :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1
    
    flg = 0
    for i in range(H-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == H-1 :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 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])

ans += 1

print(ans)


Fixed submission:
H,W = map(int,input().split())

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


for i in range(H) :
    flg = 0
    for j in range(W) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == 0 :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    flg = 0
    for j in range(W-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == W-1 :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    flg = 0
    for i in range(H) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == 0 :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1
    
    flg = 0
    for i in range(H-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == H-1 :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 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])

ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
A = [list(input()) for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]

for i in range(H) :
    for j in range(1,W) :
        if (A[i][j] == "#") or (A[i][j-1] == "#") :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    for j in range(W-2,-1,-1) :
        if (A[i][j] == "#") or (A[i][j+1] == "#") :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    for i in range(1,H) :
        if (A[i][j] == "#") or (A[i-1][j] == "#") :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1

    for i in range(H-2,-1,-1) :
        if (A[i][j] == "#") or (A[i+1][j] == "#") :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 1

ans = 0

for i in range(H) :
    for j in range(W) :
        calc = L[i][j] + R[i][j] + U[i][j] + D[i][j]
        ans = max(ans,calc)

ans += 1

print(ans)


Fixed submission:
H,W = map(int,input().split())

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


for i in range(H) :
    flg = 0
    for j in range(W) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == 0 :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    flg = 0
    for j in range(W-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == W-1 :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    flg = 0
    for i in range(H) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == 0 :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1
    
    flg = 0
    for i in range(H-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == H-1 :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 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])

ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
A = [list(input()) for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]

for i in range(H) :
    for j in range(1,W) :
        if (A[i][j] == "#") or (A[i][j-1] == "#") :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    for j in range(W-2,-1,-1) :
        if (A[i][j] == "#") or (A[i][j+1] == "#") :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    for i in range(1,H) :
        if (A[i][j] == "#") or (A[i-1][j] == "#") :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1

    for i in range(H-2,-1,-1) :
        if (A[i][j] == "#") or (A[i+1][j] == "#") :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 1

ans = 0

for i in range(H) :
    for j in range(W) :
        calc = L[i][j] + R[i][j] + U[i][j] + D[i][j]
        ans = max(ans,calc)

ans += 1

print(ans)


Fixed submission:
H,W = map(int,input().split())

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


for i in range(H) :
    flg = 0
    for j in range(W) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == 0 :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    flg = 0
    for j in range(W-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == W-1 :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    flg = 0
    for i in range(H) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == 0 :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1
    
    flg = 0
    for i in range(H-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == H-1 :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 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])

ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

q = deque([])

H,W = map(int,input().split())
L = []

for i in range(H) :
    S = input()
    for j in range(W) :
        if S[j] == "." :
            q.append((i,j))
    L.append(list(S))

ans = 0

while q :
    y,x = q.popleft()
    
    cnt = 1
    
    d = [1,-1]
    
    for dy in d :
        ny = y
        
        while True :
            ny += dy
            
            if (ny < 0) or (ny >= H) :
                break
            
            if L[ny][x] == "#" :
                break
            
            cnt += 1
    
    for dx in d :
        nx = x
        
        while True :
            nx += dx
            
            if (nx < 0) or (nx >= W) :
                break
            
            if L[y][nx] == "#" :
                break
            
            cnt += 1
    
    ans = max(ans,cnt)

print(ans)


Fixed submission:
H,W = map(int,input().split())

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


for i in range(H) :
    flg = 0
    for j in range(W) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == 0 :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    flg = 0
    for j in range(W-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == W-1 :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    flg = 0
    for i in range(H) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == 0 :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1
    
    flg = 0
    for i in range(H-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == H-1 :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 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])

ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

q = deque([])

H,W = map(int,input().split())
L = []

for i in range(H) :
    S = input()
    for j in range(W) :
        if S[j] == "." :
            q.append((i,j))
    L.append(list(S))

ans = 0

while q :
    y,x = q.popleft()
    
    cnt = 1
    
    d = [1,-1]
    
    for dy in d :
        ny = y
        
        while True :
            ny += dy
            
            if (ny < 0) or (ny >= H) :
                break
            
            if L[ny][x] == "#" :
                break
            
            cnt += 1
    
    for dx in d :
        nx = x
        
        while True :
            nx += dx
            
            if (nx < 0) or (nx >= W) :
                break
            
            if L[y][nx] == "#" :
                break
            
            cnt += 1
    
    ans = max(ans,cnt)

print(ans)


Fixed submission:
H,W = map(int,input().split())

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


for i in range(H) :
    flg = 0
    for j in range(W) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == 0 :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    flg = 0
    for j in range(W-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif j == W-1 :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    flg = 0
    for i in range(H) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == 0 :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1
    
    flg = 0
    for i in range(H-1,-1,-1) :
        if S[i][j] == "#" :
            flg = 1
        elif flg :
            flg = 0
        elif i == H-1 :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 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])

ans += 1

print(ans)