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):
val = input().split(' ')
n = int(val[0])
x = int(val[1])
y = int(val[2])

dists = {}
for i in range(1, n):
    dists[i] = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        len1 = j - i
        len2 = abs(j - y) + abs(x - i) + 1
        len3 = abs(y - i) + abs(j - x) + 1
        dist = len1 if len1 < len2 else len2
        dist = dist if dist < len3 else len3
        dists[dist] += 1

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

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


def bfs(start):
    queue = deque([start])
    dist = [-1] * n
    dist[start] = 0
    while queue:
        v = queue.popleft()
        for nv in graph[v]:
            if dist[nv] != -1:
                continue
            queue.append(nv)
            dist[nv] = dist[v] + 1
    return dist


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

x -= 1
y -= 1

graph = defaultdict(set)
for i in range(n - 1):
    graph[i].add(i + 1)
    graph[i + 1].add(i)
graph[x].add(y)
graph[y].add(x)

dic = defaultdict(int)
for i in range(n):
    for k, v in Counter(bfs(i)).items():
        dic[k] += v

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

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

Solution (Python):
n,x,y = (int(x) for x in input().split())
x-=1
y-=1
middle=(y+x)/2
list=[[0 for i in range(n)]for j in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        if i<=x and j<=x:
            list[i][j] = j-i
        elif j==middle:
            list[i][j] = j-i
        elif i==middle:
            list[i][j] = j-i
        elif i<=x and j>=x and j<=middle:
            list[i][j] = j-i
        elif i<=x and j>=middle and j<=y:
            list[i][j] = (x-i) + 1 + (y-j)
        elif i<=x and j>=middle and j>=y:
            list[i][j] = (x-i) + 1 + (j-y)
        elif i>=x and i<=middle and j<=middle:
            list[i][j] = j-i
        elif i>=x and i<=middle and j>=middle and j<=y:
            list[i][j] = min(j-i, i-x+y-j+1)
        elif i>=x and i<=middle and j>=y:
            list[i][j] = i-x + j-y + 1
        elif i>=middle and j<=y:
            list[i][j] = j-i
        elif i>=middle and j>=y:
            list[i][j] = j-i
        elif i>=y and j>=y:
            list[i][j] = j-i
dic={}
for i in range(n-1):
    for j in range(i+1,n):
        if list[i][j] not in dic:
            dic[list[i][j]]=1
        else:
            dic[list[i][j]]+=1
for i in range(1,n):
    if i not in dic:
        print(0)
    else:
        print(dic[i])

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


if __name__ == '__main__':
    main()

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

Solution (Python):
N, R1, R2 = map(int, input().split())
n = R2 - R1 - 1
count={}
for m in range(N-1):
    count[m+1] = 0 
for i in range(N):
    for j in range(i+1, N):
        k = min(j-i, abs((R1-1)-i) + 1 +abs((R2-1)-j))
        count[k]+=1
for k in count.values():
    print(k)

Solution (Python):
x = input().split()
N = int(x[0])
X = int(x[1])
Y = int(x[2])

L = [0 for _ in range(N+1)]

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

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

Solution (Python):
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    ans = {i: 0 for i in range(1, N)}
    for i in range(1, N + 1):
        cost = [-1]*(N+1)
        cost[i] = 0
        d = deque([i])
        while len(d) != 0:
            v = d.popleft()
            c = cost[v]
            for j in [-1, 1]:
                vj = v + j
                if vj > 0 and vj <= N and cost[vj] == -1:
                    cost[vj] = c + 1
                    d.append(vj)
                    ans[c + 1] += 1
            if v in [X, Y]:
                vxy = X + Y - v
                if cost[vxy] == -1:
                    cost[vxy] = c + 1
                    d.append(vxy)
                    ans[c + 1] += 1
    for a in ans:
        print(ans[a]//2)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import combinations

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

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

    for a in A:
        print(a)

if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '
        
        
    return ret


MOD = 10**9 + 7

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  

N, X, Y = read_ints()
X -= 1
Y -= 1






from scipy.sparse import csr_matrix  


from scipy.sparse.csgraph import dijkstra
graph = [[0] * N for _ in range(N)]
for i in range(N - 1):
    graph[i][i + 1] = 1
    graph[i + 1][i] = 1
graph[X][Y] = 1
graph[Y][X] = 1
adj_mat = csr_matrix(graph)
D = dijkstra(adj_mat, directed=False)
cnt = Counter(D.reshape(-1))
ans=[]
for i in range(1, N):
    ans.append(int(cnt[i]) // 2)
print(*ans, sep='\n')

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

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

for i in A:
    print(i)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '
        
        
    return ret


MOD = 10**9 + 7

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  

N, X, Y = read_ints()
X -= 1
Y -= 1






from scipy.sparse import csr_matrix, lil_matrix  


from scipy.sparse.csgraph import dijkstra
graph = lil_matrix((N,N))
for i in range(N - 1):
    graph[i,i + 1] = 1
    graph[i + 1,i] = 1
graph[X,Y] = 1
graph[Y,X] = 1
adj_mat = csr_matrix(graph)
D = dijkstra(adj_mat, directed=False)
cnt = Counter(D.reshape(-1))
for i in range(1, N):
    print(int(cnt[i]) // 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):
        ans[min(j-i,abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1)]+=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):
        min_distance = min(abs(i-j), abs(i-X)+abs(j-Y)+1, abs(j-X)+abs(i-Y)+1)
        ans[min_distance-1] += 1
for i in range(N-1):
    print(ans[i])

Solution (Python):
x = input().split()
N = int(x[0])
X = int(x[1])
Y = int(x[2])

L = [0 for _ in range(N+1)]

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

Solution (Python):
n,x,y = [int(x) for x in input().split()]
count = [0]*(n+1)
for i in range(1,n):
    for j in range(i+1,n+1):
        if i < x and j <= x:
            nagasa = j - i
        elif i < x and x < j and j < y:
            nagasa = x-i + min(j-x,y-j+1)
        elif i < x and y <= j:
            nagasa = x-i + j - y + 1
        elif x <= i and i < y and j <= y:
            nagasa = min(j-i,i-x+y-j+1)
        elif x <= i and i < y and y < j:
            nagasa = j - y + min(y-i,i-x+1)
        elif y <= i:
            nagasa = j -i
        count[nagasa] += 1
for i in range(1,n):
    print(count[i])

Solution (Python):
import collections

def main():
    N, X, Y = [int(x) for x in input().split()]
    dist = collections.defaultdict(int)

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


if __name__ == '__main__':
    main()

Solution (Python):
sel='D'

if sel=='A':
    S=input()
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

if sel=='D':
    N,X,Y=map(int,input().split())
    cnt={}
    for k in range(1,N):
        cnt[k]=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            k=j-i 
            k=min(k,abs(i-X)+1+abs(j-Y)) 
            k=min(k,abs(i-Y)+1+abs(X-j)) 
            cnt[k]+=1

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n,x,y = MI()
	x-=1;y-=1
	dist = [0]*(n-1)
	for i in range(n-1):
		for j in range(i+1,n):
			dist[min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))-1]+=1
	printV(dist)


if __name__ == '__main__':
	main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

from collections import deque
INF = 1001001001
N, X, Y = map(int, input().split())
X -= 1; Y -= 1

ans = [0] * N
for sv in range(N):
    dist = [INF] * N
    q = deque()
    def push(v, d):
        if dist[v] != INF: return
        dist[v] = d
        q.append(v)
    push(sv, 0)
    while q:
        v = q.popleft()
        d = dist[v]
        if v-1 >= 0: push(v-1, d+1)
        if v+1 < N:  push(v+1, d+1)
        if v==X:     push(Y,   d+1)
        if v==Y:     push(X,   d+1)
    for i in range(N):
        ans[dist[i]] += 1

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

Solution (Python):
def main():
    n,x,y=map(int,input().split())
    Ans=[0]*n
    for i in range(1,n):
        for j in range(i+1,n+1):
            Ans[min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))]+=1
    for ans in Ans[1:]:
        print(ans)
    
if __name__=='__main__':
    main()

Solution (Python):
import collections

n, x, y = list(map(int, input().split()))
lst = [
    min(abs(i - j), (abs(i - x) + abs(j - y) + 1))
    for j in range(2, n + 1)
    for i in range(1, j)
]
dic = collections.Counter(lst)
for k in range(1, n):
    print(dic[k])

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

lis = range(N)
ans = [0] * (N-1)
for a, b in itertools.permutations(lis, 2):
  if a >= b:
    continue
  tmp = min(b-a, abs(X-a-1) + abs(Y-b-1) + 1)
  ans[tmp-1] += 1

for x in ans:
  print(x)

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

Solution (Python):
from collections import defaultdict
from heapq import heappop, heappush
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class Graph:
    """
    隣接リストによる無向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))
        self.graph[dst].append((src, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra:
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        
        
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    heappush(self.Q, (alt, v))

    def shortest_distance(self):
        """
        startノードから各ノードまでの最短距離
        """
        return self.dist


def main():
    N,x,y = map(int, readline().split())

    
    E = Graph()
    for i in range(1,N):
        if i == x:
            E.add_edge(x, y)
        E.add_edge(i, i+1)
    
    
    count = [0]*N
    for i in range(1,N):
        D = Dijkstra(E, i)
        dist = D.shortest_distance()
        for j in range(i+1,N+1):
            k = dist[j]
            count[k] += 1

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


if __name__ == "__main__":
    main()

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, X, Y = iim()
    ans = [N-i-1 for i in range(N-1)]
    X1, Y1 = X-1, Y -1

    xy2 = (X+Y)  // 2
    for i in range(0, xy2):
        x1 = X1 - i
        if x1 < 0: x1 = -x1
        for j in range(xy2, N):
            d1 = j - i - 1
            y1 = Y1-j
            if y1 < 0: y1 = -y1
            d2 = x1 + y1
            if d1 > d2:
                
                ans[d1] -= 1
                ans[d2] += 1

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

if __name__ == "__main__":
    resolve()

Solution (Python):
N,X,Y=map(int,input().split())
ans=0
right=X-1
cycle=Y-X+1
left=N-Y
import copy
ring=copy.copy(cycle)
branchr=copy.copy(right)
if right>0:
    branchr+=1
branchl=copy.copy(left)
if left>0:
    branchl+=1
ring_branchr=0
ring_branchl=0
branchrl=0
count=0
if cycle%2==0:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k==cycle//2:
            ring = cycle//2
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2:
                ring_branchr-=2*(k-cycle//2)-1
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2:
                ring_branchl-=2*(k-cycle//2)-1
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
if cycle%2==1:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2+1:
                ring_branchr-=2*(k-cycle//2-1)
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2+1:
                ring_branchl-=2*(k-cycle//2-1)
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

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


def resolve():
    N, X, Y = map(int, input().split())
    graph = np.zeros((N + 1, N + 1), dtype=np.int64)

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

    dist = dijkstra(csgraph=csr_matrix(graph)).astype(np.int64)
    ans = np.bincount(dist[1:, 1:].ravel(), minlength=N) // 2
    return print(*ans[1:], sep='\n')


if __name__ == "__main__":
    resolve()

Solution (Python):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
N, X, Y = map(int, input().split())

dist_matrix = [[0] * (N) for _ in range(N)] 
for i in range(1, N):
    dist_matrix[i][i-1] = 1
dist_matrix[X-1][Y-1] = 1

graph = csr_matrix(dist_matrix)

dist_matrix = dijkstra(csgraph=graph, directed=False)
ans = [0] * N

for idx, row in enumerate(dist_matrix):
    for item in row[idx + 1:]:
        ans[int(item)] += 1

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

Solution (Python):
n_x_y = list(map(int, input().split()))

n = n_x_y[0]
x = n_x_y[1]
y = n_x_y[2]

def search_min(i, j):
  
  opt_1 = abs(i-j)
  
  opt_2 = abs(x-i) + 1 + abs(y-j)
  
  opt_3 = abs(y-i) + 1 + abs(x-j)
  
  return min(opt_1, opt_2, opt_3)


answer = [0]*(n-1)
for i in range(1, n):
  for j in range(i + 1, n+1):
    answer[search_min(i, j)-1] += 1
    
for i in range(len(answer)):
  print(answer[i])

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict
from heapq import *

n, x, y = na()
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)

def dijkstra(g, x):
    dist = [inf] * len(g)
    dist[x] = 0
    q = []
    proc = [False for _ in range(len(g))]
    heappush(q, (0, x))
    while len(q):
        p = heappop(q)
        a = p[1]
        if proc[a]:
            continue
        for b in g[a]:
            if dist[a] + 1 < dist[b]:
                dist[b] = dist[a] + 1
                heappush(q, (-dist[b], b))
    
    return dist

dic = defaultdict(int)
for i in range(n):
    dist = dijkstra(g, i)
    for i in range(n):
        dic[dist[i]] += 1

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

Solution (Python):
n, x, y = map(int,input().split())
ls = [0] * n
for u in range(1, n):
    for v in range(u, n+1):
        u2x = abs(u-x)
        v2y = abs(v-y)

        d = min(v-u, u2x + 1 + v2y)
        ls[d] += 1

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

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, X, Y = iim()
    ans = [N-i-1 for i in range(N-1)]
    X1, Y1 = X-1, Y -1

    xy2 = (X+Y)  // 2
    for i in range(0, xy2+1):
        x1 = X1 - i
        if x1 < 0: x1 = -x1
        for j in range(xy2, N):
            d1 = j - i - 1
            y1 = Y1-j
            if y1 < 0: y1 = -y1
            d2 = x1 + y1
            if d1 > d2:
                
                ans[d1] -= 1
                ans[d2] += 1

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

if __name__ == "__main__":
    resolve()

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, x, y = MAP()
x -= 1; y -= 1

G = list2d(N, N, 0)
for i in range(N):
    for j in range(i+1, N):
        G[i][j] = min(j - i, abs(i - x) + abs(j - y) + 1, abs(j - x) + abs(i - y) + 1)
ans = [0] * N
for i in range(N):
    for j in range(i+1, N):
        ans[G[i][j]] += 1
[print(a) for a in ans[1:]]

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

ans = [0] * (N - 1)

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

for a in ans:
    print(a)

Solution (Python):
n,x,y = [int(i) for i in input().split()]
ans = []
for i in range(1,n):
  for j in range(i+1,n+1):
    chk = min(j-i,1+abs(x-i)+abs(j-y))
    ans.append(chk)   
import collections
c = collections.Counter(ans)
for i in range(1,n):
  print(c[i])

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

ans = [0] * (N - 1)

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

for a in ans:
    print(a)

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

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

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

Solution (Python):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    n,x,y = map(int, input().split())
    costList = [0]*n

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


    for i in range(n):
        if i >0:
            print(costList[i])

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

Solution (Python):
from collections import deque
import sys
input=sys.stdin.readline
n,x,y=map(int,input().split())
x-=1
y-=1
g=[[] for i in range(n)]
g[x].append(y)
g[y].append(x)
for i in range(n-1):
    g[i].append(i+1)
    g[i+1].append(i)
ans=[0]*n
for i in range(n):
    s=i
    q=deque([s])
    v=[-1]*n
    v[s]=0
    while q:
        p=q.popleft()
        for j in g[p]:
            if v[j]==-1:
                ans[v[p]]+=1
                v[j]=v[p]+1
                q.append(j)
for i in range(n-1):
    print(ans[i]//2)

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

for p in range(1, N):
    for q in range(p, N+1):
        p2X = abs(p - X)
        q2Y = abs(q - Y)

        distance = min(q-p, p2X+1+q2Y)
        k_list[distance] += 1

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

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

for p in range(1, N):
    for q in range(p, N+1):
        p2X = abs(p - X)
        p2Y = abs(p - Y)
        q2X = abs(q - X)
        q2Y = abs(q - Y)

        distance = min(q-p, p2X+1+q2Y)
        k_list[distance] += 1

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

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

for k in range(0,n-1):
  print(int(t[k]))

Solution (Python):
n,x,y=map(int,input().split())
def dist(i,j):
  if i>=j:
    d=0
  else:
    d=min(abs(j-i),abs(y-j)+1+abs(x-i),abs(y-i)+1+abs(x-j))
  return d
distmap=[0]*n
for l in range(2,n+1):
  for k in range(1,l):
    distmap[dist(k,l)]+=1
print('\n'.join(map(str,distmap[1:])))

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

for p in range(1, N):
    for q in range(p, N+1):
        p2X = abs(p - X)
        p2Y = abs(p - Y)
        q2X = abs(q - X)
        q2Y = abs(q - Y)

        distance = min(q-p, p2X+1+q2Y, p2Y+1+q2X)
        k_list[distance] += 1
        
for k in range(1, N):
    print(k_list[k])

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n,x,y=mii()
x-=1
y-=1
ans=[0]*n

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