Buggy python submission (verdict: Time Limit Exceeded):

from collections import defaultdict
import heapq


def dijkstra(n, s, edges, count):
    dist = [float('inf') for _ in range(n)]
    dist[s] = 0
    q = []
    heapq.heappush(q, (0, s))
    while len(q):
        d, p = heapq.heappop(q)
        if s < p:
            count[d] += 1
        if dist[p] < d:
            continue
        for e in edges[p]:
            if d + 1 < dist[e]:
                dist[e] = d + 1
                heapq.heappush(q, (dist[e], e))
    return dist, count


def submit():
    n, x, y = map(int, input().split())
    
    edges = {i: [] for i in range(n)}
    for i in range(n - 1):
        edges[i].append(i + 1)
        edges[i + 1].append(i)
    edges[x - 1].append(y - 1)
    edges[y - 1].append(x - 1)
    
    dist_list = {}
    count = defaultdict(int)
    for s in range(n):
        dist_list[s], count = dijkstra(n, s, edges, count)

    for i in range(1, n):
        print(count[i])


submit()

Fixed submission:
def submit():
    n, x, y = map(int, input().split())

    count = {i: 0 for i in range(1, n)}
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            # i, j <= X, or Y <= i, j
            if (i <= x and j <= x) or (x <= i and y <= j):
                d = j - i
            
            # X < i, j < Y
            if x < i and j < y:
                d = min(j - i, i - x + 1 + y - j)
            
            # i <= X and X < j < Y
            if i <= x and x < j < y:
                d = min(j - i,
                        x - i + 1 + y - j)            

            # X < i < Y and Y <= j
            if x < i < y and y <= j:
                d = min(j - i,
                        j - y + 1 + i - x)

            if i <= x and y <= j:
                d = min(j - i,
                        x - i + j - y + 1)
            count[d] += 1            
            

    for i in range(1, n):
        print(count[i])

submit()

Buggy python submission (verdict: Time Limit Exceeded):

from collections import defaultdict
import heapq


def dijkstra(n, s, edges):
    dist = [float('inf') for _ in range(n)]
    dist[s] = 0
    q = []
    heapq.heappush(q, (0, s))
    while len(q):
        d, p = heapq.heappop(q)
        if dist[p] < d:
            continue
        for e in edges[p]:
            if d + 1 < dist[e]:
                dist[e] = d + 1
                heapq.heappush(q, (dist[e], e))
    return dist


def submit():
    n, x, y = map(int, input().split())
    
    edges = {i: [] for i in range(n)}
    for i in range(n - 1):
        edges[i].append(i + 1)
        edges[i + 1].append(i)
    edges[x - 1].append(y - 1)
    edges[y - 1].append(x - 1)
    
    dist_list = {}
    for s in range(n):
        dist_list[s] = dijkstra(n, s, edges)

    count = defaultdict(int)
    for i in range(n):
        dist = dist_list[i]
        for j in range(i + 1, n):
            count[dist[j]] += 1

    for i in range(1, n):
        print(count[i])


submit()

Fixed submission:
def submit():
    n, x, y = map(int, input().split())

    count = {i: 0 for i in range(1, n)}
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            # i, j <= X, or Y <= i, j
            if (i <= x and j <= x) or (x <= i and y <= j):
                d = j - i
            
            # X < i, j < Y
            if x < i and j < y:
                d = min(j - i, i - x + 1 + y - j)
            
            # i <= X and X < j < Y
            if i <= x and x < j < y:
                d = min(j - i,
                        x - i + 1 + y - j)            

            # X < i < Y and Y <= j
            if x < i < y and y <= j:
                d = min(j - i,
                        j - y + 1 + i - x)

            if i <= x and y <= j:
                d = min(j - i,
                        x - i + j - y + 1)
            count[d] += 1            
            

    for i in range(1, n):
        print(count[i])

submit()