Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            if v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

        for i in range(N):
            ans[dist[i]] += 1
  
    for k in range(1, N):
        print(ans[k] // 2)


if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            if v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

        for i in range(N):
            ans[dist[i]] += 1
  
    for k in range(1, N):
        print(ans[k] // 2)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    matrix = [[-1 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        matrix[i][i] = 0
    for s in range(N):
        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if matrix[s][Y] == -1:
                    d.append(Y)
                    matrix[s][Y] = matrix[s][v] + 1
            if v == Y:
                if matrix[s][X] == -1:
                    d.append(X)
                    matrix[s][X] = matrix[s][v] + 1
            if v + 1 < N:
                if matrix[s][v+1] == -1:
                    d.append(v+1)
                    matrix[s][v+1] = matrix[s][v] + 1
            if v - 1 >= 0:
                if matrix[s][v-1] == -1:
                    d.append(v-1)
                    matrix[s][v-1] = matrix[s][v] + 1
    
    cnt = {k: 0 for k in range(1, N)}
    for h in range(N):
        for w in range(h+1, N):
            cnt[matrix[h][w]] += 1
    
    for k in range(1, N):
        print(cnt[k])


if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            if v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

        for i in range(N):
            ans[dist[i]] += 1
  
    for k in range(1, N):
        print(ans[k] // 2)


if __name__ == "__main__":
    main()