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):

"""
Created on Sat Mar 28 20:51:45 2020

@author: naoki
"""
from collections import deque
N, X, Y = map(int,input().split())

distance_count = [0] * (N + 1)
route = [[i-1, i+1] for i in range(N+1)]

del route[-1][-1]

All_distances = [0]*N
route[X].append(Y)
route[Y].append(X)

for j in range(1,N):
    todo = deque([j])
    seen = [0 for i in range(N+1)]
    distance = [N+1] * (N+1)
    distance[j] = 0
    while len(todo) > 0:
        now = todo.pop()
        if now == N+1 or now == 0:
            continue
        for checking in route[now]:
            kari1 = distance[checking]
            kari2 = distance[now] + 1
            if seen[checking] < 2 and kari1 > kari2:
                distance[checking] = kari2
                todo.append(checking)
                seen[checking] += 1
            elif kari1 > kari2:
                distance[checking] = kari2
    for i in range(j,len(distance)):
        if distance[i] != N+1:
            All_distances[distance[i]] += 1
for i in range(1,N):
    print(All_distances[i])

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

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


if __name__ == '__main__':
    main()

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

l_count = [0]*n

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

Solution (Python):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

count = [0] * (N-1)
for i in range(N):
    for j in range(i + 1, N):
        if i <= X and X <= j <= Y:
            min_d = min(j - i, X - i + (Y - j) + 1)
        elif i <= X and Y <= j:
            min_d = X - i + (j - Y) + 1
        elif X <= i <= Y and Y <= j:
            min_d = min(j - i, (i - X) + 1 + (j - Y))
        elif X <= i <= j <= Y:
            min_d = min(j - i, i - X + 1 + (Y - j))
        else:
            min_d = j - i
        
        
        count[min_d-1] += 1

for x in count:
    print(x)

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

cost = [[0 for _ in range(N)] for _ in range(N)]
output = [0 for i in range(N-1)]


X -= 1
Y -= 1
for i in range(N-1):
    for j in range(i+1, N):
        if i <= X:
            if j <= X:
                c = j-i
            elif X < j <= Y:
                c = X - i + min(j-X, Y-j+1)
            elif Y < j:
                c = X - i + j - Y + 1
        elif i < Y:
            if j <= Y:
                c = min(j-i, Y-j+i-X+1)
            else:
                c = j - Y + min(Y - i, i - X + 1)
        else:
            c = j-i
        output[c-1] += 1

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

Solution (Python):
N,X,Y=map(int,input().split())
klist=[0 for i in range(N-1)]
def returndis(x,y):
  d=min(y-x,1+abs(Y-y)+abs(X-x))
  return d
for i in range(N-1):
  for j in range(N-1-i):
    p=returndis(i+1,j+i+2)
    klist[p-1]+=1

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

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


main()

Solution (Python):

from itertools import permutations, combinations,combinations_with_replacement,product
s = input().split()
q = [int(p) for p in s]

N = q[0]
X = q[1]
Y = q[2]

num = [i+1 for i in range(N)] 
answer = [0 for i in range(N-1)] 


pairs = list(combinations(num,2)) 


def calc_dist(i, j):
    
    
    warp = abs(i-X) + 1 + abs(j-Y)
    return min(j-i, warp)
    




for i in range(len(pairs)):
    
    
    answer[calc_dist(pairs[i][0], pairs[i][1])-1] += 1

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

Solution (Python):
def main():
    n, x, y = [int(i) for i in input().split()]
    adj = {i: [i+1, i-1] for i in range(1, n-1)}
    adj[0] = [1]
    adj[n-1] = [n-2]
    adj[x-1].append(y-1)
    adj[y-1].append(x-1)
    res = [0] * n
    for i in range(n):
        memo = [-1] * n
        pos = i
        cand = [pos]
        memo[pos] = 0
        while len(cand) > 0:
            pos = cand.pop(0)
            for nx in adj[pos]:
                if memo[nx] != -1:
                    continue
                memo[nx] = memo[pos] + 1
                res[memo[nx]] += 1
                cand.append(nx)
    for r in res[1:]:
        print(int(r/2))

if __name__ == '__main__':
    main()

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

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

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

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

ret = [0 for i in range(N)]
for i in range(1, N):
    for j in range(i+1, N+1):
        if j <= X:
            idx = j-i
            ret[idx] += 1
        elif j <= Y:
            if i <= X:
                idx = X-i + min(j-X, Y-j+1)
                ret[idx] += 1
            else:
                idx = min(j-i, Y-j+1+i-X)
                ret[idx] += 1
        else:
            if i <= X:
                idx = X -i + 1 + j-Y
                ret[idx] += 1
            elif i<=Y:
                idx = j-Y + min(Y-i,i-X+1)
                ret[idx] += 1
            else:
                idx = j-i
                ret[idx] += 1

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

Solution (Python):
from collections import deque

class Node:
    def __init__(self, idx):
        self.idx = idx
        self.a = []


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

for i in range(n):
    node = Node(i+1)
    nodes.append(node)

for i in range(n-1):
    cur = nodes[i]
    next = nodes[i+1]

    cur.a.append(next)
    next.a.append(cur)

X = nodes[x-1]
Y = nodes[y-1]
X.a.append(Y)
Y.a.append(X)
dp = [[None] * (n+1) for _ in range(n+1)]

for i in range(n):
    node = nodes[i]
    q = deque()
    q.append((node, 0))
    done = set()

    while q:
        t = q.popleft()
        node, d = t[0], t[1]

        if node.idx not in done:
            dp[i + 1][node.idx] = d
            done.add(node.idx)
            for adj in node.a:
                q.append((adj, d + 1))




m = {}

for i in range(1, n + 1):
    for j in range(1, n + 1):
        dis = dp[i][j]
        if dis in m:
            m[dis] += 1
        else:
            m[dis] = 1

for k in range(1, n):
    if k in m:
        print(m[k] // 2)
    else:
        print(0)

Solution (Python):
from collections import deque
N, X, Y = map(int, input().split())



G = [[] for i in range(N)]
G[X - 1].append(Y - 1)
for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)



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


ans = [0] * N

for i in range(N - 1):
    
    for ele in bfs(i)[i + 1:]:
        ans[ele] += 1
for a in ans[1:]:
    print(a)

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

for i in li:
    print(i)

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

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

import heapq

def dijkstra(start, edge, n):

    dist = [float('inf')] * n
    dist[start] = 0

    pq = [(dist[start], start)]

    while len(pq):
        d, frm = heapq.heappop(pq)
        if dist[frm] < d:
            continue
        for to, cost in edge[frm]:
            if dist[frm] + cost < dist[to]:
                dist[to] = dist[frm] + cost
                heapq.heappush(pq, (dist[to], to))

    return dist

cnt = [0] * n

for i in range(n):
    dist = dijkstra(i, edges, n)
    for d in dist:
        cnt[d] += 1

cnt2 = []
for c in cnt:
    c //= 2
    cnt2.append(c)

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

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

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

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

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

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

Solution (Python):

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

x -= 1
y -= 1

d = y - x - 1
g = [i for i in range(n)]
for i in range(y, n):
    g[i] -= d

l = [0 for _ in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        if j <= x or y <= i:
            k = j - i
        elif i <= x and y <= j:
            k = g[j] - g[i]
        else:
            
            k = j - i
            
            _k = abs(x - i) + abs(y - j) + 1
            k = min(k, _k)
        l[k] += 1

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

Solution (Python):
import sys
from heapq import heapify, heappop, heappush

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

def dijkstra(start):
    INF = 10 ** 10
    dist = [INF] * (N+1)
    dist[start] = 0
    que = [(0,start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next in graph[prev]:
            d1 = d + 1
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

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

dist_X = dijkstra(X)
dist_Y = dijkstra(Y)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = min(j-i, dist_X[i] + dist_X[j], dist_Y[i] + dist_Y[j])
        answer[d] += 1

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

Solution (Python):
n,x,y=map(int,input().split())
x-=1
y-=1
def dist(a,b):
	return min(abs(b-a),1+abs(a-x)+abs(b-y),1+abs(b-x)+abs(a-y))

print(n)
for d in range(2,n):
	ans=0
	for i in range(n-d):
		lst=[]
		if i+d<n and dist(i,i+d)==d:
			lst.append(i+d)
		d0=d
		d0-=abs(x-i)
		d0-=1
		if d0>=0:
			if i<y-d0 and dist(i,y-d0)==d:
				lst.append(y-d0)
			if i<y+d0 and dist(i,y+d0)==d and y+d0<n:
				lst.append(y+d0)
		ans+=len(list(set(lst)))
	print(ans)

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

distance_counter = [0 for i in range(0, N-1)]


for i in range(1, N):
    for j in range(i+1, N + 1):
        if i <= X and Y <= j:
            distance = (X-i) + 1 + (j-Y)
        if i <= X and j < Y:
            distance = (X-i) + min(j-X, 1+(Y-j))
        if X < i and Y <= j:
            distance = min(Y-i, i-X+1) + (j-Y)
        if X < i and j < Y:
            distance = min(j-i, (i-X)+(Y-j)+1)

        distance_counter[distance-1] += 1

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

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    inf = 10**17
    

    def dijkstra_heap(start,edge):
        
        d = [inf]*N
        used = [False]*N
        d[start] = 0
        used[start] = True
        edgelist = []
        
        for a,b in edge[start]:
            heapq.heappush(edgelist,a*(10**6)+b)

        while len(edgelist):
            
            minedge = heapq.heappop(edgelist)
            if used[minedge%(10**6)]:
                continue
            node = minedge%(10**6)
            d[node] = minedge//(10**6)
            used[node] = True

            for e in edge[node]:
                if not used[e[1]]:
                    heapq.heappush(edgelist,(e[0]+d[node])*(10**6)+e[1])
        return d

    
    N, X, Y = map(int, input().split())
    edge = [[] for i in range(N)]
    
    for i in range(N-1):
        edge[i].append((1,i+1))
    for i in range(Y-1, X-1, -1):
        edge[i].append((1, i-1))
    edge[X-1].append((1, Y-1))
    res = [0]*N
    for k in range(N):
        d = dijkstra_heap(k, edge)
        for i in d[k+1:]:
            res[i] += 1
    for r in res[1:]:
        print(r)

            


if __name__ == '__main__':
    main()

Solution (Python):
N,X,Y=map(int,input().split())
G=[[0 for i in range(N)] for i in range(N)]
for i in range(0, N):
    for j in range(0, N-i):
        G[i][i+j]=j
G[X-1][Y-1]=1
for i in range(Y-1,N-1):
    G[X-1][i+1]=G[X-1][i]+1
for i in range(0,N):
    if G[X-1][Y-2-i]<G[X-1][Y-1-i]+1:
        break
    else:
        G[X-1][Y-2-i]=G[X-1][Y-1-i]+1
for i in range(0, N):
    
    a=abs(i-(X-1))
    for j in range(i,N-1):
        G[i][j+1]=min(G[i][j+1], a+G[X-1][j+1])
ans=[0 for i in range(N)]
for i in range(0,N):
    for j in range(0,N-i):
        ans[G[i][i+j]]+=1
for i in range(N-1):
    print(ans[i+1])

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

res = {}
for i in range(1, N):
    res[i] = 0

for i in range(1, N):
    for j in range(i+1, N+1):
        if i <= X and j >= Y:
            min_dis = min(j-i, (X-i)+(j-Y)+1)
        elif i <= X and j < Y:
            min_dis = min(j-i, (X-i)+(Y-j)+1)
        elif i > X and j >= Y:
            min_dis = min((j-i), (i-X)+(j-Y)+1)
        elif i > X and j < Y:
            min_dis = min((j-i), (i-X)+(Y-j)+1)

        res[min_dis] += 1

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

Solution (Python):
import heapq
import sys

input = sys.stdin.readline

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


n,s,t = map(int,input().split()) 
w=n-1

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

for i in range(w):
    x,y=i,i+1 
    edge[x].append([1,y])
    edge[y].append([1,x]) 
edge[s-1].append([1,t-1])
edge[t-1].append([1,s-1]) 

distance=dijkstra_heap(0,edge)
memo=[0]*n

for i in range(n-1):
    for j in range(i+1,n):
        if s-1<i<t-1:
            tmp=min(j-i,distance[i]+distance[j]-distance[s-1]*2)
        else:
            tmp=distance[j]-distance[i]

        memo[tmp]+=1
for i in range(1,n):
    print(memo[i])

Solution (Python):
from itertools import combinations
def Main(N, X, Y):
    ar = range(N)
    X -= 1
    Y -= 1
    comb = combinations(ar, 2)
    ans = {i:0 for i in range(N-1)}
    for i, j in comb:
        dist = 0
        if i <= X and Y <= j:
            dist = X - i + j - Y + 1
        elif i > X and Y <= j:
            dist = min(i-X + 1 + j-Y, j-i)
        elif i <= X and Y > j:
            dist = min(X-i + 1 + Y-j, j-i)
        else:
            dist = min(i-X + 1 + Y-j, j-i)
        ans[dist-1] += 1
    return ans.values()

def main():
    N, X, Y = map(int, input().split())
    out = Main(N, X, Y)
    for e in out:
        print(e)

if __name__ == '__main__':
    main()

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


def f(N,X,Y):
  for i in range(1,N):
    for j in range(i+1,N+1):
      if i <= X and j <= X:
        dic = j-i
      elif i >= Y and j >= Y:
        dic = j-i
      elif i <= X and j >= Y:
        dic = (j-i)-(Y-X)+1
      elif X < i < Y and j >= Y:
        dic = min(i-X+1,Y-i)+(j-Y)
      elif i<=X and X < j < Y:
        dic = (X-i)+min(Y-j+1,j-X)
      elif X < i < Y and X < j < Y:
        dic = min(j-i,(i-X+1)+(Y-j))
      ans[dic-1] = ans[dic-1]+1
  
f(n,x,y)
for ret in ans:
  print(ret)

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

for i in range(N):
  if i <= X:
    for j in range(i + 1, Y):
      p = min(j - i - 1, abs(i - X) + Y - j)
      ans[p] += 1
    for l in range(Y, N):
      ans[l - i - Z - 1] += 1
      
  elif (X < i) and (i < Y - 1):
    for j in range(i + 1, N):
      p = min(j - i - 1, abs(i - X) + abs(Y - j))
      ans[p] += 1  
      
  else:
    for j in range(i + 1, N):
      ans[j - i - 1] += 1
  
for i in range(N - 1):
  print(ans[i])

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

def f(p, length, moto):
  ans[length]+=1
  for data in link[p]:
    if kisyutu[data]==0:
      kisyutu[data]=1
      q.append([data, length+1, p])

for i in range(1, N+1):
  kisyutu=[1]+[0 for i in range(N)]
  kisyutu[i]=1
  q=deque()
  for data in link[i]:
    q.append([data, 1, i])
    kisyutu[data]=1
  while len(q)>0:
    data=q.popleft()
    f(data[0], data[1], data[2])
    
ans=[ans[i]//2 for i in range(N)]
print(*ans[1:], sep='\n')

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

def f(i,j):
  if j <= X:
    return j-i
  elif Y <= i:
    return j-i
  elif X <= i and j <= Y:
    return min(j-i,(i-X)+1+(Y-j))
  elif i <= X and Y <= j:
    return (X-i)+1+(j-Y)
  elif i <= X and X <= j and j <= Y:
    return (X-i)+min(j-X,1+(Y-j))
  else:
    return (j-Y)+min(Y-i,(i-X)+1)

A = [0]*(N-1)

for k in range(1,N,1):
  for l in range(k+1,N+1,1):
    A[f(k,l)-1] += 1

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

Solution (Python):
import sys
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]

N, X, Y = mi()

dp = [0]*(N)

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

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

Solution (Python):
from collections import deque
from collections import Counter
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
dis_lis = deque()
for i in range(N-1):
    for j in range(i+1, N):
        if abs(i-j)==1:
            dis_lis.append(1)
        else:
            min1 = abs(i-j)
            min2 = abs(i-X)+abs(j-Y)+1
            min3 = abs(i-Y)+abs(j-X)+1
            dis_lis.append(min(min1, min2, min3))
c = Counter(dis_lis)
for i in range(1, N):
    print(c[i])

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


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

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

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

for frm in range(N-1):
    for to in range(frm+1, N):
        key = min(to-frm, abs((X-1) - frm) + 1 + abs((Y-1) - to))
        
        count[key] += 1

print(*[count[i] for i in range(1, N)], sep='\n')

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

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

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if i < X :
      if j < X:
        a = j - i
        ans[a] += 1
      elif j >= X and j < Y:
        a = j - i
        b = (X-i) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a =  (X-i)+ 1 + (j - Y)
        ans[a] += 1
        
    elif i >= X and i < Y:
      if j < Y:
        a = j - i
        b = (i-X) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a = j -i
        b =  (i-X) + 1 + (j - Y)
        c = min(a,b)
        ans[c] += 1
        
    else:
      a = j - i
      ans[a] += 1
        
for i in range(1,N):
  print(int(ans[i]))

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

    count = {i: 0 for i in range(1, n)}
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            
            if (i <= x and j <= x) or (x <= i and y <= j):
                d = j - i
            
            
            if x < i and j < y:
                d = min(j - i, i - x + 1 + y - j)
            
            
            if i <= x and x < j < y:
                d = min(j - i,
                        x - i + 1 + y - j)            

            
            if x < i < y and y <= j:
                d = min(j - i,
                        j - y + 1 + i - x)

            if i <= x and y <= j:
                d = min(j - i,
                        x - i + j - y + 1)
            count[d] += 1            
            

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

submit()

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

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

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

for i in range(1,X+1):
  for j in range(X+1,Y):
    d=j-i
    e=(X-i)+1+(Y-j)
    f=min(d,e)
    A[f]+=1

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

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

Solution (Python):
import sys
INPUT=input().split()
N=int(INPUT[0])
X=int(INPUT[1])
Y=int(INPUT[2])
LENGTH=[0]*(N-1)
for i_a in range(1,N):
    for i_b in range(i_a+1,N+1):
        way_a=i_b-i_a
        way_b=abs(X-i_a)+abs(Y-i_b)+1
        LENGTH[min(way_a,way_b)-1]+=1

for _ in range(N-1):
    print(LENGTH[_])

Solution (Python):
from collections import deque
n,x,y=map(int,input().split())
edge=[[] for _ in range(n)]
edge[x-1].append(y-1)
edge[y-1].append(x-1)
for i in range(n-1):
  edge[i].append(i+1)
  edge[i+1].append(i)
visited=[[-1]*n for _ in range(n)]
def bfs(s):
  q=deque([s])
  visited[s][s]=0
  while q:
    x=q.popleft()
    for nx in edge[x]:
      if visited[s][nx]==-1:
        visited[s][nx]=visited[s][x]+1
        q.append(nx)
for i in range(n):
  bfs(i)
ans=[0]*n
for i in range(n):
  for j in range(n):
    if i<j:
      continue
    if visited[i][j]>=1:
      ans[visited[i][j]]+=1
for i in range(1,n):
  print(ans[i])

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

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

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

for i in range(1,n):
    for j in range(i+1,n+1):
        
        if j-i==1:
            result[1]+=1
        else:
            temp=min(j-i,abs(x-i)+1+abs(j-y))
            result[temp]+=1
for i in range(1,n):
    print(result[i])

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

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

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

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,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 fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,L,R=MI()
    edge = [ [] for i in range(N)]
    for i in range(N):
        if(i):
            edge[i].append(i-1)
        if(i<N-1):
            edge[i].append(i+1)
    L-=1
    R-=1
    edge[L].append(R)
    edge[R].append(L)
    ans = [0]*N
    for i in range(N):
        q = [i]
        visited = set()
        for step in range(N):
            tmp = []
            while(q):
                v = q.pop()
                if(v in visited):
                    continue
                ans[step] += 1
                visited.add(v)
                for to in edge[v]:
                    if(to in visited):
                        continue
                    tmp.append(to)
            q = tmp
    print(*[a//2 for a in ans[1:]],sep="\n")
if __name__ == '__main__':
    main()

Solution (Python):
def shortcut_path(src, dst, x, y):
    path = abs(src - x)
    path += 1 
    path += abs(dst - y)
    return path

def normally_path(src, dst):
    return dst - src

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

for i in range(1, N):
    for j in range(i+1, N+1):
        np = normally_path(i, j)
        sp = shortcut_path(i, j, X, Y)
        path = min(np, sp)
        if path in shortest_paths:
            shortest_paths[path] += 1
        else:
            shortest_paths[path] = 1

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

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

for i in range(n):
    for j in range(i + 1, n):
        if j <= x - 1or x >= y - 1:
            result[j - i - 1] += 1
        else:
            r1 = j - i
            r2 = abs(i - (x - 1)) + 1 + abs((y - 1) - j)

            v = min([r1, r2])
            result[v - 1] += 1
        
for i in result:
    print(i)

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):
            if i<=x and y<=j:
                d=x-i+j-y+1
            elif i<=x and x<=j<=y:
                d=min(j-i,x-i+1+y-j)
            elif x<=i<=y and j>=y:
                d=min(j-i,i-x+1+j-y)
            elif x<=i<=y and x<=j<=y:
                d=min(j-i,i-x+1+y-j)
            else:
                d=j-i
            
            Ans[d]+=1
    for ans in Ans[1:]:
        print(ans)
    
if __name__=='__main__':
    main()

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

answer = [0 for _ in range(n-1)]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        tmp = abs(i-x) + abs(j-y) + 1
        _id = min(j-i, tmp)
        answer[_id-1] += 1
for a in answer:
    print(a)

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):
    d_o=j-i
    if i<=x and i<=y and j<=x and j<=y:
      d_d=10**4
    elif i>=x and i>=y and j>=x and j>=y:
      d_d=10**4
    elif i<=x and i<=y and j>=x and j>=y:
      d_d=x-i+1+j-y
    elif i<=x and i<=y and x<=j<=y:
      d_d=x-i+1+(y-j)
    elif x<=i<=y and j>=x and j>=y:
      d_d=i-x+1+j-y
    elif x<=i<=y and x<=j<=y:
      d_d=i-x+1+y-j
    else:
      print("
    tmp=min(d_o,d_d)
    ans[tmp-1]+=1

for i in ans:
  print(i)

Solution (Python):

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

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


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