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

dx = [[0]*W for _ in range(H)]
dy = [[0]*H for _ in range(W)]

Sy = [[0]*H for _ in range(W)]
for i in range(H):
    for j in range(W):
        Sy[j][i] = S[i][j]
for i,s in enumerate(S):
    tmp = []
    prev = '#'
    start = -1
    for j,char in enumerate(s):
        if char == '#':
            if prev == '.':
                val = j-start-1
                for k in range(start+1, j):
                    dx[i][k] = val
                prev = char
            start = j
        prev = char
    if start == 0:
        dx[i] = [W]*W
    elif prev == '.':
        val = W - start - 1
        for k in range(start + 1, W):
            dx[i][k] = val
for i,s in enumerate(Sy):
    tmp = []
    prev = '#'
    start = -1
    for j,char in enumerate(s):
        if char == '#':
            if prev == '.':
                val = j-start-1
                for k in range(start+1, j):
                    dy[i][k] = val
                prev = char
            start = j
        prev = char
    if start == 0:
        dy[i] = [H]*H
    elif prev == '.':
        val = H - start - 1
        for k in range(start + 1, H):
            dy[i][k] = val

res = 0
for i in range(H):
    for j in range(W):
        tmp = dx[i][j] + dy[j][i]
        if tmp > res:
            res = tmp
print(res-1)


Fixed submission:
import sys
input = sys.stdin.readline
H, W = map(int,input().split())
S = [ str(input()) for i in range(H) ]
sumlist = []
for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            for k in range(tmp):
                sumlist.append(tmp)
            sumlist.append(0)
            tmp = 0
            continue
        else:
            tmp += 1
    for k in range(tmp):
        sumlist.append(tmp)
sumlist2 = []
for i in range(W):
    tmp = 0
    for j in range(H):
        if S[j][i] == '#':
            for k in range(tmp):
                sumlist2.append(tmp)
            sumlist2.append(0)
            tmp = 0
            continue
        else:
            tmp += 1
    for k in range(tmp):
        sumlist2.append(tmp)
res = [sumlist[i]+sumlist2[(i%W)*H+(i//W)] for i in range(H*W)]
print(max(res)-1)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int,input().split())
S = [ str(input()) for i in range(H) ]
sumlist = []
for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            for k in range(tmp):
                sumlist.append(tmp)
            sumlist.append(0)
            tmp = 0
            continue
        else:
            tmp += 1
    for k in range(tmp):
        sumlist.append(tmp)
sumlist2 = []
for i in range(W):
    tmp = 0
    for j in range(H):
        if S[j][i] == '#':
            for k in range(tmp):
                sumlist2.append(tmp)
            sumlist2.append(0)
            tmp = 0
            continue
        else:
            tmp += 1
    for k in range(tmp):
        sumlist2.append(tmp)
res = [sumlist[i]+sumlist2[(i%W)*H+(i//W)] for i in range(H*W)]
print(max(res)-1)


Fixed submission:
import sys
input = sys.stdin.readline
H, W = map(int,input().split())
S = [ str(input()) for i in range(H) ]
sumlist = []
for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            for k in range(tmp):
                sumlist.append(tmp)
            sumlist.append(0)
            tmp = 0
            continue
        else:
            tmp += 1
    for k in range(tmp):
        sumlist.append(tmp)
sumlist2 = []
for i in range(W):
    tmp = 0
    for j in range(H):
        if S[j][i] == '#':
            for k in range(tmp):
                sumlist2.append(tmp)
            sumlist2.append(0)
            tmp = 0
            continue
        else:
            tmp += 1
    for k in range(tmp):
        sumlist2.append(tmp)
res = [sumlist[i]+sumlist2[(i%W)*H+(i//W)] for i in range(H*W)]
print(max(res)-1)