Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int,input().split())
maze = []
def mazecal(hs,ws):
    calmaze = [[-1 for _ in range(w)] for _ in range(h)]
    #step = 0
    que = deque([[hs,ws,0]])
    smax = 0
    while len(que)!=0:
        cur = que.popleft()
        calmaze[cur[0]][cur[1]] = cur[2]
        smax = max(smax,cur[2])
        if cur[0]>0   and maze[cur[0]-1][cur[1]]==0:
            if calmaze[cur[0]-1][cur[1]] ==-1 or calmaze[cur[0]-1][cur[1]] > cur[2]+1:
                 que.append([cur[0]-1,cur[1],  cur[2]+1])
        if cur[0]<h-1 and maze[cur[0]+1][cur[1]]==0:
            if calmaze[cur[0]+1][cur[1]] ==-1 or calmaze[cur[0]+1][cur[1]] > cur[2]+1:
                que.append([cur[0]+1,cur[1],  cur[2]+1])
        if cur[1]>0   and maze[cur[0]][cur[1]-1]==0:
            if calmaze[cur[0]][cur[1]-1] ==-1 or calmaze[cur[0]][cur[1]-1] > cur[2]+1:
                que.append([cur[0]  ,cur[1]-1,cur[2]+1])
        if cur[1]<w-1 and maze[cur[0]][cur[1]+1]==0:
            if calmaze[cur[0]][cur[1]+1] ==-1 or calmaze[cur[0]][cur[1]+1] > cur[2]+1:
                que.append([cur[0]  ,cur[1]+1,cur[2]+1])        
    return smax

for i in range(h):maze.append([0 if c=='.' else 1 for c in input()])
gmax = 0
for i in range(h):
    for j in range(w):
        if maze[i][j]==0:gmax = max(gmax,mazecal(i,j))
print(gmax)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
maze = []
def mazecal(hs,ws):
    calmaze = [[-1 for _ in range(w)] for _ in range(h)]
    que = deque([[hs,ws,0]])
    smax = 0
    while len(que)!=0:
        cur = que.popleft()
        calmaze[cur[0]][cur[1]] = cur[2]
        smax = max(smax,cur[2])
        if cur[0]>0   and maze[cur[0]-1][cur[1]]==0:
            if calmaze[cur[0]-1][cur[1]] ==-1 or calmaze[cur[0]-1][cur[1]] > cur[2]+1:
                calmaze[cur[0]-1][cur[1]] = cur[2]+1
                que.append([cur[0]-1,cur[1],  cur[2]+1])
        if cur[0]<h-1 and maze[cur[0]+1][cur[1]]==0:
            if calmaze[cur[0]+1][cur[1]] ==-1 or calmaze[cur[0]+1][cur[1]] > cur[2]+1:
                calmaze[cur[0]+1][cur[1]] = cur[2]+1
                que.append([cur[0]+1,cur[1],  cur[2]+1])
        if cur[1]>0   and maze[cur[0]][cur[1]-1]==0:
            if calmaze[cur[0]][cur[1]-1] ==-1 or calmaze[cur[0]][cur[1]-1] > cur[2]+1:
                calmaze[cur[0]][cur[1]-1] = cur[2]+1
                que.append([cur[0]  ,cur[1]-1,cur[2]+1])
        if cur[1]<w-1 and maze[cur[0]][cur[1]+1]==0:
            if calmaze[cur[0]][cur[1]+1] ==-1 or calmaze[cur[0]][cur[1]+1] > cur[2]+1:
                calmaze[cur[0]][cur[1]+1] = cur[2]+1
                que.append([cur[0]  ,cur[1]+1,cur[2]+1])
    return smax

for i in range(h):maze.append([0 if c=='.' else 1 for c in input()])
gmax = 0
for i in range(h):
    for j in range(w):
        if maze[i][j]==0:gmax = max(gmax,mazecal(i,j))
print(gmax)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int,input().split())
maze = []
def mazecal(hs,ws):
    calmaze = [[-1 for _ in range(w)] for _ in range(h)]
    step = 0
    que = deque([[hs,ws,step]])
    while len(que)!=0:
        cur = que.popleft()
        #print('cur',cur)
        calmaze[cur[0]][cur[1]] = cur[2]
        if cur[0]>0   and maze[cur[0]-1][cur[1]]==0:
            if calmaze[cur[0]-1][cur[1]] ==-1 or calmaze[cur[0]-1][cur[1]] > cur[2]+1:
                 que.append([cur[0]-1,cur[1],  cur[2]+1])
        if cur[0]<h-1 and maze[cur[0]+1][cur[1]]==0:
            if calmaze[cur[0]+1][cur[1]] ==-1 or calmaze[cur[0]+1][cur[1]] > cur[2]+1:
                que.append([cur[0]+1,cur[1],  cur[2]+1])
        if cur[1]>0   and maze[cur[0]][cur[1]-1]==0:
            if calmaze[cur[0]][cur[1]-1] ==-1 or calmaze[cur[0]][cur[1]-1] > cur[2]+1:
                que.append([cur[0]  ,cur[1]-1,cur[2]+1])
        if cur[1]<w-1 and maze[cur[0]][cur[1]+1]==0:
            if calmaze[cur[0]][cur[1]+1] ==-1 or calmaze[cur[0]][cur[1]+1] > cur[2]+1:
                que.append([cur[0]  ,cur[1]+1,cur[2]+1])        
    smax = 0
    for i in range(h):smax = max(smax,max(calmaze[i]))
    return smax

for i in range(h):maze.append([0 if c=='.' else 1 for c in input()])
gmax = 0
for i in range(h):
    for j in range(w):
        if maze[i][j]==0:gmax = max(gmax,mazecal(i,j))
print(gmax)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
maze = []
def mazecal(hs,ws):
    calmaze = [[-1 for _ in range(w)] for _ in range(h)]
    que = deque([[hs,ws,0]])
    smax = 0
    while len(que)!=0:
        cur = que.popleft()
        calmaze[cur[0]][cur[1]] = cur[2]
        smax = max(smax,cur[2])
        if cur[0]>0   and maze[cur[0]-1][cur[1]]==0:
            if calmaze[cur[0]-1][cur[1]] ==-1 or calmaze[cur[0]-1][cur[1]] > cur[2]+1:
                calmaze[cur[0]-1][cur[1]] = cur[2]+1
                que.append([cur[0]-1,cur[1],  cur[2]+1])
        if cur[0]<h-1 and maze[cur[0]+1][cur[1]]==0:
            if calmaze[cur[0]+1][cur[1]] ==-1 or calmaze[cur[0]+1][cur[1]] > cur[2]+1:
                calmaze[cur[0]+1][cur[1]] = cur[2]+1
                que.append([cur[0]+1,cur[1],  cur[2]+1])
        if cur[1]>0   and maze[cur[0]][cur[1]-1]==0:
            if calmaze[cur[0]][cur[1]-1] ==-1 or calmaze[cur[0]][cur[1]-1] > cur[2]+1:
                calmaze[cur[0]][cur[1]-1] = cur[2]+1
                que.append([cur[0]  ,cur[1]-1,cur[2]+1])
        if cur[1]<w-1 and maze[cur[0]][cur[1]+1]==0:
            if calmaze[cur[0]][cur[1]+1] ==-1 or calmaze[cur[0]][cur[1]+1] > cur[2]+1:
                calmaze[cur[0]][cur[1]+1] = cur[2]+1
                que.append([cur[0]  ,cur[1]+1,cur[2]+1])
    return smax

for i in range(h):maze.append([0 if c=='.' else 1 for c in input()])
gmax = 0
for i in range(h):
    for j in range(w):
        if maze[i][j]==0:gmax = max(gmax,mazecal(i,j))
print(gmax)