Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import re


def solve(H: int, W: int, S: "List[str]"):

    
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    D = [[0] * W for i 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
            elif(j >= 1):
                L[i][j] = L[i][j-1] + 1

            # 上
            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 range(H-1,-1,-1):
        for j in range(W-1,-1,-1):
            # 右
            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

            # 下
            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)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import re


def solve(H: int, W: int, S: "List[str]"):

    
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    D = [[0] * W for i 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
            elif(j >= 1):
                L[i][j] = L[i][j-1] + 1

            # 上
            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 range(H-1,-1,-1):
        for j in range(W-1,-1,-1):
            # 右
            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

            # 下
            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)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, S: "List[str]"):
    from collections import deque

    q = deque()
    ans = 0
    for x in range(H):
        for y in range(W):
            if(S[x][y] == '.'):

                t = 1
                
                # 上
                s = 1
                while(0 <= x-s < H and 0 <= y < W and S[x-s][y] == '.'):
                    t += 1
                    s += 1

                # 下
                s = 1
                while(0 <= x+s < H and 0 <= y < W and S[x+s][y] == '.'):
                    t += 1
                    s += 1

                # 左
                s = 1
                while(0 <= x < H and 0 <= y-s < W and S[x][y-s] == '.'):
                    t += 1
                    s += 1

                # 右
                s = 1
                while(0 <= x < H and 0 <= y+s < W and S[x][y+s] == '.'):
                    t += 1
                    s += 1

                ans = max(ans, t)

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import re


def solve(H: int, W: int, S: "List[str]"):

    
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    D = [[0] * W for i 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
            elif(j >= 1):
                L[i][j] = L[i][j-1] + 1

            # 上
            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 range(H-1,-1,-1):
        for j in range(W-1,-1,-1):
            # 右
            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

            # 下
            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)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, S: "List[str]"):
    from collections import deque

    q = deque()
    ans = 0
    for x in range(H):
        for y in range(W):
            if(S[x][y] == '.'):

                t = 1
                
                # 上
                s = 1
                while(0 <= x-s < H and 0 <= y < W and S[x-s][y] == '.'):
                    t += 1
                    s += 1

                # 下
                s = 1
                while(0 <= x+s < H and 0 <= y < W and S[x+s][y] == '.'):
                    t += 1
                    s += 1

                # 左
                s = 1
                while(0 <= x < H and 0 <= y-s < W and S[x][y-s] == '.'):
                    t += 1
                    s += 1

                # 右
                s = 1
                while(0 <= x < H and 0 <= y+s < W and S[x][y+s] == '.'):
                    t += 1
                    s += 1

                ans = max(ans, t)

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import re


def solve(H: int, W: int, S: "List[str]"):

    
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    D = [[0] * W for i 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
            elif(j >= 1):
                L[i][j] = L[i][j-1] + 1

            # 上
            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 range(H-1,-1,-1):
        for j in range(W-1,-1,-1):
            # 右
            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

            # 下
            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)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, S: "List[str]"):
    from collections import deque

    q = deque()
    ans = 0
    for i in range(H):
        for j in range(W):
            if(S[i][j] == '.'):
                q.append([i,j])

    while(len(q)):
        x,y = q.pop()
        t = 1
        
        # 上
        s = 1
        while(0 <= x-s < H and 0 <= y < W and S[x-s][y] == '.'):
            t += 1
            s += 1

        # 下
        s = 1
        while(0 <= x+s < H and 0 <= y < W and S[x+s][y] == '.'):
            t += 1
            s += 1

        # 左
        s = 1
        while(0 <= x < H and 0 <= y-s < W and S[x][y-s] == '.'):
            t += 1
            s += 1

        # 右
        s = 1
        while(0 <= x < H and 0 <= y+s < W and S[x][y+s] == '.'):
            t += 1
            s += 1

        ans = max(ans, t)

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import re


def solve(H: int, W: int, S: "List[str]"):

    
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    D = [[0] * W for i 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
            elif(j >= 1):
                L[i][j] = L[i][j-1] + 1

            # 上
            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 range(H-1,-1,-1):
        for j in range(W-1,-1,-1):
            # 右
            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

            # 下
            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)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, S: "List[str]"):
    from collections import deque

    q = deque()
    ans = 0
    for i in range(H):
        for j in range(W):
            if(S[i][j] == '.'):
                q.append([i,j])

    while(len(q)):
        x,y = q.pop()
        t = 1
        
        # 上
        s = 1
        while(0 <= x-s < H and 0 <= y < W and S[x-s][y] == '.'):
            t += 1
            s += 1

        # 下
        s = 1
        while(0 <= x+s < H and 0 <= y < W and S[x+s][y] == '.'):
            t += 1
            s += 1

        # 左
        s = 1
        while(0 <= x < H and 0 <= y-s < W and S[x][y-s] == '.'):
            t += 1
            s += 1

        # 右
        s = 1
        while(0 <= x < H and 0 <= y+s < W and S[x][y+s] == '.'):
            t += 1
            s += 1

        ans = max(ans, t)

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import re


def solve(H: int, W: int, S: "List[str]"):

    
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    D = [[0] * W for i 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
            elif(j >= 1):
                L[i][j] = L[i][j-1] + 1

            # 上
            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 range(H-1,-1,-1):
        for j in range(W-1,-1,-1):
            # 右
            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

            # 下
            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)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()