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

    sys.setrecursionlimit(10 ** 6)

    def dfs(now: int, depth: int):
        """深度を記録しながらDFS"""
        if temp_dis[now] <= depth:
            return
        temp_dis[now] = min(temp_dis[now], depth)
        for next in G[now]:
            dfs(next, depth + 1)
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)
    # print(G)

    # distance = [set() for _ in [0] * N]
    cnt_dis = [0] * N
    for i in range(N):
        temp_dis = [N] * N
        dfs(i, 0)
        # print(i, temp_dis)
        for j in range(N):
            # distance[temp_dis[j]].add((i, j) if i <= j else (j, i))
            cnt_dis[j] += temp_dis.count(j)
    
    # for ans in distance[1:]:
    #     print(len(ans))
    for ans in cnt_dis[1:]:
        print(ans // 2)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    from collections import deque
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

    dist = [[-1] * N for _ in [0] * N]
    for s in range(N):
        q = deque([s])
        dist[s][s] = 0
        while q:
            v = q.popleft()
            for nv in G[v]:
                if dist[s][nv] == -1:
                    dist[s][nv] = dist[s][v] + 1
                    q.append(nv)
    res = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            res[dist[i][j]] += 1
    for d in range(1, N):
        print(res[d])


if __name__ == '__main__':
    main()

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

    sys.setrecursionlimit(10 ** 6)

    def dfs(now: int, depth: int):
        """深度を記録しながらDFS"""
        if temp_dis[now] <= depth:
            return
        temp_dis[now] = min(temp_dis[now], depth)
        for next in G[now]:
            dfs(next, depth + 1)
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)
    # print(G)

    distance = [set() for _ in [0] * N]
    for i in range(N):
        temp_dis = [N] * N
        dfs(i, 0)
        # print(i, temp_dis)
        for j in range(N):
            distance[temp_dis[j]].add((i, j) if i <= j else (j, i))
    
    for ans in distance[1:]:
        print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    from collections import deque
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

    dist = [[-1] * N for _ in [0] * N]
    for s in range(N):
        q = deque([s])
        dist[s][s] = 0
        while q:
            v = q.popleft()
            for nv in G[v]:
                if dist[s][nv] == -1:
                    dist[s][nv] = dist[s][v] + 1
                    q.append(nv)
    res = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            res[dist[i][j]] += 1
    for d in range(1, N):
        print(res[d])


if __name__ == '__main__':
    main()

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

    sys.setrecursionlimit(10 ** 6)

    def dfs(now: int, depth: int):
        """深度を記録しながらDFS"""
        if temp_dis[now] < depth:
            return
        temp_dis[now] = min(temp_dis[now], depth)
        for next in G[now]:
            dfs(next, depth + 1)
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)
    # print(G)

    distance = [set() for _ in [0] * N]
    for i in range(N):
        temp_dis = [N] * N
        dfs(i, 0)
        # print(i, temp_dis)
        for j in range(N):
            distance[temp_dis[j]].add((i, j) if i <= j else (j, i))
    
    for ans in distance[1:]:
        print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    from collections import deque
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

    dist = [[-1] * N for _ in [0] * N]
    for s in range(N):
        q = deque([s])
        dist[s][s] = 0
        while q:
            v = q.popleft()
            for nv in G[v]:
                if dist[s][nv] == -1:
                    dist[s][nv] = dist[s][v] + 1
                    q.append(nv)
    res = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            res[dist[i][j]] += 1
    for d in range(1, N):
        print(res[d])


if __name__ == '__main__':
    main()

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

    sys.setrecursionlimit(10 ** 6)

    def dfs(now: int, depth: int):
        """深度を記録しながらDFS"""
        if depth >= N:
            return
        seen[now] = True
        temp_dis[now] = min(temp_dis[now], depth)
        for next in G[now]:
            dfs(next, depth + 1)
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)
    # print(G)

    distance = [set() for _ in [0] * N]
    for i in range(N):
        seen = [False] * N
        temp_dis = [N] * N
        dfs(i, 0)
        # print(i, temp_dis)
        for j in range(N):
            distance[temp_dis[j]].add((i, j) if i <= j else (j, i))
    
    for ans in distance[1:]:
        print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    from collections import deque
        
    N, X, Y = map(int, input().split())

    G = [[1]] + [[x - 1, x + 1] for x in range(1, N - 1)] + [[N - 2]]
    G[X - 1].append(Y - 1)
    G[Y - 1].append(X - 1)

    dist = [[-1] * N for _ in [0] * N]
    for s in range(N):
        q = deque([s])
        dist[s][s] = 0
        while q:
            v = q.popleft()
            for nv in G[v]:
                if dist[s][nv] == -1:
                    dist[s][nv] = dist[s][v] + 1
                    q.append(nv)
    res = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            res[dist[i][j]] += 1
    for d in range(1, N):
        print(res[d])


if __name__ == '__main__':
    main()