Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

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

field = [list(f) for f in s]

def dfs(x, y):
    global total
    total += 1
    # 移動する4方向をループ
    for dx in [-1, 1]:
        nx = x + dx; ny = y
        while 0 <= nx and nx < h and 0 <= ny and ny < w and field[nx][ny] == '.':
            total += 1
            # x方向にdx, y方向にdy移動した場所を(nx, ny)とする
            nx += dx
    for dy in [-1, 1]:
        nx = x; ny = y + dy
        while 0 <= nx and nx < h and 0 <= ny and ny < w and field[nx][ny] == '.':
            total += 1
            # x方向にdx, y方向にdy移動した場所を(nx, ny)とする
            ny += dy
    
    return total

res = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            # '.'からdfsを始める
            total = 0
            dfs(i, j)
            res = max(total, res)

print(res)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

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

field = [list(f) for f in s]

def dfs(x, y):
    global total
    total += 1
    # 移動する4方向をループ
    for dx in [-1, 1]:
        nx = x + dx; ny = y
        while 0 <= nx and nx < h and 0 <= ny and ny < w and field[nx][ny] == '.':
            total += 1
            # x方向にdx, y方向にdy移動した場所を(nx, ny)とする
            nx += dx
    for dy in [-1, 1]:
        nx = x; ny = y + dy
        while 0 <= nx and nx < h and 0 <= ny and ny < w and field[nx][ny] == '.':
            total += 1
            # x方向にdx, y方向にdy移動した場所を(nx, ny)とする
            ny += dy
    
    return total

res = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            # '.'からdfsを始める
            total = 0
            dfs(i, j)
            res = max(total, res)

print(res)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

print(ans)