Problem:
 Score : 400 points    Problem Statement  We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:   For each i=1,2,...,N-1 , there is an edge between Vertex i and Vertex i+1 .  There is an edge between Vertex X and Vertex Y .   For each k=1,2,...,N-1 , solve the problem below:   Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k .       Constraints   3 \leq N \leq 2 \times 10^3  1 \leq X,Y \leq N  X+1 < Y  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  X  Y       Output  For each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.        Sample Input 1 5 2 4      Sample Output 1 5
4
1
0  The graph in this input is as follows:     There are five pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 1 : (1,2)\,,(2,3)\,,(2,4)\,,(3,4)\,,(4,5) . There are four pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 2 : (1,3)\,,(1,4)\,,(2,5)\,,(3,5) . There is one pair (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 3 : (1,5) . There are no pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 4 .       Sample Input 2 3 1 3      Sample Output 2 3
0  The graph in this input is as follows:           Sample Input 3 7 3 7      Sample Output 3 7
8
4
2
0
0       Sample Input 4 10 4 8      Sample Output 4 10
12
10
8
4
1
0
0
0

Solution (Python):
import numpy as np
N, X, Y = [int(_) for _ in input().split()]
X -= 1
Y -= 1
cnt = np.zeros(N, dtype=int)
for i in range(0, (X + Y) // 2):
    
    
    
    
    tmin = abs(i - X) + 1
    tmax = 0 - -(abs(i - X) + 1 + Y + i) // 2
    cnt[1:tmax - i] += 1
    cnt[tmin:tmin + Y - tmax + 1] += 1
    cnt[tmin + 1:tmin + N - Y] += 1
for i in range((X + Y) // 2, N):
    cnt[1:N - i] += 1
print(*cnt[1:], sep='\n')

Solution (Python):
import numpy as np
N, X, Y = [int(_) for _ in input().split()]
X -= 1
Y -= 1
cnt = np.zeros(N, dtype=int)
for i in range(0, (X + Y) // 2):
    
    
    
    
    
    tmin = abs(i - X) + 1
    tmax = 0 - -(abs(i - X) + 1 + Y + i) // 2
    cnt[1:tmax - i] += 1
    cnt[tmin:tmin + Y - tmax + 1] += 1
    cnt[tmin + 1:tmin + N - Y] += 1
for i in range((X + Y) // 2, N):
    cnt[1:N - i] += 1
print(*cnt[1:], sep='\n')

Solution (Python):
def main():
    N, X, Y = (int(i) for i in input().split())
    cnt = [0]*N
    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), abs(i-X)+abs(X-Y)+abs(j-Y))
            cnt[d] += 1
    for d in cnt[1:]:
        print(d)


if __name__ == '__main__':
    main()

Solution (Python):



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


graph = [[0]*(N+1) for i in range(N+1)]
kyori_list = [0]*N


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


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

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

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

Solution (Python):
n,x,y=map(int,input().split())
l=[0 for _ in range(n)]

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

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

Solution (Python):
from collections import deque

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

for i in range(1, n + 1):
    if i == 1:
        a.append([2])
    elif i == n:
        a.append([n - 1])
    else:
        a.append([i - 1, i + 1])
a[x - 1].append(y)
a[y - 1].append(x)

d = {}
for i in range(n - 1):
    d[i + 1] = 0

def solve(s):
    queue = deque()
    queue.append(a[s - 1])
    visit = set()
    visit.add(s)
    depth = 0

    while queue:
        depth += 1
        nn = queue.popleft()
        adj = []
        for i in nn:
            if i not in visit:
                d[depth] += 1
                adj = adj + a[i-1]
            visit.add(i)
        if adj != []:
            queue.append(adj)

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

for i in range(n - 1):
    print(d[i + 1] // 2)

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

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

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

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

Solution (Python):
from collections import deque

N, X, Y = [int(x) for x in input().split()]
X -= 1
Y -= 1

result = {x: 0 for x in range(N)}


def push(v, d, queue, dist):
    if v in dist:
        return
    dist[v] = d
    queue.appendleft(v)


def check(i):
    queue = deque()
    dist = {}
    push(i, 0, queue, dist)

    while queue:
        pos = queue.pop()
        d = dist[pos]

        if pos - 1 >= 0:
            push(pos - 1, d + 1, queue, dist)
        if pos + 1 < N:
            push(pos + 1, d + 1, queue, dist)
        if pos == X:
            push(Y, d + 1, queue, dist)
        if pos == Y:
            push(X, d + 1, queue, dist)

    for i in range(N):
        result[dist[i]] += 1


for i in range(N):
    check(i)

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

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


def shortest_path(i, j):
    res = min(abs(i-x)+abs(j-y)+1, j-i)
    return res


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

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

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

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

if __name__ == "__main__":
    main()

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,x,y = MAP()

dd = defaultdict(int)

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

Solution (Python):
def resolve():
    '''
    code here
    '''
    import collections
    N, X, Y = [int(item) for item in input().split()]
    X -= 1
    Y -= 1

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


    fp = [-1 for _ in range(N)]

    res_memo = [0 for _ in range(N)]
    for i in range(N):
        fp = [-1 for _ in range(N)]
        que = collections.deque([[i, 0]])
        fp[i] = 0
        while que:
            node, dist = que.popleft()
            for to_node in edges[node]:
                if fp[to_node] == -1:
                    que.append([to_node, dist+1])
                    fp[to_node] = dist+1

        for item in fp:
            res_memo[item] +=1
    
    for item in res_memo[1:]:
        print(item//2)



if __name__ == "__main__":
    resolve()

Solution (Python):
N,X,Y = map(int,input().split())
g = [[] for _ in range(N+1)]
for i in range(1,N+1):
    if i != 1:
        g[i].append(i-1)
    if i != N:
        g[i].append(i+1)
g[X].append(Y)
g[Y].append(X)
from collections import deque
answer = [0]*(N+1)
for i in range(1,N+1):
    q = deque([i])
    d = [None]*(N+1)
    d[i] = 0
    while q:
        p = q.popleft()
        for j in g[p]:
            if d[j] == None:
                d[j] = d[p]+1
                q.append(j)
    for k in d[1:]:
        answer[k] += 1
for l in answer[1:-1]:
    print(l//2)

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

l = [0]*(n-1)

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

for i in l:
    print(i)

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

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

for a in ans:
    print(a)

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

Solution (Python):
n,x,y = map(int,input().split())
ko = [0 for i in range(10**4)]
for i in range(1,n):
  for j in range(i+1,n+1):
    c1 = j-i
    if i<=x and y<=j:
      c2 = (x-i)+1+(j-y)
    elif i<=x and j<y:
      c2 = (x-i)+1+(y-j)
    elif x<i and y<=j:
      c2 = (i-x)+1+(j-y)
    else:
      c2 = (i-x)+1+(y-j)
    ko[min(c1,c2)] += 1
  
for i in range(1,n):
  print(ko[i])

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7




N, X, Y = MAP()

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)

dic = defaultdict(int)
for i in range(N):
	q = deque([i])
	dist = [-1]*N
	dist[i] = 0

	while q:
		n = q.popleft()
		for node in graph[n]:
			if dist[node] == -1:
				dist[node] = dist[n] + 1
				q.append(node)

	for i in range(N):
		dic[dist[i]] += 1

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



def dijkstra(E, start): 
	N_d = len(E)
	dist = [INF] * N_d
	dist[start] = 0
	q = [(0, start)]
	while q:
		dist_v, v = heappop(q)
		if dist[v] != dist_v:
			continue
		for u, dist_vu in E[v]:
			dist_u  = dist_v + dist_vu
			if dist[u] > dist_u:
				dist[u] = dist_u
				heappush(q, (dist_u, u))
	return dist	

N, X, Y = MAP()

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

dic = defaultdict(int)

ans = 0
for i in range(N):
	ans = dijkstra(graph, i)
	for key in ans:
		dic[key] += 1

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

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

Solution (Python):
from collections import deque
n,x,y=map(int,input().split())
l=[[1]]
for i in range(1,n-1):
    l.append([i-1,i+1])
l.append([n-2])
x,y=x-1,y-1
l[x].append(y)
l[y].append(x)

p=[0 for i in range(n)]
for j in range(n):
    s=[-1 for i in range(n)]
    s[j]=0
    q=deque([j])
    while len(q)>0:
        a=q.popleft()
        for i in l[a]:
            if s[i]==-1:
                s[i]=s[a]+1
                q.append(i)
    for i in s:
        if i!=0:
            p[i]+=1
print(*map(lambda x:x//2,p[1:]),sep='\n')

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, X, Y = LI()
    X -= 1
    Y -= 1
    cnt = [0] * N

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

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


main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, X, Y = LI()
    X -= 1
    Y -= 1
    cnt = [0] * N

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

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


main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, X, Y = LI()
    X -= 1
    Y -= 1
    dist = [[N] * N for _ in range(N)]

    q = deque()
    for i in range(N):
        q.append(i)
        dist[i][i] = 0
        while q:
            u = q.popleft()
            t = dist[i][u] + 1
            if u < N - 1:
                if dist[i][u + 1] > t:
                    q.append(u + 1)
                    dist[i][u + 1] = t
            if u >= 1:
                if dist[i][u - 1] > t:
                    q.append(u - 1)
                    dist[i][u - 1] = t
            if u == X:
                if dist[i][Y] > t:
                    q.append(Y)
                    dist[i][Y] = t
            if u == Y:
                if dist[i][X] > t:
                    q.append(X)
                    dist[i][X] = t

    cnt = [0] * N

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

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


main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, X, Y = LI()
    X -= 1
    Y -= 1
    dist = [[N] * N for _ in range(N)]

    q = deque()
    for i in range(N):
        q.append(i)
        dist[i][i] = 0
        while q:
            u = q.popleft()
            if u < N - 1:
                if dist[i][u + 1] > dist[i][u] + 1:
                    q.append(u + 1)
                    dist[i][u + 1] = dist[i][u] + 1
            if u >= 1:
                if dist[i][u - 1] > dist[i][u] + 1:
                    q.append(u - 1)
                    dist[i][u - 1] = dist[i][u] + 1
            if u == X:
                if dist[i][Y] > dist[i][u] + 1:
                    q.append(Y)
                    dist[i][Y] = dist[i][u] + 1
            if u == Y:
                if dist[i][X] > dist[i][u] + 1:
                    q.append(X)
                    dist[i][X] = dist[i][u] + 1

    cnt = [0] * N

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

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


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

for i in ans:
    print(i)

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

from collections import deque

INF = 1000000000
ans = [0]*(N-1)


def rep(sv,dist):
    que = deque()

    def push(v,d):
        if (dist[v] != INF): return
        dist[v] = d
        que.append(v)

    push(sv,0)

    while(que):
        v = que.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-1:
            push(Y-1, d+1)
        
        if v == Y-1:
            push(X-1, d+1)

for i in range(N):
    dist = [INF]*N
    rep(i,dist)
    
    for d in dist:
        if d-1 == -1:continue
        ans[d-1] += 1


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

Solution (Python):
from collections import Counter
N, X, Y = map(int, input().split())
cnt = []

for i in range(1, N):
    for j in range(i+1, N+1):
        cnt.append(min(j-i, abs(X-i)+abs(Y-j)+1))

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

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

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

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

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

reselt = [0]*(n-1)

for i in range(n):
    stack=deque([i])
    check = [-1]*n
    check[i] = 0
 
    while len(stack)>0:
        v = stack.popleft()
        for i in root[v]:
            if check[i] == -1:
                check[i] = check[v]+1
                reselt[check[i]-1] += 1
                stack.append(i)

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

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

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

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

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

for i in range(len(ans)):
  print(ans[i])

Solution (Python):


import sys
input=sys.stdin.readline
from collections import deque

def main():
    N,X,Y=map(int,input().split())
    X-=1
    Y-=1
    adj=[[] for i in range(N)]
    adj[X].append(Y)
    adj[Y].append(X)
    for i in range(N-1):
        adj[i].append(i+1)
        adj[i+1].append(i)
    cnt=[0]*(N)
    for i in range(N):
        dist=[-1]*N
        qu=deque([i])
        dist[i]=0
        while(len(qu)>0):
            v=qu.popleft()
            for nv in adj[v]:
                if dist[nv]==-1:
                    dist[nv]=dist[v]+1
                    cnt[dist[nv]]+=1
                    qu.append(nv)
    for i in range(1,N):
        print(cnt[i]//2)
    
    
if __name__=="__main__":
    main()

Solution (Python):
import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,X,Y = map(int,readline().split())
ans = [0]*N
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)

def bfs(x,q,dist):
    while q:
        v = q.popleft()
        for nx in graph[v]:
          if dist[nx] != 0:
            continue
          dist[nx] = dist[v] + 1
          q.append(nx)
          if nx > x:
            ans[dist[nx]] +=1

for i in range(N):
    dist = [0]*N
    q = deque([i])
    bfs(i,q,dist)
      
print('\n'.join(str(n) for n in ans[1:]))

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,X,Y = map(int,readline().split())
ans = [0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        dist = min(j-i,abs(i-X)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))
        ans[dist]+=1
print('\n'.join(str(n) for n in ans[1:]))

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def main():
    n, x, y = LI()
    x, y = x - 1, y - 1
    d = [[INF] * n for _ in range(n)]
    ans = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            d[i][j] = min([j - i,
                           abs(x - i) + 1 + abs(j - y),
                           abs(y - i) + 1 + abs(j - x)])
            ans[int(d[i][j])] += 1
    print(*ans[1:], sep='\n')


main()

Solution (Python):
import itertools
import functools
import math
from collections import Counter

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

k=[]

for i in range(1,N):
    for j in range(i+1,N+1):
        chk = min(abs(j-i),abs(X-i)+abs(j-Y)+1)
        k.append(chk)

a=Counter(k)

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

Solution (Python):
import itertools
import functools
import math
from collections import Counter

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

k=[]

for i in range(1,N):
    for j in range(i+1,N+1):
        chk = min(abs(j-i),abs(X-i)+abs(j-Y)+1)
        k.append(chk)

a=Counter(k)

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

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

mi={i:0 for i in range(1,n)}
for i in range(1,n):
  for j in range(i+1,n+1):
    if i<=x and y<=j:
      mi[x-i+1+j-y]+=1
    elif x<i and y<=j:
      mi[min(i-x+1+j-y,j-i)]+=1
    elif i<=x and j<y:
      mi[min(x-i+1+y-j,j-i)]+=1
    elif x<i and j<y:
      mi[min(i-x+1+y-j,j-i)]+=1
    else:
      mi[j-i]+=1
      
for i in range(1,n):
  print(mi[i])

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

Solution (Python):

import sys
input = sys.stdin.readline

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

for i in range(n-1):
    a,b = i,i+1
    g[a].append(b)
    g[b].append(a)
g[x-1].append(y-1)
g[y-1].append(x-1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n 
    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


di = [0]*n
for i in range(n):
    l = bfs(i)
    for j in l:
        if j == 0:
            continue
        di[j-1] += 1
di = di[:-1]
for k in di:
    print(k//2)

Solution (Python):
from collections import deque

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

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

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

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

ans = [0]*(n-1)
for i in range(n):
    q = deque([])
    q.append(i)

    dist = [-1]*n
    dist[i] = 0

    while len(q) > 0:
        v = q.popleft()
    
        for nv in adj[v]:
            if dist[nv] != -1:
                continue
        
            dist[nv] = dist[v] + 1
            q.append(nv)
    for i in dist:
        if i != 0:
            ans[i-1] += 1

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

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

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