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 itertools import combinations

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

cnt = [0] * n
for i, j in combinations(range(n), 2):
    i, j = i + 1, j + 1
    dist = min(abs(j - i), abs(i - x) + abs(j - y) + 1,
               abs(i - y) + abs(j - x) + 1)
    cnt[dist] += 1

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

Solution (Python):

"""
ある２点xとyがつながっているので、
二重ループを回して、
・単純にiとjの距離
・i-x,j-yをつなげた時の距離
・i-y,j-xをつなげた時の距離
の最小値がi-jの距離になる。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,x,y = map(int,readline().split())
ans = [0]*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,
                abs(i-y)+abs(j-x)+1
            )
            ] += 1
for i in ans[1:]:
    print(i)

Solution (Python):
from heapq import heapify, heappush, heappop
def dijkstra(S, N, Edge):
    
    
    
    
    INF = 10**20
    dist = [INF]*N
    dist[S] = 0
    que = [(0, S)]
    heapify(que)
    
    while que:
        c, v = heappop(que)
        if dist[v] < c: continue

        for nv, nc in Edge[v]:
            if c+nc < dist[nv]:
                dist[nv] = c+nc
                heappush(que, (c+nc, nv))
    
    return dist


import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

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

Solution (Python):
import heapq
def dijkstra(S, N, Edge):
    
    
    
    
    INF = 10**20
    dist = [INF]*N
    dist[S] = 0
    que = [(0, S)]
    heapq.heapify(que)
    
    while que:
        c, v = heapq.heappop(que)
        if dist[v] < c: continue

        for nv, nc in Edge[v]:
            if c+nc < dist[nv]:
                dist[nv] = c+nc
                heapq.heappush(que, (c+nc, nv))
    
    return dist


import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

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

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

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

from collections import deque
def bfs(u):
    queue = deque([u])
    d = [None]*(N+1)
    d[u]=0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i]=d[v]+1
                queue.append(i)
    return d

ans = [0]*(N-1)
for i in range(1,N+1):
    d = bfs(i)
    for j in range(1,N+1):
        if d[j]>0:
            ans[d[j]-1] += 1
for a in ans:
    print(a//2)

Solution (Python):
from collections import deque 
def main():
    n,x,y=map(int,input().split())
    root=[[]for i in range(n)]
    for i in range(1,n):
        root[i-1].append(i)
        root[i].append(i-1)
    root[x-1].append(y-1)
    root[y-1].append(x-1)
    short=[0 for i in range(n)]
    dictlen={}
    for i in range(1,n):
        dictlen[i]=0
    for start in range(n):
        distance=[0]*n
        toVis=deque()
        checkVis=[-1 for i in range(n)]
        toVis.append(start)
        while len(toVis)>0:
            now=toVis.popleft()
            checkVis[now]=1
            for nex in root[now]:
                if checkVis[nex]==1:
                    continue
                toVis.append(nex)
                checkVis[nex]=1
                tonex=distance[now]+1
                distance[nex]=tonex
                dictlen[tonex]+=1
    
    for key in dictlen.keys():
        print(dictlen[key]//2)
if __name__=="__main__":
    main()

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

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

x,y = x-1,y-1

d={}
for k in range(1,n):
    d[k]=0


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

        d[dist]+=1

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

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

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

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

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))


N,X,Y=inputintlist()
X-=1
Y-=1
G=[[] for a in range(N)]
for a in range(N-1):
    G[a].append(a+1)
    G[a+1].append(a)
G[X].append(Y)
G[Y].append(X)
D=defaultdict(int)
for a in range(N):
    for b in range(a,N):
        d=b-a
        d=min(d,abs(a-X)+1+abs(b-Y))
        d=min(d,abs(a-Y)+1+abs(b-X))
        D[d]+=1
for k in range(1,N):
    print(D[k])

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

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

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

ans = [0]*(N-1)

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

for v in ans:
    print(v)

Solution (Python):
from collections import deque, Counter
n, x, y = map(int, input().split())
edge = [[] for i in range(n)]

for i in range(n-1):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x-1].append(y-1)
edge[y-1].append(x-1)

def bfs(i):
    dq = deque([i])
    dist = [-1]*n
    dist[i] = 0
    while dq:
        now = dq.popleft()
        d = dist[now]
        for e in edge[now]:
            if dist[e]==-1:
                dist[e] = d + 1
                dq.append(e)
    return dist

c = Counter()
for i in range(n):
    c = c + Counter(bfs(i))

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

Solution (Python):
N, X, Y = map(int, input().split())
cnt = [0 for _ in range(N)]

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

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

Solution (Python):
from collections import deque
def bfs(v):
    todo = deque()
    todo.append(v)
    seen[v] = 0
    while len(todo) > 0:
        v = todo.popleft()
        d = seen[v]
        for w in graph[v]:
            if seen[w] != -1:
                continue
            seen[w] = d + 1
            todo.append(w)


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)

cnt = [0 for _ in range(N)]
for i in range(N-1):
    seen = [-1 for _ in range(N)]
    bfs(i)
    for j in range(i+1, N):
        cnt[seen[j]] += 1

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

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

Solution (Python):
from collections import deque

n, x, y = map(int, input().split())
eage = [[] for _ in range(n)]

for i in range(n-1):
  eage[i].append( i+1 )
  eage[i+1].append( i )

x -= 1
y -= 1

eage[x].append( y )
eage[y].append( x )

visited = [[-1] * n for _ in range(n)]

counter = [0] * n
for start_point in range(n):
  visited[start_point][start_point] = 0
  
  q = deque([start_point])
  while q:
    v = q.popleft()
    for j in eage[v]:
      
      if visited[start_point][j] == -1:
        
        visited[start_point][j] = visited[start_point][v] + 1
        q.append( j )
  for c in visited[start_point]:
    counter[c] += 1

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

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):
        dict1=j-i
        dict2=abs(x-i)+abs(y-j)+1
        d=min(dict1,dict2)
        ans[d]+=1
for i in range(1,n):
    print(ans[i])

Solution (Python):
import collections
def main():
    N,X,Y = map(int, input().split())
    
    X -= 1
    Y -= 1
    
    shortest = [[-1]*N for _ in range(N)]
    coll = collections.Counter()
    for i in range(N):
        k1 = abs(X-i)
        for j in range(i+1,N):
            k2 = abs(j-Y)
            shortest[i][j] = min(j-i, k1+1+k2)
        coll += collections.Counter(shortest[i])

    for i in range(1,N):
        print(coll.get(i,0))
        
main()

Solution (Python):
from collections import Counter
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
dis = []
for i in range(N-1):
    for j in range(i, N):
        dis.append(min(abs(i-j), abs(i-X)+abs(j-Y)+1,  abs(i-Y)+abs(j-X)+1))
cnt = Counter(dis)
for k in range(1, N):
    print(cnt[k])

Solution (Python):
from heapq import heappop, heappush

def dijkstra(s):
    used = [1] * n
    dp = [INF] * n
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

INF = 10 ** 18
n, x, y = map(int, input().split())
cost = [[] for _ in range(n)]

for i in range(n - 1):
    a = i
    b = i + 1
    cost[a].append([1, b])
    cost[b].append([1, a])
cost[x - 1].append([1, y - 1])
cost[y - 1].append([1, x - 1])
ans = [0] * n
for i in range(n - 1):
    dp1 = dijkstra(i)
    for j in dp1[i:]:
        ans[j] += 1

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

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


dic = {}
x = x-1
y = y-1
for i in range(n):
    for j in range(n):
        if(i == j):
            break

        nm = abs(j - i)
        if(abs(x-i) > abs(y-i)):
            lp = abs(y-i) + abs(x-j) + 1
        else:
            lp = abs(x-i) + abs(y-j) + 1
        
        k = min(nm,lp)
        if(k in dic):
            dic[k] += 1
        else:
            dic[k] = 1



for i in range(1,n):
    if not (i in dic):
        print(0)
    else:
        print(dic[i])

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, x, y = map(int, input().split())
    ans = [0] * (n - 1)
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            d = min(j - i, abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1)
            ans[d - 1] += 1
    print(*ans, sep='\n')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

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

from collections import Counter
c=Counter(ans)

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X, Y = lr()
dis = [[0] * (N+1) for _ in range(N+1)]
for i in range(1, N):
    for j in range(i+1, N+1):
        dis[i][j] = dis[j][i] = j - i

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

print('\n'.join(map(str, answer[1:])))

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.buffer.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X, Y = lr()
dist = []
for i in range(1, N+1):
    z = np.arange(i+1, N+1)
    d1 = z - i
    d2 = np.abs(i - X) + np.abs(z - Y) + 1
    d = np.minimum(d1, d2)
    dist.append(d)

dist = np.concatenate(dist)
cnt = np.bincount(dist, minlength=N)
print('\n'.join(cnt[1:].astype(str)))

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

dis=[]

for i in range(n-1):
    for j in range(i,n):
        dis.append(min(abs(i-j),abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1))
c=Counter(dis)
for i in range(1,n):
    print(c[i])

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

    ans = "\n".join(map(str, m))
    print(ans)


if __name__ == '__main__':
    main()

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

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

count_dict = {key:0 for key in range(1,n)}

for s in range(1,n):
    for e in range(s+1,n+1):
        count_dict[min(e-s, abs(x-s)+1+abs(y-e),abs(y-s)+1+abs(x-e))] += 1


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

Solution (Python):
import sys
from collections import deque

input = sys.stdin.readline


def bfs(G, v, dist):
    queue = deque([v])
    while queue:
        v = queue.popleft()
        for u in G[v]:
            if dist[u] == -1:
                dist[u] = dist[v] + 1
                queue.append(u)


def main():
    N, X, Y = map(int, 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
    for i in range(N):
        dist = [-1] * N
        dist[i] = 0
        bfs(G, i, dist)
        for j in range(i + 1, N):
            ans[dist[j]] += 1

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


if __name__ == "__main__":
    main()

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

def dist(i, j):
  d1 = abs(i - j)
  d2 = abs(x - i) + 1 + abs(y - j)
  return min(d1, d2)

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

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

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,x,y = nm()

dist = [0]*n

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

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

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))



def main():
    n, x, y = ns()

    ans = [0 for _ in range(n-1)]

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

    for ai in ans:
        print(ai)


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
import itertools
from collections import defaultdict

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

def dis(x, y):
  d1 = abs(x - y)
  d2 = abs(X - x) + 1 + abs(Y - y)
  return min(d1, d2)

for p in itertools.combinations(range(1, N+1), 2):
  d = dis(p[0], p[1])
  ans[d] += 1

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

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):
        dist1 = j-i
        dist2 = abs(x-i)+abs(y-j)+1
        d = min(dist1,dist2)
        ans[d] += 1
for i in range(1, n):
    print(ans[i])

Solution (Python):
n,x,y=map(int,input().split())
le=x-1
ri=n-y
rnd=y-x+1
L=[0]*(n-1)
lim=rnd//2
for i in range(1,n):
    if i <= lim:
        if rnd%2==0 and i==lim:
            L[i-1] += lim
        else:
            L[i-1] += rnd

for i in range(1,le+1):
    for j in range(1,lim+1):
        if rnd%2==0 and j==lim:
            L[i-1+j] += 1
        else:
            L[i-1+j] += 2

for i in range(1,ri+1):
    for j in range(1,lim+1):
        if rnd%2==0 and j==lim:
            L[i-1+j] += 1
        else:
            L[i-1+j] += 2

for i in range(le):
    for j in range(ri):
        L[i+j+2] += 1

for i in range(le):
    L[i] += le-i
for j in range(ri):
    L[j] += ri-j

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X, Y = lr()
dis = [[0] * (N+1) for _ in range(N+1)]
for i in range(1, N):
    for j in range(i+1, N+1):
        dis[i][j] = j - i
        dis[j][i] = j - i

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

answer = [0] * (N)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = dis[i][j]
        answer[d] += 1

print('\n'.join(map(str, answer[1:])))

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X, Y = lr()
dis = [[0] * (N+1) for _ in range(N+1)]
for i in range(1, N):
    for j in range(i+1, N+1):
        dis[i][j] = j - i
        dis[j][i] = j - i

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

answer = [0] * (N)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = dis[i][j]
        answer[d] += 1

print('\n'.join(map(str, answer[1:])))

Solution (Python):

import sys
import time
import unittest
from io import StringIO
from collections import defaultdict


def resolve():
    N, X, Y = [int(i) for i in input().split()]
    dd = defaultdict(int)
    X -= 1
    Y -= 1
    for i in range(N):
        for j in range(i + 1, N):
            dd[min(j - i, abs(X - i) + 1 + abs(Y - j),
                   abs(Y - i) + 1 + abs(X - j))] += 1
    for i in range(1, N):
        print(dd[i])


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

    def checkTLE(self, input):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin

    def debugIO(self, input):
        stdin = sys.stdin
        sys.stdin = StringIO(input)
        resolve()
        sys.stdin = stdin

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """5 2 4"""
        output = """5
4
1
0"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 1 3"""
        output = """3
0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """7 3 7"""
        output = """7
8
4
2
0
0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """10 4 8"""
        output = """10
12
10
8
4
1
0
0
0"""
        self.assertIO(input, output)

    def test_入力例_TLE(self):  
        input = """2000 2 4"""
        self.checkTLE(input)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()

Solution (Python):
n,x,y = [int(n) for n in input().split()]


ans = [0] * (n-1)

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

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

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

for v in val:
    print(v)

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

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

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):
        r1 = j-i
        r2 = abs(x-i) + 1 + abs(j-y)
        r3 = abs(y-i) + 1 + abs(j-x)
        ans[min(r1,r2,r3)] += 1

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

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):
import sys
import os

def file_input():
    f = open('ABC160/input.txt', 'r')
    sys.stdin = f

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

    out=[0]*(N-1)

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

    [print(x) for x in out]

if __name__ == '__main__':
    main()

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

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 -= 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())

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

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

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


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



d = [0] * N

for i in range(1, N+1):
    q = deque()
    q.append(i)
    visit = [-1]*N
    visit[i-1] = 0
    while q:
        p = q.popleft()
        for next_p in G[p]:
            if visit[next_p-1] == -1:
                visit[next_p-1] = visit[p-1] + 1
                q.append(next_p)

    for l in range(N):
        d[visit[l]] += 1

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

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
for i in range(1, N):
    print(ans[i])

Solution (Python):
import itertools

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

ans = [0] * N
comb = list(itertools.combinations(range(1,N+1),2))


for i in range(len(comb)):
    if comb[i][0] <= X and comb[i][1] >= Y:
        k = comb[i][1] - Y + X - comb[i][0]  + 1
        ans[k] += 1
    elif comb[i][0] <= X:
        k = X - comb[i][0] + min(comb[i][1] - X, Y - comb[i][1]+1)
        ans[k] += 1
    elif comb[i][1] >= Y:
        k = comb[i][1] - Y + min(Y - comb[i][0], comb[i][0] - X + 1)
        ans[k] += 1
    else:
        k = min(comb[i][1] - comb[i][0], comb[i][0] - X + Y - comb[i][1] + 1)
        ans[k] += 1
for i in range(1,N):
    print(ans[i])

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

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

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

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

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

Solution (Python):
from collections import Counter

n, x, y = map(int, input().split())
ans = []
for i in range(1, n+1):
    for j in range(1, n+1):
        ans.append(min(abs(j - i),
                       abs(x - i)+1+abs(j - y),
                       abs(y - i)+1+abs(j - x)))
ans_cnt = Counter(ans)
for i in range(1, n):
    print(ans_cnt[i] // 2)

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

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

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

n,x,y = list(map(int,sys.stdin.readline().split()))
x -= 1
y -= 1
table=[0]*(n-1)



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

for ans in table:
    print(ans)