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

import queue
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans = [[0]*n for _ in range(n)]
    t = [[i+1, i-1] for i in range(n)]
    t[x].append(y)
    t[y].append(x)
    q = queue.Queue()
    for i in range(n):
        f = [True]*n
        f[i] = False
        q.put([i, 0])
        while not q.empty():
            a, b = q.get()
            for v in t[a]:
                if 0 < v and v < n:
                    if f[v]:
                        if i < v:
                            ans[i][b + 1] += 1
                        f[v] = False
                        if i < v or (i <= (x+y+1)//2 and x <= v):
                            q.put([v, b+1])
    for i in range(1, n):
        p = 0
        for j in range(n):
            p += ans[j][i]
        print(p)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import queue
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans = [0]*n
    t = [[i+1, i-1] for i in range(n)]
    t[x].append(y)
    t[y].append(x)
    for i in range(n):
        for j in range(i+1, n):
            if j <= x:
                ans[j-i] += 1
            elif j <= y:
                buf = min(j-i, abs(i-x) + 1 + (y-j))
                ans[buf] += 1
            else:
                buf = min(y-i, abs(x-i)+1)
                ans[buf + (j-y)] += 1
    for i in range(1, n):
        print(ans[i])
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import defaultdict
n, p = map(int, input().split())
s = input()

# dp[i][j] = (s[i]で終わる部分文字列で、pで割ったあまりがjな数の個数)
dp = [defaultdict(int), defaultdict(int)]

ans = 0
for i in range(n):
    i0, i1 = (i + 0) % 2, (i + 1) % 2
    dp[i1] = defaultdict(int)
    for j in dp[i0]:
        dp[i1][(j * 10 + int(s[i])) % p] += dp[i0][j]
    dp[i1][int(s[i]) % p] += 1

    ans += dp[i1][0]
    # print(dp[i1])

print(ans)


### FIXED CODE ###

from collections import defaultdict


def comb(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    k = min(k, n - k)
    ans = 1
    for i in range(1, k + 1):
        ans *= n - i + 1
        ans //= i
    return ans


n, p = map(int, input().split())
s = input()

if p == 2:
    ans = 0
    for i in range(n):
        if int(s[i]) % 2 == 0:
            ans += i + 1
elif p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) in [0, 5]:
            ans += i + 1
else:
    mod_list = [0] * (n + 1)
    d = 1
    for i in reversed(range(n)):
        mod_list[i] = int(s[i]) * d + mod_list[i + 1]
        mod_list[i] %= p
        d = (d * 10) % p

    mod_dict = defaultdict(int)
    for i in range(n + 1):
        mod_dict[mod_list[i]] += 1

    # print(mod_list)
    # print(mod_dict)

    ans = 0
    for c in mod_dict:
        ans += comb(mod_dict[c], 2)

print(ans)
### BUGGY CODE ###

s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        cntANext = 0
        for j in range(0, cntA):
            ans += 1
            cntANext += 1
        cntA = cntANext
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
# print(*data, sep='\n')


### FIXED CODE ###

s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        ans += cntA
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
# print(*data, sep='\n')
### BUGGY CODE ###

X = int(input())
mod = X % 100
q = int(X //100)
sum = 0
ans = 0
for i in range (0,q+1):
    for j in range (0,q+1-i):
        for k in range (0,q+1-i-j):
            for l in range (0,q+1-i-k-j):
                for m in range (0,q+1-i-j-k-l):
                    sum = i+(2*j)+(3*k)+(4*l)+(5*m)
                    if sum == mod:
                        ans = 1
print(ans)


### FIXED CODE ###

X = int(input())
mod = X % 100
q = int(X //100)
sum = 0
ans = 0
if q >= 20:
    ans = 1
else:
    for i in range (0,q+1):
        for j in range (0,q+1-i):
            for k in range (0,q+1-i-j):
                for l in range (0,q+1-i-k-j):
                    for m in range (0,q+1-i-j-k-l):
                        sum = i+(2*j)+(3*k)+(4*l)+(5*m)
                        if sum == mod:
                            ans = 1
print(ans)
### BUGGY CODE ###

s=input()
l=len(s)
se=dict()
k=0
for i in range(l-1,-1,-1):
    k+=((10**(l-1-i))*int(s[i]))
    k%=2019
    if k in se:
        se[k]+=1
    else:
        se[k]=1

ans=0
for j in se:
    i=se[j]
    if i>1:
        ans+=(i*(i-1)//2)
    if j==0:
        ans+=i
print(ans)

### FIXED CODE ###

s=input()
l=len(s)
se=dict()
k=0
for i in range(l-1,-1,-1):
    #print(0)
    k+=(pow(10,l-1-i,2019)*int(s[i]))
    k%=2019
    if k in se:
        se[k]+=1
    else:
        se[k]=1

ans=0
for j in se:
    i=se[j]
    if i>1:
        ans+=(i*(i-1)//2)
    if j==0:
        ans+=i
print(ans)
### BUGGY CODE ###

N = int(input())
a = input().split()
number = 1
for i in a[:N]:
    number *= int(i)


if number>1000000000000000000:
    number = -1

print(number)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
number =1

if 0 in a:
    print(0)
    exit()

for i in a:
    number *= i
    if number > 10**18:
            print(-1)
            exit()

print(number)
### BUGGY CODE ###

def makeRelation():
  for n in range(1,N+1):
    visited=set((n,))
    D[n].add(n)
    while visited:
      v=visited.pop()
      for i in F[v]:
        if i not in D[n]:
          visited.add(i)
          D[n].add(i)
          #D[i].add(n)


def main():
  makeRelation()
  #print(D)
  ans=[0]*(N+1)
  for n in range(1, N+1):
  	ans[n]=len(D[n]) - len(F[n]) - len(D[n]&set(B[n])) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[[] for n in range(N+1)]
  for m in range(M):
    a, b = map(int, input().split())
    F[a]+=[b]
    F[b]+=[a]
  B=[[] for n in range(N+1)]
  for k in range(K):
    c, d = map(int, input().split())
    B[c]+=[d]
    B[d]+=[c]
  D=[set() for n in range(N+1)]
  #print(F)
  #print(B)
  main()

### FIXED CODE ###

def makeRelation():
  visited=[False]*(N+1)
  g=0 # group
  for n in range(1,N+1):
    if visited[n]:
      continue
    q={n}
    D.append(set())
    while q:
      j=q.pop()
      for i in F[j]: # search for friend
        if not visited[i]:
          visited[i]=True
          q.add(i)
          D[g]|={i}
    g+=1
    
def main():
  makeRelation()
  #print(D)
  for g in D:
    for d in g:
      ans[d]=len(g) - len(F[d]) - len(g&B[d]) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[set() for n in range(N+1)]
  AB=[list(map(int, input().split())) for m in range(M)]
  for a,b in AB:
    F[a].add(b)
    F[b].add(a)
  B=[set() for n in range(N+1)]
  CD=[list(map(int, input().split())) for k in range(K)]
  for c,d in CD:
    B[c].add(d)
    B[d].add(c)
  D=[]
  #print(F)
  #print(B)
  ans=[0]*(N+1)
  main()
### BUGGY CODE ###

n,k=map(int,input().split())
m=10**9+7

k=min(k,n-1)
c=[1]+[0]*k
h=[1]+[0]*k

for i in range(1,k+1):
  c[i]=c[i-1]*(n-i+1)* pow(i,m-2,m)
  h[i]=h[i-1]*(n-i)  * pow(i,m-2,m)

t=0
for i in range(k+1):
  t+=(c[i]*h[i])%m

print(t%m)


### FIXED CODE ###

n,k=map(int,input().split())
m=10**9+7

k=min(k,n-1)
t,c,h=1,1,1
for i in range(1,k+1):
  p=pow(i,m-2,m)
  c=(c*(n-i+1)* p)%m
  h=(h*(n-i)  * p)%m
  t=(t+c*h)%m

print(t%m)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
import sys
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n=int(input())
    graph = [[] for _ in range(n)]
    for _ in range(n-1):
        a,b,w=map(int,input().split())
        a-=1
        b-=1
        graph[a].append((b,w))
        graph[b].append((a,w))
    graph = tuple(graph)
    q,k = map(int,input().split())
    pre1 = []
    pre2 = []
    for e in range(n):
        que = [e]
        dis = [0 for _ in range(n)]
        did = [False for _ in range(n)]
        did[e] = True
        if e == k-1:
            pre1.append(0)
        while que:
            tank = []
            for i in que:
                for j in range(len(graph[i])):
                    go = graph[i][j][0]
                    d = graph[i][j][1]
                    if did[go]:
                        continue
                    dis[go] = dis[i] + d
                    if k-1 == go:
                        pre1.append(dis[go])
                        tank=[]
                        que=[]
                        break
                    tank.append(go)
                    did[go] = True
            que = tank
        
    que = [k-1]
    dis = [0 for _ in range(n)]
    did = [False for _ in range(n)]
    did[k-1] = True
    while que:
        tank = []
        for i in que:
            for j in range(len(graph[i])):
                go = graph[i][j][0]
                d = graph[i][j][1]
                if did[go]:
                    continue
                dis[go] = dis[i] + d
                tank.append(go)
                did[go] = True
        que = tank
    pre2 = dis
 
    pre1 = tuple(pre1)
    pre2 = tuple(pre2)
    for _ in range(q):
        x,y = map(int,input().split())
        print( pre1[x-1] + pre2[y-1] ) 

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter,defaultdict,deque
import sys
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n=int(input())
    graph = [[] for _ in range(n)]
    for _ in range(n-1):
        a,b,w=map(int,input().split())
        a-=1
        b-=1
        graph[a].append((b,w))
        graph[b].append((a,w))
    graph = tuple(graph)
    q,k = map(int,input().split())
    que = deque([k-1])
    dis = [-1 for _ in range(n)]
    dis[k-1]=0
    while que:
        i = que.pop()
        for j in range(len(graph[i])):
            go = graph[i][j][0]
            d = graph[i][j][1]
            if dis[go]==-1:
                dis[go] = dis[i] + d
                que.append(go)
    for _ in range(q):
        x,y = map(int,input().split())
        print( dis[x-1] + dis[y-1] ) 

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

from collections import deque

h, w = map(int, input().split())

todo = deque([])
draw = ((1, 0), (-1, 0), (0, 1), (0, -1))
done = [[1] * (w + 2)]
for i in range(h):
    done.append([1] + [0 for _ in range(w)] + [1])
done.append([1] * (w + 2))

grid = [list("#" * (w + 2))]
for i in range(h):
    s = input()
    for j, k in enumerate(s):
        if k == "#":
            todo.append((i + 1, j + 1))
            done[i + 1][j + 1] = 1
    grid.append(list("#" + s + "#"))
grid.append(list("#" * (w + 2)))

cnt = 0
while todo:
    tmp = deque([])
    while todo:
        n, m = todo.popleft()
        for dn, dm in draw:
            if done[n + dn][m + dm] != 0:
                pass
            elif grid[n + dn][m + dm] == "#":
                pass
            elif grid[n + dn][m + dm] == ".":
                tmp.append((n + dn, m + dm))
                done[n + dn][m + dm] = 1
                grid[n + dn][m + dm] = "#"
    todo = tmp
    cnt += 1

print(cnt - 1)

### FIXED CODE ###

import numpy as np

h, w = map(int, input().split())
grid = (np.array([list(input())
                  for _ in range(h)]) == "#")
cost = np.full((h, w), 10 ** 9, dtype=np.int64)
cost[grid[:, :]] = 0

for i in range(1, h):
    cost[i] = np.minimum(cost[i], cost[i - 1] + 1)

for i in range(h - 1)[::-1]:
    cost[i] = np.minimum(cost[i], cost[i + 1] + 1)

for i in range(1, w):
    cost[:, i] = np.minimum(cost[:, i], cost[:, i - 1] + 1)

for i in range(w - 1)[::-1]:
    cost[:, i] = np.minimum(cost[:, i], cost[:, i + 1] + 1)

print(np.max(cost))
### BUGGY CODE ###

def resolve():
    import sys
    import numpy as np

    read = sys.stdin.read
    readline = sys.stdin.readline

    N, K = map(int, readline().split())
    h = np.array(read().split(), np.int32)

    # 貰うDP
    inf = 10 ** 9
    dp = np.full(N, inf, np.int32)
    dp[0] = 0

    for i in range(1, N):
        leng = i + 1 if i < K else K + 1
        val = h[i]
        for j in range(leng):
            # 高速化ののため，min関数ではなくif文を使用
            cal = dp[i - j] + abs(val - h[i - j])
            if dp[i] > cal:
                dp[i] = cal

    print(dp[-1])
            

resolve()


### FIXED CODE ###

def resolve():
    import sys
    
    readline = sys.stdin.readline

    N, K = map(int, readline().split())
    h = [int(x) for x in readline().split()]

    inf = float('inf')
    dp = [inf] * N
    dp[0] = 0

    for i in range(1, N):
        leng = i + 1 if i < K else K + 1
        for j in range(leng):
            cal = dp[i - j] + abs(h[i] - h[i - j])
            if dp[i] > cal:
                dp[i] = cal

    print(dp[-1])
            

resolve()
### BUGGY CODE ###

def fennec_vs_monster():
    # 入力
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    # 体力リストの大きい順からK個だけ排除
    for i in range(K):
        # 体力リストが空でないときは以下を実行
        if i < N:
            max_H = max(H)
            H.remove(max_H)
    # 残りの体力リストを合計
    sum_H = sum(H)
    # 攻撃の回数の最小値
    return sum_H

result = fennec_vs_monster()
print(result)

### FIXED CODE ###

def fennec_vs_monster():
    # 入力
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    # 体力リストを降順でソート
    H.sort(reverse=True)
    # 体力リストを先頭からK個だけ除外
    H = H[K:]
    # 残りの体力リストを合計
    sum_H = sum(H)
    # 攻撃の回数の最小値
    return sum_H

result = fennec_vs_monster()
print(result)
### BUGGY CODE ###

n = int(input())
a_lst = list(map(int, input().split()))

for i in range(n):
  d = 0
  lst = a_lst[:i] + a_lst[i+1:]
  for i, elem in enumerate(lst):
    if i == 0:
      d += abs(elem)
    else:
      d += abs(elem - lst[i-1])
  d += abs(lst[-1])
  print(d)

### FIXED CODE ###

n = int(input())
a = [0]
a += list(map(int, input().split()))
a.append(0)
d = []
for i in range(n + 1):
  d.append(abs(a[i] - a[i + 1]))
s = sum(d)
for i in range(n):
  print(s - d[i] - d[i + 1] + abs(a[i] - a[i + 2]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import heapq

def dijkstra(n, graph, s, yen=True):
    dist = [10**18] * n
    queue = [(s, 0)]
    dist[s] = 0
    while queue:
        v, d = heapq.heappop(queue)
        if dist[v] < d:
            continue
        for child, costa, costb in graph[v]:
            if yen:
                cost = costa
            else:
                cost = costb
            if dist[v] + cost < dist[child]:
                dist[child] = dist[v] + cost
                heapq.heappush(queue, (child, dist[child]))
    return dist

def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    s_graph = [[] for _ in range(n)]
    t_graph = [[] for _ in range(n)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        s_graph[u].append((v, a, b))
        s_graph[v].append((u, a, b))
        t_graph[u].append((v, a, b))
        t_graph[v].append((u, a, b))
    s_dist = dijkstra(n, s_graph, s, True)
    t_dist = dijkstra(n, t_graph, t, False)

    cost = 10 ** 18
    ans = []
    for i in range(n-1, -1, -1):
        cost = min(cost, s_dist[i] + t_dist[i])
        ans.append(10 ** 15 - cost)
    for x in reversed(ans):
        print(x)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from heapq import heappop, heappush
INF = 10 ** 18

def dijkstra(n, s, g, mode):
    dist = [INF] * n
    dist[s] = 0
    hq = [(0, s)]
    while hq:
        d, v = heappop(hq)
        if dist[v] < d:
            continue
        for w, *a in g[v]:
            nd = d + a[mode]
            if dist[w] > nd:
                dist[w] = nd
                heappush(hq, (nd, w))
    return dist

def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    graph = [[] for _ in range(n)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))
    s_dist = dijkstra(n, s, graph, 0)
    t_dist = dijkstra(n, t, graph, 1)

    cost = float("inf")
    ans = [0] * n
    for i in range(n-1, -1, -1):
        cost = min(cost, s_dist[i] + t_dist[i])
        ans[i] = 10 ** 15 - cost
    print(*ans, sep="\n")


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

S = input()
Q = int(input())

jun = True

for _ in range(Q):
    tmpS = S
    T = input().split()
    if T[0] == "1":
        jun = not jun
    if T[0] == "2":
        if T[1] == "1":
            S = T[2] + tmpS if jun else tmpS + T[2]
        if T[1] == "2":
            S = tmpS + T[2] if jun else T[2] + tmpS
if jun:
    print(S)
else:
    print(S[::-1])

### FIXED CODE ###

S = input()
Q = int(input())

jun = True
head = ""

for _ in range(Q):
    T = input().split()
    if T[0] == "1":
        jun = not jun
    
    else:

        if (T[1] == "1" and jun) or (T[1] == "2" and not jun):
            head += T[2]
            continue

        else:
            S += T[2]

if jun:
    print(head[::-1] + S)
else:
    print(S[::-1] + head)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    x = 0
    y = 0
    if i >= 1:
        x = max(a[:i])
    if i < n - 1 :
        y = max(a[i+1:])
    print(max(x,y))

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

maxa = max(a)
maxb = max(a)
cntmax = a.count(maxa)
if cntmax >= 2:
    for i in range(n):
        print(maxa)
    exit()
else:
    maxi = a.index(maxa)
    x = 0
    y = 0
    if maxi >= 1:
        x = max(a[:maxi])
    if maxi < n - 1 :
        y = max(a[maxi+1:])
    maxb = max(x,y)

for i in a:
    if i == maxa:
        print(maxb)
    else:
        print(maxa)
### BUGGY CODE ###

n, m = map(int, input().split())
ab = sorted(list(map(int, input().split())) for _ in range(m))


def dfs(now, count):
    if count > 2:
        pass
    elif visit[n] == 0:
        visit[now] = 1
        for x in graph[now]:
            dfs(x, count + 1)


flag = False
if ab[0][0] == 1:
    graph = [[] for _ in range(n + 1)]
    for a, b in ab:
        graph[a].append(b)
        graph[b].append(a)

    visit = [0] * (n + 1)
    visit[1] = 1

    dfs(1, 0)

    if visit[n] == 1:
        flag = True

print('POSSIBLE') if flag else print('IMPOSSIBLE')


### FIXED CODE ###

n, m = map(int, input().split())
ab = sorted(list(map(int, input().split())) for _ in range(m))


def dfs(now, count):
    if count <= 2 and visit[n] == 0:
        visit[now] = 1
        if count <= 1:
            for x in graph[now]:
                dfs(x, count + 1)


flag = False
if ab[0][0] == 1:
    graph = [[] for _ in range(n + 1)]
    for a, b in ab:
        graph[a].append(b)
        graph[b].append(a)

    visit = [0] * (n + 1)
    dfs(1, 0)

    if visit[n] == 1:
        flag = True

print('POSSIBLE') if flag else print('IMPOSSIBLE')
### BUGGY CODE ###

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

a = list(a)
for i in range(n):
    print(a.count(i + 1))


### FIXED CODE ###

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

a = list(a)
result = [0] * n
for i in range(n - 1):
    result[a[i] - 1] += 1

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

import sys
input = sys.stdin.readline

def ncr(n,r,p):
    num = den = 1
    for i in xrange(r):
        num = (num * (n-i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p-2, p)) % p

n,m,k = (int(x) for x in input().split())
p = 998244353
ans = 0
for i in xrange(k+1):
    ans += m*pow(m-1, n-i-1,p) * ncr(n-1,i,p)
    ans = ans % p 
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

f = [(1,1), ]

def ncr(n,r,p):
    num = (f[-1][0] * (n-(r-1))) % p
    den = (f[-1][1] * ((r-1) + 1)) % p
    f.append([num, den])
    return (num * pow(den, p-2, p)) % p

n,m,k = (int(x) for x in input().split())
p = 998244353
ans = 0

for i in range(k+1):
    if i == 0:
        ans += m*pow(m-1, n-i-1,p)
    else:
        ans += m*pow(m-1, n-i-1,p) * ncr(n-1,i,p)
    ans = ans % p 
print(ans)
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))

j = 0

for i in range(1,n+1):
  lii = sorted(li[0:i])
  if lii[0] == li[i-1]:
    j = j + 1

print(j)


### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))

i = 0
j = 0
a = 10**6
for i in range(i,n):
  a = min(a,li[i])
  if a == li[i]:
    j = j + 1

print(j)
### BUGGY CODE ###

t=int(input())
for _ in range(t):
    a,b,c,d=map(int,input().split())
    e=b*(max((a-c)//b,1))
    a-=e
    while a>c:
        a-=b
    if a<0:
        print('No')
        continue
    if d<b:
        print('No')
        continue
    if c<=b and d>b:
        """
        while a<=c:
            a+=(d-b)
        """
        a+=(d-b)*((c-a)//(d-b))
        while a<=c:
            a+=(d-b)
        if a<b:
            print('No')
            continue
        else:
            f=a-b
            ff=0
            for __ in range(50000):
                f+=(d-b)*((c-f)//(d-b))
                while f<=c:
                    f+=(d-b)
                if f<b:
                    print('No')
                    ff=1
                    break
                f=f-b
            if ff:continue
    print('Yes')
    


### FIXED CODE ###

from fractions import*
_,*t=open(0)
for t in t:
  a,b,c,d=map(int,t.split())
  g=gcd(b,d)
  print('YNeos'[b>min(a,d)or b-g+a%g>c::2])
### BUGGY CODE ###

N=int(input())
IDs =list(map(int,input().split()))

for i in range(1,N+1):
    array = [x for x in IDs if x==i]
    print(len(array))

### FIXED CODE ###

N=int(input())
IDs =list(map(int,input().split()))

from collections import Counter

c=Counter(IDs)

for i in range(1,N+1):
    print(c[i])
### BUGGY CODE ###

from collections import Counter

def is_anagram(s1,s2):
  cnt_s1 = Counter(s1)
  for key in cnt_s1:
    if s2.count(key) != cnt_s1[key]:
      return False
  return True

N = int(input())
S = [input() for _ in range(N)]
used = [False for _ in range(N)]
ans = 0
for i in range(N-1):
  if used[i]==True:
    continue
  tmp_ans = 0
  for j in range(i+1,N):
    if used[j]==True:
      continue
    if is_anagram(S[i],S[j]):
      tmp_ans += 1
      used[i], used[j] = True, True
  
  ans += (tmp_ans+1)*tmp_ans//2 
print(ans)

### FIXED CODE ###

import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)