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 in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var H = (int)inputArray[0];
			var W = (int)inputArray[1];

			//光の情報を格納する
			var lumpInfo = new Dictionary<string, bool>();
			for (int i = 0; i < H; i++) {
				var rightinfo = retreiveStringArray()[0];
				for (int j = 0; j < W; j++) {
					var right = rightinfo[j] == '.' ? true : false;
					var position = i + "_" + j;
					lumpInfo.Add(position, right);
				}

			}
			//左方向に照らす数を記録する
			var leftInfo = new List<int[]>();
			for (int i = 0; i < H; i++) {
				var left = new int[W];
				for (int j = 0; j < W; j++) {
					var position = i + "_" + j;

					if (lumpInfo[position]) {
						left[j]= j-1 >= 0 ? left[j - 1] + 1:1;
					}
					else {
						left[j] = 0;
					}
				}
				leftInfo.Add(left);
			}
			//右方向に照らす数を記録する
			var rightInfo = new List<int[]>();
			for (int i = 0; i < H; i++) {
				var right = new int[W];
				for (int j = W-1; j >= 0; j--) {
					var position = i + "_" + j;

					if (lumpInfo[position]) {
						right[j] = j + 1 < W ? right[j+1] + 1 : 1;
					}
					else {
						right[j] = 0;
					}
				}
				rightInfo.Add(right);
			}

			//上方向に照らす数を記録する
			var upInfo = new List<int[]>();
			for (int j = 0; j < W; j++) {
				var up = new int[H];
				for (int i = 0; i < H; i++) {
					var position = i + "_" + j;

					if (lumpInfo[position]) {
						up[i] = i - 1 >= 0 ? up[i - 1] + 1 : 1;
					}
					else {
						up[i] = 0;
					}
				}
				upInfo.Add(up);

			}
			//下方向に照らす数を記録する
			var downInfo = new List<int[]>();
			for (int j = 0; j < W; j++) {
				var down = new int[W];
				for (int i = H - 1; i >= 0; i--) {
					var position = i + "_" + j;

					if (lumpInfo[position]) {
						down[i] = i + 1 < H ? down[i + 1] + 1 : 1;
					}
					else {
						down[i] = 0;
					}
				}
				downInfo.Add(down);
			}



			var max = 0;

			//最も強く照らす場所を探す
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					var right = leftInfo[i][j] + rightInfo[i][j] + upInfo[j][i] + downInfo[j][i];
					max = Math.Max(max, right);
				}

			}
			//答えの出力
			var ans = max-3;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}