Problem p03014 (python)

Fixed submission:
R = lambda: list(map(int, input().split()))
h, w = R()
s = [input() for i in range(h)]

# h, w = 4, 6
# s = ["#..#..",".....#","....#.","#.#..."]
s_ = [list(x) for x in zip(*s)]

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

for j,str in enumerate(s):
    count = 0
    col = 0
    for i, eachstr in enumerate(str):
        if eachstr == "#":
            if i == 0:
                pass
            else:
                for k in range(col,i):
                    ho[j][k] = count
            col = i + 1
            count = 0
        else:
            count += 1
    else:
        if col < w:
            for k in range(col,i+1):
                ho[j][k] = count

for j,str in enumerate(s_):
    count = 0
    col = 0
    for i, eachstr in enumerate(str):
        if eachstr == "#":
            if i == 0:
                pass
            else:
                for k in range(col,i):
                    he[j][k] = count
            col = i + 1
            count = 0
        else:
            count += 1
    else:
        if col < w:
            for k in range(col,i+1):
                he[j][k] = count

he_ = [list(x) for x in zip(*he)]

ans = 0
for i,j in zip(ho,he_):
    for ss, tt in zip(i,j):
        ans = max(ans, ss+tt)
print(ans-1)

Buggy submission (verdict: Runtime Error):
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(i, y) returns the tuple (i//y, i%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same words: Ctrl+Shift+l
import sys
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from math import factorial
def combinations_count(n, r):
    # faster than the following code
    # def combinations_count(n, r):
    #     return factorial(n) // (factorial(n - r) * factorial(r))
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combination_with_repetition_count(n, r):
    return combinations_count(n + r - 1, r)
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(i, y):
    return (i * y) // gcd(i, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)
# set the inputs
    # open(0).read() is a convenient method:
    # ei) n, m, *i = map(int, open(0).read().split())
    #     min(i[::2]) - mai(i[1::2])
    # ei2) *i, = map(int, open(0).read().split())
    #     don't forget to add comma after *i if only one variable is used
    # R = lambda: map(int, input().split()) :it's fashionable, isn't it?
    # ei1) n, k = R()
    # ei2) v = list(R())
    # ei3) bc = [list(R()) for i in range(m)]

# R = lambda: list(map(int, input().split()))
# n = int().input()
# ab = [R() for i in range(n)]
# c = R()
# c = sorted(c, reverse = True)

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

# h, w = 4, 6
# s = ["#..#..",".....#","....#.","#.#..."]
s_ = [list(x) for x in zip(*s)]

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

for j,str in enumerate(s):
    count = 0
    col = 0
    for i, eachstr in enumerate(str):
        if eachstr == "#":
            if i == 0:
                pass
            else:
                for k in range(col,i):
                    ho[j][k] = count
            col = i + 1
            count = 0
        else:
            count += 1
    else:
        if col < w:
            for k in range(col,i+1):
                ho[j][k] = count

for j,str in enumerate(s_):
    count = 0
    col = 0
    for i, eachstr in enumerate(str):
        if eachstr == "#":
            if i == 0:
                pass
            else:
                for k in range(col,i):
                    he[j][k] = count
            col = i + 1
            count = 0
        else:
            count += 1
    else:
        if col < w:
            for k in range(col,i+1):
                he[j][k] = count

he_ = [list(x) for x in zip(*he)]

ans = 0
for i,j in zip(ho,he_):
    for ss, tt in zip(i,j):
        ans = max(ans, ss+tt)
print(ans-1)