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,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'
    
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()

class Tree:
    def __init__(self,inp_size=None,ls=None,init=True,index=1):
        self.LCA_init_stat=False
        self.ETtable=[]
        if init:
            if ls==None:
                self.stdin(inp_size,index=index)
            else:
                self.node_size=len(ls)+1
                self.edges,_=GI(self.node_size,self.node_size-1,ls,index=index)
        return
 
    def stdin(self,inp_size=None,index=1):
        if inp_size==None:
            self.node_size=int(input())
        else:
            self.node_size=inp_size
        self.edges,_=GI(self.node_size,self.node_size-1,index=index)
        return
    
    def listin(self,ls,index=0):
        self.node_size=len(ls)+1
        self.edges,_=GI(self.node_size,self.node_size-1,ls,index=index)
        return
 
    def dfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def bfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.node_size
        v[x]=root_v
        while q:
            c=q.popleft()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def parent(self,x):
        return self.dfs(0,func=lambda pr,prv,nx,dist:pr,root_v=-1)
 
    def topological_sort(self,x):  
        tps=[]
        q=deque([x])
        v=[None]*self.node_size
        v[x]=0
        while q:
            c=q.popleft()
            tps.append(c)
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=0
        return tps
 
    def EulerTour(self,x):
        q=deque()
        q.append(x)
        self.depth=[None]*self.node_size
        self.depth[x]=0
        self.ETtable=[]
        self.ETdepth=[]
        self.ETin=[-1]*self.node_size
        self.ETout=[-1]*self.node_size
        cnt=0
        while q:
            c=q.pop()
            if c<0:
                ce=~c
            else:
                ce=c
                for nb,d in self.edges[ce]:
                    if self.depth[nb]==None:
                        q.append(~ce)
                        q.append(nb)
                        self.depth[nb]=self.depth[ce]+1
            self.ETtable.append(ce)
            self.ETdepth.append(self.depth[ce])
            if self.ETin[ce]==-1:
                self.ETin[ce]=cnt
            else:
                self.ETout[ce]=cnt
            cnt+=1
        return
    
    def LCA_init(self,root):
        self.EulerTour(root)
        self.st=SparseTable(self.ETdepth,init_func=min,init_idl=inf)
        
        self.LCA_init_stat=True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.LCA_init(root)
        xin,xout=self.ETin[x],self.ETout[x]
        yin,yout=self.ETin[y],self.ETout[y]
        a=min(xin,yin)
        b=max(xout,yout,xin,yin)
        id_of_min_dep_in_et=self.st.query_id(a,b+1)
        return self.ETtable[id_of_min_dep_in_et]
 
    def __str__(self):
        return  str(self.edges)
 
    def show(self):
        if all([all([d==1 for nd,d in e]) for e in self.edges]):
            print( [[nd for nd,d in e] for e in self.edges] )
        else:
            print(self)

class SparseTable: 
    def __init__(self,ls,init_func=min,init_idl=float('inf')):
        self.func=init_func
        self.idl=init_idl
        self.size=len(ls)
        self.N0=self.size.bit_length()
        self.table=[ls[:]]
        self.index=[list(range(self.size))]
        self.lg=[0]*(self.size+1)
        
        for i in range(2,self.size+1):
            self.lg[i]=self.lg[i>>1]+1
 
        for i in range(self.N0):
            tmp=[self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) for j in range(self.size)]
            tmp_id=[self.index[i][j] if self.table[i][j]==self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) else self.index[i][min(j+(1<<i),self.size-1)] for j in range(self.size)]
            self.table+=[tmp]
            self.index+=[tmp_id]
    
    
    def query(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        return self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))])
    
    
    def query_id(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        a,b=self.index[N][l],self.index[N][max(0,r-(1<<N))]
        if self.table[0][a]==self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))]):
            b=a
        return b
    
    
    def right_bound(self,pos,x):
        k=(self.size-pos).bit_length()
        for j in range(k)[::-1]:
            nx=pos+(1<<j)
            if nx<n and self.query(pos,nx+1)<=x:
                pos+=(1<<j)
        return pos
    
    
    def left_bound(self,pos,x):
        k=pos.bit_length()
        for j in range(k)[::-1]:
            nx=pos-(1<<j)
            if 0<=nx and self.query(nx,pos+1)<=x:
                pos-=(1<<j)
        return pos
 
    def __str__(self):
        return str(self.table[0])
 
    def print(self):
        for i in self.table:
            print(*i)


show_flg=False
show_flg=True


ans=0

n,x,y=LI_()
n+=1
m=defaultdict(int)
for i in rep(n):
    for j in rep(i+1,n):
        d=min(j-i,abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
        m[d]+=1

for i in rep(1,n):
    print(m[i])

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

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

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

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

Solution (Python):
from collections import OrderedDict
n, x, y = map(int, input().split())
x = x-1
y = y-1
dist_hist = OrderedDict({i: 0 for i in range(1, n)})
for i in range(n-1):
  for j in range(i+1, n):
    if i<=x and j>=y:
      dist = j-i + 1 - (y-x)
    elif i<=x and x<j<y:
      dist = min(j-i, x-i + 1 + y-j)
    elif x<i<y and y<=j:
      dist = min(i-x + 1 + j-y, j-i)
    elif x<i<y and x<j<y:
      dist = min(j-i, i-x + 1 + y-j)
    else:
      dist = j - i
    dist_hist[dist] += 1
[print(value) for value in dist_hist.values()]

Solution (Python):

import numpy as np
from scipy.sparse.csgraph import  dijkstra
from scipy.sparse import csr_matrix

def resolve():
    N, X, Y = map(int, input().split())
    G = np.zeros((N+1, N+1), dtype=np.int64)
    for i in range(1, N):
        G[i, i+1] += 1
        G[i+1, i] += 1
    G[X, Y] += 1
    G[Y, X] += 1

    csr = csr_matrix(G)
    dist = dijkstra(csr)

    dic = {}
    for di in dist:
        for d in di:
            if d in dic:
                dic[d] += 1
            else:
                dic[d] = 1
    for i in range(1, N):
        if i in dic:
            print(dic[i]//2)
        else:
            print(0)

if __name__ == "__main__":
    resolve()

Solution (Python):
from collections import defaultdict
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    klist = defaultdict(int)
    for i in range(n):
        for j in range(i+1, n):
            if (i <= x and j <= x) or (y <= i and y <= j):
                k = j - i
                klist[k] += 1
            elif i <= x and x < j <= y:
                k = min(j - i, (x - i + y - j) + 1)
                klist[k] += 1
            elif i <= x and y <= j:
                k = (j - i) - (y - x) + 1
                klist[k] += 1
            else:
                k = min((j - i), ((i - x) + abs(y - j) + 1))
                klist[k] += 1
    for i1 in range(1, n):
        print(klist[i1])

if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import deque
inf=10**9


def BFS(num):
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    queue=deque([num])

    color[num]="gray"
    D[num]=0

    while len(queue)>0:
        u=queue.popleft()
        for i in M[u]:
            if color[i]=="white" and D[u]+1<D[i]:
                D[i]=D[u]+1
                color[i]="gray"
                queue.append(i)
        color[u]="black"

    return D


n,x,y=map(int,input().split())
M=[[] for _ in range(n+1)]
for i in range(1,n):
    M[i].append(i+1)
    M[i+1].append(i)
M[x].append(y)
M[y].append(x)

ans=[0 for _ in range(n-1)]
for i in range(1,n+1):
    for j in BFS(i)[i+1:]:
        ans[j-1] +=1

for i in ans:
    print(i)

Solution (Python):
from collections import deque
inf=10**9


def BFS(num):
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    queue=deque([num])

    color[num]="gray"
    D[num]=0

    while len(queue)>0:
        u=queue.popleft()
        for i in M[u]:
            if color[i]=="white" and D[u]+1<D[i]:
                D[i]=D[u]+1
                color[i]="gray"
                queue.append(i)
        color[u]="black"

    return D


n,x,y=map(int,input().split())
M=[[] for _ in range(n+1)]
for i in range(1,n):
    M[i].append(i+1)
    M[i+1].append(i)
M[x].append(y)
M[y].append(x)

ans=[0 for _ in range(n-1)]
for i in range(1,n+1):
    for j in BFS(i)[i+1:]:
        ans[j-1] +=1

for i in ans:
    print(i)

Solution (Python):
n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque
def bfs(start):
    queue = deque()
    queue.append(start)
    isSearched = [-1]*(n+1)
    isSearched[start] = 0
    while(queue):
        i = queue.popleft()
        cnt = isSearched[i]
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            if(j < 1 or n < j):
                continue
            if(isSearched[j]!=-1):
                continue
            queue.append(j)
            isSearched[j] = cnt
            cnt_l[cnt] += 1
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)

Solution (Python):
n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque
def bfs(start):
    queue = deque()
    queue.append(start)
    isSearched = [-1]*(n+1)
    isSearched[start] = 0
    while(len(queue)>0):
        i = queue.popleft()
        cnt = isSearched[i]
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            if(j < 1 or n < j):
                continue
            if(isSearched[j]!=-1):
                continue
            queue.append(j)
            isSearched[j] = cnt
            cnt_l[cnt] += 1
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)

Solution (Python):
import sys
from io import StringIO
import unittest
import os
from collections import deque
import collections


sys.setrecursionlimit(999999999)



def resolve(test_def_name=""):
    n, x, y = map(int, input().split())

    ans = []

    for i in range(1, n + 1):

        que = deque()
        que.append(i)
        work_ans = [9999 for i in range(n + 1)]
        work_ans[i] = 0

        while len(que) is not 0:

            now = que.pop()
            
            target = []
            if now > 1:
                target.append(now - 1)
            if now < n:
                target.append(now + 1)
            if now == x:
                target.append(y)
            if now == y:
                target.append(x)

            for j in target:
                
                if work_ans[j] < work_ans[now] + 1:
                    continue
                
                work_ans[j] = work_ans[now] + 1
                que.appendleft(j)

        ans += work_ans

    
    counter = collections.Counter(ans)

    
    for i in range(1, n):
        print(counter.get(i, 0)//2)



class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5 2 4"""
        output = """5
4
1
0"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3 1 3"""
        output = """3
0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """7 3 7"""
        output = """7
8
4
2
0
0"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """10 4 8"""
        output = """10
12
10
8
4
1
0
0
0"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,x,y = IL()
    x -= 1
    y -= 1
    dist = [0]*(n-1)
    for i in range(n):
        for j in range(i+1,n):
            dist[min(abs(j-i),abs(j-x)+abs(x-i),abs(y-j)+abs(x-i)+1)-1] += 1
    for rep in dist:
        print(rep)
    return

if __name__=='__main__':
    Main()

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

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

Solution (Python):
N,X,Y=map(int,input().split())
distance=[0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        k=min(j-i,abs(j-X)+abs(i-Y)+1,abs(j-Y)+abs(i-X)+1)
        distance[k]+=1
print(*distance[1:],sep="\n")

Solution (Python):
N,X,Y=map(int,input().split())
count=[0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        distance=min(j-i,abs(j-X)+abs(i-Y)+1,abs(j-Y)+abs(i-X)+1)
        count[distance]+=1
print(*count[1:],sep="\n")

Solution (Python):
n,x,y = map(int,input().split())
ans = [0] * (n-1)
l = list(range(1,n+1))

import itertools

for a,b in itertools.combinations(l, 2):
    dis = min(b-a, abs(b-y)+abs(x-a)+1)
    ans[dis-1] += 1

for i in ans:
    print(i)

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

count=[0]*(n-1)
for i in range(n):
    l=i
    for j in range(i+1,n):
        r=j
        dis=min(j-i, abs(x-1-l)+1+abs(y-1-r))
        count[dis-1]+=1
        

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

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

rlt = [0]*N

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if (i < X and j < X) or (i > Y and j > Y):
      rlt[j-i] += 1
    elif i < X and j > Y:
      rlt[X-i+j-Y+1] += 1
    elif i < X and j <= Y:
      rlt[min(j-i,X-i+1+Y-j)] += 1
    elif i >= X and j > Y:
      rlt[min(j-i,i-X+1+j-Y)] += 1
    elif i >= X and j <= Y:
      rlt[min(j-i,i-X+Y-j+1)] += 1
      
for i in rlt[1:]:
  print(i)

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

if __name__ == '__main__':
    main()

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

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

count = [0]*(N+1)
for i in range(1, N+1):
    for k in range(i+1, N+1):
        distik = min(k-i, abs(k-X) + abs(i - Y)+1, abs(k-Y) + abs(i-X)+1)
        count[distik] += 1

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

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

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

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

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

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

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

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def dist(i, j, X, Y):
    a = j - i
    b = abs(X - i) + 1 + abs(j - Y)
    return min(a, b)


def solve():
    N, X, Y = Scanner.map_int()
    ans = [0 for _ in range(1, N + 1)]
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            d = dist(i, j, X, Y)
            ans[d] += 1

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


def main():
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def dist(i, j, X, Y):
    if j <= X:
        return j - i
    if i >= Y:
        return j - i
    if i <= X < Y <= j:
        return X - i + 1 + j - Y
    if X <= i < j <= Y:
        d1 = j - i
        d2 = i - X + 1 + Y - j
        return min(d1, d2)
    if i <= X <= j <= Y:
        d1 = j - i
        d2 = X - i + 1 + Y - j
        return min(d1, d2)
    else:
        d1 = j - i
        d2 = i - X + 1 + j - Y
        return min(d1, d2)


def solve():
    N, X, Y = Scanner.map_int()
    ans = [0 for _ in range(1, N + 1)]
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            d = dist(i, j, X, Y)
            ans[d] += 1

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


def main():
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

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

print(*ans[1:])

Solution (Python):


from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
from collections import Counter

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

start = list(range(0, N-1)) + list(range(1, N)) + [X-1, Y-1] 
end = list(range(1, N)) + list(range(0, N-1)) + [Y-1, X-1]
cost = [1] * len(start)

graph = csr_matrix((cost, (start, end)))
lengths = dijkstra(graph, directed = False)

c = Counter(lengths.astype(np.int64).reshape(-1))
for k in range(1, N):
    print(c[k]//2)

Solution (Python):



N, X, Y = map(int, input().split(' '))
edges = [(i, i+1) for i in range(N-1)]
graph = [{} for _ in range(N)]
for src, dst in edges:
    graph[src][dst] = 1
    graph[dst][src] = 1
graph[X-1][Y-1] = 1
graph[Y-1][X-1] = 1

import collections
d_frq_dict = collections.Counter()
for start in range(N):
    dist = [float('inf') for _ in range(N)]
    dist[start] = 0
    buf = [start]
    while buf:
        src = buf.pop(0)
        for dst in graph[src]:
            if dist[dst] == float('inf'):
                dist[dst] = dist[src] + 1
                buf.append(dst)

    d_frq_dict.update(dist)
    

for d in range(1, N):
    print(d_frq_dict[d]//2)

Solution (Python):
n, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0]*(n-1)
for start in range(n):
    for end in range(start+1, n):
        dst = min(end-start, abs(x-start) + abs(end-y) + 1)
        dist[dst-1] += 1

for d in dist:
    print(d)

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

def main():
    ans = {}
    for i in range(1, n):
        ans[i] = 0

    for i in range(0, n - 1):
        for j in range(i + 1, n):
            ans[solve(i, j)] += 1

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

def solve(i, j):
    """
    最短距離を計算する
    O(1)
    """

    dist = min(abs(i - j), abs(x - i) + abs(y - j) + 1, abs(y  -i) + abs(x - j) + 1)

    return dist

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque, defaultdict
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)
X -= 1
Y -= 1
graph[X].append(Y)
graph[Y].append(X)



ans = defaultdict(int)
for i in range(N):
    q = deque()
    
    q.append(i)
    visited = [False]*N
    visited[i] = True
    distant = [100000] * N
    distant[i] = 0
    while len(q):
        v = q.popleft()
        for e in graph[v]:
            if visited[e]:
                continue
            distant[e] = distant[v] + 1
            ans[distant[e]] += 1
            visited[e] = True
            q.append(e)
    

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

Solution (Python):
import collections
n,x,y=map(int,input().split())
lst=[]
num=[0]*(n+1)
for i in range(1,n):
  for j in range(i+1,n+1):
    k=min(abs(i-j),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))
    if num[k]==0:
      num[k]+=1
    lst.append(k)
    
Lst=list(collections.Counter(lst).items())
key=0
for i in range(1,n):
  if num[i]==0:
    print(0)
  else:
    print(Lst[key][1])
    key+=1

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

if __name__ == '__main__':
    main()