Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
ans = [[1]*w for i in range(h)]
x = [[0]*w for i in range(h)]
for i in range(h):
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        x[i][j] = x[i][j-1] +1
                if s[i][j] == ".":
                        ans[i][j] += x[i][j]

x = [[0]*w for i in range(h)]
for i in range(h):
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        x[i][j] = x[i][j+1] +1
                if s[i][j] == ".":
                        ans[i][j] += x[i][j]
x = [[0]*w for i in range(h)]
for i in range(w):
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        x[j][i] = x[j+1][i] +1
                if s[j][i] == ".":
                        ans[j][i] += x[j][i]
x = [[0]*w for i in range(h)]
for i in range(w):
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        x[j][i] = x[j-1][i] +1
                if s[j][i] == ".":
                        ans[j][i] += x[j][i]               
ans2 = 0
for i in range(h):
        for j in range(w):
                ans2 = max(ans2,ans[i][j])
print(ans2)

Fixed submission:
import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
ans = [[1]*w for i in range(h)]
res = 0
for i in range(h):
        res = 0
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0

res = 0
for i in range(h):
        res = 0
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        res = res+1
                if s[j][i] == ".":
                        ans[j][i] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        res = res +1
                if s[j][i] == ".":
                        ans[j][i] += res           
                else:
                        res = 0  
ans2 = 0
for i in range(h):
        for j in range(w):
                ans2 = max(ans2,ans[i][j])
print(ans2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
x = [[[0,0,0,0]for i in range(w)] for j in range(h)]
for i in range(h):
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        x[i][j][0] = x[i][j-1][0] +1

for i in range(h):
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        x[i][j][1] = x[i][j+1][1] +1

for i in range(w):
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        x[j][i][2] = x[j+1][i][2] +1
ans = 0
for i in range(w):
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        x[j][i][3] = x[j-1][i][3] +1
                if s[j][i] == ".":
                        ans = max(ans,sum(x[j][i])+1)                   
print(ans)

Fixed submission:
import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
ans = [[1]*w for i in range(h)]
res = 0
for i in range(h):
        res = 0
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0

res = 0
for i in range(h):
        res = 0
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        res = res+1
                if s[j][i] == ".":
                        ans[j][i] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        res = res +1
                if s[j][i] == ".":
                        ans[j][i] += res           
                else:
                        res = 0  
ans2 = 0
for i in range(h):
        for j in range(w):
                ans2 = max(ans2,ans[i][j])
print(ans2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
x = [[[0,0,0,0]for i in range(w)] for j in range(h)]
for i in range(h):
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        x[i][j][0] = x[i][j-1][0] +1

for i in range(h):
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        x[i][j][1] = x[i][j+1][1] +1

for i in range(w):
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        x[j][i][2] = x[j+1][i][2] +1

for i in range(w):
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        x[j][i][3] = x[j-1][i][3] +1                   
ans = 0
for i in range(h):
        for j in range(w):
                if s[i][j] == ".":
                        ans = max(ans,sum(x[i][j])+1)

print(ans)

Fixed submission:
import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
ans = [[1]*w for i in range(h)]
res = 0
for i in range(h):
        res = 0
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0

res = 0
for i in range(h):
        res = 0
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        res = res+1
                if s[j][i] == ".":
                        ans[j][i] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        res = res +1
                if s[j][i] == ".":
                        ans[j][i] += res           
                else:
                        res = 0  
ans2 = 0
for i in range(h):
        for j in range(w):
                ans2 = max(ans2,ans[i][j])
print(ans2)