Problem:
 Score : 400 points    Problem Statement There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.
The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.
In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i ( 1 \leq i \leq H ), each of length W . If the j -th character ( 1 \leq j \leq W ) of S_i is # , there is an obstacle on the square at the i -th row from the top and the j -th column from the left; if that character is . , there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.      Constraints  1 \leq H \leq 2,000  1 \leq W \leq 2,000  S_i is a string of length W consisting of # and . .  . occurs at least once in one of the strings S_i ( 1 \leq i \leq H ).         Input Input is given from Standard Input in the following format:  H  W  S_1  :  S_H       Output Print the maximum possible number of squares lighted by the lamp.        Sample Input 1 4 6
#..#..
.....#
....#.
#.#...      Sample Output 1 8  If Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.       Sample Input 2 8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#      Sample Output 2 13

Solution (Python):

mod = 1000000007

h,w = map(int,input().split())
vals = []
for i in range(h):
	vals.append(input())


v_up_length = [[0 for i in range(w)]for j in range(h)]
v_down_length = [[0 for i in range(w)]for j in range(h)]
h_right_length = [[0 for i in range(w)]for j in range(h)]
h_left_length = [[0 for i in range(w)]for j in range(h)]

for x in range(w):
	for y in range(h):
		if vals[y][x]== "
			continue
		if x != 0:
			if vals[y][x-1] == ".":
				h_left_length[y][x] = h_left_length[y][x-1] + 1
		if y != 0:
			if vals[y-1][x] == ".":
				v_up_length[y][x] = v_up_length[y-1][x] + 1



for x in range(w-1,-1,-1):
	for y in range(h-1,-1,-1):
		if vals[y][x]== "
			continue
		if x != w-1:
			if vals[y][x+1] == ".":
				h_right_length[y][x] = h_right_length[y][x+1] + 1
		if y != h-1:
			if vals[y+1][x] == ".":
				v_down_length[y][x] = v_down_length[y+1][x] + 1


ans = 0
scores = [[0 for i in range(w)]for j in range(h)]
for x in range(w):
	for y in range(h):
		if vals[y][x]== "
			continue
		
		scores[y][x] = 1 + v_up_length[y][x] + v_down_length[y][x] + h_right_length[y][x] + h_left_length[y][x]
		
		ans = max(ans, 1 + v_up_length[y][x] + v_down_length[y][x] + h_right_length[y][x] + h_left_length[y][x])








print(ans)

Solution (Python):
H, W = map(int, input().split())
grid = []
for i in range(H):
    grid.append(input())

light = [[None for i in range(W)] for j in range(H)]

for i in range(H):
    j = 0
    count = 0
    before = 0
    while j <= W-1:
        if grid[i][j] == ".":
            count += 1
        else:
            for k in range(before, j):
                light[i][k] = count
            light[i][j] = 0
            before = j+1
            count = 0
        j += 1
    else:
        if count >= 0:
            for k in range(before, j):
                light[i][k] = count

light2 = [[None for i in range(W)] for j in range(H)]

for i in range(W):
    j = 0
    count = 0
    before = 0
    while j <= H-1:
        if grid[j][i] == ".":
            count += 1
        else:
            for k in range(before, j):
                light2[k][i] = count
            light2[j][i] = 0
            before = j+1
            count = 0
        j += 1
    else:
        if count >= 0:
            for k in range(before, j):
                light2[k][i] = count

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, light[i][j] + light2[i][j])
print(ans-1)

Solution (Python):

import sys
INF = float("inf")


def solve(H: int, W: int, S: "List[str]"):

    table1 = [[0]*W for _ in range(H)]
    for h in range(H):
        for i, c in enumerate(S[h]):
            if c == "
                table1[h][i] = 0
            else:
                if i == 0:
                    table1[h][i] = 1
                else:
                    table1[h][i] = table1[h][i-1]+1
    
    
    
    for h in range(H):
        buf = 0
        for w in range(W-1, -1, -1):
            if table1[h][w] != 0:
                if buf == 0:
                    buf = table1[h][w]
                table1[h][w] = buf
            else:
                buf = 0
    
    
    table2 = [[0]*W for _ in range(H)]
    for w in range(W):
        for h in range(H):
            c = S[h][w]
            if c == "
                table2[h][w] = 0
            else:
                if h == 0:
                    table2[h][w] = 1
                else:
                    table2[h][w] = table2[h-1][w]+1
    
    
    for w in range(W):
        buf = 0
        for h in range(H-1, -1, -1):
            if table2[h][w] != 0:
                if buf == 0:
                    buf = table2[h][w]
                table2[h][w] = buf
            else:
                buf = 0
    
    
        

    m = -INF
    for h in range(H):
        for w in range(W):
            buf = table1[h][w] + table2[h][w]
            if buf > m:
                m = buf
                
    print(m-1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    W = int(next(tokens))  
    S = [next(tokens) for _ in range(H)]  
    solve(H, W, S)


if __name__ == '__main__':
    main()

Solution (Python):
H, W = map(int, input().split())
S = [[0]*W for _ in range(H)]

for i in range(H):
    Si = list(input())
    for j in range(W):
        if Si[j] == '
            S[i][j] = 1


S_row = [[0]*W for _ in range(H)]
for i in range(H):
    c = 0
    for j in range(W):
        if S[i][j] == 1:
            c = 0
        else:
            c += 1
        S_row[i][j] = c
    
    for j in range(W-2, -1, -1):
        if S_row[i][j+1] > 0 and S_row[i][j] > 0:
            S_row[i][j] = S_row[i][j+1]


S_col = [[0]*W for _ in range(H)]
for j in range(W):
    c = 0
    for i in range(H):
        if S[i][j] == 1:
            c = 0
        else:
            c += 1
        S_col[i][j] = c
    
    for i in range(H-2, -1, -1):
        if S_col[i+1][j] > 0 and S_col[i][j] > 0:
            S_col[i][j] = S_col[i+1][j]


res = max([max([S_row[i][j] + S_col[i][j] - 1 for j in range(W)]) for i in range(H)])
print(res)

Solution (Python):
h, w = map(int, input().split())
cells = [input() for _ in range(h)]

us = [[0] * w for i in range(h)]
ds = [[0] * w for i in range(h)]
ls = [[0] * w for i in range(h)]
rs = [[0] * w for i in range(h)]

for x in range(w):
    u_cnt = 0
    for y in range(h):
        us[y][x] = u_cnt
        if cells[y][x] == '.':
            u_cnt += 1
        else:
            u_cnt = 0
    d_cnt = 0
    for y in range(h - 1, -1, -1):
        ds[y][x] = d_cnt
        if cells[y][x] == '.':
            d_cnt += 1
        else:
            d_cnt = 0
for y in range(h):
    l_cnt = 0
    for x in range(w):
        ls[y][x] = l_cnt
        if cells[y][x] == '.':
            l_cnt += 1
        else:
            l_cnt = 0

    r_cnt = 0
    for x in range(w - 1, -1, -1):
        rs[y][x] = r_cnt
        if cells[y][x] == '.':
            r_cnt += 1
        else:
            r_cnt = 0

maxv = 0
for y in range(h):
    for x in range(w):
        if cells[y][x] == '
            continue
        maxv = max(maxv, us[y][x] + ds[y][x] + ls[y][x] +
                   rs[y][x] + (1 if cells[y][x] == '.' else 0))
print(maxv)

Solution (Python):
h,w=map(int,input().split())
board=[list(input())+['
board.append(['
hacum=[[0]*(w+1) for _ in range(h+1)]
wacum=[[0]*(w+1) for _ in range(h+1)]
for i in range(h):
  tmp=0
  for j in range(w+1):
    if board[i][j]=='
      for k in range(tmp,j):
        wacum[i][k]=j-tmp
      tmp=j+1
for i in range(w):
  tmp=0
  for j in range(h+1):
    if board[j][i]=='
      for k in range(tmp,j):
        hacum[k][i]=j-tmp
      tmp=j+1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,wacum[i][j]+hacum[i][j]-1)
print(ans)

Solution (Python):
H, W = map(int, input().split())
S = [[1 if i == '

Hdp = [[0] * W for _ in range(H)]
Wdp = [[0] * W for _ in range(H)]

for i in range(H) :
    start = 0
    count = 0
    for j in range(W) :
        if S[i][j] == 1 :
            for k in range(start, j) :
                Hdp[i][k] = count
            start = j + 1
            count = 0
        else :
            count += 1
            
    for k in range(start, j + 1) :
        Hdp[i][k] = count
        
for i in range(W) :
    start = 0
    count = 0
    for j in range(H) :
        if S[j][i] == 1 :
            for k in range(start, j) :
                Wdp[k][i] = count
            start = j + 1
            count = 0
        else :
            count += 1
            
    for k in range(start, j + 1) :
        Wdp[k][i] = count

ret = 0  
for i in range(H) :
    for j in range(W) :
        ret = max(ret, Hdp[i][j] + Wdp[i][j])
        
print(ret - 1)

Solution (Python):
H,W=map(int,input().split())
S=[input() for i in range(H)]
A=[[0]*W for i in range(H)]
B=[[0]*W for i in range(H)]
for i in range(H):
    s=0
    t=0
    num=0
    while t<W:
        
        if S[i][t]=='
            for k in range(s,t):
                A[i][k]=num
            num=0
            t+=1
            s=t
        else:
            t+=1
            num+=1
    for k in range(s,t):
        A[i][k] = num
for j in range(W):
    s=0
    t=0
    num=0
    while t<H:
        
        if S[t][j]=='
            for k in range(s,t):
                B[k][j]=num
            num=0
            t+=1
            s=t
        else:
            t += 1
            num += 1
    for k in range(s,t):
        B[k][j] = num


ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]=='.':
            ans=max(ans,A[i][j]+B[i][j]-1)
print(ans)

Solution (Python):
H, W = map(int, input().split())
G = [[1 if s == '
T = [[0]*W for _ in range(H)]
for j, g in enumerate(G):
    S = [0]*W
    pre = 0
    for ig, g in enumerate(g):
        if g:
            pre = 0
            continue
        pre += 1
        S[ig] = pre
    pre = 0
    for k, s in enumerate(S[::-1]):
        k = W - 1 - k
        if not s:
            pre = 0
            continue
        pre = max(pre, s)
        T[j][k] = pre

G = list(map(list, zip(*G)))
T2 = [[0]*H for _ in range(W)]

for j, g in enumerate(G):
    S = [0]*H
    pre = 0
    for ig, g in enumerate(g):
        if g:
            pre = 0
            continue
        pre += 1
        S[ig] = pre
    pre = 0
    for k, s in enumerate(S[::-1]):
        k = H - 1 - k
        if not s:
            pre = 0
            continue
        pre = max(pre, s)
        T2[j][k] = pre
T2 = list(map(list, zip(*T2)))
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, T[i][j] + T2[i][j])
print(ans - 1)

Solution (Python):
H,W = map(int,input().split())
S = ["

h = [[-int(c=="
v = [[-int(c=="

for i in range(1,H+1):
    l = 1
    cnt = 0
    for j in range(1,W+2):
        if S[i][j] == "
            h[i][l:j] = [cnt]*(j-l)
        elif S[i][j] == "." and S[i][j-1] == "
            l = j
            cnt = 1
        elif S[i][j] == "." and S[i][j-1] == ".":
            cnt += 1
            
for j in range(1,W+1):
    l = 1
    cnt = 0
    for i in range(1,H+2):
        if S[i][j] == "
            for k in range(l,i):
                v[k][j] = cnt
        elif S[i][j] == "." and S[i-1][j] == "
            l = i
            cnt = 1
        elif S[i][j] == "." and S[i-1][j] == ".":
            cnt += 1

print(max(h[i][j]+v[i][j] for i in range(1,H+1) for j in range(1,W+2))-1)

Solution (Python):
h,w = map(int, input().split())
s = [input() for i in range(h)]

l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]
u = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w-1):
        if s[i][j]=='.':
            l[i][j+1] = l[i][j]+1

for i in range(h):
    for j in range(1,w):
        if s[i][w-j]=='.':
            r[i][w-j-1] = r[i][w-j]+1

for i in range(h-1):
    for j in range(w):
        if s[i][j]=='.':
            u[i+1][j] = u[i][j]+1

for i in range(1,h):
    for j in range(w):
        if s[h-i][j]=='.':
            d[h-i-1][j] = d[h-i][j]+1

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            ans = max(ans, l[i][j]+r[i][j]+u[i][j]+d[i][j]+1)

print(ans)

Solution (Python):
H, W = map(int, input().split())
T = [[] for i in range(H)]
for i in range(H):
    a = list(input())
    T[i] = a

U = [[0] * W for j in range(H)]
L = [[0] * W for j in range(H)]
R = [[0] * W for j in range(H)]
D = [[0] * W for j in range(H)]
for i in range(H):
    for j in range(W):
        if i > 0:
            if T[i][j] != "
                U[i][j] = U[i - 1][j] + 1
        else:
            U[i][j] = int(T[i][j] != "

        if j > 0:
            if T[i][j] != "
                L[i][j] = L[i][j - 1] + 1
        else:
            L[i][j] = int(T[i][j] != "

for i in range(H - 1, -1, -1):
    for j in range(W - 1, -1, -1):
        if i < H - 1:
            if T[i][j] != "
                D[i][j] = D[i + 1][j] + 1
        else:
            D[i][j] = int(T[i][j] != "

        if j < W - 1:
            if T[i][j] != "
                R[i][j] = R[i][j + 1] + 1
        else:
            R[i][j] = int(T[i][j] != "


num = 0
for i in range(H):
    for j in range(W):
        tmp = 0
        if T[i][j] == '.':
            tmp += U[i][j] + D[i][j] + R[i][j] + L[i][j] - 3
        num = max(num, tmp)
print(num)

Solution (Python):
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hor = [[0] * w for _ in range(h)]
ver = [[0] * w for _ in range(h)]

for i in range(h):
    now = 0
    for j in range(w):
        if s[i][j] == '
            now = 0
        else:
            now += 1
            hor[i][j] = now

for j in range(w):
    now = 0
    for i in range(h):
        if s[i][j] == '
            now = 0
        else:
            now += 1
            ver[i][j] = now

for i in range(h-1, -1, -1):
    now = 0
    for j in range(w-1, -1, -1):
        if s[i][j] == '
            now = 0
        else:
            now = max(now, hor[i][j])
            hor[i][j] = now

for j in range(w-1, -1, -1):
    now = 0
    for i in range(h-1, -1, -1):
        if s[i][j] == '
            now = 0
        else:
            now = max(now, ver[i][j])
            ver[i][j] = now

res = 0
for i in range(h):
    for j in range(w):
        res = max(hor[i][j] + ver[i][j] - 1, res)
print(res)

Solution (Python):
from itertools import accumulate

def getNums(Ss):
    lenS = len(Ss)
    nums = [0] * lenS
    Ss += '
    num = -1
    for i, S in enumerate(Ss):
        if S == '.':
            num += 1
        else:
            if num > 0:
                nums[i-(num+1)] = num
                if i < lenS:
                    nums[i] = -num
            num = -1
    return accumulate(nums)


H, W = map(int, input().split())
Sss = [input() for _ in range(H)]

numHss = [list(getNums(Ss)) for Ss in Sss]
Sss_tr = list(map(''.join, zip(*Sss))) 
numVss_tr = [getNums(Ss) for Ss in Sss_tr]
numVss = list(map(list, zip(*numVss_tr))) 

ans = 0
for i in range(H):
    for j in range(W):
        num = numHss[i][j] + numVss[i][j] + 1
        if num > ans:
            ans = num

print(ans)

Solution (Python):
import sys
def input():
	return sys.stdin.readline()[:-1]

H, W = map(int, input().split())
s = [input() for _ in range(H)]
tate = [[0 for _ in range(W)] for _ in range(H)]
yoko = [[0 for _ in range(W)] for _ in range(H)]
for h in range(H):
	ba, fr = 0, 0
	while ba < W:
		if s[h][ba] == "
			ba += 1
			fr += 1
		while fr < W and s[h][fr] == ".":
			fr += 1
		for w in range(ba, fr):
			yoko[h][w] = fr-ba
		ba = fr

for w in range(W):
	ba, fr = 0, 0
	while ba < H:
		if s[ba][w] == "
			ba += 1
			fr += 1
		while fr < H and s[fr][w] == ".":
			fr += 1
		for h in range(ba, fr):
			tate[h][w] = fr-ba
		ba = fr

ans = 1
for h in range(H):
	for w in range(W):
		ans = max(ans, yoko[h][w]+tate[h][w]-1)
print(ans)

Solution (Python):
H, W = [int(i) for i in input().split()]
S = [[i for i in input()] for j in range(H)]

T = [[0 if S[j][i] == '

for h in range(H):
    s = 0
    for w in range(W):
        if S[h][w] == '
            s = 0
            continue
        T[h][w] += s
        s += 1

for h in range(H):
    s = 0
    for w in range(W - 1, -1, -1):
        if S[h][w] == '
            s = 0
            continue
        T[h][w] += s
        s += 1

for w in range(W):
    s = 0
    for h in range(H):
        if S[h][w] == '
            s = 0
            continue
        T[h][w] += s
        s += 1

for w in range(W):
    s = 0
    for h in range(H - 1, -1, -1):
        if S[h][w] == '
            s = 0
            continue
        T[h][w] += s
        s += 1

print(max(max(t) for t in T))

Solution (Python):
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]


right_space = [[-1] * (W + 2) for i in range(H + 2)]
down_space = [[-1] * (W + 2) for i in range(H + 2)]
left_space = [[-1] * (W + 2) for i in range(H + 2)]
up_space = [[-1] * (W + 2) for i in range(H + 2)]


for h in range(1, H + 1):
    for w in range(1, W + 1):
        if G[h - 1][w - 1] == '.':
            up_space[h][w] = up_space[h - 1][w] + 1
            left_space[h][w] = left_space[h][w - 1] + 1


for h in reversed(range(1, H + 1)):
    for w in reversed(range(1, W + 1)):
        if G[h - 1][w - 1] == '.':
            down_space[h][w] = down_space[h + 1][w] + 1
            right_space[h][w] = right_space[h][w + 1] + 1

ans = 0
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if G[h - 1][w - 1] == '.':
            tmp_ans = right_space[h][w] + down_space[h][w] + left_space[h][w] + up_space[h][w] + 1
            ans = max(ans, tmp_ans)

print(ans)

Solution (Python):
H, W = map(int, input().split())
X = [[0]*W for _ in range(H)]
Y = [[0]*W for _ in range(H)]
S = [input() for _ in range(H)]
for y, s in enumerate(S):
    for x, c in enumerate(s):
        if c==".":
            X[y][x] = X[y][x-1] + 1
    vp = X[y][-1]

    for x in range(W-2, -1, -1):
        v = X[y][x]
        if v != 0:
            v = X[y][x] = max(v, vp)
        vp = v

for x in range(W):
    for y in range(H):
        c = S[y][x]
        if c==".":
            Y[y][x] = Y[y-1][x] + 1

    vp = Y[-1][x]
    for y in range(H-2, -1, -1):
        v = Y[y][x]
        if v != 0:
            v = Y[y][x] = max(v, vp)
        vp = v

ans = 0
for x, y in zip(X, Y):
    for xx, yy in zip(x, y):
        ans = max(ans, xx+yy)
print(ans-1)

Solution (Python):










h,w = [int(i) for i in input().split()]
b = [input() for i in range(h)]

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

for i in range(h):
    res = 0
    for j in range(w):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0



for i in range(h):
    res = 0
    for j in range(w-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0



for j in range(w):
    res = 0
    for i in range(h):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0



for j in range(w):
    res = 0
    for i in range(h-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0



print(max(max(row) for row in ans) + 1)

Solution (Python):
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    grid = [[0] * W for _ in range(H)]
    for i in range(H):
        seq = 0
        start = 0
        for j in range(W):
            if S[i][j] == "
                for x in range(start, j):
                    grid[i][x] += seq
                seq = 0
                start = j+1
            else:
                seq += 1
        if seq:
            for x in range(start, W):
                grid[i][x] += seq
    for j in range(W):
        seq = 0
        start = 0
        for i in range(H):
            if S[i][j] == "
                for x in range(start, i):
                    grid[x][j] += seq
                seq = 0
                start = i+1
            else:
                seq += 1
        if seq:
            for x in range(start, H):
                grid[x][j] += seq
    ans = 1    
    for i in range(H):
        for j in range(W):
            if grid[i][j]:
                ans = max(grid[i][j] - 1, ans)
    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]
Iplus=[[-1 for j in range(W)] for i in range(H)]
Iminus=[[-1 for j in range(W)] for i in range(H)]
Jplus=[[-1 for j in range(W)] for i in range(H)]
Jminus=[[-1 for j in range(W)] for i in range(H)]
for j in range(W):
    if S[0][j]==".":
        Iplus[0][j]=0
for i in range(1,H):
    for j in range(W):
        if S[i][j]==".":
            Iplus[i][j]=Iplus[i-1][j]+1
        else:
            Iplus[i][j]=-1
for j in range(W):
    if S[-1][j]==".":
        Iminus[-1][j]=0
for i in range(H-1)[::-1]:
    for j in range(W):
        if S[i][j]==".":
            Iminus[i][j]=Iminus[i+1][j]+1
        else:
            Iminus[i][j]=-1
for i in range(H):
    if S[i][0]==".":
        Jplus[i][0]=0
for j in range(1,W):
    for i in range(H):
        if S[i][j]==".":
            Jplus[i][j]=Jplus[i][j-1]+1
        else:
            Jplus[i][j]=-1
for i in range(H):
    if S[i][-1]==".":
        Jminus[i][-1]=0
for j in range(W-1)[::-1]:
    for i in range(H):
        if S[i][j]==".":
            Jminus[i][j]=Jminus[i][j+1]+1
        else:
            Jminus[i][j]=-1
ans=0
for i in range(H):
    for j in range(W):
        tmp=Iplus[i][j]+Iminus[i][j]+Jplus[i][j]+Jminus[i][j]+1
        if ans<tmp:
            ans=tmp
            

print(ans)

Solution (Python):
h,w = map(int, input().split())

b = [list(input()) for i in range(h)]
yoko = [[0]*w for i in range(h)]
for i in range(h):
    now = 0
    while now < w:
        if b[i][now] == "
            now += 1
            continue
        cnt = 0
        to = now
        while to<w and b[i][to] == ".":
            cnt += 1
            to += 1
        for j in range(now, to):
            yoko[i][j] = cnt
        now = to

for i in range(w):
    now = 0
    while now < h:
        if b[now][i] == "
            now += 1
            continue
        cnt = 0
        to = now
        while to<h and b[to][i] == ".":
            cnt += 1
            to += 1
        for j in range(now, to):
            yoko[j][i] += cnt
        now = to

ans = 0
for i in range(h):
    for j in range(w):
        if ans < yoko[i][j]:
            ans = yoko[i][j]
if ans:
    ans -= 1
print(ans)

Solution (Python):
H, W = map(int, input().split())
X = [[[0, 1][a=="
Y = [[0]*W for _ in range(H)]
Z = [[0]*W for _ in range(H)]

for i in range(H):
    t = 0
    for j in range(W):
        if X[i][j]:
            t = 0
        else:
            t += 1
            Y[i][j] = t

for i in range(H):
    t = 0
    for j in range(W)[::-1]:
        if X[i][j]:
            t = 0
        else:
            Y[i][j] += t
            t += 1

for j in range(W):
    t = 0
    for i in range(H):
        if X[i][j]:
            t = 0
        else:
            t += 1
            Z[i][j] = t

for j in range(W):
    t = 0
    for i in range(H)[::-1]:
        if X[i][j]:
            t = 0
        else:
            Z[i][j] += t
            t += 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, Y[i][j] + Z[i][j])

print(max(ans-1, 0))

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
h,w=IL()
G=[S() for i in range(h)]
V=[[0]*w for i in range(h)]
H=[[0]*w for i in range(h)]
c=0
for i in range(h):
    for j in range(w):
        if G[i][j]=="
            for k in range(c):
                H[i][j-k-1]=c
            c=0
        elif j==w-1:
            c+=1
            for k in range(c):
                H[i][j-k-1]=c
            c=0
        else:
            c+=1
            
for i in range(w):
    for j in range(h):
        if G[j][i]=="
            for k in range(c):
                V[j-k-1][i]=c
            c=0
        elif j==h-1:
            c+=1
            for k in range(c):
                V[j-k-1][i]=c
            c=0
        else:
            c+=1

ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,V[i][j]+H[i][j]-1)
print(ans)

Solution (Python):
H, W = map(int, input().split())
S = [input() for _ in range(H)]

dp1 = [[0 for _ in range(W)] for _ in range(H)]
dp2 = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if dp1[i][j] == 0 and S[i][j] == '.':
            c = 0
            for k in range(i, H):
                if S[k][j] == '.':
                    c += 1
                else:
                    break
            for k in range(i, H):
                if S[k][j] == '.':
                    dp1[k][j] = c
                else:
                    break
for i in range(H):
    for j in range(W):
        if dp2[i][j] == 0 and S[i][j] == '.':
            c = 0
            for k in range(j, W):
                if S[i][k] == '.':
                    c += 1
                else:
                    break
            for k in range(j, W):
                if S[i][k] == '.':
                    dp2[i][k] = c
                else:
                    break

ans = max(
    dp1[i][j] + dp2[i][j] - 1
    for i in range(H)
    for j in range(W)
)
print(ans)

Solution (Python):
H, W = map(int, input().split())
S = [input() for i in range(H)]
P = [[0]*W for i in range(H)]
Q = [[0]*W for i in range(H)]
for i in range(H):
    p = -1
    for j in range(W):
        if S[i][j] == '
            c = j - p - 1
            for k in range(p+1, j):
                P[i][k] = c
            p = j
    c = W - p - 1
    for k in range(p+1, W):
        P[i][k] = c
for j in range(W):
    p = -1
    for i in range(H):
        if S[i][j] == '
            c = i - p - 1
            for k in range(p+1, i):
                Q[k][j] = c
            p = i
    c = H - p - 1
    for k in range(p+1, H):
        Q[k][j] = c
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '
            ans = max(ans, P[i][j] + Q[i][j])
print(ans - 1)

Solution (Python):
h, w = [int(i) for i in input().split(" ")]
s = ["" for i in range(0, h)]

for i in range(0, h):
    s[i] = input()

xs = [[0 for j in range(0, w)] for i in range(0, h)]
ys = [[0 for j in range(0, w)] for i in range(0, h)]

for i in range(0, h):
    l = 0
    r = 0
    c = 0
    for j in range(0, w + 1):
        if j < w and s[i][j] == ".":
            r = j
            c += 1
        else:
            for k in range(l, r + 1):
                xs[i][k] = c
            l = j
            r = j
            c = 0

for j in range(0, w):
    l = 0
    r = 0
    c = 0
    for i in range(0, h + 1):
        if i < h and s[i][j] == ".":
            r = i
            c += 1
        else:
            for k in range(l, r + 1):
                ys[k][j] = c
            l = i
            r = i
            c = 0

mx = 0

for i in range(0, h):
    for j in range(0, w):
        if s[i][j] == "." and xs[i][j] + ys[i][j] - 1 > mx:
            mx = xs[i][j] + ys[i][j] - 1
print(mx)

Solution (Python):
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]

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

for i in range(h):
    cnt = 0
    for j in range(w):
        if s[i][j] == '
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1

    cnt = 0
    for j in range(w-1,-1,-1):
        if s[i][j] == '
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1



for j in range(w):
    cnt = 0
    for i in range(h):
        if s[i][j] == '
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1
    cnt = 0
 
    for i in range(h-1,-1,-1):
        if s[i][j] == '
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1

res = -1
for i in range(h):
    for j in range(w):
        res = max(res,num[i][j])
print(res+1)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    p,q,r = LI()
    print(p+q+r-max(p,q,r))
    return


def B():
    n = I()
    w = LI()
    ans = float("inf")
    for i in range(n):
        m = sum(w[:i])
        l = sum(w[i:])
        ans = min(ans,abs(m-l))
    print(ans)
    return


def C():
    n,m = LI()
    f = [1 for i in range(n+1)]
    for i in range(m):
        a = I()
        f[a] = 0
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(1,n+1):
        if f[i]:
            dp[i] = dp[i-1]+dp[i-2]
            dp[i] %= mod
    print(dp[n])
    return


def D():
    h,w = LI()
    s = SR(h)
    vi = [[0 for j in range(w)] for i in range(h)]
    ho = [[0 for j in range(w)] for i in range(h)]
    q = deque()
    for y in range(h):
        for x in range(w):
            if s[y][x] == "
                l = len(q)
                while q:
                    i,j = q.pop()
                    vi[i][j] = l
            else:
                q.append((y,x))
        l = len(q)
        while q:
            i,j = q.pop()
            vi[i][j] = l
    for x in range(w):
        for y in range(h):
            if s[y][x] == "
                l = len(q)
                while q:
                    i,j = q.pop()
                    ho[i][j] = l
            else:
                q.append((y,x))
        l = len(q)
        while q:
            i,j = q.pop()
            ho[i][j] = l
    ans = 0
    for y in range(h):
        for x in range(w):
            ans = max(ans,vi[y][x]+ho[y][x]-1)
    print(ans)
    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    D()