Problem:
 Score : 400 points    Problem Statement  We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:   For each i=1,2,...,N-1 , there is an edge between Vertex i and Vertex i+1 .  There is an edge between Vertex X and Vertex Y .   For each k=1,2,...,N-1 , solve the problem below:   Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k .       Constraints   3 \leq N \leq 2 \times 10^3  1 \leq X,Y \leq N  X+1 < Y  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  X  Y       Output  For each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.        Sample Input 1 5 2 4      Sample Output 1 5
4
1
0  The graph in this input is as follows:     There are five pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 1 : (1,2)\,,(2,3)\,,(2,4)\,,(3,4)\,,(4,5) . There are four pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 2 : (1,3)\,,(1,4)\,,(2,5)\,,(3,5) . There is one pair (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 3 : (1,5) . There are no pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 4 .       Sample Input 2 3 1 3      Sample Output 2 3
0  The graph in this input is as follows:           Sample Input 3 7 3 7      Sample Output 3 7
8
4
2
0
0       Sample Input 4 10 4 8      Sample Output 4 10
12
10
8
4
1
0
0
0

Solution (Python):
import sys
input = sys.stdin.readline

n, x, y = map(int, input().split())
ans = [0] * (n - 1)
for i in range(n):
    check = 0
    for j in range(i + 1, n):
        check += 1
        if x - 1 <= i:
            a = i - x + 1
        else:
            a = x - 1 - i
        if y - 1 <= j:
            b = j - y + 1
        else:
            b = y - 1 - j
        cnt = min(check, a + b + 1)
        ans[cnt - 1] += 1
for i in range(n - 1):
    print(ans[i])

Solution (Python):
import itertools

N, X, Y = map(int, input().split())
lst = [0] * N
for l, r in itertools.combinations(range(1, N + 1), 2):
    lst[min(r - l, abs(r - Y) + 1 + abs(l - X))] += 1
for i in range(1, N):
    print(lst[i])

Solution (Python):
N, X, Y = [int(i) for i in input().split()]

counts = [0 for _ in range(N-1)]

for n1 in range(1, N):
  for n2 in range(n1+1, N+1):
    if n2 >= Y:
      upper = n2 - Y
    else:
      upper = Y - n2
    if n1 <= X:
      lower = X - n1
    else:
      lower = n1 - X
    diff = min(n2 - n1, upper + lower + 1)
    counts[diff-1] += 1
for c in counts:
  print(c)

Solution (Python):
n,xx,yy = (int(x) for x in input().split())
x = min(xx, yy)
y = max(xx, yy)
ans = [0 for i in range(n+1)]
for i in range(1, n):
    for j in range(i+1, n+1): 
        d = min(j - i, abs(x-i) + abs(y-j)+1)    
        ans[d] += 1

for k in range(1, n):
    print(ans[k])

Solution (Python):
import numpy as np
from scipy.sparse.csgraph import shortest_path

N,X,Y = map(int,input().split())

l = [[0 for _ in range(N)] for _ in range(N)]

for i in range(1,N):
    l[i-1][i] = 1
    l[i][i-1] = 1
l[X-1][Y-1] = 1
l[Y-1][X-1] = 1

a = np.array(l)

cnt = 1
ans = [0]*(N+1)
for i in shortest_path(a):
    for j in range(cnt,N):
        ans[int(i[j])] += 1
    cnt += 1

for i in range(1,N):
    print(ans[i])

Solution (Python):
n,x,y=[int(i) for i in input().split()]
l=[0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        
        index=min(abs(y-j)+abs(x-i)+1,j-i)-1
        
        l[index]=l[index]+1
for i in range(len(l)):
    print(l[i])

Solution (Python):
n, x, y= map(int, input().split())
res_list = [0] * (n-1)

def get_shortest_path(i, j, x, y):
  base_dist = j - i
  dist_short = abs(x-i) + abs(y-j) + 1
  return min(base_dist, dist_short)

for i in range(n-1):
  for j in range(i+1, n):
    dist = get_shortest_path(i, j, x-1, y-1)
    res_list[dist-1] += 1
for i in range(n-1):
  print(res_list[i])

Solution (Python):
n, x, y = map(int, input().split())

cnt = [0] * n
cycle = y - x + 1

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i < x and j > y:
            cnt[j - y + x - i + 1] += 1
        elif i < x:
            d = min(j - x, y - j + 1)
            cnt[x - i + d] += 1
        elif j > y:
            d = min(y - i, i - x + 1)
            cnt[j - y + d] += 1
        else:
            d = min(j - i, y - j + 1 + i - x)
            cnt[d] += 1

print(*cnt[1:], sep="\n")

Solution (Python):
n,x,y = map(int,input().split())
x -= 1
y -= 1
ansl = [0 for i in range(n-1)]

for i in range(n):
    for j in range(i+1, n):
        k = min(j-i, abs(x-i) + abs(y-j) + 1)
        ansl[k-1] += 1

for a in ansl:
    print(a)

Solution (Python):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import deque
def resolve():
    N, X, Y = lr()
    edges = [[1]]
    for i in range(1, N-1):
        edges.append([i-1, i+1])
    edges.append([N-2])
    edges[X-1].append(Y-1)
    edges[Y-1].append(X-1)
    cnt = [0]*(N-1)
    for i in range(N):
        s = deque([[i, 1]])
        vis = [0]*N
        vis[i] = 1
        while len(s) > 0:
            v, dis = s.popleft()
            for j in edges[v]:
                if not vis[j]:
                    s.append([j, dis+1])
                    vis[j] = 1
                    cnt[dis-1] += 1
    for c in cnt:
        print(c//2)
resolve()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, x, y = list(map(int, input().split()))
graph = [0] + [[] for _ in range(n)]
for i in range(n - 1):
    graph[i+1].append(i+2)
    graph[i+2].append(i+1)
graph[x].append(y)
graph[y].append(x)

def bfs(graph, queue, dist, num):
    while queue:
        current = queue.pop(0)

        for c in graph[current]:
            if dist[c] != -1:
                continue
            dist[c] = dist[current] + 1
            num[dist[c]] += 1
            queue.append(c)

num = [0] + [0] * (n - 1)
for i in range(1, n+1):
    queue = [i]
    dist = [-1] + [-1] * n
    dist[i] = 0
    bfs(graph, queue, dist, num)

for v in num[1:]:
    print(v // 2)

Solution (Python):
N, X, Y = list(map(int, input().split()))
X,Y = X-1,Y-1
dist = [[1000]*(m-1) for m in range(N,0,-1)]

for i in range(N-1):
    for j in range(i+1, N):
        dist[i][j-i-1] = min(j-i, abs(X-i)+abs(Y-j)+1)
a = {i:0 for i in range(1, N)}
for dis in dist:
    for d in dis:
        a[d]+=1
for i in range(1, N):
    print(a[i])

Solution (Python):
from collections import deque

n, x, y = map(int, input().split())

g = {}
for i in range(n - 1):
    g.setdefault(i, [])
    g.setdefault(i + 1, [])
    g[i].append(i + 1)
    g[i + 1].append(i)


g[x - 1].append(y - 1)

global_stat = [0] * n

def bfs(i, g):
    q = deque([(i, 0)])
    vis = [0] * len(g)
    vis[i] = 1
    stat = [0] * len(g)
    while q:
        cur_v, cur_dist = q.popleft()
        
        if cur_v > i:
            stat[cur_dist] += 1
        for adj_v in g[cur_v]:
            if not vis[adj_v]:
                vis[adj_v] = 1
                q.append((adj_v, cur_dist + 1))
    
    return stat

for i in range(n):
    local_stat = bfs(i, g)
    for i, v in enumerate(local_stat):
        global_stat[i] += v




for v in global_stat[1:]:
    print(v)

Solution (Python):
import sys
from itertools import combinations

n, x, y = map(int, sys.stdin.readline().split())
    
def main():
    res = [0] * (n + 1)
    for i, j in combinations(range(1, n+1), 2):
        d = min(j - i, abs(i - x) + 1 + abs(j - y))
        res[d] += 1
        
    for i in range(1, n):
        print(res[i])

if __name__ == "__main__":
    main()

Solution (Python):
n, x, y = map(int, input().split())

cnt = [0] * n
cycle = y - x + 1

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i < x and j > y:
            cnt[j - y + x - i + 1] += 1
        elif i < x:
            d = min(j - x, y - j + 1)
            cnt[x - i + d] += 1
        elif j > y:
            d = min(y - i, i - x + 1)
            cnt[j - y + d] += 1
        else:
            d = min(j - i, y - j + 1 + i - x)
            cnt[d] += 1

print(*cnt[1:], sep="\n")

Solution (Python):
import itertools

N, X, Y = map(int, input().split())
answers = [0 for _ in range(N - 1)]


def min_distance(a, b):
    global X, Y
    simple = b - a
    a_to_x = abs(X - a)
    x_to_y = 1
    y_to_b = abs(Y - b)
    return min(simple, a_to_x + x_to_y + y_to_b)

G = [(i + 1) for i in range(N)]

for v in itertools.combinations(G, 2):
    
    
    answers[min_distance(v[0], v[1]) - 1] += 1

for answer in answers:
    print(answer)

Solution (Python):

import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect
import scipy.sparse
from scipy.sparse.csgraph import shortest_path

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N, X, Y = map(int, input().split())
L = min(X, Y)
R = max(X, Y)

ans = [0] * (N - 1)

for i in range(1, N):
    for j in range(i + 1, N + 1):
        ans[min(j - i, abs(L - i) + abs(R - j) + 1) - 1] += 1
for i in ans:
    print(i)

Solution (Python):
N,X,Y = map(int, input().split())
ans = [0]*(N-1)

X = X-1
Y = Y-1

for i in range(N-1):
    for j in range(N-i-1):
        k = i + j + 1
        if k <= X+1 or Y-1 <= i:
            ans[k-i-1] = ans[k-i-1] + 1
        else:
            xy = abs(i-X)+1+abs(k-Y)
            if xy < k-i:
                ans[xy-1] = ans[xy-1] + 1
            else:
                ans[k-i-1] = ans[k-i-1] + 1

for ii in range(N-1):
    print(ans[ii])

Solution (Python):
import sys
import math
import collections
from collections import deque

n, x, y = map(int, sys.stdin.readline().split())



ans = [0 for i in range(n-1)]
for i in range(1, n):
    for j in range(i+1, n+1):
        ans[(min((j-i), abs(x-i)+1+abs(y-j)))-1] += 1

for i in range(n-1):
    print(ans[i])

Solution (Python):
N, x, y = map(int, input().split())

cnt = {n: 0 for n in range(1, N)}
for i in range(1, N + 1):
    for j in range(i+1, N + 1):
        d1 = abs(i - j)
        d2 = 1 + min(abs(x - i) + abs(y - j), abs(x - j) + abs(y - i))
        cnt[min(d1, d2)] += 1

for k in range(1, N):
    print(cnt[k])

Solution (Python):
from collections import deque

n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0] * (n-1)

g = [[] * n for _ in range(n)]
for i in range(n-1):
    g[i].append(i + 1)
    g[i + 1].append(i)
g[x].append(y)
g[y].append(x)



def bfs(u):
    dist = [-1] * n
    dist[u] = 0
    que = deque([])
    que.append(u)
    while que:
        v = que.popleft()
        for nv in g[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)
    for i in dist:
        if i == 0:
            continue
        ans[i - 1] += 1
    return ans



for i in range(n):
    bfs(i)
for i in ans:
    print(i // 2)

Solution (Python):
import numpy as np
from scipy.sparse.csgraph import shortest_path
import collections

def main():
    n, x, y = map(int, input().split(" "))
    graph = np.zeros([n, n])
    for i in range(n-1):
        graph[i, i+1] = 1
        graph[x-1, y-1] = 1
    
    s_path = shortest_path(graph, method='D', directed=False)
    
    c = collections.Counter(s_path.flatten())
    for k in range(n-1):
        k += 1
        ans = int(c[k] / 2)
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import heapq

n, x, y = map(int, input().split())

Edge = [[] for _ in range(n+1)]
for i in range(1,n):
    Edge[i].append([1, i+1])
    Edge[i+1].append([1, i])

Edge[x].append([1,y])
Edge[y].append([1,x])

def dijkstra_heap(s):
    
    d = [10**10] * (n+1)
    used = [False] * (n+1)
    d[s] = 0
    used[s] = True
    edgelist = []
    
    
    for e in Edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)

        
        if used[minedge[1]] == True:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True

        for e in Edge[v]:
            if used[e[1]] == False:
                heapq.heappush(edgelist, [e[0]+d[v], e[1]])
    return d

Ans = [0 for _ in range(n+1)]
for i in range(1,n):
    Dist = dijkstra_heap(i)
    
    for dist in Dist[i:]:
        Ans[dist] += 1

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

Solution (Python):
N,X,Y = map(int,input().split())

X -= 1
Y -= 1
ans = [0]*(N)

d = [[N]*N for i in range(N)]

for i in range(N):
    for j in range(i,N):
        if i<=X and Y<=j:
            d[i][j] = X-i+j-Y+1
        else:
            d[i][j] = min(abs(i-X)+abs(Y-j)+1,j-i)



for i in range(N):
    for j in range(i+1,N):
        ans[d[i][j]] += 1

for i in range(1,N):
    print(ans[i])

Solution (Python):
N, X, Y = map(int, input().split())

graph = [[] for _ in range(N)]
for i in range(N - 1):
    graph[i].append(i + 1)
    graph[i + 1].append(i)

graph[X - 1].append(Y - 1)
graph[Y - 1].append(X - 1)

import heapq





















dist = [[None] * N for _ in range(N)]
for i in range(N):
    for j in range(i, N):
        val = abs(i - j)
        dist[i][j] = val
        val = abs((X - 1) - i) + 1 + abs((Y - 1) - j)
        dist[i][j] = min(dist[i][j], val)
        val = abs((Y - 1) - i) + 1 + abs((X - 1) - j)
        dist[i][j] = min(dist[i][j], val)

cnt = [0] * (N * N + 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        cnt[dist[i][j]] += 1

for i in range(1, N):
    print(cnt[i])

Solution (Python):
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
import heapq

sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, X, Y = map(int, input().split())

def dijkstra_heap(s,edge):
    d = [10**20] * N
    used = [True] * N 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


edge = [[] for i in range(N)]

for i in range(1, N-1):
    edge[i].append([1, i+1])
    edge[i].append([1, i-1])
edge[0].append([1, 1])
edge[N-1].append([1, N-2])
edge[X-1].append([1, Y-1])
edge[Y-1].append([1, X-1])

dd = defaultdict(int)
for i in range(N):
    dists = dijkstra_heap(i, edge)
    for j in dists[i+1:]:
        dd[j] += 1

for k in range(1, N):
    print(dd[k])

Solution (Python):


N, X, Y = map(int, input().split())

DP = [[abs(i - j) for i in range(N)] for j in range(N)]

DP[X - 1][Y - 1] = 1
DP[Y - 1][X - 1] = 1







x = X - 1
y = Y - 1
for i in range(N - 1):
    for j in range(i + 1, N):
        DP[i][j] = min(DP[i][j], DP[i][x] + DP[y][j] + 1, DP[i][y] + DP[x][j] + 1)

lst = [0] * N
for i in range(N - 1):
    
    
    for j in range(i + 1, N):
        lst[DP[i][j]] += 1
    
print (*lst[1:], sep = '\n')

Solution (Python):
n,x,y=map(int,input().split())
D=[0]*(n-1)
x-=1
y-=1
for i in range(n-1):
    for j in range(i+1,n):
        D[min(j-i-1,abs(x-i)+abs(y-j))]+=1
for d in D:print(d)

Solution (Python):
import sys
from collections import Counter
input = sys.stdin.readline

N, X, Y = map(int, input().split())
skip = Y - X  - 1
ans = []

for i in range(1, N):
    for j in range(i+1, N+1):
        dist = j - i
        if i < X and j >= X and j <= Y:
            left = j - X
            right = Y - j + 1
            if right < left:
                dist = j - i + right - left
        elif i >= X and i <= Y and j >= X and j <= Y:
            r1 = j - i
            r2 = i - X + Y - j + 1
            if r2 < r1:
                dist = r2
        elif i >= X and i < Y and j > Y:
            left2 = i - X + 1
            right2 = Y - i
            if left2 < right2:
                dist = j - i + left2 - right2
        elif i <= X and j >= Y:
            dist = j - i - skip
        ans.append(dist)
out = Counter(ans)

for i in range(1, N):
    if i in out:
        print(out[i])
    else:
        print(0)

Solution (Python):
n, x, y = map(int, input().split())
x -= 1
y -= 1
cnt = [0] * (n-1)

def calc(i, j):
    return min(j-i, (abs(i-x)+abs(j-y)+1))

for i in range(n-1):
    for j in range(i+1, n):
        cnt[calc(i,j)-1] += 1

for c in cnt: print(c)

Solution (Python):
N, X, Y = map(int, input().split())

n_minus_route = [0] * N
n_plus_route = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        tmp = abs(X-i) + 1 + abs(Y-j)
        if j-i > tmp:
            n_minus_route[j-i] += 1
            n_plus_route[tmp] += 1

for k in range(1, N):
    ans = N - k - n_minus_route[k] + n_plus_route[k]
    print(ans)

Solution (Python):

import sys


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

INF =10**9
dist = [[INF]*N for _ in range(N)]


for i in range(N):
    for j in range(i+1,N):
        dist[i][j] = min(j-i, abs(Y-j)+abs(X-i)+1)

ans = [0]*(N-1)
for dst in dist:
    for d in dst:
        if d!=INF:
            ans[d-1] += 1

for a in ans:
    print(a)

Solution (Python):
from collections import defaultdict as dd
n, x, y = map(int, input().split())

ans_lis = dd(lambda: 0)
for j in range(1, n+1):
  for i in range(1, n+1):
    reg_way = abs(j - i)
    warp_x_y = abs(x - i) + 1 + abs(y - j)
    warp_y_x = abs(y - i) + 1 + abs(x - j)
    ans = min(reg_way, warp_x_y, warp_y_x)
    
    ans_lis[ans] += 1
    
for i in range(1, n):
  print(ans_lis[i] // 2)

Solution (Python):
import sys
from collections import Counter
input = sys.stdin.readline

N, X, Y = map(int, input().split())
skip = Y - X  - 1
ans = []

for i in range(1, N):
    for j in range(i+1, N+1):
        dist = j - i
        if i < X and j >= X and j <= Y:
            left = j - X
            right = Y - j + 1
            if right < left:
                dist = j - i + right - left
        elif i >= X and i <= Y and j >= X and j <= Y:
            r1 = j - i
            r2 = i - X + Y - j + 1
            if r2 < r1:
                dist = r2
        elif i >= X and i < Y and j > Y:
            left2 = i - X + 1
            right2 = Y - i
            if left2 < right2:
                dist = j - i + left2 - right2
        elif i <= X and j >= Y:
            dist = j - i - skip
        ans.append(dist)
out = Counter(ans)

for i in range(1, N):
    if i in out:
        print(out[i])
    else:
        print(0)

Solution (Python):
n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1, n):
    for j in range(i + 1, n + 1):
        d = min(j - i, abs(x - i) + 1 + abs(y - j))
        ans[d] += 1
print(*ans[1:], sep="\n")

Solution (Python):
n,x,y = (int(x) for x in input().split())
count = {v:0 for v in range(1,n)}

for i in range(1,n+1):
  for j in range(i+1,n+1):
    if j <= x or y <= i:
      count[j-i] += 1
    else:
      c1 = j-i
      c2 = abs(i-x) + abs(j-y) + 1
      count[min(c1,c2)] += 1
      
for v in count.values():
	print(v)

Solution (Python):
n, x, y = map(int, input().split())
dist = {}
distance = 0
for m in range(1, n):
    dist[m] = 0
for i in range(1, n):
    for j in range(i+1, n+1):
        distance = min(j-i, abs(i-x)+abs(j-y)+1)
        dist[distance] += 1
for p in range(1, n):
    print(dist[p])

Solution (Python):
N,X,Y = map(int,input().split())
ans = [0]*N
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if i <= X and j <= Y:
            d = min(j-i,(X-i)+(Y-j)+1)
            ans[d] += 1
        if i <= X and j > Y:
            d = (X - i) + (j - Y) + 1
            ans[d] += 1
        if i > X and j <= Y:
            d = min(j-i,(i-X)+(Y-j)+1)
            ans[d] += 1
        if i > X and j > Y:
            d = min(j-i,(i-X)+(j-Y)+1)
            ans[d] += 1

for i in ans[1:]:
    print(i)

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math

import itertools



import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,x,y=map(int,input().split())
    d2=[[INFI for i in range(n+1)] for j in range(n+1)]
    total=[0]*(n+1)
    d2[x][y]=1
    d2[y][x]=1
    for i in range(1,n+1):
        for j in range(1,n+1):
            d2[i][j]=min(d2[i][j],abs(i-j),d2[i][x]+d2[y][j]+1,abs(d2[i][y]+d2[x][j]+1))
    for i in range(1,n+1):
        for j in range(1,n+1):
            d2[i][j]=min(d2[i][j],abs(i-j),d2[i][x]+d2[y][j]+1,abs(d2[i][y]+d2[x][j]+1))

    for i in range(1,n+1):
        for j in range(1,n+1):
            total[d2[i][j]]+=1

    for i in range(1,n):
        print(total[i]//2)




if __name__ == "__main__":

    main()

Solution (Python):
def z(x,y):
    if x > y:
        return(x-y)
    else:
        return(y-x)
N,X,Y = map(int,input().split())
X -= 1
Y -= 1
A = [0] * N
for i in range(N):
    for j in range(i+1,N):
        a = min(j-i,z(i,X) + 1 + z(j,Y))
        A[a] += 1
for i in range(N-1):
    print(A[i+1])

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, x, y = [int(s) for s in input().strip().split()]

    result = [0] * n

    def bfs(src):
        seen = {src}
        q = [src]
        step = 0
        while q:
            q2 = []
            for u in q:
                if u > src:
                    result[step] += 1
                if u > 1 and u - 1 not in seen:
                    seen.add(u - 1)
                    q2.append(u - 1)
                if u < n and u + 1 not in seen:
                    seen.add(u + 1)
                    q2.append(u + 1)
                if u == x and y not in seen:
                    seen.add(y)
                    q2.append(y)
                if u == y and x not in seen:
                    seen.add(x)
                    q2.append(x)
            q = q2
            step += 1
    
    for i in range(1, n + 1):
        bfs(i)
    for i in range(1, n):
        print(result[i])




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    n, x, y = map(int, input().strip().split())
    dist = [[0] * (n+1) for _ in range(n+1)]

    def calc_dist(i, j):
        return min(j-i, abs(i-x)+1+abs(j-y))

    for i in range(1, n+1):
        for j in range(i+1, n+1):
            dist[i][calc_dist(i, j)] += 1

    for k in range(1, n):
        ans = 0
        for node in range(1, n+1):
            ans += dist[node][k]
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import collections
n,x,y=map(int,input().split())
ls = [[] for i in range(n)]
for i in range(n-1):
    ls[i].append(i+1)
ls[x-1].append(y-1)
ls[y-1].append(x-1)
co = collections.Counter()
for i in range(n):
    for j in range(i):
        d = min(i-j,abs(x-1-j)+abs(y-1-i)+1)
        co[d] +=1
for k in range(1,n):
    print(co[k])

Solution (Python):
from collections import defaultdict

n, x, y = map(int, input().split())
x -= 1
y -= 1

ctr = defaultdict(int)

for i in range(n):
    for j in range(i + 1, n):
        v = min(j - i, abs(x - i) + 1 + abs(j - y))
        ctr[v] += 1

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

Solution (Python):
def calc(u,v,x,y):
    a = v - u
    b = abs(u-x) + abs(y-v) + 1
    c = abs(u-y) + abs(x-v) + 1
    
    return min(a,b,c)

n,x,y = map(int, input().split())
d = {}
for i in range(1,n):
    for j in range(i+1,n+1):
        dist = calc(i,j,x,y)
        if dist not in d:
            d[dist] = 0
        d[dist] += 1
        

for i in range(1,n):
    print(d.get(i,0))

Solution (Python):
import math
n, x, y = map(int,input().split())
dif = y-x
ans = [0]*(n-1)

for i in range(1,n):
    for j in range(i+1,n+1):
        dist = abs(x-i)+abs(y-j)+1
        ans[min(dist,(j-i))-1] += 1

for i in ans:
    print(i)

Solution (Python):
n,x,y = map(int, input().split())
x -= 1
y -= 1
ans = [0]*n
for i in range(n):
    for j in range(i+1,n):
        if j <= x or y <= i:
            ans[j-i] += 1
        elif i <= x and x <= j and j <= y:
            d = min(j-i,x+y-i-j+1)
            ans[d] += 1
        elif x <= i and y<= j:
            d = min(j-i,i-x+1+j-y)
            ans[d] += 1
        elif x <= i and j <= y:
            d = min(j-i,i-x+1+y-j)
            ans[d] += 1
        else:
            d = x - i + 1 + j - y
            ans[d] += 1


for i in ans[1:]:
    print(i)

Solution (Python):
from collections import deque

def bfs(i):
    global ans
    q = deque()
    c = [0] * n
    d = [0] * n
    c[i] = 1
    d[i] = 0
    q.append(i)
    while q:
        p = q.popleft()
        if p != 0:
            if c[p - 1] == 0:
                q.append(p - 1)
                d[p - 1] += d[p] + 1
                c[p - 1] = 1
                ans[d[p - 1]] += 1
        if p != n - 1:
            if c[p + 1] == 0:
                q.append(p + 1)
                d[p + 1] += d[p] + 1
                c[p + 1] = 1
                ans[d[p + 1]] += 1
        if p == x:
            if c[y] == 0:
                q.append(y)
                d[y] = d[x] + 1
                c[y] = 1
                ans[d[y]] += 1
        if p == y:
            if c[x] == 0:
                q.append(x)
                d[x] = d[y] + 1
                c[x] = 1
                ans[d[x]] += 1
    
    


n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0] * n
for i in range(n):
    bfs(i)

for i in range(1, n):
    print(ans[i] // 2)

Solution (Python):


N,X,Y=map(int,input().split())
G=[[] for i in range(N)]

for i in range(N):
    if i<N-1:
        G[i].append(i+1)
    if i>0:
        G[i].append(i-1)

G[X-1].append(Y-1)
G[Y-1].append(X-1)

ans=[0 for i in range(N)]

INF=10**5

for i in range(N):
    queue=[]
    queue.append(i)
    d=[INF for j in range(N)]
    d[i]=0
    unused=[True for j in range(N)]
    unused[i]=False
    
    while queue:
        u=queue.pop(0)
        
        for j in range(len(G[u])):
            n=G[u][j]
            if unused[n] and d[n]>d[u]+1:
                unused[n]=False
                d[n]=d[u]+1
                queue.append(n)
    
    for j in range(N):
        ans[d[j]]+=1


for i in range(N-1):
    print(ans[i+1]//2)

Solution (Python):

n,x,y = map(int,input().split())


if x > y: x,y = y,x

ans = [0]*n
for i in range(1,n):
    for j in range(i+1,n+1):
        
        if y <= i or j <= x:
            k = j-i
            ans[k] += 1
        
        elif (x<=i and i <= y and y <= j):
            k = min(j-i,i-x+j-y+1)
            ans[k] += 1
        
        elif (i<=x and x <= j and j<=y):
            k = min(j-i,y-j+1+x-i)
            ans[k] += 1
        elif i <=x and y <= j:
            k = x-i+1+j-y
            ans[k] += 1
        else:
            k = min(j-i,1+i-x+y-j)
            ans[k] += 1
        
for i in range(1,n):
    print(ans[i])

Solution (Python):
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def main():
    N,X,Y = isRaw()
    Es = [[1]]+[[n-1,n+1] for n in range(1,N-1)]+[[N-2]]
    Es[X-1].append(Y-1)
    Es[Y-1].append(X-1)
    def shortest(n):
        qu = deque()
        visited = [0]*N
        qu.append(n)
        visited[n]=1
        path =[INF]*N
        path[n]=0
        while len(qu)!=0:
            m = qu.popleft()
            for l in Es[m]:
                if visited[l]!=0:
                    continue
                path[l] = min(path[m]+1,path[l])
                visited[l]=1
                qu.append(l)
        return path
    shortests = [shortest(n) for n in range(N)]
    npathes = [0 for i in range(N-1)]
    for n in range(N):
        for m in range(n+1,N):
            npathes[shortests[n][m]-1]+=1
    return "\n".join([str(a) for a in npathes])

if __name__ == "__main__":
    print(main())