Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
n, q = map(int,input().split())
d = {}
for i in range(n-1):
    ai, bi = map(int,input().split())
    if ai-1 in d:
        d[ai-1] += [bi-1]
    else:
        d[ai-1] = [bi-1]
    if bi-1 in d:
        d[bi-1] += [ai-1]
    else:
        d[bi-1] = [ai-1]
#point
px = [0 for i in range(n)]
for i in range(q):
    pi,xi = map(int,input().split())
    px[pi-1] += xi
sp = [0 for i in range(n)]
s = [[0,0]]
while len(s) > 0:
    x = s.pop(0)
    sp[x[0]] += px[x[0]]
    for xc in d[x[0]]:
        if xc != x[1]:
            s.append([xc,x[0]])
            sp[xc] += sp[x[0]]
for i in range(n):
    print(sp[i])


### FIXED CODE ###

from collections import deque
n, q = map(int,input().split())
d = [[] for i in range(n)]
for i in range(n-1):
    ai, bi = map(int,input().split())
    d[ai-1].append(bi-1)
    d[bi-1].append(ai-1)
#point
px = [0 for i in range(n)]
for i in range(q):
    pi,xi = map(int,input().split())
    px[pi-1] += xi
sp = [0 for i in range(n)]
s = deque()
s.append(0)
visited = [False for i in range(n)]
while len(s) > 0:
    x = s.popleft()
    visited[x] = True
    sp[x] += px[x]
    for xc in d[x]:
        if not visited[xc]:
            s.append(xc)
            sp[xc] += sp[x]
for i in range(n):
    print(sp[i])
### BUGGY CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0,i-k),i))
print(dp[-1])
                  



### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*n
    dp[1] = abs(h[1] - h[0])
    for i in range(2,n):
        dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0,i-k),i))
    print(dp[-1])

main()
### BUGGY CODE ###

from collections import deque
import numpy as np

n, m  = map(int, input().split())
g     = {}
maxD  = np.array([-1 for i in range(n)])
color = np.array([0  for _ in range(n)])

for _ in range(m):
    u, v = map(int, input().split())
    u-=1
    v-=1
    if u not in g:
        g[u] = []
    if v not in g:
        g[v] = []
    g[u].append(v)
    g[v].append(u)
    
q = int(input())
Q = []

for _ in range(q):
    node, dis, col = map(int, input().split())
    Q.append([node-1, dis, col])
Q = Q[::-1]

def bfs(curQ):
    while len(curQ) > 0:
        node, dis, col = curQ.pop()
    
        if maxD[node] > dis:
            continue
            
        if dis < 0:
            continue
            
        maxD[node] = dis
    
        if color[node] == 0:
            color[node] = col

        if node in g:
            for v in g[node]:
                if dis-1 > maxD[v]:
                    curQ.append([v, dis-1, col])
                    
for node, dis, col in Q:
    curQ = deque()
    curQ.append([node, dis, col])
    bfs(curQ)

ans = ''
for x in color:
    ans += str(x)+'\n'
print(ans)

### FIXED CODE ###

n, m  = map(int, input().split())
g     = {}
used  = {i:[False for _ in range(11)] for i in range(n)}
color     = [0  for _ in range(n)]

for _ in range(m):
    u, v = map(int, input().split())
    u-=1
    v-=1
    if u not in g:
        g[u] = []
    if v not in g:
        g[v] = []
    g[u].append(v)
    g[v].append(u)
    
q = int(input())
Q = []

for _ in range(q):
    node, dis, col = map(int, input().split())
    Q.append([node-1, dis, col])
Q = Q[::-1]

def bfs(now, dist, col):
    if dist < 0:
        return
    
    if used[now][dist]:
        return
 
    used[now][dist] = True
    
    if not color[now]:
        color[now] = col
 
    if now in g:
        for x in g[now]:
            bfs(x, dist - 1, col)
            
for node, dis, col in Q:
    bfs(node, dis, col)

for x in color:
    print(x)
### BUGGY CODE ###

from itertools import combinations
N = int(input())
d = {}
for c in input():
  if c in d.keys():
    d[c] += 1
  else:
    d[c] = 1
ans = 0
for i in range(1, len(d.keys())+1):
  for com in combinations(d.keys(),i):
    tmp = 1
    for c in com:
      tmp *= d[c]
    ans += tmp
    ans %= 10**9+7
print(ans) 



### FIXED CODE ###

from itertools import combinations
N = int(input())
S = list(input().strip())
d = {}
for c in S:
  if c in d.keys():
    d[c] += 1
  else:
    d[c] = 1
ans = 0
for n in d.values():
  ans = (ans+n+ans*n)%(10**9+7)
print(ans)
### BUGGY CODE ###

import sys
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)

if len(set(A))!=len(A) or len(set(B))!=len(B):
    print(0)
    sys.exit()

else:
    ans = 1
    rows, columna = 0,0
    mod = 10**9+7
    for x in range(N*M, 0, -1):
        in_A = x in A
        in_B = x in B

        if in_A and in_B:
            rows += 1
            columna += 1

        elif in_A:
            rows += 1
            ans = ans * (columna)

        elif in_B:
            columna += 1
            ans = ans *(rows)

        else:
            ans = ans * (rows * columna -(N*M-x))

        ans %= mod

    print(ans%mod)


### FIXED CODE ###

def solve():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    
    row, columun = 0, 0
    ans = 1
    for i in range(N * M, 0, -1):
        in_A = i in A
        in_B = i in B
        if in_A and in_B:
            row += 1
            columun += 1
        elif in_A:
            row += 1
            ans *= columun
        elif in_B:
            columun += 1
            ans *= row
        else:
            ans *= row * columun - (N * M - i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

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

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

for i in cnt:
	print(i)

### FIXED CODE ###

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

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

[print(i) for i in dis]
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


def main():
    N, M =two_int()

    key_list=[]
    treasures=[]

    for i in range(M):
        mon,_ =two_int()
        key_list.append(mon)
        temp = map(lambda x: 1<<(x-1), many_int())
        sums = sum(temp)
        treasures.append(sums)

    max_index=2**N
    INF=10**15

    dp=[INF for i in range(max_index)]
    dp_i=[set([j for j in range(M)]) for i in range(max_index)]
    dp[0]=0

    for i in range(max_index-1):
        
        lists = list( dp_i[i])
        min_key=0
        for j in lists:
            new_i = int(bin(treasures[j] | i),2)
            cost = dp[i] + key_list[j]
            dp[new_i] = min(dp[new_i], cost) 
            min_key = j
        dp_i[i] = dp_i[i] - set([min_key])
        
    goal_index=max_index-1
    if dp[goal_index]!=INF:
        print(dp[goal_index])
    else:
        print(-1)

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


def main():
    N, M =two_int()

    key_list=[]
    treasures=[]
    check={}

    for i in range(M):
        mon,_ =two_int()
        temp = map(lambda x: 1<<(x-1), many_int())
        sums = sum(temp)
        
        if sums in check:
            if check[sums] > mon:
                check[sums]=mon
        else:
            check[sums]=mon
            
    for k,v in check.items():
        key_list.append(v)
        treasures.append(k)

    max_index=2**N
    INF=10**15

    dp=[INF for i in range(max_index)]
    dp[0]=0
    M=len(key_list)

    for i in range(max_index-1):
        for j in range(M):
            new_i = int(bin(treasures[j] | i),2)
            cost = dp[i] + key_list[j]
            dp[new_i] = min(dp[new_i], cost) 
        
    goal_index=max_index-1
    if dp[goal_index]!=INF:
        print(dp[goal_index])
    else:
        print(-1)

main()
### BUGGY CODE ###

n, m, k = list(map(int, input().split()))

# 二項係数を 10^9+7 で割った余りを求める
# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
# https://www.hamayanhamayan.com/entry/2018/06/06/210256

mod = 10**9 + 7

# x ** a をmodで割った余りを、O(log(a))時間で求める。
def power(x, a):
	if a == 0:
		return 1
	elif a == 1:
		return x
	elif a % 2 == 0:
		return power(x, a//2) **2 % mod
	else:
		return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
	return power(x, mod-2)

# 二項係数の左側の数字の最大値を max_len　とする。nとかだと他の変数と被りそうなので。
# factori_table = [1, 1, 2, 6, 24, 120, ...] 要は factori_table[n] = n!
# 計算時間はO(max_len * log(mod))

max_len = n * m #適宜変更する

factori_table = [1] * (max_len + 1)
factori_inv_table = [1] * (max_len + 1)
for i in range(1, max_len + 1):
	factori_table[i] = factori_table[i-1] * (i) % mod
	factori_inv_table[i] = modinv(factori_table[i])

def binomial_coefficients(n, k):
	# n! / (k! * (n-k)! )
	return factori_table[n] * factori_inv_table[k] * factori_inv_table[n-k]

ans_1 = 0
for i in range(n):
	ans_1 += i * m**2 * (n-i)
for i in range(m):
	ans_1 += i * n**2 * (m-i)

print(binomial_coefficients(n*m-2, k-2) * ans_1 % mod)


### FIXED CODE ###

n, m, k = list(map(int, input().split()))

# 二項係数を 10^9+7 で割った余りを求める
# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
# https://www.hamayanhamayan.com/entry/2018/06/06/210256

mod = 10**9 + 7

# x ** a をmodで割った余りを、O(log(a))時間で求める。
def power(x, a):
	if a == 0:
		return 1
	elif a == 1:
		return x
	elif a % 2 == 0:
		return power(x, a//2) **2 % mod
	else:
		return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
	return power(x, mod-2)

# 二項係数の左側の数字の最大値を max_len　とする。nとかだと他の変数と被りそうなので。
# factori_table = [1, 1, 2, 6, 24, 120, ...] 要は factori_table[n] = n!
# 計算時間はO(max_len * log(mod))

max_len = n * m #適宜変更する

factori_table = [1] * (max_len + 1)
factori_inv_table = [1] * (max_len + 1)
for i in range(1, max_len + 1):
	factori_table[i] = factori_table[i-1] * (i) % mod

# 	factori_inv_table[i] = modinv(factori_table[i])
#	↑が遅いので、使うところだけ逆元を計算する↓
for i in [k-2, n*m-k]:
	factori_inv_table[i] = modinv(factori_table[i])

def binomial_coefficients(n, k):
	# n! / (k! * (n-k)! )
	return factori_table[n] * factori_inv_table[k] * factori_inv_table[n-k]

ans_1 = 0
for i in range(n):
	ans_1 += i * m**2 * (n-i) % mod
for i in range(m):
	ans_1 += i * n**2 * (m-i) % mod

print(binomial_coefficients(n*m-2, k-2) * ans_1 % mod)
### BUGGY CODE ###

s = input()
k = int(input())
number = len(s)
word_list = []
for i in range(number):
  for j in range(1,number+1):
    if i+j > number:
      break
    word_list.append(s[i:i+j])

unique_list = list(set(word_list))

print(sorted(unique_list)[k-1])


### FIXED CODE ###

s = input()
k = int(input())
number = len(s)
word_list = []
for i in range(number):
  for j in range(1,6):
    if i+j > number:
      break
    word_list.append(s[i:i+j])

unique_list = list(set(word_list))

print(sorted(unique_list)[k-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline  #文字列入力では注意！
from copy import deepcopy
from functools import lru_cache
N,M = map(int,input().split())
graph = [[] for _ in range(N)]
s = set()
for i in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    s.add(y)
    graph[x].append(y)

@lru_cache(maxsize = None)
def dfs(x):
    if not graph[x]:
        return 0
    stack = deepcopy(graph[x])
    ret = 0
    while stack:
        now = stack.pop(0)
        ret = max(ret,dfs(now)+1)
    return ret

ans = 0
for i in range(N):
    if i not in s:
        ans = max(ans,dfs(i))
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline  #文字列入力では注意！
from copy import deepcopy
from functools import lru_cache
N,M = map(int,input().split())
graph = [[] for _ in range(N)]
s = set()
for i in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    s.add(y)
    graph[x].append(y)

@lru_cache(maxsize = None)
def dfs(x):
    if not graph[x]:
        return 0
    stack = deepcopy(graph[x])
    ret = 0
    while stack:
        now = stack.pop(0)
        ret = max(ret,dfs(now)+1)
    return ret

ans = 0
for i in range(N):
    if i not in s:
        ans = max(ans,dfs(i))
print(ans)
### BUGGY CODE ###

n=int(input())
a=[]
time=0
for i in range(n):
    x,y=map(int,input().split())
    a.append([x,y])
c=sorted(set([a[i][1] for i in range(n)]))
for i in c:
    for x,y in a:
        if i==y:
            time+=x
            if time>y:
                print("No")
                exit()
print("Yes")

### FIXED CODE ###

n=int(input())
a,f,b=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[1]),1,0
for i in range(n):
    b+=a[i][0] 
    if b>a[i][1]: 
        f=0 
print('Yes' if f==1 else 'No')
### BUGGY CODE ###

import heapq

num = int(input())
a = [int(input()) for i in range(num)]
b = heapq.nlargest(2, a)
c = [b[0] for i in range(num)]
if b[0] == b[1]:
  for j in c:
    print(j)
else:
  for f in range(num):
    if f == a.index(b[0]):
      print(b[1])
    else:
      print(b[0])



### FIXED CODE ###

from heapq import nlargest

n = int(input())
a = [int(input()) for i in range(n)]
b = nlargest(2, a)
ma = max(a)
for j in a:
  if j == ma:
    print(b[1])
  else:
    print(ma)
### BUGGY CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
r=[0]
for i in range(n):
    r.append(r[i]+a[i])
r.pop(0)
q=[r[i] for i in range(n)]

pm=[1-2*(i%2) for i in range(n)]
mp=[1-2*((i+1)%2) for i in range(n)]

sum1,sum2=0,0
sousa1,sousa2=0,0

for i in range(n):
    if np.sign(r[i]) != pm[i]:
        sum1+=abs(pm[i]-r[i])
        sousa1=pm[i]-r[i]
        for j in range(n-i-1):
            r[i+j+1]=r[i+j+1]+sousa1
        
for i in range(n):
    if np.sign(q[i]) != mp[i]:
        sum2+=abs(mp[i]-q[i])
        sousa2=mp[i]-q[i]
        for j in range(n-i-1):
            q[i+j+1]=q[i+j+1]+sousa2
        
print(min(sum1,sum2))

### FIXED CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
r=[0]
for i in range(n):
    r.append(r[i]+a[i])
r.pop(0)
q=[r[i] for i in range(n)]

pm=[1-2*(i%2) for i in range(n)]
mp=[1-2*((i+1)%2) for i in range(n)]

sum1,sum2=0,0
sousa1,sousa2=0,0

for i in range(n):
    if np.sign(r[i]+sousa1) != pm[i]:
        sum1+=abs(pm[i]-r[i]-sousa1)
        sousa1=pm[i]-r[i]
        
for i in range(n):
    if np.sign(q[i]+sousa2) != mp[i]:
        sum2+=abs(mp[i]-q[i]-sousa2)
        sousa2=mp[i]-q[i]

print(min(sum1,sum2))
### BUGGY CODE ###

H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

dpl = H+max(A)
x = 10**10
dp = [x]*dpl
dp[0] = 0

for a, b in zip(A, B):
    for i in range(a, dpl):
        dp[i] = min(dp[i-a]+b, dp[i])
    for i in range(dpl-2, -1, -1):
        dp[i] = min(dp[i+1], dp[i])

print(dp[H])

### FIXED CODE ###

H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

dpl = H+max(A)
x = 10**10
dp = [x]*dpl
dp[0] = 0

for a, b in zip(A, B):
    for i in range(a, dpl):
        dp[i] = min(dp[i-a]+b, dp[i])
    for i in range(dpl-2, -1, -1):
        dp[i] = min(dp[i+1], dp[i])

print(dp[H])
### BUGGY CODE ###

import bisect
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
BC = [ list(map(int, input().split())) for _ in range(m) ]
for b, c in BC:
  d = bisect.bisect_left(A, c)
  t = min(d, b)
  for i in range(t):
    A[i] = c
  if t == b:
    A = A[b:d] + A[:b] + A[d:]
print(sum(A))


### FIXED CODE ###

from operator import itemgetter
n, m = map(int, input().split())
A = [(1, i) for i in map(int, input().split())]
BC = [ tuple(map(int, input().split())) for _ in range(m) ]
XY = sorted(A + BC, reverse=True, key=itemgetter(1))
c = n
now = 0
ans = 0
while c > 0 and now < n+m:
  x, y = XY[now]
  t = min(c, x)
  ans += y*t
  c -= t
  now += 1
print(ans)
### BUGGY CODE ###

a = int(input())
res = 0
remainer = 0
while True:
    res += (360+remainer)//a
    remainer = 360%a
    if remainer==0:break
print(res)


### FIXED CODE ###

a = int(input())
res = 0
remainer = 0
while True:
    res += (360+remainer)//a
    remainer = (360+remainer)%a
    if remainer==0:break
print(res)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

from collections import Counter, OrderedDict

c = Counter(a)
d = OrderedDict(sorted(c.items(), key=lambda x: x[1]))

if len(d) <= k:
    print(0)

else:
    ans = 0
    while len(d) > k:
        item = list(d.items())[0]
        ans += item[1]
        del d[item[0]]
    print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

from collections import Counter

c = Counter(a)
d = c.most_common()

if len(d) <= k:
    print(0)

else:
    ans = 0
    while len(d) > k:
        item = d.pop()
        ans += item[1]
    print(ans)
### BUGGY CODE ###

class PQueue:
    def __init__(self):
        self.keys = []
        self.size = 0
        
    def maxHeapify(self, i):
        l = i * 2 + 1
        r = i * 2 + 2
        if l < self.size and self.keys[l] > self.keys[i]:
            largest = l
        else:
            largest = i
        if r < self.size and self.keys[r] > self.keys[largest]:
            largest = r
        if largest != i:
            self.keys[i], self.keys[largest] = self.keys[largest], self.keys[i]
            self.maxHeapify(largest)

    def insert(self, key):
        i = self.size
        self.size += 1
        self.keys.append(key)
        parent = (i - 1) // 2
        while i > 0 and self.keys[parent] < self.keys[i]:
            self.keys[i], self.keys[parent] = self.keys[parent], self.keys[i]
            i = parent
            parent = (parent - 1) // 2

    def heapExtraMax(self):
        max_key = self.keys[0]
        if self.size > 1:
            self.keys[0] = self.keys.pop()
            self.size -= 1
            if self.size > 1:
                self.maxHeapify(0)
        else:
            del self.keys[0]
            self.size -= 1
        return max_key


S = PQueue()

import sys

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        S.insert(k)
    elif x[:2] == 'ex':
        m_k = S.heapExtraMax()
        print(m_k)
    else:
        pass

### FIXED CODE ###

def setHeapDown_max(heap, pos):
    targetkey = heap[pos]
    while pos > 0:
        parentpos = (pos - 1) >> 1
        parent = heap[parentpos]
        if parent < targetkey:
            heap[pos] = parent
            pos = parentpos
            continue
        break
    heap[pos] = targetkey

def setHeapUp_max(heap, pos):
    endpos = len(heap)
    targetkey = heap[pos]
    childpos = 2*pos + 1
    while childpos < endpos:
        rightpos = childpos + 1
        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
            childpos = rightpos
        heap[pos] = heap[childpos]
        pos = childpos
        childpos = 2*pos + 1
    heap[pos] = targetkey
    setHeapDown_max(heap, pos)

def heapPush_max(heap, key):
    heap.append(key)
    setHeapDown_max(heap, len(heap) - 1)

def heapPop_max(heap):
    lastkey = heap.pop()
    if heap:
        returnkey = heap[0]
        heap[0] = lastkey
        setHeapUp_max(heap, 0)
        return returnkey
    return lastkey


import sys

S = []

ans = []

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        heapPush_max(S, k)
    elif x[1] == 'x':
        ans.append(heapPop_max(S))
    else:
        pass

print(*ans, sep = '\n')
### BUGGY CODE ###

import collections
import itertools

def main():
    s=["".join(sorted(input())) for _ in range(int(input()))]
    c=0
    for i in collections.Counter(s).values():
        c+=len(list(itertools.combinations(range(i),2)))
    print(c)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import collections

def main():
    s=["".join(sorted(input())) for _ in range(int(input()))]
    c=0
    for i in collections.Counter(s).values():
        c+=i*(i-1)//2
    print(c)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

from  collections import defaultdict
N, X, Y = map(int, input().split())
D = defaultdict(int)
for i in range(1,N):
    for j in range(i+1, N+1):
        r = min(j-i, abs(X-i)+abs(X-j)+1, abs(X-i)+abs(Y-j)+1, abs(Y-i)+abs(Y-j)+1)
        D[r] += 1
for i in range(1, N):
    print(D[i])


### FIXED CODE ###

from  collections import defaultdict
N, X, Y = map(int, input().split())
D = defaultdict(int)
for i in range(1,N):
    for j in range(i+1, N+1):
        r = min(j-i, abs(X-i)+abs(X-j)+1, abs(X-i)+abs(Y-j)+1, abs(Y-i)+abs(Y-j)+1)
        D[r] += 1
for i in range(1, N):
    print(D[i])
### BUGGY CODE ###

N=int(input())
a=[]
for i in range(N):
	a.append(int(input()))
for j in range(N):
	b=a[:j]+a[j+1:]
	print(max(b))

### FIXED CODE ###

N=int(input())
a=[]
for i in range(N):
	a.append(int(input()))
k=max(a)
count=0
for j in range(N):
	if count==1:
		print(k)
	else:
		if a[j]==k:
			b=a[:j]+a[j+1:]
			count=1
			print(max(b))
		else:
			print(k)
### BUGGY CODE ###

# Write and Erase
n = int(input())
a = []
count = 0
for _ in range(n):
    a.append(input())
for i in set(a):
    count += a.count(i)%2
print(count)

### FIXED CODE ###

# Write and Erase
n = int(input())
a = {}
count = 0
for _ in range(n):
    elem = input()
    if elem not in a:
        a[elem] = 1
    else:
        a[elem] += 1
for i in a.values():
    count += i % 2
print(count)
### BUGGY CODE ###

import itertools

n, m = list(map(int, input().split(" ")))
l = [ 10**100 + i for i in range(n + 1) ]
div = 10**9 + 7

ans = set()
for i in range(m, n + 2):
    for v in itertools.combinations(l, i):
        ans.add(sum(v) % div)
print(len(ans))

### FIXED CODE ###

n, k = map(int, input().split(" "))

ans = 0
for i in range(k, n+2):
    min = i * ( 0 + i-1) / 2
    max = i * ( (n+1 - i) + n) / 2
    ans += int(max - min + 1)

print(ans % (10**9 + 7))
### BUGGY CODE ###

N, K = map(int, input().split())

numList = []

for _ in range(N):
    a, b = map(int, input().split())

    for _ in range(b):
        numList.append(a)

numList.sort()

print(numList[K-1])

### FIXED CODE ###

N, K = map(int, input().split())

numList = []
for _ in range(N):
    numList.append(list(map(int, input().split())))

numList.sort(key=lambda x:x[0])

idx = 0
while True:
    K = K - numList[idx][1]
    if K <= 0:
        print(numList[idx][0])
        exit()
    idx = idx + 1
### BUGGY CODE ###

def minjump(li , lir):
    #print(li,lir)
    if tuple(li) in lir.keys():
        return lir[tuple(li)]
    else:
        if(len(li)<2):
            return 0 
        elif(len(li) == 2):
            lir[tuple(li)] = abs(li[0]-li[1])
            return lir[tuple(li)]   
        else:
            val1 = abs(li[0]-li[1])+minjump(li[1:],lir)
            val2 = abs(li[0]-li[2])+minjump(li[2:],lir)
            lir[tuple(li)] = min(val1,val2)
            #print(li,lir[tuple(li)])
            return lir[tuple(li)] 

t= int(input())
num = list(map(int,input().split()))
listi = dict()
print(minjump(num,listi))


### FIXED CODE ###

n  = int(input())
k = 2
num = list(map(int,input().split()))
numval = list()
for data in range(n):
    numval.append(1000000000)
numval[0] = 0
i = 0
if(n<k):
    k = n-1
for i in range(0,n):
    for data in range(1,k+1):
        if(i+data)>=n:
            break
        numval[i+data] = min(numval[i+data],numval[i]+abs(num[i]-num[i+data]))
    i += 1
print(numval[n-1])