Buggy python submission (verdict: Time Limit Exceeded):
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)


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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

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

TS = list(zip(*S))

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)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

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

TS = list(zip(*S))

TtoUP = [[0] * h for _ in range(w)]
for itr1, line in enumerate(TS):
  cnt = 0
  for itr2, s in enumerate(line):
    if s == ".":
      cnt += 1
      TtoUP[itr1][itr2] = cnt
    else:
      cnt = 0
toUP = list(zip(*TtoUP))


TtoDOWN = [[0] * h for _ in range(w)]
for itr1, line in enumerate(TS):
  cnt = 0
  for itr2, s in enumerate(line[::-1]):
    if s == ".":
      cnt += 1
      TtoDOWN[itr1][h - itr2- 1] = cnt
    else:
      cnt = 0
toDOWN = list(zip(*TtoDOWN))


toLEFT = [[0] * w for _ in range(h)]
for itr1, line in enumerate(S):
  cnt = 0
  for itr2, s in enumerate(line):
    if s == ".":
      cnt += 1
      toLEFT[itr1][itr2] = cnt
    else:
      cnt = 0
    
toRIGHT = [[0] * w for _ in range(h)]
for itr1, line in enumerate(S):
  cnt = 0
  for itr2, s in enumerate(line[::-1]):
    if s == ".":
      cnt += 1
      toRIGHT[itr1][w - itr2 - 1] = 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)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

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

TS = list(zip(*S))

TtoUP = [[0] * h for _ in range(w)]
for itr1, line in enumerate(TS):
  cnt = 0
  for itr2, s in enumerate(line):
    if s == ".":
      cnt += 1
      TtoUP[itr1][itr2] = cnt
    else:
      cnt = 0
toUP = list(zip(*TtoUP))


TtoDOWN = [[0] * h for _ in range(w)]
for itr1, line in enumerate(TS):
  cnt = 0
  for itr2, s in enumerate(line[::-1]):
    if s == ".":
      cnt += 1
      TtoDOWN[itr1][h - itr2- 1] = cnt
    else:
      cnt = 0
toDOWN = list(zip(*TtoDOWN))


toLEFT = [[0] * w for _ in range(h)]
for itr1, line in enumerate(S):
  cnt = 0
  for itr2, s in enumerate(line):
    if s == ".":
      cnt += 1
      toLEFT[itr1][itr2] = cnt
    else:
      cnt = 0
    
toRIGHT = [[0] * w for _ in range(h)]
for itr1, line in enumerate(S):
  cnt = 0
  for itr2, s in enumerate(line[::-1]):
    if s == ".":
      cnt += 1
      toRIGHT[itr1][w - itr2 - 1] = 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)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    road = S[i][::-1][W - j - 1:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    L[i][j] = cnt
    
    road = S[i][j:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    R[i][j] = cnt

# 転置行列を準備
ST = list(map(list, zip(*S)))

for i in range(W):
  for j in range(H):
    road = ST[i][::-1][H - j - 1:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    U[j][i] = cnt

    road = ST[i][j:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    D[j][i] = cnt

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

print(ans)


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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    road = S[i][::-1][W - j - 1:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    L[i][j] = cnt
    
    road = S[i][j:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    R[i][j] = cnt

# 転置行列を準備
ST = list(map(list, zip(*S)))

for i in range(W):
  for j in range(H):
    road = ST[i][::-1][H - j - 1:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    U[j][i] = cnt

    road = ST[i][j:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    D[j][i] = cnt

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

print(ans)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def numset(a):
    li = []
    preS = - 1
    for i, v in enumerate(a):
        if v == "#":
            li.append(0)
            preS = i
        else:
            hoge = a[i:].find("#")
            if hoge > 0:
                li.append(hoge+i-(preS+1))
            else:
                li.append(len(a)-(preS+1))
    return li

H, W = map(int, input().split())
S = [input() for i in range(H)]
xs = [numset(i) for i in S]

xy = []
for i in range(W):
  stt = ''
  for j in range(H):
    stt += S[j][i]
  xy.append(numset(stt)) 
#print(xy)

ans = 0
for i in range(W):
  for j in range(H):
    aa = xs[j][i] + xy[i][j] -1
    if aa > ans:
      ans = aa
print(ans)

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

# L, R, U, D方向の照らされるマス数を事前に計算
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(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif 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(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)