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):
h, w = map(int, input().split())

mm = ['
m = ['

vertical = [[0] * (w+1) for i in range(h+1)]
for i in range(1, h+1):
    c = 0
    for j in range(1, w+2):
        if m[i][j] == '
            for k in range(c+1, j):
                vertical[i][k] = j-c-1
            c = j


horizontal = [[0] * (w+1) for i in range(h+1)]
for i in range(1, w+1):
    c = 0
    for j in range(1, h+2):
        if m[j][i] == '
            for k in range(c+1, j):
                horizontal[k][i] = j-c-1
            c = j

ans = 1
for i in range(1, h+1):
    for j in range(1, w+1):
        if m[i][j] == '
            continue
        ans = max(ans, vertical[i][j] + horizontal[i][j] - 1)

print(ans)

Solution (Python):
H, W = list(map(int, input().split()))
Hs = [[0] * W for i in range(H)]
Vs = [[0] * W for i in range(H)]
 
Ss = [0] * H
for i in range(H):
    Ss[i] = input()
 
for i in range(H):
    s = 0
    e = 0
    c = 0
    for k in range(W):
        if Ss[i][k] == ".":
            c += 1
        else:
            e = k
            for m in range(e - s):
                Hs[i][s + m] = c
            s = e + 1
            c = 0
    e = W
    for m in range(e - s):
        Hs[i][s + m] = c

for i in range(W):
    s = 0
    e = 0
    c = 0
    for k in range(H):
        if Ss[k][i] == ".":
            c += 1
        else:
            e = k
            for m in range(e - s):
                Vs[s + m][i] = c
            s = e + 1
            c = 0
    e = H
    for m in range(e - s):
        Vs[s + m][i] = c
 
maxv = 0
for i in range(H):
    for k in range(W):
        t = Hs[i][k] + Vs[i][k] - 1
        if t > maxv:
            maxv = t
print(maxv)

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

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

yoko=[[0 for i in range(w)] for j in range(h)]
tate=[[0 for i in range(w)] for j in range(h)]

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




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



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

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

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

for y in range(h):
  for x in range(w):
    if smap[y][x] == '
      L[y][x] = 0
      D[y][x] = 0
    else:
      if 0 < x <= w-1:
        L[y][x] = L[y][x-1] + 1
      else:
        L[y][x] = 1
      if 0 < y <= h-1:
        D[y][x] = D[y-1][x] + 1
      else:
        D[y][x] = 1

for y in range(h-1, -1, -1):
  for x in range(w-1, -1, -1):
    if smap[y][x] == '
      R[y][x] = 0
      U[y][x] = 0
    else:
      if 0 <= x < w-1:
        R[y][x] = R[y][x+1] + 1
      else:
        R[y][x] = 1
      if 0 <= y < h-1:
        U[y][x] = U[y+1][x] + 1
      else:
        U[y][x] = 1

ans = 0
for y in range(h):
  for x in range(w):
    tmp = L[y][x] + R[y][x] + U[y][x] + D[y][x] - 3
    if ans < tmp:
      ans = tmp

print(ans)

Solution (Python):
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)

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

def cal(l):
    ll = list(l)
    ll.append('
    vol = [-100 for j in range(len(ll))]
    i = 0
    while i <= len(ll)-1:
        cnt = 0
        while (ll[i] != '
            cnt += 1
            i += 1

        for j in range(i-cnt,i):
            vol[j] = cnt

        i += 1
    return vol[:-1]

ver = [] 
hori = [] 
fmap = []

for h in range(H):
    l = list(input())
    hori.append(cal(l))
    fmap.append(l)



new_map = []
for i in range(len(fmap[0])):
    mini_l = []
    for j in range(len(fmap)):
        mini_l.append(fmap[j][i])
    new_map.append(mini_l)

fmap = new_map    

for w in range(W):
    ver.append(cal(fmap[w]))

ans = 0

for h in range(H):
    for w in range(W):
        s = hori[h][w]+ver[w][h]
        if s > ans:
            ans = s
print(ans-1)

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


Rs = [[0]*W for i in range(H)]
Ls = [[0]*W for i in range(H)]
Ds = [[0]*W for i in range(H)]
Us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    
    for j in range(W):
        if S[i][j] == '
            tmp = 0
        else:
            tmp += 1
            Ls[i][j] = tmp
    tmp = 0
    
    for j in reversed(range(W)):
        if S[i][j] == '
            tmp = 0
        else:
            tmp += 1
            Rs[i][j] = tmp


for j in range(W):
    tmp = 0
    
    for i in range(H):
        if S[i][j] == '
            tmp = 0
        else:
            tmp += 1
            Us[i][j] = tmp
    tmp = 0
    
    for i in reversed(range(H)):
        if S[i][j] == '
            tmp = 0
        else:
            tmp += 1
            Ds[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '
            continue
        
        tmp = Rs[i][j] + Ls[i][j] + Ds[i][j] + Us[i][j] - 3
        ans = max(ans, tmp)
print(ans)

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

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

light = [[0 for i in range(w)] for j in range(h)]

for j in range(h):
    point = 0
    for i in range(w):
        if s[j][i] == ".":
            point += 1
            light[j][i] += point
        else:
            point = 0

    point = 0
    for i in range(w):
        if s[j][-1-i] == ".":
            point += 1
            light[j][-1-i] += point
        else:
            point = 0

for j in range(w):
    point = 0
    for i in range(h):
        if s[i][j] == ".":
            point += 1
            light[i][j] += point
        else:
            point = 0

    point = 0
    for i in range(h):
        if s[-1-i][j] == ".":
            point += 1
            light[-1-i][j] += point
        else:
            point = 0

ans = 0
for i in range(h):
    ans = max(ans, max(light[i]))
print(ans-3)

Solution (Python):
import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
ans = [[1]*w for i in range(h)]
res = 0
for i in range(h):
        res = 0
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0

res = 0
for i in range(h):
        res = 0
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        res = res+1
                if s[j][i] == ".":
                        ans[j][i] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        res = res +1
                if s[j][i] == ".":
                        ans[j][i] += res           
                else:
                        res = 0  
ans2 = 0
for i in range(h):
        for j in range(w):
                ans2 = max(ans2,ans[i][j])
print(ans2)

Solution (Python):
h,w=map(int,input().split())
T=[["
T.extend([["
T.append(["
L=[[0]*w for _ in range(h)]
R=[[0]*w for _ in range(h)]
U=[[0]*w for _ in range(h)]
D=[[0]*w for _ in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if T[i][j]==".":
      if j==1:
        L[i-1][j-1]=1
      else:
        L[i-1][j-1]=L[i-1][j-2]+1
      if i==1:
        U[i-1][j-1]=1
      else:
        U[i-1][j-1]=U[i-2][j-1]+1
    if T[h+1-i][w+1-j]==".":
      if j==1:
        R[h-i][w-j]=1
      else:
        R[h-i][w-j]=R[h-i][w-j+1]+1
      if i==1:
        D[h-i][w-j]=1
      else:
        D[h-i][w-j]=D[h-i+1][w-j]+1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)

Solution (Python):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]
for h in range(H):
    for w in range(W):
        if grid[h][w] ==".":
            L[h][w] = L[h][w-1]+1
            U[h][w] = U[h-1][w]+1
        if grid[h][W-w-1]==".":
            R[h][-w-1]=R[h][-w]+1
        if grid[H-h-1][w] ==".":
            D[-h-1][w] = D[-h][w]+1
ans = 0
for i in range(H):
    for j in range(W):
        if grid[i][j] =="
            ans = max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j])
        else:
            ans = max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)

Solution (Python):
MOD = int(1e9) + 7

def main():
    buf = input()
    buflist = buf.split()
    H = int(buflist[0])
    W = int(buflist[1])
    S = []
    for i in range(H):
        buf = input()
        S.append(buf)
    lightmap_h = []
    for i in range(H):
        lightmap_h.append([])
        for j in range(W):
            lightmap_h[i].append(0)
    lightmap_v = []
    for j in range(H):
        lightmap_v.append([])
        for i in range(W):
            lightmap_v[j].append(0)
    for i in range(H):
        light_count = 0
        last_pointer = 0
        for j in range(W):
            if S[i][j] == '.':
                light_count += 1
            else:
                for k in range(last_pointer, j):
                    lightmap_h[i][k] = light_count
                light_count = 0
                last_pointer = j+1
        for k in range(last_pointer, W):
            lightmap_h[i][k] = light_count
    for j in range(W):
        light_count = 0
        last_pointer = 0
        for i in range(H):
            if S[i][j] == '.':
                light_count += 1
            else:
                for k in range(last_pointer, i):
                    lightmap_v[k][j] = light_count
                light_count = 0
                last_pointer = i+1
        for k in range(last_pointer, H):
            lightmap_v[k][j] = light_count
    maximum = 0
    for i in range(H):
        for j in range(W):
            hor = lightmap_h[i][j]
            vert = lightmap_v[i][j]
            if hor == 0 or vert == 0:
                continue
            light_distance = hor + vert - 1
            if light_distance > maximum:
                maximum = light_distance
    print(maximum)

if __name__ == '__main__':
    main()

Solution (Python):
H,W = map(int,input().split())
S = list(input() for i in range(H))
Grid1 = [[0]*W for i in range(H)]
for i in range(H):
    cou = 0
    l = 0
    for j in range(W):
        if S[i][j] == ".":
            cou += 1
        else:
            for x in range(l,j):
                Grid1[i][x] = cou
            l = j+1
            cou = 0
    for x in range(l,j+1):
        Grid1[i][x] = cou    
for i in range(W):
    cou = 0
    l = 0
    for j in range(H):
        
        if S[j][i] == ".":
            cou += 1
        else:
            for x in range(l,j):
                Grid1[x][i] += cou
            l = j+1
            cou = 0
    for x in range(l,j+1):
        Grid1[x][i] += cou

print(max(max(Grid1[i]) for i in range(H))-1)

Solution (Python):
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
count_matw = [[0 for w in range(W)]for h in range(H)]
count_math = [[0 for w in range(W)]for h in range(H)]

for h in range(H):
    count = 0
    for w in range(W):
        if '
            count = 0
        else:
            count += 1
        count_matw[h][w] = count
    for w in range(W-1, 0, -1):
        if count_matw[h][w-1] == 0:
            continue
        count_matw[h][w-1] = max(count_matw[h][w], count_matw[h][w-1])

for w in range(W):
    count = 0
    for h in range(H):
        if '
            count = 0
        else:
            count += 1
        count_math[h][w] = count
    for h in range(H-1, 0, -1):
        if count_math[h-1][w] == 0:
            continue
        count_math[h-1][w] = max(count_math[h][w], count_math[h-1][w])
ans = 1
for h in range(H):
    for w in range(W):
        ans = max(ans, count_math[h][w] + count_matw[h][w])



print(ans-1)

Solution (Python):
import numpy as np
import sys

H, W = list(map(int, sys.stdin.readline().split()))
S = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)]) == '.'
ups = np.zeros((H, W), dtype=int)
downs = np.zeros((H, W), dtype=int)
rights = np.zeros((H, W), dtype=int)
lefts = np.zeros((H, W), dtype=int)

for h in range(1, H):
    ups[h] = (ups[h - 1] + 1) * S[h - 1]
    downs[H - h - 1] = (downs[H - h] + 1) * S[H - h]
for w in range(1, W):
    lefts[:, w] = (lefts[:, w - 1] + 1) * S[:, w - 1]
    rights[:, W - w - 1] = (rights[:, W - w] + 1) * S[:, W - w]
print(((ups + downs + lefts + rights) * S).max() + 1)

Solution (Python):
H,W = list(map(int, input().split()))
S = [[0 if s=='

SH = [[0]*W for _ in range(H)]
SH_ = [[0]*W for _ in range(H)]

SV = [[0]*W for _ in range(H)]
SV_ = [[0]*W for _ in range(H)]


for h in range(H):
  SH[h][0] = S[h][0]
  for w in range(1,W):
    if S[h][w]:
      SH[h][w] = SH[h][w-1] + 1
  
  SH_[h][-1] = S[h][-1]
  for w in range(W-1)[::-1]:
    if S[h][w]:
      SH_[h][w] = SH_[h][w+1] + 1
  


for w in range(W):
  SV[0][w] = S[0][w]
  for h in range(1,H):
    if S[h][w]:
      SV[h][w] = SV[h-1][w] + 1
  
  SV_[-1][w] = S[-1][w]
  for h in range(H-1)[::-1]:
    if S[h][w]:
      SV_[h][w] = SV_[h+1][w] + 1




ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans, SH[h][w] + SH_[h][w] + SV[h][w] + SV_[h][w] -3)

print(ans)

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

w_score = [[0]*W for _ in range(H)]
h_score = [[0]*W for _ in range(H)]

begin = -1
streak = 1
for hi in range(H):
    for wi in range(W):
        if begin == -1 and S[hi][wi]=='.':
            begin = wi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if wi ==W-1 or(begin != -1 and S[hi][wi]=='
            if wi == W-1 and S[hi][wi]=='.':
                w_score[hi][wi]=streak
            for i in range(W)[begin:wi]:
                w_score[hi][i] = streak
            streak = 1
            begin = -1





begin = -1
streak = 1
for wi in range(W):
    for hi in range(H):
        if begin == -1 and S[hi][wi]=='.':
            begin = hi
        elif begin != -1 and S[hi][wi] == '.':
            streak += 1
        if hi ==H-1 or(begin != -1 and S[hi][wi]=='
            if hi == H-1 and S[hi][wi]=='.':
                h_score[hi][wi]= streak
            for i in range(H)[begin:hi]:
                h_score[i][wi] = streak
            streak = 1
            begin = -1





ans = 0
score = [[0]*W for _ in range(H)]
for hi in range(H):
    for wi in range(W):
        w =w_score[hi][wi] 
        h= h_score[hi][wi] 
        score_ = w+h
        score_ += -1 if w>0 and h>0 else 0
        ans = max(ans,score_)
        score[hi][wi] = score_
        



print(ans)

Solution (Python):
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
count_matw = [[0 for w in range(W)]for h in range(H)]
count_math = [[0 for w in range(W)]for h in range(H)]

for h in range(H):
    count = 0
    for w in range(W):
        if '
            count = 0
        else:
            count += 1
        count_matw[h][w] = count
    for w in range(W-1, 0, -1):
        if count_matw[h][w-1] == 0:
            continue
        count_matw[h][w-1] = max(count_matw[h][w], count_matw[h][w-1])

for w in range(W):
    count = 0
    for h in range(H):
        if '
            count = 0
        else:
            count += 1
        count_math[h][w] = count
    for h in range(H-1, 0, -1):
        if count_math[h-1][w] == 0:
            continue
        count_math[h-1][w] = max(count_math[h][w], count_math[h-1][w])
ans = 1



ans = max([count_math[h][w] + count_matw[h][w] for h in range(H) for w in range(W)])


print(ans-1)

Solution (Python):
import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

h, w = lmi()
s = [input() for i in range(h)]

a = [[] for i in range(h)]

b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
    k = 0
    for j in range(w):
        if s[i][j] == '.':
            k += 1
            if j == w-1:
                a[i].append(k)
                
        elif j != 0 and s[i][j-1] == '.':
            a[i].append(k)
            
            k = 0

for i in range(w):
    k = 0
    for j in range(h):
        if s[j][i] == '.':
            k += 1
            if j == h-1:
                b[i].append(k)
                bl[i].append(j)
        elif j != 0 and s[j-1][i] == '.':
            b[i].append(k)
            bl[i].append(j-1)
            k = 0
'''
print(a)
print(al)
print(b)
print(bl)
'''

ans = 0
for i in range(h):
    k = 0
    c = -1
    for j in range(w):
        if s[i][j] == '.':
            c = a[i][k]
            d = b[j][bisect_left(bl[j], i)]
            
            ans = max(ans, c+d-1)
        elif j != 0 and s[i][j-1] == '.' and c != -1:
                k += 1
print(ans)

Solution (Python):
import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

h, w = lmi()
s = [input() for i in range(h)]

a = [[] for i in range(h)]
al = [[] for i in range(h)]
b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
    k = 0
    for j in range(w):
        if s[i][j] == '.':
            k += 1
            if j == w-1:
                a[i].append(k)
                al[i].append(j)
        elif j != 0 and s[i][j-1] == '.':
            a[i].append(k)
            al[i].append(j-1)
            k = 0

for i in range(w):
    k = 0
    for j in range(h):
        if s[j][i] == '.':
            k += 1
            if j == h-1:
                b[i].append(k)
                bl[i].append(j)
        elif j != 0 and s[j-1][i] == '.':
            b[i].append(k)
            bl[i].append(j-1)
            k = 0
'''
print(a)
print(al)
print(b)
print(bl)
'''

ans = 0
for i in range(h):
    k = 0
    c = -1
    for j in range(w):
        if s[i][j] == '.':
            c = a[i][k]
            d = b[j][bisect_left(bl[j], i)]
            
            ans = max(ans, c+d-1)
        elif j != 0 and s[i][j-1] == '.' and c != -1:
                k += 1
print(ans)

Solution (Python):
h, w = map(int, input().split())
s = [input() for i in range(h)]
yoko = [([0] * w) for i in range(h)]
tate = [([0] * w) for i in range(h)]
 
for i in range(h):
    f = 0
    j = 0
    m = 0
    while j < w:
        if s[i][j] == ".":
            if m == 0:
                j += 1
            else:
                f = j
                m = 0
                j += 1
        else:
            if m == 0:
                for p in range(f, j):
                    yoko[i][p] = j - f
            m = 1
            j += 1
    if m == 0:
        for p in range(f, j):
            yoko[i][p] = j - f
 
for i in range(w):
    f = 0
    j = 0
    m = 0
    while j < h:
        if s[j][i] == ".":
            if m == 0:
                j += 1
            else:
                f = j
                m = 0
                j += 1
        else:
            if m == 0:
                for p in range(f, j):
                    tate[p][i] = j - f
            m = 1
            j += 1
    if m == 0:
        for p in range(f, j):
            tate[p][i] = j - f
ans = 0
for i in range(h):
    for j in range(w):
        q = yoko[i][j] + tate[i][j] - 1
        if q > ans:
            ans = q
print(ans)

Solution (Python):
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
dpyoko = [[1]*(W) for i in range(H)]
for j in range(W):
    for i in range(H):
        if S[i][j] == '
            dpyoko[i][j] = 0
        else:
            if j != 0:
                dpyoko[i][j] += dpyoko[i][j-1]
for j in range(W-1,-1,-1):
    for i in range(H):
        if dpyoko[i][j] == 0:
            continue
        if j == W-1:
            continue
        dpyoko[i][j] = max(dpyoko[i][j],dpyoko[i][j+1])
dptate = [[1]*(W) for i in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '
            dptate[i][j] = 0
        else:
            if i != 0:
                dptate[i][j] += dptate[i-1][j]
for i in range(H-1,-1,-1):
    for j in range(W):
        if dptate[i][j] == 0:
            continue
        if i == H-1:
            continue
        dptate[i][j] = max(dptate[i][j],dptate[i+1][j])
res = 0
for i in range(H):
    for j in range(W):
        res = max(res,dptate[i][j]+dpyoko[i][j]-1)
print(res)

Solution (Python):
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
X = [[-10**2 for __ in range(W)] for _ in range(H)]
Y = [[-10**2 for __ in range(W)] for _ in range(H)]
for y in range(H):
  last_x = -1
  for x in range(W):
    if S[y][x] == "
      for t in range(last_x+1,x):
        X[y][t] = x-1-last_x
      last_x = x
  for t in range(last_x+1,W):
    X[y][t] = W-1-last_x
for x in range(W):
  last_y = -1
  for y in range(H):
    if S[y][x] == "
      for t in range(last_y+1,y):
        Y[t][x] = y-1-last_y
      last_y = y
  for t in range(last_y+1,H):
    Y[t][x] = H-1-last_y
ans = 0
for y in range(H):
  for x in range(W):
    ans = max(ans, Y[y][x]+X[y][x])
print(ans-1)

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

graph_1 = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            if j != 0 and grid[i][j - 1] == '.':
                graph_1[i][j] = graph_1[i][j - 1] + 1
            else:
                graph_1[i][j] = 1

for i in range(H):
    for j in reversed(range(W - 1)):
        if grid[i][j + 1] == '.' and grid[i][j] == '.':
            graph_1[i][j] = graph_1[i][j + 1]

graph_2 = [[0] * W for _ in range(H)]
for j in range(W):
    for i in range(H):
        if grid[i][j] == '.':
            if i != 0 and grid[i - 1][j] == '.':
                graph_2[i][j] = graph_2[i - 1][j] + 1
            else:
                graph_2[i][j] = 1

for j in range(W):
    for i in reversed(range(H - 1)):
        if grid[i + 1][j] == '.' and grid[i][j] == '.':
            graph_2[i][j] = graph_2[i + 1][j]

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

Solution (Python):
h, w = map(int, input().split())
s = [input() for _ in range(h)]
a = [[None] * w for _ in range(h)]
for i in range(h):
    p = 0
    while p < w:
        j = p
        while j < w and s[i][j] == '.':
            j += 1
        for k in range(p, j):
            a[i][k] = j - p
        p = j + 1
r = 0
for j in range(w):
    p = 0
    while p < h:
        i = p
        while i < h and s[i][j] == '.':
            i += 1
        for k in range(p, i):
            r = max(r, a[k][j] + i - p - 1)
        p = i + 1

print(r)

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

for i in range(H):
    j = 0
    while j < W:
        if S[i][j]==".":
            dj = 1
            for nj in range(1, W+1):
                if j+nj == W or S[i][j+nj] == "
                    for nnj in range(nj):
                        dj = nj
                        distW[i][j+nnj] = nj
                    break
            j += dj
        elif S[i][j]=="
            distW[i][j] = 0
            j+=1

for j in range(W):
    i = 0
    while i < H:
        if S[i][j]==".":
            di = 1
            for ni in range(1, H+1):
                if i+ni == H or S[i+ni][j] == "
                    di = ni
                    for nni in range(ni):
                        distH[i+nni][j] = ni
                    break
            i += di
        elif S[i][j]=="
            distH[i][j] = 0
            i+=1

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

print(ans)

Solution (Python):

import sys
inf = 10 ** 20; INF = float("INF"); ans = 0
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]
def mi(n): return [wi() for _ in range(n)]
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

h, w = wi()
s = []
for i in range(h):
    s.append([str(m) for m in list(input())])

numj = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0:
            if s[i][j] != "
                numj[i][j] += 1
        elif s[i][j] != "
            numj[i][j] += numj[i][j - 1] + 1
        else:
            numj[i][j] = 0
    for j2 in range(w - 2, -1, -1):
        if s[i][j2] != "
            if s[i][j2 + 1] != "
                numj[i][j2] = numj[i][j2 + 1]

numi = [[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    for i in range(h):
        if i == 0:
            if s[i][j] != "
                numi[i][j] += 1
        elif s[i][j] != "
            numi[i][j] += numi[i - 1][j] + 1
        else:
            numi[i][j] = 0
    for i2 in range(h - 2, -1, -1):
        if s[i2][j] != "
            if s[i2 + 1][j] != "
                numi[i2][j] = numi[i2 + 1][j]

for i in range(h):
    for j in range(w):
        ans = max(ans, numj[i][j] + numi[i][j])


print(ans - 1)

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

G_jouge = []
G_sayu = []
for h in range(H):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for w in range(W):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[h][W-1-w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_sayu.append([G_hidari[W-1-i]+G_migi[i] for i in range(W)])
for w in range(W):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for h in range(H):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[H-1-h][w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_jouge.append([G_hidari[H-1-i]+G_migi[i] for i in range(H)])

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,G_sayu[h][w]+G_jouge[w][h])
print(ans+1)

Solution (Python):
import sys
h,w = map(int,input().split())
left = [[0 for x in range(w)]for _ in range(h)]
right = [[0 for x in range(w)]for _ in range(h)]
up = [[0 for x in range(w)]for _ in range(h)]
down = [[0 for x in range(w)]for _ in range(h)]
arr = []
for i in range(h):
    arr.append(sys.stdin.readline())
for i in range(h):
    s = 0
    for j in range(w):
        if arr[i][j]=='.':
            left[i][j]=s
            s+=1
        else:
            s=0
for i in range(h):
    s = 0
    s2 =0
    for j in range(w):
        if arr[i][j] == '.':
            left[i][j] = s
            s += 1
        else:
            s = 0
        if arr[i][w-1-j]=='.':
            right[i][w-1-j] = s2
            s2+=1
        else:
            s2=0
for i in range(w):
    s = 0
    s2 = 0
    for j in range(h):
        if arr[j][i] == '.':
            up[j][i] = s
            s+=1
        else:
            s=0
        if arr[h-1-j][i] == '.':
            down[h-1-j][i] = s2
            s2+=1
        else:
            s2=0
mm = 0
for i in range(h):
    for j in range(w):
        if arr[i][j] =='.':
            mm = max(mm,left[i][j]+right[i][j]+up[i][j]+down[i][j]+1)
print(mm)