Buggy python submission (verdict: Time Limit Exceeded):
# 定数
INF = float("inf")
MOD = int(1e9 + 7)

# エントリーポイント
def main():
    H, W = map(int, input().split())
    S = tuple(tuple(input()) for _ in range(H))

    hstage = []
    for n in range(H):
        line, c = [], 0
        for m in range(W):
            if S[n][m] == "#":
                line += [c] * c + [0]
                c = 0
            else:
                c += 1
        else:
            line += [c] * c
        hstage += [line]

    vstage = []
    for m in range(W):
        line, c = [], 0
        for n in range(H):
            if S[n][m] == "#":
                line += [c] * c + [0]
                c = 0
            else:
                c += 1
        else:
            line += [c] * c
        vstage += [line]

    max_lumps = 0
    for y in range(H):
        for x in range(W):
            if max_lumps < (hstage[y][x] + vstage[x][y] - 1):
                max_lumps = hstage[y][x] + vstage[x][y] - 1
    print(max_lumps)

main()


Fixed submission:
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)

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

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)


Fixed submission:
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)

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

	#上下左右
	STAGE_score = []

	result = 0
	for y in range(H):
		count, score = 0, []
		for x in range(W):
			if STAGE[y][x] == ".":
				count += 1
				if x == W - 1:
					score += [count] * count
			else:
				if 0 < count:
					score += [count] * count
				score += [0]
				count = 0
		STAGE_score += [score]

	#for l in STAGE_score:
	#	print(*l)

	for y in range(H):
		for x in range(W):
			if STAGE[y][x] == "#":
				continue
			else:
				score = STAGE_score[y][x]
				for n in range(y - 1, -1, -1):
					if STAGE[n][x] == "#":
						break
					else:
						score += 1
				for n in range(y + 1, H):
					if STAGE[n][x] == "#":
						break
					else:
						score += 1
			result = max(result, score)
			#print(y, x, result)

	print(result)
main()

Fixed submission:
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)

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

def score(y, x):
	if STAGE[y][x] == "#":
		return 0
	s = 1
	for n in range(y + 1, H):
		if STAGE[n][x] == ".":
			s += 1
		else:
			break
	for n in range(y - 1, -1, -1):
		if STAGE[n][x] == ".":
			s += 1
		else:
			break
	for n in range(x + 1, W):
		if STAGE[y][n] == ".":
			s += 1
		else:
			break
	for n in range(x - 1, -1, -1):
		if STAGE[y][n] == ".":
			s += 1
		else:
			break
	return s

result = 0
for y in range(H):
	for x in range(W):
		result = max(result, score(y, x))

print(result)


Fixed submission:
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)

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

def score(y, x):
	if STAGE[y][x] == "#":
		return 0
	s = 1
	for n in range(y + 1, H):
		if STAGE[n][x] == ".":
			s += 1
		else:
			break
	for n in range(y - 1, -1, -1):
		if STAGE[n][x] == ".":
			s += 1
		else:
			break
	for n in range(x + 1, W):
		if STAGE[y][n] == ".":
			s += 1
		else:
			break
	for n in range(x - 1, -1, -1):
		if STAGE[y][n] == ".":
			s += 1
		else:
			break
	return s

result = 0
for y in range(H):
	for x in range(W):
		result = max(result, score(y, x))

print(result)


Fixed submission:
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)