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())
S = []
for i in range(H):
    S.append(list(input()))
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '
            continue
        elif j == 0:
            L[i][j] += 1
        else:
            L[i][j] += L[i][j-1] + 1
for i in range(H):
    for j in range(-1,-W-1,-1):
        if S[i][j] == '
            continue
        elif j == -1:
            R[i][j] += 1
        else:
            R[i][j] += R[i][j+1] + 1
for i in range(W):
    for j in range(H):
        if S[j][i] == '
            continue
        elif j == 0:
            U[j][i] += 1
        else:
            U[j][i] += U[j-1][i] + 1
for i in range(W):
    for j in range(-1,-H-1,-1):
        if S[j][i] == '
            continue
        elif j == -1:
            D[j][i] += 1
        else:
            D[j][i] += D[j+1][i] + 1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,U[i][j]+D[i][j]+L[i][j]+R[i][j]-3)
print(ans)

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

m = []
for i in range(H):
    m.append(input().rstrip('\n'))

wei = [[0]*(W+1) for _ in range(H+1)]
for h in range(H):
    for w in range(W):
        if m[h][w] == '.':
             wei[h][w] = wei[h][w-1] + 1
        else:
            wei[h][w] = 0
    
    for wz in range(W-1, -1, -1):
        if wei[h][wz] > 0 and wei[h][wz] < wei[h][wz+1]:
                wei[h][wz] = wei[h][wz + 1]

hei = [[0]*(W+1) for _ in range(H+1)]
for w in range(W):
    for h in range(H):
        if m[h][w] == '.':
             hei[h][w] = hei[h-1][w] + 1
        else:
            hei[h][w] = 0

    
    for hz in range(H-1, -1, -1):
        if hei[hz][w] > 0 and hei[hz][w] < hei[hz+1][w]:
            hei[hz][w] = hei[hz+1][w]

ans = 0
for h in range(H):
    for w in range(W):
       val = wei[h][w] + hei[h][w] - 1
       if ans < val:
           ans = val

print(ans)

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    H, W = LI()
    maze = SR(H)
    
    info = [[0 for _ in range(W)] for _ in range(H)]

    
    for w in range(W):
        current = 0
        for h in range(H):
            if maze[h][w] == "
                current = 0
            else:
                info[h][w] += current
                current += 1

    
    for h in range(H):
        current = 0
        for w in range(W)[::-1]:
            if maze[h][w] == "
                current = 0
            else:
                info[h][w] += current
                current += 1

    
    for w in range(W):
        current = 0
        for h in range(H)[::-1]:
            if maze[h][w] == "
                current = 0
            else:
                info[h][w] += current
                current += 1

    
    for h in range(H):
        current = 0
        for w in range(W):
            if maze[h][w] == "
                current = 0
            else:
                info[h][w] += current
                current += 1

    ans = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == ".":
                ans = max(ans, info[h][w] + 1)
    print(ans)

if __name__ == '__main__':
    main()

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

toUP = [[0] * w for _ in range(h)]
for i in range(w):
  cnt = 0
  for j in range(h):
    if S[j][i] == ".":
      cnt += 1
      toUP[j][i] = cnt
    else:
      cnt = 0

toDOWN = [[0] * w for _ in range(h)]
for i in range(w):
  cnt = 0
  for j in range(h - 1, -1, -1):
    if S[j][i] == ".":
      cnt += 1
      toDOWN[j][i] = cnt
    else:
      cnt = 0

toLEFT = [[0] * w for _ in range(h)]
for i in range(h):
  cnt = 0
  for j in range(w):
    if S[i][j] == ".":
      cnt += 1
      toLEFT[i][j] = cnt
    else:
      cnt = 0
    
toRIGHT = [[0] * w for _ in range(h)]
for i in range(h):
  cnt = 0
  for j in range(w - 1, -1, -1):
    if S[i][j] == ".":
      cnt += 1
      toRIGHT[i][j] = cnt
    else:
      cnt = 0

ans = 0
for i in range(h):
  for j in range(w):
    if S[i][j] == ".":
      ans = max(ans, toUP[i][j] + toDOWN[i][j] + toLEFT[i][j] + toRIGHT[i][j] - 3)
print(ans)

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

for i in range(h):
    for j in range(w):
        if s[i][j] == "
            pass
        elif j >= 1 and hol[i][j-1] != 0:
            hol[i][j] = hol[i][j-1]
        else:
            for k in range(2000):
                if j+k+1 >= w:
                    break
                if s[i][j+k+1] == "
                    break
            hol[i][j] = k+1
            
for j in range(w):
    for i in range(h):
        if s[i][j] == "
            pass
        elif ver[i][j] == 0 and i >= 1 and ver[i-1][j] != 0:
            ver[i][j] = ver[i-1][j]
        else:
            for k in range(2000):
                if i+k+1 >= h:
                    break
                elif s[i+k+1][j] == "
                    break
            ver[i][j] = k+1

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

Solution (Python):



from math import *
from copy import *					
from heapq import *					
from string import *				
from random import *				
from bisect import *				
from sys import stdin				
from sys import maxsize				
from operator import *				
from itertools import *				
from decimal import Decimal 		
from collections import Counter		
from collections import defaultdict 

'''
4 6

.....
....

'''

def transpose(m):
	rez = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] 
	return rez

def giveLightIntervals(L,h,w):
	l = [[] for i in range(h)]
	for i in range(h):
		s,e,c = '','',0
		for j in range(w):
			if(L[i][j] == '
				if(c > 0):
					e = j
					l[i].append([s,e-1])
					c = 0
				s,e = '',''
			else:
				if(s == ''):
					s = j
				c += 1
		if(L[i][-1] == '.'):
			l[i].append([s,w-1])
	return l

def solve(L,h,w):
	T = transpose(L)
	l = giveLightIntervals(L,h,w)
	t = giveLightIntervals(T,w,h)

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

	for i in range(h):
		zz = 0
		for j in range(w):
			if(len(l[i]) > zz):
				s,e = l[i][zz]
				val = e - s + 1
				if(s <= j <= e):
					H[i][j] = val
				if(j == e):
					zz += 1
			else:
				break

	for i in range(w):
		zz = 0
		for j in range(h):
			if(len(t[i]) > zz):
				s,e = t[i][zz]
				val = e - s + 1
				if(s <= j <= e):
					W[i][j] = val
				if(j == e):
					zz += 1
			else:
				break

	ans = 0

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

	return ans


H,W = list(map(int, stdin.readline().rstrip().split()))
L = []
for m in range(H):
	L.append(list(input()))
ans = solve(L,H,W)
print(ans)

Solution (Python):



from math import *
from copy import *					
from heapq import *					
from string import *				
from random import *				
from bisect import *				
from sys import stdin				
from sys import maxsize				
from operator import *				
from itertools import *				
from decimal import Decimal 		
from collections import Counter		
from collections import defaultdict 

'''
4 6

.....
....


6 4

....
...

..
.

0 -> [[1,2][4,5]]
1 -> [[0,4]]
2 -> [[0,3],[5,5]]
3 -> [[1,1],[3,5]]

0 -> [[1,2]]
1 -> [[0,3]]
2 -> [[0,2]]
3 -> [[1,3]]
4 -> [[0,2],[3,3]]
5 -> [[0,0],[2,3]]

'''

def transpose(m):
	rez = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] 
	return rez

def giveLightIntervals(L,h,w):
	l = [[] for i in range(h)]
	for i in range(h):
		s,e,c = '','',0
		for j in range(w):
			if(L[i][j] == '
				if(c > 0):
					e = j
					l[i].append([s,e-1])
					c = 0
				s,e = '',''
			else:
				if(s == ''):
					s = j
				c += 1
		if(L[i][-1] == '.'):
			l[i].append([s,w-1])
	return l

def solve(L,h,w):
	T = transpose(L)
	l = giveLightIntervals(L,h,w)
	t = giveLightIntervals(T,w,h)

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

	for i in range(h):
		zz = 0
		for j in range(w):
			if(len(l[i]) > zz):
				s,e = l[i][zz]
				val = e - s + 1
				if(s <= j <= e):
					H[i][j] = val
				if(j == e):
					zz += 1
			else:
				break

	for i in range(w):
		zz = 0
		for j in range(h):
			if(len(t[i]) > zz):
				s,e = t[i][zz]
				val = e - s + 1
				if(s <= j <= e):
					W[i][j] = val
				if(j == e):
					zz += 1
			else:
				break

	ans = 0

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

	return ans


H,W = list(map(int, stdin.readline().rstrip().split()))
L = []
for m in range(H):
	L.append(list(input()))
ans = solve(L,H,W)
print(ans)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
from operator import mul

INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)



class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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

imos1 = [[0 for j in range(w + 1)] for i in range(h)]
imos2 = [[0 for j in range(w)] for i in range(h + 1)]

cnt1 = 0
start1 = None
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j == 0 or s[i][j - 1] == "
                start1 = j
                cnt1 = 1
            else:
                cnt1 += 1
        elif j == 0 or s[i][j - 1] == "
            continue
        else:
            imos1[i][start1] = cnt1
            imos1[i][j] = -cnt1
            cnt1 = 0
    if s[i][-1] == ".":
        imos1[i][start1] = cnt1
        imos1[i][-1] = -cnt1
    start1 = None
    cnt1 = 0
for i in range(h):
    for j in range(1, w):
        imos1[i][j] += imos1[i][j - 1]

    



cnt2 = 0
start2 = None
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j == 0 or s[j - 1][i] == "
                start2 = j
                cnt2 = 1
            else:
                cnt2 += 1
        elif j == 0 or s[j - 1][i] == "
            continue
        else:
            imos2[start2][i] = cnt2
            imos2[j][i] = -cnt2
            cnt2 = 0
    if s[h - 1][i] == ".":
        imos2[start2][i] = cnt2
        imos2[h][i] -= cnt2
    start2 = None
    cnt2 = 0
for i in range(w):
    for j in range(1, h):
        imos2[j][i] += imos2[j - 1][i]

    


ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == "
            continue
        ans = max(ans, imos1[i][j] + imos2[i][j] - 1)
print(ans)

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

    g = [list("
    for _ in range(h):
        g.append(["
    g += [list("
    area = [[0] * (w + 2) for _ in range(h + 2)]

    for i in range(h + 2):
        cnt = 0
        for j in range(w + 2):
            if g[i][j] == "
                for k in range(j - cnt, j):
                    area[i][k] += cnt
                cnt = 0
            else:
                cnt += 1

    for i in range(w + 2):
        cnt = 0
        for j in range(h + 2):
            if g[j][i] == "
                for k in range(j - cnt, j):
                    area[k][i] += cnt
                cnt = 0
            else:
                cnt += 1

    res = 0
    for i in range(h + 2):
        for j in range(w + 2):
            res = max(res, area[i][j])
    print(res - 1)
if __name__ == '__main__':
    main()

Solution (Python):
h,w = map(int, input().split())
g = []
for _ in range(h):
  g.append(input())
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
u = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if g[i][j] == '.':
      if j == 0:
        l[i][j] = 1
      else:
        l[i][j] = l[i][j-1]+1
      if i == 0:
        u[i][j] = 1
      else:
        u[i][j] = u[i-1][j]+1
for i in reversed(range(h)):
  for j in reversed(range(w)):
    if g[i][j] == '.':
      if j == w-1:
        r[i][j] = 1
      else:
        r[i][j] = r[i][j+1]+1
      if i == h-1:
        d[i][j] = 1
      else:
        d[i][j] = d[i+1][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    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())
g = []
for _ in range(h):
  g.append(input())
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
u = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if g[i][j] == '
      l[i][j] = 0
      u[i][j] = 0
    else:
      if j == 0:
        l[i][j] = 1
      else:
        l[i][j] = l[i][j-1]+1
      if i == 0:
        u[i][j] = 1
      else:
        u[i][j] = u[i-1][j]+1
for i in reversed(range(h)):
  for j in reversed(range(w)):
    if g[i][j] == '
      r[i][j] = 0
      d[i][j] = 0
    else:
      if j == w-1:
        r[i][j] = 1
      else:
        r[i][j] = r[i][j+1]+1
      if i == h-1:
        d[i][j] = 1
      else:
        d[i][j] = d[i+1][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    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())
S = [input() for i in range(H)]

U = [[0]*W for i in range(H)]
D = [[0]*W for i in range(H)]
R = [[0]*W for i in range(H)]
L = [[0]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '
            U[i][j] = 0
        elif i == 0 and S[i][j] == '.':
            U[i][j] = 1
        else:
            U[i][j] = U[i-1][j] + 1
            
    for j in range(W):
        if S[i][j] == '
            L[i][j] = 0
        elif j == 0 and S[i][j] == '.':
            L[i][j] = 1
        else:
            L[i][j] = L[i][j-1] + 1
            
for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        if S[i][j] == '
            D[i][j] = 0
        elif i == H-1 and S[i][j] == '.':
            D[i][j] = 1
        else:
            D[i][j] = D[i+1][j] + 1
            
    for j in range(W-1,-1,-1):
        if S[i][j] == '
            R[i][j] = 0
        elif j == W-1 and S[i][j] == '.':
            R[i][j] = 1
        else:
            R[i][j] = R[i][j+1] + 1
            
ans = 0 

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

Solution (Python):
def main():
    h,w = map(int, input().split())
    sl = []
    for _ in range(h):
        sl.append(list(input()))

    left_cnts = []
    for hi, row in enumerate(sl):
        curr_left_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row):
            if s == '.':
                curr_left_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_left_cnts.append(-1)
                curr_cnt = 0
        left_cnts.append(curr_left_cnts)


    right_cnts = []
    for hi, row in enumerate(sl):
        curr_right_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row[::-1]):
            if s == '.':
                curr_right_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_right_cnts.append(-1)
                curr_cnt = 0
        curr_right_cnts = curr_right_cnts[::-1]
        right_cnts.append(curr_right_cnts)


    sl_t = [list(x) for x in zip(*sl)]
    left_cnts_t = []
    for hi, row in enumerate(sl_t):
        curr_left_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row):
            if s == '.':
                curr_left_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_left_cnts.append(-1)
                curr_cnt = 0
        left_cnts_t.append(curr_left_cnts)


    right_cnts_t = []
    for hi, row in enumerate(sl_t):
        curr_right_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row[::-1]):
            if s == '.':
                curr_right_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_right_cnts.append(-1)
                curr_cnt = 0
        curr_right_cnts = curr_right_cnts[::-1]
        right_cnts_t.append(curr_right_cnts)


    ans = 0
    for hi in range(h):
        for wi in range(w):
            if sl[hi][wi] == '
            cnt = left_cnts[hi][wi] + right_cnts[hi][wi] + left_cnts_t[wi][hi] + right_cnts_t[wi][hi]
            ans = max(ans, cnt)

    print(ans+1)


if __name__ == "__main__":
    main()

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

left_cnts = []
for hi, row in enumerate(sl):
    curr_left_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row):
        if s == '.':
            curr_left_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_left_cnts.append(-1)
            curr_cnt = 0
    left_cnts.append(curr_left_cnts)


right_cnts = []
for hi, row in enumerate(sl):
    curr_right_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row[::-1]):
        if s == '.':
            curr_right_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_right_cnts.append(-1)
            curr_cnt = 0
    curr_right_cnts = curr_right_cnts[::-1]
    right_cnts.append(curr_right_cnts)


sl_t = [list(x) for x in zip(*sl)]
left_cnts_t = []
for hi, row in enumerate(sl_t):
    curr_left_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row):
        if s == '.':
            curr_left_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_left_cnts.append(-1)
            curr_cnt = 0
    left_cnts_t.append(curr_left_cnts)


right_cnts_t = []
for hi, row in enumerate(sl_t):
    curr_right_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row[::-1]):
        if s == '.':
            curr_right_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_right_cnts.append(-1)
            curr_cnt = 0
    curr_right_cnts = curr_right_cnts[::-1]
    right_cnts_t.append(curr_right_cnts)


ans = 0
for hi in range(h):
    for wi in range(w):
        if sl[hi][wi] == '
        cnt = left_cnts[hi][wi] + right_cnts[hi][wi] + left_cnts_t[wi][hi] + right_cnts_t[wi][hi]
        ans = max(ans, cnt)

print(ans+1)

Solution (Python):
import numpy as np

h, w  = map(int,input().split())
sn = [[0]*w for i in range(h)]
 
for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == '.':
            sn[i][j] = 1
sn = np.array(sn)
score = np.zeros_like(sn)
total = np.zeros_like(sn)

score[0] += sn[0]
for i in range(1, h):
    score[i] = (score[i-1] + sn[i]) * sn[i]
total += score

score[h-1] = sn[h-1]
for i in range(h-2, -1, -1):
    score[i] = (score[i+1] + sn[i]) * sn[i]
total += score

score[:,0] = sn[:,0]
for i in range(1, w):
    score[:,i] = (score[:,i-1] + sn[:,i]) * sn[:,i]
total += score

score[:,w-1] = sn[:,w-1]
for i in range(w-2, -1, -1):
    score[:,i] = (score[:,i+1] + sn[:,i]) * sn[:,i]
total += score
    
print(total.max()-3)

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

grid0 = [[0] * (W + 1) for _ in range(H + 1)]


for i in range(H):
    for j in range(W):
        if X[i][j] == ".":
            grid0[i + 1][j + 1] = grid0[i + 1][j] + 1
        

for i in range(H):
    for j in reversed(range(W)):
        if grid0[i + 1][j] > 0:
            grid0[i + 1][j] = max(grid0[i + 1][j], grid0[i + 1][j + 1])

grid1 = [[0] * (W + 1) for _ in range(H + 1)]
for i in range(H):
    for j in range(W):
        if X[i][j] == ".":
            grid1[i + 1][j + 1] = grid1[i][j + 1] + 1

for i in reversed(range(H)):
    for j in range(W):
        if grid1[i][j + 1] > 0:
            grid1[i][j + 1] = max(grid1[i][j + 1], grid1[i + 1][j + 1])

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
H, W = MAP()
S = [input() for _ in range(H)]

w = [[-1]*W for _ in range(H)]
h = [[-1]*W for _ in range(H)]

for i in range(H):
	cnt = 0
	for j in range(W):
		if S[i][j] == ".":
			cnt += 1
			w[i][j] = cnt
		else:
			cnt = 0
	for j in range(W-2, -1, -1):
		if S[i][j] == ".":
			w[i][j] = max(w[i][j], w[i][j+1])


for i in range(W):
	cnt = 0
	for j in range(H):
		if S[j][i] == ".":
			cnt += 1
			h[j][i] = cnt
		else:
			cnt = 0

	for j in range(H-2, -1, -1):
		if S[j][i] == ".":
			h[j][i] = max(h[j][i], h[j+1][i])


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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
H, W = MAP()
S = [input() for _ in range(H)]

w = [[-1]*W for _ in range(H)]
h = [[-1]*W for _ in range(H)]

for i in range(H):
	cnt = 0
	for j in range(W):
		if S[i][j] == ".":
			cnt += 1
			w[i][j] = cnt
		else:
			cnt = 0
	for j in range(W-2, -1, -1):
		if S[i][j] == ".":
			w[i][j] = max(w[i][j], w[i][j+1])


for i in range(W):
	cnt = 0
	for j in range(H):
		if S[j][i] == ".":
			cnt += 1
			h[j][i] = cnt
		else:
			cnt = 0

	for j in range(H-2, -1, -1):
		if S[j][i] == ".":
			h[j][i] = max(h[j][i], h[j+1][i])


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

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

h,w = lr()
s = [input() for i in range(h)]
dicw = [[0 for j in range(w)] for i in range(h)]
dich = [[0 for j in range(w)] for i in range(h)]

for i in range(h):
    ind = 0
    now = 0
    while ind < w:
        now = 0
        while ind < w and s[i][ind] == '.':
            now+=1
            ind+=1
        for j in range(now):
            dicw[i][ind-1-j] = now
        ind+=1
for i in range(w):
    ind = 0
    now = 0
    while ind < h:
        now = 0
        while ind < h and s[ind][i] == '.':
            now+=1
            ind+=1
        for j in range(now):
            dich[ind-1-j][i] = now
        ind+=1

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            ans = max(ans, dich[i][j]+dicw[i][j]-1)
print(ans)