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

# -*- coding: utf-8 -*-
import sys
from bisect import bisect_right

def main():
	N, K = map(int, input().split(" "))
	osushi = []
	for _ in  range(N):
		t, d = map(int, input().split(" "))
		osushi.append((d, t))
		
	osushi.sort()
	osushi.reverse()
	
	osushi_list = []
	syu_total = 0
	syu_list = []
	man = 0
	syu = 0
	for i, val in enumerate(osushi):
		d, t = val;
		if not t in syu_list:
			syu_total += 1
			syu_list.append(t)
			t = 1
		else:
			t = 0
		osushi_list.append((d, t))
		if i < K:
			man += d
			if t == 1:
				syu += 1
	
	ans = man + (syu ** 2)
	tmp1 = sorted(osushi_list, key = lambda k:k[1], reverse=True)
	tmp2 = sorted(osushi_list, key = lambda k:k[1])
	for syu_mokuhyou in range(syu+1, syu_total+1):
		man = 0
		syu_local = 0
		count = 0
		for i, val in enumerate(tmp1):
			d, t = val
			syu_local += 1
			man += d
			count += 1
			if syu_local == syu_mokuhyou or count >= K:
				break
					
		for i, val in enumerate(tmp2):
			if count >= K:
				break
			d, t = val
			man += d
			count += 1
		tmp = man + (syu_local ** 2)
		if tmp > ans:
			ans = tmp
		
	print(ans)
	
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()
	sushi_mii = []
	sushi_kii = []
	syu = [[] for i in range(N)]
	for i in range(N):
		t,d = inputMap()
		t -= 1
		syu[t].append(d)

	for i in syu:
		if len(i) > 0:
			i.sort()
			i = i[::-1]
			for j,val in enumerate(i):
				if j == 0:
					sushi_mii.append(val)
				else:
					sushi_kii.append(val)

	sushi_mii.sort()
	sushi_mii = sushi_mii[::-1]
	sushi_kii.sort()
	sushi_kii = sushi_kii[::-1]

	sushi_mi = []
	sushi_ki = []
	for i,val in enumerate(sushi_mii):
		if i == 0:
			sushi_mi.append(val)
		else:
			tmp = sushi_mi[i-1]
			sushi_mi.append(tmp + val)

	for i,val in enumerate(sushi_kii):
		if i == 0:
			sushi_ki.append(val)
		else:
			tmp = sushi_ki[i-1]
			sushi_ki.append(tmp + val)

	ans = 0
	for i in range(1, min(len(sushi_mi), K)+1):
		x = 0
		tmp = 0
		if K - i > len(sushi_ki):
			continue

		tmp += sushi_mi[i-1]
		x = i

		if K - i > 0:
			tmp += sushi_ki[K - i-1]

		oishi = tmp + x * x
		if ans < oishi:
			ans = oishi
	print(ans)

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

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

for i in range(a, 0, -1):
    if m % i == 0:
        ans = i
        break
        
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = m // n
ans = 0

for i in range(1, a + 1):
    if m % i == 0:
        ans = i
        
        if (m // i) > i and (m // i) <= a:
            ans = m // i
            break
        
print(ans)
### BUGGY CODE ###

a = input()
c = input()
d=[]
alist = list(a)
count = 0
for i in range(int(c)):
  e = input().split()
  d.append(e)
for i in range(int(c)):
  if d[i][0]=="1":
    count = count + 1
  else:
    if d[i][1] == "1" and count % 2 == 0:
      alist = [d[i][2]] + alist
    elif d[i][1] == "2" and count % 2 == 1:
      alist = [d[i][2]] + alist
    else:
      alist = alist + [d[i][2]]
if count % 2 == 1:
  l = len(alist)
  for x in range(int(l//2)):
    alist[x],alist[l-x-1] = alist[l-x-1],alist[x]
answer = "".join(alist)
print(answer)

### FIXED CODE ###

from collections import deque
a = input()
c = input()
d = []
alist = list(a)
adeque = deque(a)
count = 0
for i in range(int(c)):
  e = input().split()
  d.append(e)
for i in range(int(c)):
  if d[i][0]=="1":
    count = count + 1
  else:
    if d[i][1] == "1" and count % 2 == 0:
      adeque.appendleft(d[i][2])
    elif d[i][1] == "2" and count % 2 == 1:
      adeque.appendleft(d[i][2])
    else:
      adeque.append(d[i][2])
alist = list(adeque)
if count % 2 == 1:
  l = len(alist)
  for x in range(int(l//2)):
    alist[x],alist[l-x-1] = alist[l-x-1],alist[x]
answer = "".join(alist)
print(answer)
### BUGGY CODE ###

def bin_search1(L1,L2,l):#長すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (L1+L2<=l[mid]):#長すぎ
            high = mid
        else:
            low = mid
    if L1+L2>l[high]:#全部ok
        return 0
    elif L1+L2<=l[low]:#全部ng
        return len(l)
    else:
        return len(l)-high

def bin_search2(L1,L2,l):#短すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (abs(L1-L2)>=l[mid]):
            low = mid
        else:
            high = mid
    if abs(L1-L2)<l[low]:
        return 0
    elif abs(L1-L2)>=l[high]:
        return len(l)
    else:
        return high

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N):
    for j in range(N):
        if i!=j:
            L_temp = L#修正面倒なため
            a = L[i]
            b = L[j]
            if i<j:
                L_temp.pop(j)
                L_temp.pop(i)
                ans += (N-2-bin_search1(a,b,L_temp)-bin_search2(a,b,L_temp))
                L.insert(i,a)
                L.insert(j,b)
            else:
                L_temp.pop(i)
                L_temp.pop(j)
                ans += (N-2-bin_search1(a,b,L_temp)-bin_search2(a,b,L_temp))
                L.insert(j,b)
                L.insert(i,a)
                
ans = ans//6

print(ans)

### FIXED CODE ###

from bisect import bisect＿left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

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

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

N,M = [int(x) for x in input().split()]
next =[set() for _ in range(N+1)]

for i in range(M):
    A,B = [int(x) for x in input().split()]
    next[A].add(B)
    next[B].add(A)

opened = deque()
opened.append(1)

closed = [False] * (N+1)
prev = [-1] * (N+1)
prevlen = [float('inf')] * (N+1)
prevlen[1] = 0

while len(opened) != 0:
    target = opened.popleft()
    closed[target] = True
    for n in next[target]:
        if closed[n] == False:
            opened.append(n)
        if prevlen[n] > prevlen[target]+1:
            prev[n] = target
            prevlen[n] = prevlen[target]+1


print('Yes')
# for i in range(2,N+1):
#     print(prev[i])
print(" ".join([str(x) for x in prev[2:]]))

### FIXED CODE ###

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

N,M = [int(x) for x in input().split()]
next =[set() for _ in range(N+1)]

for i in range(M):
    A,B = [int(x) for x in input().split()]
    next[A].add(B)
    next[B].add(A)

opened = deque()
opened.append(1)

prev = [-1] * (N+1)
prev[1] = 1

while len(opened) != 0:
    target = opened.popleft()
    for n in next[target]:
        if prev[n] == -1:
            opened.append(n)
            prev[n] = target


print('Yes')
# for i in range(2,N+1):
#     print(prev[i])
print(" ".join([str(x) for x in prev[2:]]))
### BUGGY CODE ###

s = int(input())

def func(n):
    if n%2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1

a = [s]
i = 0
flg = 1

while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                break
        else:
            continue
        break   
        
    i += 1
            
    


### FIXED CODE ###

s = int(input())

def func(n):
    if n%2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1

a = [s]
i = 0
flg = 1
while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                flg = 0
                break
        if flg == 0:
            break
        
    i += 1
### BUGGY CODE ###

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
ans = 1
num = a[0]
while num != 2:
    if num == 1:
        ans = -1
        break
    num = a[num-1]
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = [0] * (n+1)
for i in range(n):
    a[i+1] = int(input())

ans = 0
idx = 1
for i in range(n-1):
    if a[idx] == 2:
        print(ans+1)
        exit()
    else:
        ans += 1
        idx = a[idx]
print(-1)
### BUGGY CODE ###

import numpy as np
inputs = open(0).readlines()

def main(inputs):
    h, w, k = map(int, inputs[0].split())
    cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
    for i, s in enumerate(inputs[1:]):
        for j, c in enumerate(s):
            if c == '#':
                count += 1
                cake[i, j] = count
                coords[count] = (j, i)

    for i in range(1, count+1):
        x, y = coords[i]
        x0, y0 = x-1, y-1
        x1, y1 = x+1, y+1
        while 0 <= x0 and cake[y, x0] == 0:
            cake[y, x0] = i
            x0 -= 1
        x0 += 1
        while x1 < w and cake[y, x1] == 0:
            cake[y, x1] = i
            x1 += 1
        while 0 <= y0 and not np.any(cake[y0, x0:x1]):
            cake[y0, x0:x1] = i
            y0 -= 1
        while y1 < h and not np.any(cake[y1, x0:x1]):
            cake[y1, x0:x1] = i
            y1 += 1

    for rows in cake:
        print(*rows)

main(inputs)

### FIXED CODE ###

import numpy as np
inputs = open(0).readlines()

def main(inputs):
    h, w, k = map(int, inputs[0].split())
    cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
    for i, s in enumerate(inputs[1:]):
        for j, c in enumerate(s):
            if c == '#':
                count += 1
                cake[i, j] = count
                coords[count] = (j, i)
    empty_rows = {i for i, rows in enumerate(cake) if not np.any(rows)}

    for i in range(1, count+1):
        x, y = coords[i]
        x0, y0 = x-1, y-1
        x1, y1 = x+1, y+1
        while 0 <= x0 and cake[y, x0] == 0:
            cake[y, x0] = i
            x0 -= 1
        x0 += 1
        while x1 < w and cake[y, x1] == 0:
            cake[y, x1] = i
            x1 += 1
        while 0 <= y0 and y0 in empty_rows:
            cake[y0, x0:x1] = i
            y0 -= 1
        while y1 < h and y1 in empty_rows:
            cake[y1, x0:x1] = i
            y1 += 1

    for rows in cake:
        print(*rows)

main(inputs)
### BUGGY CODE ###

#横にn個入力
n, k = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
nli = []
b = 0
for i in range(n):
    for j in range(i, n):
        b += a[j]
        nli.append(b)
    b = 0
nli.sort(reverse=True)
m = 40
x = 0

cnt = 0
candili = []
for i in range(m - 1, 0, -1):
    if x == 0:
        for j in range(len(nli)):
            if nli[j] & (x + 2 ** i) == x + 2 ** i:
                candili.append(nli[j])
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
            candili = []
    else:
        for j in candili:
            if j & (x + 2 ** i) == x + 2 ** i:
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
print(x)

### FIXED CODE ###

#横にn個入力
n, k = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
nli = []
b = 0
for i in range(n):
    for j in range(i, n):
        b += a[j]
        nli.append(b)
    b = 0
nli.sort(reverse=True)
m = 41
x = 0

cnt = 0
candili = []
for i in range(m - 1, -1, -1):
    if x == 0:
        for j in range(len(nli)):
            if nli[j] & (x + 2 ** i) == x + 2 ** i:
                candili.append(nli[j])
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
            candili = []
    else:
        for j in candili:
            if j & (x + 2 ** i) == x + 2 ** i:
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
print(x)
### BUGGY CODE ###

n,m=map(int,input().split())
collect=[]
pen=[]
sum=0
for i in range(m):
  p,s=input().split()
  if p not in collect:
    if s=='WA':
      pen.append(p)
    else:
      collect.append(p)
      sum=sum+pen.count(p)
print(len(collect),sum)

### FIXED CODE ###

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

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

for i in range(n + 1):
    if ac[i] != 1:
        wa[i] = 0

print(sum(ac), sum(wa))
### BUGGY CODE ###

#python3
#python3
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
MOD = int(1e9+7)
ans=0
for k in range(60):
  x=0
  for i in range(n):
    if(a[i]>>k)&1:
      x+=1
  ans+=x*(n-x)*2**k
  ans%=MOD
print(ans)


### FIXED CODE ###

#python3
import numpy as np
N = int(input())
A = np.array([int(_) for _ in input().split()])
mod = 10**9 + 7
ans = 0
for b in range(60):
    B = (A >> b) & 1
    M = np.count_nonzero(B)
    ans += 2**b * M * (N - M)
    ans %= mod
print(ans)
### BUGGY CODE ###

h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())
s = []
g = []
search = []
for i in range(q):
    s, g = map(int, input().split())
    search.append([])
    while(s != g):
        search[i].append([s, s + d])
        s += d

for i in range(h):
    for j in range(w):
        for l in range(q):
            for k in range(len(search[l])):
                if(search[l][k][0] == A[i][j]):
                    search[l][k][0] = (i, j)
                elif(search[l][k][1] == A[i][j]):
                    search[l][k][1] = (i, j)

for i in range(q):
    ans = 0
    for x in search[i]:
        ans += abs(x[0][0] - x[1][0]) + abs(x[0][1] - x[1][1])
    print(ans)


### FIXED CODE ###

h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())

I = [0] * (w * h + 1)
for i in range(h):
    for j in range(w):
        I[A[i][j]] = (i, j)
D = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    D[i] = D[i - d] + abs(I[i][0] - I[i - d][0]) + abs(I[i][1] - I[i - d][1])
s = []
g = []
for i in range(q):
    s, g = map(int, input().split())
    print(D[g] - D[s])
### BUGGY CODE ###

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

for i in range(Q):
  tmp = input().split()
  l = int(tmp[0])
  r = int(tmp[1])
  
  deleted = S[l-1:r]
  print(len(''.join(deleted).split('AC'))-1)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(1, N+1):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])
### BUGGY CODE ###

a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, 2) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)

### FIXED CODE ###

a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b-2) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    plus = sum(a[i+1:])%MOD
    ans += a[i]*plus
    ans %= MOD

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)
### BUGGY CODE ###

N,M = map(int,input().split(" "))
ans = 0
GATE_ID = []
for i in range(M):
    GATE_ID1,GATE_ID2 = map(int,input().split(" "))
    GATE_ID.append([GATE_ID1,GATE_ID2])
#print(GATE_ID)

for i in range(N):
    CARD_ID = i+1
    #print("CARD_ID:",CARD_ID)
    ALL_GATE_PASS_COUNT = 0
    for j in range(M):
        GATE_ID1,GATE_ID2 = GATE_ID[j][0],GATE_ID[j][1]
        #print(GATE_ID1,GATE_ID2)
        if CARD_ID >= GATE_ID1 and CARD_ID <= GATE_ID2:
            ALL_GATE_PASS_COUNT += 1
            #print(CARD_ID,":PASS")
    #print("ALL_GATE_PASS_COUNT:",ALL_GATE_PASS_COUNT)
    if ALL_GATE_PASS_COUNT == M:
        ans += 1
print(ans)

### FIXED CODE ###

N,M = map(int,input().split(" "))
L_list = []
R_list = []
for i in range(M):
    L,R = map(int,input().split(" "))
    L_list.append(L)
    R_list.append(R)
if min(R_list) - max(L_list) >= 0:
    print(min(R_list) - max(L_list) +1)
else:
    print(0)
### BUGGY CODE ###

# YouTube解説の方法（deque使わない）
from bisect import bisect_left

def bisect_right_reverse(L, target):
    return len(L) - bisect_left(L[::-1], target)

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

L = []
for i in range(N):
    k = bisect_right_reverse(L, A[i])
    if k == len(L):
        L.append(A[i])
    else:
        L[k] = A[i]

print(len(L))

### FIXED CODE ###

from collections import deque
from bisect import bisect_left
N = int(input())
A = [int(input()) for _ in range(N)]
que = deque()
for i in range(N):
    k = bisect_left(que, A[i])
    if k == 0:
        que.appendleft(A[i])
    else:
        que[k - 1] = A[i]

print(len(que))
### BUGGY CODE ###

N, K=map(int, input().split())
A=list(map(int, input().split()))
for i in range(K,N):
    if i==K:
        tmp=1
        for j in range(1,K):
            tmp*=A[j]
        a=tmp*A[0]
        b=tmp*A[K]
    else:
        a=b
        b=b/A[i-K]*A[i]
    if a<b: print('Yes')
    else: print('No')

### FIXED CODE ###

N, K=map(int, input().split())
A=list(map(int, input().split()))
for i in range(K,N):
    if A[i-K]<A[i]: print('Yes')
    else: print('No')
### BUGGY CODE ###

N, M = map(int, input().split())
H = list( map(int, input().split()) )
A = []
for m in range(M):
    A.append( list( map(lambda x: x-1, list(map(int, input().split()))) ) )
    
K = [i for i in range(N)]

for m in range(M):
    if A[m][0] in K:
        if H[ A[m][1] ] >= H[ A[m][0] ]:
            K.remove(A[m][0])
            
    if A[m][1] in K:
        if H[ A[m][0] ] >= H[ A[m][1] ]:
            K.remove(A[m][1])
            
print(len(K))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 08:53:27 2020

@author: asaka
"""

N, M = map(int, input().split())
H = list( map(int, input().split()) )
A = []
for m in range(M):
    A.append( list( map(lambda x: x-1, list(map(int, input().split()))) ) )
    
K = [1]*N

for m in range(M):
    if H[ A[m][1] ] >= H[ A[m][0] ] and K[A[m][0]] ==1 :
        K[A[m][0]] -= 1
            
    if H[ A[m][0] ] >= H[ A[m][1] ] and K[A[m][1]] ==1:
        K[A[m][1]] -= 1
            
print(sum(K))
### BUGGY CODE ###

def main():
 n=int(input())
 N=[i for i in range(1,n+1)]

 count=0
 for a in N:
   for b in N:
     if str(a)[0]==str(b)[-1] and str(a)[-1]==str(b)[0]:
       count+=1

 print(count)

if __name__=='__main__':
  main()

### FIXED CODE ###

N=int(input())
d=[[0]*10 for i in range(10)]
#10x10のグリッドを作る

#9x9パターンに分類されるため、各数字をグリッドに振り分ける
for i in range(1,N+1):
  n=str(i)
  d[int(n[0])][int(n[-1])]+=1

#組み合わせの数は[Aの数]x[Bの数] 先頭か語尾に0が付くものはカウントしない
r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
S = input()

dic = defaultdict(list)
for i in range(N):
    dic[S[i]].append(int(i))

'''count = 0
print(dic["R"])
print(dic["G"])
print(dic["B"])

for i in dic["R"]:
    for j in dic["G"]:
        for k in dic["B"]:
            if i < j and j < k and (j-i != k-j):
                count += 1

print(count)
'''
count = 0
for i in range(N-1):
    for j in range(i+1,N):
        if S[i] == "R" and S[j] == "G":
            for k in dic["B"]:
                if i < j and j < k and (j-i != k-j):
                   count += 1

        elif S[i] == "R" and S[j] == "B":
            for k in dic["G"]:
                if i < j and j < k and (j-i != k-j):
                   count += 1

        elif S[i] == "G" and S[j] == "B":
            for k in dic["R"]:
                if i < j and j < k and (j-i != k-j):
                   count += 1

        elif S[i] == "G" and S[j] == "R":
            for k in dic["B"]:
                if i < j and j < k and (j-i != k-j):
                   count += 1

        elif S[i] == "B" and S[j] == "R":
            for k in dic["G"]:
                if i < j and j < k and (j-i != k-j):
                   count += 1

        elif S[i] == "B" and S[j] == "G":
            for k in dic["R"]:
                if i < j and j < k and (j-i != k-j):
                   count += 1

print(count) 

### FIXED CODE ###

N = int(input())
S = input()

rcount = S.count("R")
gcount = S.count("G")
bcount = N-rcount-gcount



count = rcount * gcount * bcount
k = 0
for i in range(N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if k < N :
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                count -= 1
print(count)
### BUGGY CODE ###

def flpl(): return [float(i) for i in input().split()]
def inpl(): return [int(i) for i in input().split()]
import numpy as np
xs, ys, xt, yt = flpl()
rs,rt = 0, 0
N = int(input())
xyr = [(xs, ys, rs),(xt, yt,rt)] + [inpl() for _ in range(N)]
X, Y, R = np.array(xyr).T
edge = np.zeros((N+2,N+2))
for i in range(N+2):
    for j in range(i+1):
        edge[i][j] = edge[j][i] = max(0, \
            ((X[i]-X[j])**2 + (Y[i]-Y[j])**2)**(1/2) - (R[i]+R[j]))
        inf = float('inf')
dist = np.array([inf for _ in range(N+2)])
dist[0] = 0 
import heapq

decided = [False for _ in range(N+2)]
Q = []
heapq.heappush(Q,(0,0))
for _ in range(N+2):
    while True:
        k = heapq.heappop(Q)
        k = k[1]
        if not decided[k]:
            decided[k] = True
            break
    for j in range(N+2):
        if decided[j]:
            continue
        dist[j] = min(dist[k] + edge[k][j], dist[j])
        heapq.heappush(Q,(dist[j],j)) 
    if decided[1]:
        break
print(dist[1])

### FIXED CODE ###

def flpl(): return [float(i) for i in input().split()]
def inpl(): return [int(i) for i in input().split()]
import heapq
def dijkstra(vnum, vs):
    dist = [float('inf') for _ in range(vnum)]
    dist[vs] = 0 
    remain = set(range(vnum))
    Q = []
    heapq.heappush(Q,(0,vs))
    while Q:
        c, vn = heapq.heappop(Q)
        if vn not in remain :
            continue
        remain.remove(vn)
        for j in remain:
            evnj = edge(vn, j)
            if dist[vn] + evnj < dist[j]:
                dist[j] = dist[vn] + evnj 
                heapq.heappush(Q,(dist[j],j)) 
        if not remain:
            break
    return dist
def edge(s, t):
    return max(((X[s] - X[t])**2 + (Y[s] - Y[t])**2)**(1/2) -(R[s]+R[t]), 0)

xs, ys, xt, yt = flpl()
N = int(input())
xyr = [(xs, ys, 0),(xt, yt, 0)] + [inpl() for _ in range(N)]
X, Y, R = list(map(list, zip(*xyr)))
D = dijkstra(N+2, 0)
print(D[1])
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
for i in range(N):
  print(A.count((i+1)))

### FIXED CODE ###

import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
for i in range(N):
  print(c[i+1])