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

N=int(input())
S=list(input())
ans=0
R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i)
    elif S[i]=="G":
        G.append(i)
    else:
        B.append(i)
for r in R:
    for g in G:
        for b in B:
            a=r+g+b
            e=max(r,g,b)
            d=min(r,g,b)
            c=a-e-d
            if e-c!=c-d:
                ans+=1
print(ans)


### FIXED CODE ###

N=int(input())
S=list(input())
ans=0
R=0
G=0
B=0
for i in range(N):
    if S[i]=="R":
        R=R+1
    elif S[i]=="G":
        G=G+1
    else:
        B=B+1
ans=R*G*B
for i in range(N-2):
    for j in range(i+1,N-1):
        if S[i]!=S[j]:
            k=2*j-i
            if N<=k:
                continue
            if S[i]!=S[k] and S[k]!=S[j]:
                ans=ans-1
print(ans)
### BUGGY CODE ###

import numpy as np
import sys
import collections
import copy
deque=collections.deque
fastinput=sys.stdin.readline
H,W=map(int,input().split())
A=[list(fastinput().rstrip()) for j in range(H)]
went=[[False]*W for i in range(H)]
queue=deque()
for x,i in enumerate(A):
    for y,j in enumerate(i):
        if j=="#":
            went[x][y]=True
            queue.append((x,y,0))
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in ((1,0),(-1,0),(0,1),(0,-1)):
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append((newx,newy,newct))
print(ct)

### FIXED CODE ###

import collections
H,W=map(int,input().split())
went=[[False]*W for i in range(H)]
queue=collections.deque()
for hoge in range(H):
    for huga,t in enumerate(input()):
        if t=="#":
            went[hoge][huga]=True
            queue.append([hoge,huga,0])
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append([newx,newy,newct])
print(ct)
### BUGGY CODE ###

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

while(abs(n-k) <= abs(pre-k)):
    if n % k == 0:
        n = 0
        break
    pre = n
    n = abs(n-k)

print(n)

### FIXED CODE ###

n, k = map(int, input().split())
rem = n % k

print(min(rem, abs(rem-k)))
### BUGGY CODE ###

s = input()
q = int(input())

for i in range(q):
  query = list(map(str, input().split()))
  if query[0] == "1":
    s = s[::-1]
  else:
    f = query[1]
    c = query[2]
    if f == "1":
      s = c + s
    else:
      s = s + c

print(s)

### FIXED CODE ###

from collections import deque

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

S = deque(S)
rev = 1
for _ in range(Q):
    query = input()
    if len(query) == 1:
        rev *= -1
    else:
        T, F, C = query.split()
        if rev == 1:
            if F == "1":
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if F == "1":
                S.append(C)
            else:
                S.appendleft(C)

if rev == -1:
    S = reversed(S)

print("".join(S))
### BUGGY CODE ###

def main():
    import copy

    H, W = map(int, input().split())
    g = []
    cnt = 0
    for _ in range(H):
        A = str(input())
        row = []
        for i in range(W):
            row.append(A[i])
            if A[i] == '#':
                cnt += 1
        g.append(row)
    ans = 0
    dh = [1, 0, 0, -1]
    dw = [0, -1, 1, 0]
    while cnt < H * W:
        ans += 1
        newg = copy.deepcopy(g)
        for h in range(H):
            for w in range(W):
                if g[h][w] == '#':
                    for i in range(4):
                        nh = h + dh[i]
                        nw = w + dw[i]
                        if 0 <= nh < H and 0 <= nw < W and g[nh][nw] == '.' and newg[nh][nw] != '#':
                            newg[nh][nw] = '#'
                            cnt += 1
        g = newg
    print(ans)
main()


### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    g = []
    q = []
    cnt = 0
    for h in range(H):
        A = str(input())
        row = []
        for w in range(W):
            row.append(A[w])
            if A[w] == '#':
                cnt += 1
                q.append([h, w])
        g.append(row)
    ans = 0
    dh = [1, 0, 0, -1]
    dw = [0, -1, 1, 0]
    while cnt < H * W:
        ans += 1
        nextq = []
        while q:
            h, w = q.pop()
            for i in range(4):
                nh = h + dh[i]
                nw = w + dw[i]
                if 0 <= nh < H and 0 <= nw < W and g[nh][nw] == '.':
                    g[nh][nw] = '#'
                    nextq.append([nh, nw])
                    cnt += 1
        q = nextq
    print(ans)
main()
### BUGGY CODE ###

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

from functools import reduce
import fractions

def gcd(num_list):
    return reduce(fractions.gcd, num_list)

kys = []

for i in range(N):
    B = A.copy()
    B.pop(i)
    kys.append(gcd(B))

print(max(kys))

### FIXED CODE ###

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

index = list(range(N))
L = index.copy()

L[0] = 0
for i in index[:-1]:
    #print(i)
    L[i+1] = gcd(L[i], A[i])

R = index.copy()
R.append(0)
for i in reversed(index):
    #print(i)
    R[i] = gcd(R[i+1], A[i])

# confirm
#print(L)
#print(R)

M = []
for j in range(len(L)):
    m = gcd(L[j], R[j+1])
    #print(m)
    M.append(m)

# Confirm
#print(M)

# Answer
print(max(M))
### BUGGY CODE ###

r,g,b,n = map(int, input().split())

ans = 0
for i in range(n+1):
    for j in range(n+1):
        if (n - i*r - j*g) >= 0 and (n -i*r -j*g)%b == 0:
            ans += 1
            
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())

cnt = 0

for i in range(N//R + 1):
    for j in range(N//G + 1):
        sum = N - i * R - j * G
        if sum >= 0 and sum % B == 0:
            cnt += 1

print(cnt)
### BUGGY CODE ###

def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N = int(input())
    *p, = (int(x) - 1 for x in input().split())

    H = [[-1] * (N + 1) for _ in range(N + 1)]  # 離席コスト,J字にコスト-1の区画を設ける
    for r in range((N + 1) // 2 + 1):
        dr = min(r, N - 1 - r)
        for c in range((N + 1) // 2 + 1):
            dc = min(c, N - 1 - c)
            H[r][c] = H[N - 1 - r][c] = H[N - 1 - r][N - 1 - c] = H[r][N - 1 - c] = min(dr, dc)
    S = [[1] * N for _ in range(N)]  # 着席

    ans = 0
    for pi in p:
        pi_r, pi_c = divmod(pi, N)

        hpi = H[pi_r][pi_c]  # piの離席コスト
        ans += hpi  # piの離席コストを加算
        S[pi_r][pi_c] = 0  # piを空席にする

        # BFSで離席コストを更新
        dq = deque()
        dq.append((pi_r, pi_c, hpi))
        while dq:
            r, c, h = dq.popleft()
            for nr, nc in ((r - 1, c), (r, c - 1), (r + 1, c), (r, c + 1)):
                if H[nr][nc] > h:
                    H[nr][nc] = h
                    dq.append((nr, nc, h + S[nr][nc]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def build_cost_table(n):
    ret = [-1] * (n ** 2)
    for r in range(n):
        dr = min(r, n - 1 - r)
        for c in range(n):
            dc = min(c, n - 1 - c)
            ret[r * n + c] = min(dr, dc)
    return ret


def main():
    from collections import deque

    N = int(input())
    *p, = (int(x) - 1 for x in input().split())

    H = build_cost_table(N)  # 離席コスト
    S = [1] * (N ** 2)  # 着席

    ans = 0
    for pi in p:
        hpi = H[pi]  # piの離席コスト
        ans += hpi  # piの離席コストを加算
        S[pi] = 0  # piを空席にする

        # BFSで離席コストを更新
        dq = deque()
        dq.append((pi, hpi))
        while dq:
            x, h = dq.popleft()
            r, c = divmod(x, N)

            nx = x - N
            if r != 0 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

            nx = x + N
            if r != N - 1 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

            nx = x - 1
            if c != 0 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

            nx = x + 1
            if c != N - 1 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

    print(ans)


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

N,K,Q=map(int, input().split())
M=K-Q
A=[]
for i in range(0,Q):
    A.append(int(input()))
for i in range(0,N):
    if M+A.count(i+1)>0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K,Q=map(int, input().split())
M=K-Q
A=[M]*N
for i in range(Q):
    B=int(input())
    A[B-1]+=1
for i in range(N):
    if A[i]<1:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

s = open(0).read().rstrip()

state = [1]*len(s)

# from collections import defaultdict

# d = defaultdict(int)
d = set()
i = 0

def transit(l, s):
    tmp = [0]*len(l)
    for i in range(len(l)):
        if s[i] == 'R':
            tmp[i+1] += l[i]
        else:
            tmp[i-1] += l[i]
    return tmp

d.add(tuple(state))

while 1:
    state = transit(state, s)
    i += 1
    tup = tuple(state)
    if tup in d:
        break
    d.add(tup)

if i%2:
    state = transit(state, s)

print(*state)

### FIXED CODE ###

s = input().rstrip() + 'X'

r_cnt = l_cnt = 0
is_r = True
begin_l = None
ans = [0] * (len(s)-1)
for i in range(len(s)):
    if is_r and s[i] == 'R':
#         print(f'{i}: R')
        r_cnt += 1
    elif not is_r and s[i] == 'L':
#         print(f'{i}: L')
        l_cnt += 1
    elif s[i] == 'L':
#         print(f'{i}: R>L')
        is_r = False
        l_cnt = 1
        begin_l = i
    else:
#         print(f'{i}: L>?')
        is_r = True
#         print(l_cnt, r_cnt)
        tot = l_cnt + r_cnt
        small = tot//2
        large = tot - small
        if r_cnt%2:
            ans[begin_l-1] = large 
            ans[begin_l] = small
        else:
            ans[begin_l-1] = small
            ans[begin_l] = large
        r_cnt = 1
        l_cnt = 0

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

N = int(input())
nums = [input() for _ in range(N)]

paper = []
for num in nums:
    if num not in paper:
        paper.append(num)
    else:
        paper.remove(num)

print(len(paper))

### FIXED CODE ###

n = int(input())
nums = [int(input()) for _ in range(n)]
cnt = {}
ans = 0
for x in nums:
    if x not in cnt:
        cnt[x] = 1
    else:
        cnt[x] += 1
for y in cnt.values():
    if y % 2 != 0:
        ans += 1

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

import heapq
def SME(Whole,start,end,L,ANS):
    A = []
    if end > N : end = N
    count = 0
    count2 = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        tmp = count
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] == 0 and idx < end:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count == tmp : count2 += 1
        if count2 > 100 : break
    for i in range(L):
        if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ANS = [0]*N
start = 0
K = L * int(N ** 0.3 + 2 )
if K > N : K = N
end = K
while (end <= N):
    ANS = SME(A, start, end, L, ANS)
    start = end
    end += K 
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

N,M=map(int,input().split())
LA=list(map(int,input().split()))
for m in range(M):
    B,C=map(int,input().split())
    LA.extend([C]*B)
LA.sort(reverse=True)
print(sum(LA[0:N]))

### FIXED CODE ###

N,M=map(int,input().split())
LA=list(map(int,input().split()))
L=[]
for i in LA:
    L.extend([[1,i]])
for m in range(M):
    B,C=map(int,input().split())
    L.extend([[B,C]])
L.sort(key=lambda _:_[1] ,reverse=True)

ans=0
n=0
x=0
while x<=N-1:
    y=0
    while y<=L[n][0]-1:
        ans+=L[n][1]
        y+=1
        x+=1
        if x==N:
            break
        else:
            pass
    n+=1

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

N, Q = map(int, input().split())
S = input()

for count in range(Q):
    l, r = map(int, input().split())
    count = 0

    for i in range(len(S[l-1: r])-1):

        if S[l-1 + i: l-1 + i +2 ] == "AC":    
            count += 1
    print(count)



### FIXED CODE ###

N, Q = map(int, input().split())
data = input()
result = [0] * N
for i in range(N-1):
  if data[i] == "A" and data[i+1] == "C":
    result[i+1] = result[i] + 1
  else:
    result[i+1] = result[i]

for i in range(Q):
  l, r = map(int, input().split())
  print(result[r-1]-result[l-1])
### BUGGY CODE ###

#!/usr/bin/env python3

# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence

Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])

    codList: Set[Cod] = []
    for i in range(M):
        args = input().split()
        codList.append((int(args[0]), int(args[1])))

    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H

    for item in codList:
        columnSumList[item[1] - 1] += 1
        rowSumList[item[0] - 1] += 1

    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]

    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if (row + 1, column + 1) in codList:
                continue
            else:
                print(result)
                return

    print(result - 1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence

Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])

    codList = {}
    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H
    for i in range(M):
        h, w = map(lambda x: int(x), input().split())
        item = (h, w)
        codList.setdefault(h, {})
        codList[h][w] = item
        columnSumList[w - 1] += 1
        rowSumList[h - 1] += 1

    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]

    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if row + 1 in codList and column + 1 in codList[row + 1]:
                continue
            else:
                print(result)
                return

    print(result - 1)


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

s = input()
maximum = [(0, [()])]

s = tuple(s)
for i in range(1, len(s) + 1):
    j = i - 1
    while j >= 0:
        max_count, previous = maximum[j]
        if max_count < 0:
            j -= 1
            continue
        current = s[j:i]
        if any(p != current for p in previous):
            if len(maximum) == i + 1:
                mc, blocks = maximum[i]
                if mc == max_count + 1:
                    blocks.append(current)
                    break
            else:
                maximum.append((max_count + 1, [current]))
        j -= 1
    else:
        if len(maximum) != i + 1:
            maximum.append((-1, []))
    assert len(maximum) == i + 1

print(maximum[-1][0])

### FIXED CODE ###

s = input()
maximum = [(0, [()])]

s = tuple(s)
for i in range(1, len(s) + 1):
    j = i - 1
    while j >= 0:
        max_count, previous = maximum[j]
        if max_count < 0:
            j -= 1
            continue
        current = s[j:i]
        if any(p != current for p in previous):
            if len(maximum) == i + 1:
                mc, blocks = maximum[i]
                if mc == max_count + 1:
                    blocks.append(current)
                break
            else:
                maximum.append((max_count + 1, [current]))
        j -= 1
    else:
        if len(maximum) != i + 1:
            maximum.append((-1, []))
    assert len(maximum) == i + 1

print(maximum[-1][0])
### BUGGY CODE ###

# coding: utf-8
from itertools import permutations


def solve(*args: str) -> str:
    k, n = map(int, args[0].split())
    A = list(map(int, args[1].split()))

    ret = k+1
    for P in permutations(A):
        total = 0
        cur = P[0]
        for a in P[1:]:
            total += min(abs(k-a)+cur, abs(a-cur))
            cur = a
        ret = min(ret, total)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


### FIXED CODE ###

# coding: utf-8


def solve(*args: str) -> str:
    k, n = map(int, args[0].split())
    A = list(map(int, args[1].split()))

    D = [k-A[-1]+A[0]] + [A[i+1]-A[i] for i in range(n-1)]

    return str(k-max(D))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
### BUGGY CODE ###

n,k=map(int,input().split())
c=list(map(int,input().split()))
dp=[0]
for i in range(1,n):
    dp.append(min([dp[j]+abs(c[i]-c[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()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

nums, jump = list(map(int, input().split()))
height = list(map(int,input().split()))
dp = [0 for i in range(nums)]

for i in range(1,nums):
    c = float("inf")
    for x in range(1,jump+1):
        if i-x < 0: continue
        check = dp[i-x] + abs(height[i-x] - height[i])
        if check < c:
            c = check
            dp[i] = c

print(dp[nums-1])

### FIXED CODE ###

import numpy as np

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

h = np.array(h)
dp = np.zeros(n, dtype=int)

for i in range(1,n):
    m = max(0,i-k)
    dp[i] = min(dp[m:i] + np.abs(h[i] - h[m:i]))
print(dp[n-1])
### BUGGY CODE ###

n,k = map(int,input().split())
if(k==1):
  print(0)
else:
  t = n//k
  for i in range(t):
    n = abs(n-k)
  if(n < abs(k-n)):
    print(n)
  else:
    print(abs(k-n))

### FIXED CODE ###

N, K = map(int,input().split())
t = N%K
if (K - t) >= t:
    print(t)
else:
    print(K - t)
### BUGGY CODE ###

import numpy as np
h, w = map(int, input().split())

M = h + w
data = np.ones((h+2, w+2), np.int16) * M
for ln in range(1, h+1):
    line = list(input().rstrip())
    for r, letter in zip(range(1, w+1), line):
        if letter == '#':
            data[ln,r] = 0


for d in range(1, -2, -2):
    if d == 1:
        cur, curW, addS, addE, mov= [[1, 1], [h+1, w+1], [0, 1], [1, 0], [1, -1]]
    else:
        cur, curW, addS, addE, mov= [[h, w], [0, 0], [0, -1], [-1, 0], [-1, 1]]
    curS = np.array(cur)
    curE = curS.copy()
    addS = np.array(addS)
    addE = np.array(addE)
    mov = np.array(mov)
    for i in range(w+h-1):

        cur = curS.copy()

        while True:
            x, y = cur

            data[x][y] = min(data[x][y], data[x-d][y]+1, data[x][y-d]+1)

            if np.alltrue(cur==curE):
                break
            cur += mov

        curS += addS
        if np.max(curS == curW):
            curS -= addS
            addS = np.array([addS[1], -addS[0]])
            curS += addS


        curE += addE
        if np.max(curE== curW):
            curE -= addE
            addE = np.array([-addE[1], addE[0]])
            curE += addE

print(np.max(data[1:h+1,1:w+1]))


### FIXED CODE ###

from collections import deque
H,W = map(int, input().split())
A = 0
dp = [None] * H
mat = [None] * (H*W)
matS = matE = 0
for h in range(H):
    s = list(input())
    for w, x in zip(range(W), s):
        if x == "#":
            mat[matE] = (h, w, 0)
            matE+=1
    dp[h] = s

def search(dp, mat, nH, nW, cnt):
    global matE
    if dp[nH][nW] == ".":
        mat[matE] = (nH, nW, cnt+1)
        matE+=1
        dp[nH][nW] = "#"

while matS < matE:
    h, w, cnt = mat[matS]
    matS += 1

    if h > 0:
        search(dp, mat, h - 1, w, cnt)
    if h < H-1:
        search(dp, mat, h + 1, w, cnt)
    if w > 0:
        search(dp, mat, h , w - 1, cnt)
    if w < W-1:
        search(dp, mat, h , w + 1, cnt)

print(cnt)
### BUGGY CODE ###

import sys

N,K = map(int, sys.stdin.readline().strip().split())

if K == 1:
    print(0)
    sys.exit()
if N == K:
    print(0)
    sys.exit()

d = []

d.append(N)
while True:
    d.append(abs(d[-1] - K))
    if d[-1] > d[-2]:
        print(d[-2])
        sys.exit()


### FIXED CODE ###

import sys

N,K = map(int, sys.stdin.readline().strip().split())

if K == 1:
    print(0)
    sys.exit()
if N == K:
    print(0)
    sys.exit()

d = []

d.append(N % K)
while True:
    d.append(abs(d[-1] - K))
    if d[-1] > d[-2]:
        print(d[-2])
        sys.exit()
### BUGGY CODE ###

from functools import reduce
import operator

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt, precnt = 0, reduce(operator.mul, a[:k])

for i in range(1, n-k+1):
    cnt = reduce(operator.mul, a[i:k+i])
    if cnt > precnt:
        print("Yes")
    else:
        print("No")
    precnt = cnt



### FIXED CODE ###

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

for i in range(n-k):
    if a[i] >= a[k+i]:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

import queue
h,w = map(int,input().split())
grid = [list(input()) for _ in range(h)]
nxt = queue.Queue()
for i in range(h):
		for j in range(w):
			if grid[i][j] == "#":
				nxt.put((i,j,0))
a=0
while not nxt.empty():
	i,j,t = nxt.get()
	if t > a:
		a+=1
	for i,j in ((i-1,j),(i+1,j),(i,j-1),(i,j+1)):
		if (-1<i<h)&(-1<j<w):
			if grid[i][j] == ".":
				grid[i][j] = "#"
				nxt.put((i,j,t+1))
print(a)

### FIXED CODE ###

from collections import deque
h,w = map(int,input().split())
grid = [list(input()) for _ in range(h)]
nxt = deque()
for i in range(h):
		for j in range(w):
			if grid[i][j] == "#":
				nxt.append((i,j,0))
a=0
while nxt:
	i,j,t = nxt.popleft()
	if t > a:
		a+=1
	for i,j in ((i-1,j),(i+1,j),(i,j-1),(i,j+1)):
		if (-1<i<h)&(-1<j<w) and grid[i][j] == ".":
				grid[i][j] = "#"
				nxt.append((i,j,t+1))
print(a)
### BUGGY CODE ###

n = int(input())
d = input().split(" ")
for i in range(1, n+1):
	print(d.count(str(i)))

### FIXED CODE ###

n = int(input())
d = input().split(" ")
l = [0] * n
for i in range(n-1):
	l[int(d[i])-1] += 1
for i in range(n):
	print(l[i])