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):
from collections import deque


def main():

    N, X, Y = map(int, input().split())
    G = [set() for _ in range(N)]
    for i in range(N - 1):
        G[i].add(i + 1)
        G[i + 1].add(i)
    G[X - 1].add(Y - 1)
    G[Y - 1].add(X - 1)

    ans = [0] * (N - 1)
    for i in range(N - 1):
        
        dist = [-1] * N
        dist[i] = 0
        q = deque([i])
        while len(q):
            v = q.pop()
            for nv in G[v]:
                if dist[nv] != -1:
                    continue
                q.appendleft(nv)
                dist[nv] = dist[v] + 1

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

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


if __name__ == '__main__':
    main()

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

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


for k in range(1, n):
    count = 0
    for a in range(1, (n-k) + 1):
        
        b = k+a
        if((abs(x-a) + abs(y-b) + 1) >= k):
            count += 1
        
        to_y = k - abs(x-a) - 1
        if(to_y >= 0):
            b1 = y + to_y
            b2 = y - to_y
            if(b1 <= n and b1 - a >= k and b != b1):
                count += 1
            if(b2 - a >= k and b != b2 and b1 != b2):
                count += 1
    print(count)

Solution (Python):
from itertools import combinations

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

c = [0] * (n-1)
for a, b in combinations(range(1, n+1), 2):
    p = b - a
    q = abs(x-a)+1+abs(y-b)
    r = min(p, q)
    c[r-1] += 1

print('\n'.join([str(num) for num in c]))

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

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

D = [0 for _ in range(n+1)]
    
for i in range(n-1):
    for j in range(i+1,n):
        dist1 = j-i
        dist2 = abs(i-x) +1 + abs(j-y)
        dist = min(dist1,dist2)
        D[dist] = D[dist]+1


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

Solution (Python):

import sys
import math
import numpy as np
import itertools

n,x,y = (int(i) for i in input().split())  

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


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

Solution (Python):
from collections import deque
N, X, Y = [int(i) for i in input().split()]
X -= 1
Y -= 1
G = [[] for _ in range(N)]
for i in range(N):
    if i!=0: G[i].append(i-1)
    if i!=N-1: G[i].append(i+1)
G[X].append(Y)
G[Y].append(X)


def bfs(G, N, s):
    dist = [-1]*N
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    return dist

res = [0]*(N+1)
for i in range(N):
    d = bfs(G, N, i)
    for j in range(i+1, N):
        res[d[j]] += 1

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

Solution (Python):




def bfs_len_max(ind,graph,q_num):
    distance_arr=[0 if i==ind  else -1 for i in range(len(graph))]
    q=[-1 for _ in range(q_num)]
    q[0]=ind
    l=1
    n=0
    while len(q)>l:
        for i in graph[ind]:
            if distance_arr[i]==-1:
                distance_arr[i]=distance_arr[ind]+1
                q[l]=i
                l+=1
        
        
        
        
        n+=1
        ind=q[n]


    return distance_arr
    

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



q_num=n
graph=[[1]]
for i in range(1,n-1):
    graph.append([i-1,i+1])
graph.append([n-2])
graph[x-1].append(y-1)
graph[y-1].append(x-1)
ans=[0 for _ in range(n)]

for s in range(n):
    if len(graph[s])==0:
        continue
    
    tmp=bfs_len_max(s,graph,q_num)
    for each in tmp:
        ans[each]+=1
    

for each in ans[1:]:
    print(each//2)

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

L = [0] * N

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

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

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

def main():
    N,A,B = map(int,input().split())
    A -= 1
    B -= 1
    
    ans = [0 for _ in range(N-1)]
    
    for i in range(N):
        for j in range(i+1,N):
            if i < A:
                if j <= A:
                    ans[j-i-1] += 1
                elif A < j <= B:
                    l = min(j-i,(A-i)+1+(B-j))
                    ans[l-1] += 1
                else:
                    ans[(A-i)+(j-B)] += 1
            elif A <= i < B:
                l = min(j-i,(i-A)+1+abs(B-j))
                ans[l-1] += 1
            else:
                ans[j-i-1] += 1
                
    print(*ans,sep="\n")
    
if __name__ == "__main__":
    main()

Solution (Python):
[N,X,Y] = list(map(int,input().split()))
out = [0]*(N-1)
for i in range(1,N+1):
    for j in range(i+1,N+1):
        L = min(j-i,1+abs(X-i)+abs(Y-j),1+abs(X-j)+abs(Y-i))
        out[L-1]+=1
for i in range(N-1):
    print(out[i])

Solution (Python):
N,X,Y = map(int,input().split())
ans = [0]*N
for i in range(1,N+1):
  for j in range(i,N+1):
    y = min(abs(i-X)+abs(j-Y)+1,abs(i-Y)+abs(j-X)+1)
    x = min(j-i,y)
    ans[x]+=1

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

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

def dist(fr, to):
    return min(
        to - fr,
        abs(to - Y) + 1 + abs(fr - X),
        abs(fr - Y) + 1 + abs(to - X)
    )

cnt = [0] * N

ans = 0
for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cnt[dist(fr, to)] += 1

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

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

X = X-1
Y = Y-1

dis = Y-X
dis = dis/2
ans_list = [0]*(N-1)

for i in range(N-1):
  for j in range(i+1,N):
    normal = j-i
    a = abs(i-X)
    b = abs(j-Y)
    cut = a+b+1
    ans = min(normal, cut)
    ans_list[ans-1] += 1
for i in ans_list:
  print(i)

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

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

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

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

Solution (Python):
N,X,Y = map(int,input().split())
D = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(i+1,N):
        D[i][j] = j-i
D[X-1][Y-1] = 1
A = [0]*(N-1)
for i in range(N):
    for j in range(i+1,N):
        c,d = max(i,X-1),min(i,X-1)
        e,f = max(Y-1,j),min(j,Y-1)
        a = min(D[i][j-1]+1,D[d][c]+D[f][e]+1)
        D[i][j] = a
        if a == 0:
            continue
        A[a-1] += 1
for a in A:
    print(a)

Solution (Python):
N, X, Y = map(int,input().split())
X -= 1
Y -= 1
ls = [0]*(N)
for i in range(N):
    for j in range(i+1, N):
        d = min(j-i, abs(X-i)+1+abs(Y-j))
        ls[d] += 1
for i in range(1, N):
    print(ls[i])

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

ret = [0] * n

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

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

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


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

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

Solution (Python):

import sys


def solve(N: int, X: int, Y: int):
    matrix = [[float('inf')]*(N+1) for _ in range(N+1)]

    answer = [0]*N

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

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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    solve(N, X, Y)

if __name__ == '__main__':
    main()

Solution (Python):
n,x,y = map(int,input().split())
left = x-1
mid = y-x+1
right = n-y

x_to_mid = [0] * n
x_to_mid[0] = 1
for i in range(1, mid//2):
    x_to_mid[i] = 2
x_to_mid[mid//2] = 1 + mid%2

ans = [0] * n

for i in [left,right]:
    for j in range(1,i):
        ans[j] += i-j


for i in range(1, 1 + mid//2):
    ans[i] += mid * x_to_mid[i] // 2


for i in range(left):
    for j in range(right):
        ans[i+j+3] += 1


for i in [left,right]:
    for j in range(n):
        tmp = x_to_mid[j]
        if(tmp==0):
            break
        for k in range(1,i+1):
            ans[ j+k ] += tmp

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

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

ans = [0] * N

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

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

Solution (Python):
from itertools import combinations
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

table = [0]*N

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

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

Solution (Python):
import collections
def main():

    N, X, Y = map(int, input().split())
    count = collections.defaultdict(int)
    for i in range(1, N+1):
        for j in range(1, i):
            v = i-j
            v = min(v, abs(i-Y)+1+abs(X-j))

            count[v] += 1

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


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, X, Y = map(int, input().split())
    ans = [0] * (N-1)
    for i in range(N):
        for j in range(i+1, N):
            dst = min(j-i, abs(X-1-i) + abs(Y-1-j) + 1)
            ans[dst-1] += 1
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

Solution (Python):
N,X,Y=map(int,input().split())
ans=[0 for i in range(N+1)]
L=[[]for i in range(N+1)]
for i in range(2,N+1):
    L[i].append(i-1)
    L[i-1].append(i)
L[X].append(Y)
L[Y].append(X)
import heapq
for i in range(1,N+1):
    C=[10**5 for i in range(N+1)]
    C[i]=0
    Q=[]
    for a in L[i]:
        Q.append((1,a))
    heapq.heapify(Q)
    for b in range(10**4):
        if len(Q)==0:
            break
        d,p=Q[0]
        heapq.heappop(Q)
        if C[p]==10**5:
            C[p]=d
            ans[d]+=1
            for c in L[p]:
                if C[c]==10**5:
                    heapq.heappush(Q,(d+1,c))
for i in range(1,N):
    print(ans[i]//2)

Solution (Python):

import sys


def solve(N: int, X: int, Y: int):
    ans = [0] * N
    for i in range(1, N):
        for j in range(i+1, N+1):
            a = min(j-i, abs(j-Y)+abs(X-i)+1)
            ans[a] += 1
    print(*ans[1:], sep='\n')



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    solve(N, X, Y)

if __name__ == '__main__':
    main()

Solution (Python):


from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))



N,X,Y=acinput()



dist=[[-1 for j in range(N+1) ] for i in range(N+1)]


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

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

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

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

for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cost = min(to - fr, abs(X - fr) + abs(to - Y) + 1)
        ans[cost] += 1

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

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

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

for i in range(0,N-1):
    for j in range(i+1,N):
        distance=0
        if X>=j:
            distance=j-i
        elif Y>=j>=X and X>=i:
            distance=min(j-i,X+Y+1-i-j)
        elif j>=Y and X>=i:
            distance=X-i+j-Y+1
        elif Y>=i>=X:
            distance=min(j-i,i-X+1+abs(Y-j))
        else:
            distance=j-i
        ans[distance]+=1

for i in range(0,N):
    if i!=0:
        print(ans[i])

Solution (Python):
n, x, y = list(map(int, input().split()))
dist_cnt = (n) * [0]
x -= 1
y -= 1
for i in range(0, n - 1):
    for j in range(i + 1, n):
        dist = j - i
        if i <= x:
            if j >= y:
                dist = x - i + j - y + 1
            else:
                dist = min(dist, y - j + 1 + x - i)
        else:
            if j >= y:
                dist = min(dist, j - y + 1 + i - x)
            else:
                dist = min(dist, i - x + 1 + y - j)
        dist_cnt[dist] += 1
print( '\n'.join(map(str, dist_cnt[1:])))

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

A = [0]*(N-1)

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

for e in A:
    print(e)

Solution (Python):
from collections import defaultdict
N, X, Y = map(int, input().split())
Y -= 1
X -= 1
dic =  defaultdict(int)
for i in range(N):
  for j in range(i):
    m = min(abs(i-Y)+abs(j-X)+1,i-j)
    dic[m] += 1
for i in range(1,N):
  print(dic[i])

Solution (Python):
from collections import defaultdict
from collections import deque

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

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

for i in range(1, n):
    edges[i].append(i-1)

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

count = defaultdict(int)


def bfs(start):
    dist = [10**4] * n
    dist[start] = 0
    todo = deque([])
    for to in edges[start]:
        todo.append([1, to])

    while todo:
        d, node = todo.popleft()
        if d >= dist[node]:
            continue

        dist[node] = d
        for to in edges[node]:
            todo.append([d+1, to])
    return dist


for start in range(n):
    dist = bfs(start)
    for d in dist:
        count[d] += 1

for k in range(1, n):
    res = count[k] // 2
    print(res)

Solution (Python):

import sys
from collections import defaultdict

def solve(N: int, X: int, Y: int):
    l = [0] * (N-1)
    for i in range(N):
        for j in range(i+1,N):
            cost = min(j-i,1+abs(Y-j-1)+abs(X-i-1))-1
            l[cost] += 1
    for ll in l:
        print(ll)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    solve(N, X, Y)

if __name__ == '__main__':
    main()

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

edges = defaultdict(lambda: [])
for i in range(1, n):
    edges[i].append(i+1)
    edges[i+1].append(i)
edges[x].append(y)
edges[y].append(x)


counter = [0 for i in range(n)]
for i in range(1, n+1):
    d = deque()
    is_checked = [False for _ in range(n+1)]
    dist = [-1 for _ in range(n+1)]
    dist[i] = 0
    d.append((i, 0))
    while len(d) > 0:
        e, pre_dist = d.popleft()
        if is_checked[e]:
            continue
        else:
            is_checked[e] = True
            dist[e] = pre_dist + 1
            for next_e in edges[e]:
                if not is_checked[next_e]:
                    d.append((next_e, pre_dist+1))
    for j in range(i+1, n+1):
        counter[dist[j]-1] += 1
print("\n".join(list(map(str, counter[1:]))))

Solution (Python):




n,x,y=map(int,input().split())
graph={i:{} for i in range(1,n+1)}



for i in range(1,n):
    graph[i][i+1]=1
    graph[i+1][i]=1
    
graph[x][y]=1
graph[y][x]=1


import heapq
def dijkstra(s,graph,n):
    
    dist=[10**20 for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    
    heapq.heappush(pq,(0,s))
    while pq:
        x=heapq.heappop(pq)
        node,mini_dis=x[1],x[0]
        for point in graph[node].keys():
            w=graph[node][point]
            
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen

    return dist

ans_dis=[0 for i in range(n)]

for i in range(1,n+1):
    sub=dijkstra(i,graph,n)
    for j in range(1,n+1):
        dis=sub[j]
        ans_dis[dis]+=1

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

Solution (Python):


import itertools


def summarize_dists(n, x, y):
    if x > y:
        x, y = y, x
    
    table = [0 for _ in range(n)]
    for i, j in itertools.combinations(range(n), 2):
        if i <= x and y <= j:
            dist = x - i + 1 + j - y
        elif i <= x:
            dist = x - i + min(j - x, 1 + y - j)
        elif y <= j:
            dist = min(i - x + 1, y - i) + j - y
        else:
            dist = min(j - i, i - x + 1 + y - j)
        table[dist] += 1
    return table


def main():
    n, x0, y0 = (int(z) for z in input().split())
    x = x0 - 1
    y = y0 - 1
    table = summarize_dists(n, x, y)
    print(*table[1:], sep="\n")


if __name__ == "__main__":
    main()

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

for i in range(n):
    for j in range(i):
        swit=0
        if (i<=x and j<=x) or (i>=y and j>=y):
            answer[abs(i-j)]+=1
        elif j<=x and y<=i:
            answer[i-y+1+x-j]+=1
        elif x<=j and j<=y and x<=i and i<=y:
            answer[min(i-j, j-x+1+y-i)]+=1
        elif j<=x and x<=i and i<=y:
            answer[min(i-j, x-j+1+y-i)]+=1
        elif x<=j and j<=y and y<=i:
            answer[min(i-j, j-x+1+i-y)]+=1
            swit=5
        

for an in range(len(answer)):
    if an!=0:
        print(answer[an])

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

roots = [[] for _ in range(n)]

for i in range(n):
    if i == 0:
        roots[i].append(1)
    elif i == n - 1:
        roots[i].append(n-2)
    else:
        roots[i].append(i-1)
        roots[i].append(i+1)

roots[x-1].append(y-1)
roots[y-1].append(x-1)
ans = [0] * (n-1)

for i in range(n):
    hq = []
    dis = [-1]* n
    dis[i] = 0
    heapq.heappush(hq, (0,i))
    while hq:
        dis1, place = heapq.heappop(hq)
        for j in roots[place]:
            if dis[j] == -1 or dis[j] > dis1 + 1:
                dis[j] = dis1 + 1
                heapq.heappush(hq, (dis1+1, j))
    for j in dis:
        if j > 0:
            ans[j-1] += 1

for i in ans:
    print(i//2)

Solution (Python):
def solve(n, x, y):
    res_list = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = min(j - i, abs(i - x + 1) + abs(j - y + 1) + 1)
            res_list[d] += 1
    
    return res_list[1:]


def main():
    n, x, y = map(int, input().split())
    res_list = solve(n, x, y)
    for res in res_list:
        print(res)


def test():
    assert solve(5, 2, 4) == [5, 4, 1, 0]
    assert solve(3, 1, 3) == [3, 0]
    assert solve(7, 3, 7) == [7, 8, 4, 2, 0, 0]


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

Solution (Python):
def main():
    N, X, Y = map(int, input().split())
    X = X - 1
    Y = Y - 1
    d = {}
    for i in range(X):
        for j in range(i+1, X+1):
            if (j - i) in d:
                d[j - i] += 1
            else:
                d[j - i] = 1
        for j in range(X+1, Y+1):
            t = min(j - i, Y - j + 1 + X - i)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
        for j in range(Y+1, N):
            t = (j - Y + 1 + X - i)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    for i in range(X, Y):
        for j in range(i+1, Y+1):
            t = min(j - i, i - X + 1 + Y - j)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
        for j in range(Y+1, N):
            t = min(j - i, i - X + 1 + j - Y)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    for i in range(Y, N):
        for j in range(i+1, N):
            if (j - i) in d:
                d[j - i] += 1
            else:
                d[j - i] = 1
    for i in range(1, N):
        if i not in d:
            print(0)
        else:
            print(d[i])
main()

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

d = []
for i in range(n):
    lst = [0 for _ in range(n)]
    temp = i+1
    umeru = 1
    while temp <= n-1:
        lst[temp] = umeru
        umeru += 1
        temp += 1
    temp = i-1
    umeru = 1
    while temp >= 0:
        lst[temp] = umeru
        umeru += 1
        temp -= 1
    d.append(lst)

d[x-1][y-1] = 1
d[y-1][x-1] = 1

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

ans = [0 for _ in range(n)]
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().rstrip().split())
ans = [0 for _ in range(N)]
dis = [0,0]
xycent = (X + Y) / 2
for i in range(1 , N):
  for i2 in range(i + 1,N + 1):
    dis[0] = i2 - i
    dis[1] = abs(i - X) + abs(i2 - Y) + 1
    if dis[0] > dis[1]:
      ans[dis[1]] += 1
    else:
      ans[dis[0]] += 1
for i in range(1,N):
  print(ans[i])

Solution (Python):
class lheapq:
    def __init__(self, p):
        self.l = []
        if p:
            for sp in p:
                self.heappush(sp)

    def heappush(self, a):
        n = len(self.l)
        self.l.append(a)
        t = n
        while t != 0:
            if self.l[t][1] < self.l[(t - 1) // 2][1]:
                self.l[t], self.l[(t - 1) // 2] = self.l[(t - 1) // 2], self.l[t]
                t = (t - 1) // 2
            else:
                break

    def heappop(self):
        n = len(self.l)
        if n == 0:
            return [-1, 0]
        if n == 1:
            return self.l.pop()
        ret = self.l[0]
        self.l[0] = self.l.pop()
        n -= 1
        t = 0
        while t < n:
            child1 = t * 2 + 1
            child2 = t * 2 + 2
            if child1 >= n:
                break
            elif child2 >= n:
                if self.l[t][1] > self.l[child1][1]:
                    self.l[t], self.l[child1] = self.l[child1], self.l[t]
                    t = child1
                else:
                    break
            else:
                if self.l[child2][1] < self.l[child1][1]:
                    child1, child2 = child2, child1
                if self.l[t][1] > self.l[child1][1]:
                    self.l[t], self.l[child1] = self.l[child1], self.l[t]
                    t = child1
                elif self.l[t][1] > self.l[child2][1]:
                    self.l[t], self.l[child2] = self.l[child2], self.l[t]
                    t = child2
                else:
                    break
        return ret

    def isnotblank(self):
        if self.l:
            return True
        else:
            return False


def dijkstra(s, g, n):
    
    
    f = [-1 for _ in range(n)]
    f[s] = 0
    q = lheapq(g[s])
    while True:
        kakutei = q.heappop()
        if kakutei[0] == -1:
            return f
        while f[kakutei[0]] != -1:
            kakutei = q.heappop()
            if kakutei[0] == -1:
                return f
        s = kakutei[0]
        f[s] = kakutei[1]
        for sg, sl in g[s]:
            if f[sg] == -1:
                q.heappush([sg, sl + f[s]])


def main():
    N, X, Y = map(int, input().split())
    g = [[] for _ in range(N)]
    for i in range(N - 1):
        g[i].append([i + 1, 1])
        g[i + 1].append([i, 1])
    g[X - 1].append([Y - 1, 1])
    g[Y - 1].append([X - 1, 1])
    res = [0 for _ in range(N)]
    for i in range(N):
        tres = dijkstra(i, g, N)
        for stres in tres:
            res[stres] += 1

    for i in range(1, N):
        print(res[i] // 2)


main()

Solution (Python):
n,x,y = [int(x) for x in input().split()]
x -= 1
y -= 1
G = [[] 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)

ans = [0]*n
from collections import deque

def bfs(num):
    q = deque()
    d = [-1]*n
    q.append(num)
    d[num]=0
    while q:
        p = q.popleft()
        for i in G[p]:
            if d[i]==-1:
                d[i] = d[p] + 1
                ans[d[i]] += 1
                q.append(i)

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())
ans = [0 for i in range(n)]

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

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

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

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

cnt = [0]*(n-1)

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

print(*cnt,sep="\n")

Solution (Python):



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

G = [[] for i 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)

from collections import deque
ans = [0]*(n-1)
def dfs(i):
    q = deque()
    q.append([i, 0])
    used = [0]*n
    while q:
        cur,d = q.popleft()
        if used[cur]:
            continue
        used[cur] = 1
        if d > 0:
            ans[d-1] += 1
        for to in G[cur]:
            if used[to]:
                continue
            q.append([to, d+1])

for i in range(n):
    dfs(i)
ans = [i//2 for i in ans]
print(*ans, sep="\n")

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

dist_count = {}
for i in range(n-1):
	for j in range(i+1, n):
		dist_simple = j - i
		dist_bridge1 = abs(i-x) + 1 + abs(j-y)
		dist_bridge2 = abs(i-y) + 1 + abs(j-x)
		res_dist = min(dist_simple, dist_bridge1, dist_bridge2)
		dist_count[res_dist] = dist_count.get(res_dist, 0) + 1


for dist in range(1, n):
	print(dist_count.get(dist, 0))

Solution (Python):
N,X,Y = map(int, input().split())
from collections import defaultdict
edges = defaultdict(list)
for i in range(N-1):
    edges[i].append([i+1,1])
    edges[i+1].append([i,1])
edges[X-1].append([Y-1,1])
edges[Y-1].append([X-1,1])


import heapq
INF = 10 ** 18
def dijkstra(n, edges, s):
    """
    input
        n : 頂点数
        edges : リスト(始点, 終点, コスト)
        s : 始点
    output
        d : 始点からの最短距離
    """
    d = [INF] * n
    used = [False] * n
    d[s] = 0
    used[s] = True
    edgelist = []
    
    for v, c in edges[s]:
        
        
        heapq.heappush(edgelist, (c, v))
    
    while len(edgelist):
        
        c_min, v_min = heapq.heappop(edgelist)
        
        if used[v_min]:
            continue
        
        d[v_min] = c_min
        used[v_min] = True
        for v, c in edges[v_min]:
            if not used[v]:
                heapq.heappush(edgelist, (c+c_min, v))
    return d

ans = [0] * N
for i in range(N):
    d = dijkstra(N,edges,i)
    
    for j in range(i+1,N):
        ans[d[j]] += 1
for i in range(1,N):
    print(ans[i])

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

X -= 1
Y -= 1

def calc(s):
	queue = [s]
	distance = [N + 1] * N
	distance[s] = 0
	while queue:
		cur = queue.pop()
		dist = distance[cur] + 1
		if cur > 0 and distance[cur - 1] > dist:
			queue.append(cur - 1)
			distance[cur - 1] = dist
		
		if cur < N - 1 and distance[cur + 1] > dist:
			queue.append(cur + 1)
			distance[cur + 1] = dist
		
		if cur == X and distance[Y] > dist:
			queue.append(Y)
			distance[Y] = dist
		
		if cur == Y and distance[X] > dist:
			queue.append(X)
			distance[X] = dist
	
	return distance

d_list = [calc(i) for i in range(N)]



d_table = [0] * N

for l in d_list:
	for d in l:
		d_table[d] += 1

for k in range(1, N):
	print(d_table[k] // 2)

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

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

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


def bfs(st, graph):
    INF = 10 ** 18
    dist = [INF] * len(graph)
    dist[st] = 0
    stack = [st]
    while stack:
        s = stack.pop()
        for t in graph[s]:
            if dist[t] > dist[s] + 1:
                dist[t] = dist[s] + 1
                stack.append(t)
    return dist

answer = [0] * (N + 1)
for i in range(1, N + 1):
    dist = bfs(i, graph)
    
    for j in range(1, N + 1):
        answer[dist[j]] += 1

for i in range(1, N):
    print(answer[i] // 2)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

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