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

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

R = []
G = []
B = []
ans = 0
for i in range(len(S)):
    if S[i] == "R":
        R.append(i)
    if S[i] == "G":
        G.append(i)
    if S[i] == "B":
        B.append(i)
rem = 0
for r in R:
    for g in G:
        if g - abs(r - g) in B:
            rem += 1
        if r - abs(g - r) in B:
            rem += 1
        if (g + r) / 2 in B:
            rem += 1
        if g + abs(r - g) in B:
            rem += 1
        if r + abs(g - r) in B:
            rem += 1


print(len(R)*len(G)*len(B) - rem)


### FIXED CODE ###

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

R = []
G = []
B = []
ans = 0
for i in range(len(S)):
    if S[i] == "R":
        R.append(i)
    if S[i] == "G":
        G.append(i)
    if S[i] == "B":
        B.append(i)
rem = 0
setB = set(B)

for r in R:
    for g in G:
        if g - abs(r - g) in setB:
            rem += 1
        if r - abs(g - r) in setB:
            rem += 1
        if (g + r) / 2 in setB:
            rem += 1
        if g + abs(r - g) in setB:
            rem += 1
        if r + abs(g - r) in setB:
            rem += 1


print(len(R)*len(G)*len(B) - rem)
### BUGGY CODE ###

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

if m == 1:
  l, r = map(int, input().split())
  print(r-l+1)
else:
  l, r = map(int, input().split())
  ans = list(range(l, r+1))
  for _ in range(m-1):
    l, r = map(int, input().split())
    lr_list = list(range(l, r+1))
    removes = []
    for a in ans:
      if a not in lr_list:
        removes.append(a)
    for r in removes:
      ans.remove(r)
    if len(ans) == 0:
      break
  print(len(ans))

### FIXED CODE ###

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

if m == 1:
  l, r = map(int, input().split())
  print(r-l+1)
else:
  ls, rs = [], []
  for _ in range(m):
    l, r = map(int, input().split())
    ls.append(l)
    rs.append(r)
  ans = min(rs) - max(ls) + 1
  if ans > 0:
    print(ans)
  else:
    print(0)
### BUGGY CODE ###

N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
for i in range(len(A)):
  if A[i]==sum(A)-N*(N+1)/2:
    se.append(i)

mod=10**9+7
 
#繰り返し二乗法
def great_power(x, y):
    if   y == 0:
      return 1
    elif y == 1:
      return x % mod
    elif y % 2 == 0:
      return great_power(x, y//2)**2 % mod
    else:
      return great_power(x, y//2)**2 * x % mod
#階乗計算
factorial=[1]
for i in range(1,N+2):
    factorial.append(factorial[i-1]*i %mod)
#逆元計算
inverse=[0]*(N+2)
inverse[N+2-1] = great_power(factorial[N+2-1], mod-2)
for i in range(N+2-2, -1, -1):
    inverse[i] = inverse[i+1] * (i+1) % mod
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
if N==1:
  print(N)
else:
  for i in range(1,N+1):
    print(int(nCr(N+1,i+1)-nCr(se[0]+N-se[1],i))%mod)

### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
c=sum(A)-N*(N+1)/2
for i in range(len(A)):
  if A[i]==c:
    se.append(i)
l=se[0]
r=se[1]

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(l+N-r,i-1))%mod)
### BUGGY CODE ###

from collections import deque

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

MAP = [[min(i, j, N-i-1, N-j-1) for i in range(N)] for j in range(N)]

d = [[1 for i in range(N)] for j in range(N)]

tx = [1, 0, -1, 0]
ty = [0, 1, 0, -1]

ans = 0

for p in P:
    x = (p-1) // N
    y = (p-1) % N
    d[x][y] = 0
    cnt = float('INF')
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx < N and 0 <= ny < N:
            cnt = min(cnt, MAP[nx][ny] + d[nx][ny])
        else:
            cnt = min(cnt, 0)
    
    ans += MAP[x][y]
    
    MAP[x][y] = cnt
    
    q = deque()
    
    q.append((x, y, cnt))
    
    while len(q) != 0:
        x, y, cnt = q.popleft()
        for i in range(4):
            nx = x + tx[i]
            ny = y + ty[i]
            if 0 <= nx < N and 0 <= ny < N and MAP[nx][ny] > MAP[x][y] + d[x][y]:
                MAP[nx][ny] = MAP[x][y] + d[x][y]
                q.append((nx, ny, cnt + d[x][y]))


print(ans)

### FIXED CODE ###

from collections import deque

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

MAP = [min(i, j, N-i-1, N-j-1) for i in range(N) for j in range(N)]

d = [1] * (N ** 2)

ans = 0

def update(np, p):
    if MAP[np] > MAP[p] + d[p]:
        q.append(np)
        MAP[np] = MAP[p] + d[p]

for p in P:
    p -= 1
    
    d[p] = 0
    
    ans += MAP[p]
    
    q = deque()
    
    q.append(p)
    
    while len(q) != 0:
        p = q.popleft()
        if p % N != N-1:
            update(p+1, p)
        if p % N != 0:
            update(p-1, p)
        if p // N != N-1:
            update(p+N, p)
        if p // N != 0:
            update(p-N, p)

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

import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
q = int(input())
tei = 0
x = []
nnn = []
for i in range(q):
        nnn.append(input().rstrip())
for i in range(q):
        nn = nnn[i]
        if int(nn[0]) == 1:
                _,a,b = map(int,nn.split())
                x.append(a)
                tei += b
        else:
                x.sort()
                t = x[(len(x)-1)//2]
                ans = 0
                for j in x:
                        ans += abs(t-j)
                print(t,tei+ans)

### FIXED CODE ###

import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
q = int(input())
tei = 0
x = []
nnn = []
import bisect
def press(a):
    n = len(a)
    b = set(a)
    b = list(b)
    b.sort()
    c = [0] * n
    for i in range(n):
        c[i] = bisect.bisect_left(b,a[i])
    return b,c
for i in range(q):
        nnn.append(input().rstrip())
for i in range(q):
        nn = nnn[i]
        if int(nn[0]) == 1:
                _,a,b = map(int,nn.split())
                x.append(a)
x.sort()
mo,za = press(x)
mo = x
d = dict()
for i in range(len(x)):
        d[mo[i]] = za[i]+1
dg = dict()
for i in range(len(x)):
        dg[za[i]+1] = mo[i]
class BIT:
    def __init__(self, node_size):
        self._node = node_size+1
        self.bit = [0]*self._node

    def add(self, index, add_val):
        while index < self._node:
            self.bit[index] += add_val
            index += index & -index

    def sum(self, index):
        res = 0
        while index > 0:
            res += self.bit[index]
            index -= index & -index
        return res
bit1 = BIT(len(x))
bit2 = BIT(len(x))
now = -1
def cheak(x,y):
  o = bit2.sum(x)
  if y >= o:
    return 0
  else:
    return 1
for i in range(q):
        nn = nnn[i]
        if int(nn[0]) == 1:
                _,a,b = map(int,nn.split())
                tei += b
                bit1.add(d[a],a)
                bit2.add(d[a],1)
                now += 1
        else:
                dai = len(x)
                syo = 1
                while True:
                        if dai-syo <= 1:
                                if cheak(syo,now//2) == 1:
                                        dai = syo
                                break
                        kon = (dai+syo)//2
                        c = cheak(kon,now//2)
                        if c == 1:
                                dai = kon
                        else:
                                syo = kon
                ans = 0
                ans -= bit1.sum(dai) - dg[dai]*bit2.sum(dai)
                ans += bit1.sum(len(x)) -bit1.sum(dai) -((bit2.sum(len(x))-bit2.sum(dai))*dg[dai])
                print(dg[dai],tei+ans)
### BUGGY CODE ###

a, b, k = map(int, input().split())
for _ in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
print(a, b)


### FIXED CODE ###

a, b, k = map(int, input().split())
if k >= a:
    b -= k-a
    a = 0
else:
    a -= k
print(max(a, 0), max(b, 0))
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,k = inpl()
value = [[0 for _ in range(m)] for i in range(n)]
for _ in range(k):
    a,b,c = inpl()
    value[a-1][b-1] = c
dp = [[[0 for _ in range(4)] for i in range(m+5)] for j in range(n+5)]
for i in range(n):
    for j in range(m):
        for k in range(3)[::-1]:
            dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k] + value[i][j])
        for k in range(4):
            dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
            dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
print(max(dp[n-1][m-1]))

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,k = inpl()
value = [[0 for _ in range(m)] for i in range(n)]
for _ in range(k):
    a,b,c = inpl()
    value[a-1][b-1] = c
dp = [0] * (4*(m+1)*(n+1))
def ind(i,j,k): 
    return 4*(m+1)*i + 4*j + k
for i in range(n):
    for j in range(m):
        for k in range(3)[::-1]:
            dp[ind(i,j,k+1)] = max(dp[ind(i,j,k+1)], dp[ind(i,j,k)] + value[i][j])
        for k in range(4):
            dp[ind(i+1,j,0)] = max(dp[ind(i+1,j,0)], dp[ind(i,j,k)])
            dp[ind(i,j+1,k)] = max(dp[ind(i,j+1,k)], dp[ind(i,j,k)])
# print(dp)
mx = 0
for k in range(4):
    mx = max(mx, dp[ind(n-1,m-1,k)])
print(mx)
### BUGGY CODE ###

import math

def log2(x):
    return math.log10(x)/math.log10(2)

N,M = map(int,input().split())
A = [0]*N
A = list(map(int,input().split()))
if (N == 1):
    print(A[0]//(2**M))
else:
    while (M != 0):
        A.sort(reverse=True)
        y = min(math.floor(log2(A[0]/A[1])+1),M)
        A[0] //= 2**y
        M -= y

    print(sum(A))


### FIXED CODE ###

import math
import heapq

N,M = map(int,input().split())
A = [0]*N
A = list(map(lambda x: int(x)*(-1),input().split()))
if (N == 1):
    print((-1 * A[0])//(2**M))
else:
    """
    while (M != 0):
        A.sort(reverse=True)
        y = min(math.floor(log2(A[0]/A[1])+1),M)
        A[0] //= 2**y
        M -= y
    """
    """
    A.sort(reverse=True)
    for i in range(N):
        y = min(A[i] // 2,M)
        A[i] //= 2**y
        M -= y
        if (M <= 0):
            break
    """
    heapq.heapify(A)

    for i in range(M):
        m = heapq.heappop(A) * -1
        heapq.heappush(A,(m//2 * -1))

    print(-sum(A))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      return [j]+dfs(j)
      break
  else:
    return []
z=dfs(1)[::-1]+[1]+dfs(1)
print(len(z))
print(*z)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[set() for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].add(b)
  g[b].add(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      l=dfs(j)
      l.append(j)
      return l
      break
  else:
    return []
z=dfs(1)+[1]+dfs(1)[::-1]
print(len(z))
print(*z)
### BUGGY CODE ###

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                c += 1
print(c)

### FIXED CODE ###

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if z <= k and z >= 0:
            c += 1
print(c)
### BUGGY CODE ###

N = int(input())
str_list = []

for i in range(N):
    n = input()
    if n in str_list:
        continue
    else:
        str_list.append(n)
print(len(str_list))


### FIXED CODE ###

N = int(input())
str_list = set()

for i in range(N):
    n = input()
    if n in str_list:
        continue
    else:
        str_list.add(n)
print(len(str_list))
### BUGGY CODE ###

n, k = [int(i) for i in input().split()]

h_arr = []
for i in range(n):
    h_arr.append(int(input()))

h_sort = sorted(h_arr, reverse=True)

tmp = 0
for i in range(n-k+1):
    if i == 0:
        tmp = max(h_sort[i:i+k]) - min(h_sort[i:i+k])
    else:
        sub = max(h_sort[i:i+k]) - min(h_sort[i:i+k])
        tmp = min(sub, tmp)

print(tmp)

### FIXED CODE ###

import copy
n, k = [int(i) for i in input().split()]

h_arr = []
for i in range(n): 
    h_arr.append(int(input()))

h_arr = sorted(h_arr)
r = 10**10
for i in range(n-k+1):
    r = min(r,h_arr[i+k-1]-h_arr[i])

print(r)
### BUGGY CODE ###

s = input()
count = 0
while '10' in s:
    s = s.replace('10', '', 1)
    count += 1

while '01' in s:
    s = s.replace('01', '', 1)
    count += 1
print(count * 2)

### FIXED CODE ###

s = input()
print(min(s.count('0'), s.count('1')) * 2)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
j=0
#N=int(input())
N, W=map(int, input().split())#intとinputの間がコンマであることに注意
w, v =[0]*N, [0]*N
#S=input()
#T=input()
#S_list=list(S)
#h_list=  list(map(int, input().split(" ")))
#M=int(input())
#drink_list = [list(map(int, input().split(" ")))for i in range(M)]
#print(T_list[1]) 
#不本意だが内包表記で二次元の空のリストを作成する
for i in range(N):
 w[i], v[i] =map(int,input().split())
#下のやつだとなんかdp内にstr型で入ってしまう
#dp=[[[0] for i in range(2)] for j in range(N+1)]
dp =[[0] *(W+1) for j in range(N+1)]
#上のやり方でやると全てのdpに値が入ってエラーがでなくなり幸せになる
i=0
j=0
#やや理解が浅く遷移図をうまく頭の中で描けていないので別解を考えるべき2019/1/5
for i in range(N):
    for j in range(W+1):
        if j >=w[i]:
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i], dp[i+1][j])##ここの行のj-w[i]をあまり良くわかっていない

        dp[i+1][j]=max(dp[i+1][j], dp[i][j])

print(max(dp[N]))
            

### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]
 
DP = np.zeros(W+1, dtype=int)
# i 円以下で買える商品の最大価値
# TLE案件のやつ
for i in range(N):
    DP[w[i]:] = np.maximum(DP[:-w[i]]+ v[i], DP[w[i]:])
print(DP[-1])
### BUGGY CODE ###

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

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
for i in range(len(arr)):
    if arr[i][1]==1:
        s=arr[i][0]+s

    else:s=s+arr[i][0]
print(s)        
        
    
    
    
    

### FIXED CODE ###

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

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
ans1=""
ans2=""
for i in range(len(arr)):
    if arr[i][1]==1:
        ans1+=arr[i][0]

    else:ans2+=arr[i][0]
print("%s%s%s"%(ans1[::-1],s,ans2))
### BUGGY CODE ###

n=int(input())
s=[]
for i in range(n):
  a=input()
  if not a in s:
    s.append(a)
print(len(s))

### FIXED CODE ###

n=int(input())
s=set()
for i in range(n):
  s.add(input())
print(len(s))
### BUGGY CODE ###

from collections import Counter
n=int(input())
nums=input().split()
counter=Counter(nums).most_common()
k=0
for num, c in counter:
    num=int(num)
    if num==c:
        continue
    elif num>c:
        for v in range(c):
            nums.remove(str(num))
            k+=1
    else:
        for v in range(c-num):
            nums.remove(str(num))
            k+=1   

print(k)

### FIXED CODE ###

from collections import Counter
n=int(input())
counter=Counter(map(int,input().split()))
print(sum(c-num if c>=num else c for num,c in counter.items()))
### BUGGY CODE ###

n,m=(int(i) for i in input().split(' '))
i=m//n
while True:
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1
  if i==1:
    print(i)
    break

### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
### BUGGY CODE ###

n, k = map(int,input().split())
al = list(map(int,input().split()))
dics = {}
 
for i in range(n):
    if al[i] in dics:
        dics[al[i]] = dics[al[i]] + 1
    else:
        dics.update({al[i]:1})
        
counts = len(dics.values())
kesu = 0
sortv = list(sorted(list((dics.values()))))
 
while len(sortv) > k:
    kesu = kesu + sortv[0]
    del sortv[0]
print(kesu)


### FIXED CODE ###

n, k = map(int,input().split())
al = list(map(int,input().split()))
dics = {}
 
for i in range(n):
    if al[i] in dics:
        dics[al[i]] = dics[al[i]] + 1
    else:
        dics.update({al[i]:1})
        
counts = len(dics.values())
kesu = 0
sortv = list(sorted(list((dics.values()))))

i = counts
j = 0
while i > k:
    kesu = kesu + sortv[j]
    i = i - 1
    j = j + 1
print(kesu)
### BUGGY CODE ###

n,m=map(int, input().split())
ko=[[] for i in range(n)]
oya=[[] for i in range(n)]
rank=[0]*n 
for i in range(n-1+m):
    a,b=map(int, input().split())
    ko[b-1].append(a-1)
    oya[a-1].append(b-1)
from collections import deque
s=0
for i in range(n):
    if not ko[i]:s=i
p=deque([s])
nr=1
ans=[0]*n
while p:
    now=p.popleft()
    nr=rank[now]+1
    p.extend(oya[now])
    for i in oya[now]:
        rank[i]=nr
        ans[i]=now+1
for i in ans:print(i)

### FIXED CODE ###

n,m=map(int,input().split())
oya=[set() for i in range(n)]
ko=[set() for i in range(n)]
rank=[0]*n
for i in range(n+m-1):
    a,b=map(int,input().split())
    ko[a-1].add(b-1)
    oya[b-1].add(a-1)
for s in range(n):
    if not oya[s]:break
q=[[s,ko[s]]]
ans=[0]*n
while q:
    now,nex=q.pop()
    for i in nex:
        oya[i].remove(now)
        if not oya[i]:
            ans[i]=now+1
            q.append([i,ko[i]])
for i in ans:print(i)
### BUGGY CODE ###

N = input()

cnt = 0
for s in N:
    cnt += int(N)

if cnt % 9 == 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = input()

cnt = 0
for s in N:
    cnt += int(s)

if cnt % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

A,B = map(int,input().split())
ans = int(0)
for i in range(max(A,B)):
    if abs(A-i) == abs(B-i):
        ans = i
if (ans == 0):
    print("IMPOSSIBLE")
else:
    print(ans)

### FIXED CODE ###

A,B = map(int,input().split())
k = (A+B)
if k%2 == 0:
    print(int(k/2))
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

import math

N = int(input())
An = [int(x) for x in input().split()]  
Cn = [An.count(i) for i in range(1,N+1)]  # どの数字が何個あるか？

# ボールを全部使えるときの合計を求める
s = 0
for i in range(N):
    if Cn[i] > 1:
        s += int(math.factorial(Cn[i]) / (math.factorial(Cn[i]-2) * 2))

for k in range(N):
    print(s - (Cn[An[k]-1]-1))

### FIXED CODE ###

import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))
### BUGGY CODE ###

def yabai(a):
    al=''
    a2=a
    if a2%4==0 or a2%4==3:
        al='00'
    elif a2%4==2:
        al='11'
    else:
        al='01'
    
    kaisu_a=0
    while a2!=0:
        if a2%2==0:
            #pass
            a2=a2/2
            #al='0'+al
        else:
            #pass
            a2=(a2-1)/2
            #al='1'+al
        kaisu_a+=1
    #print(kaisu_a)
    #print('1!')
    for a_i in range(kaisu_a-2):
        #print(2**(a_i+2))
        #print(a%(2**(a_i+2)))
        amari=a%(2**(a_i+3))
        if amari>=2**(a_i+2) and amari%2==0:
            al='1'+al
        else:
            al='0'+al
    #print(al)
    return al

def main():
    list=input().split(' ')
    a=int(list[0])
    b=int(list[1])
    if 1==2:
        print(a)
    else:
        newa=yabai(a-1)
        #print(newa)
        newb=yabai(b)
        for sa in range(len(newb)-len(newa)):
            newa='0'+newa
        #print(newb)
        answer=0
        for i in range(len(newa)):
            if (newa[i]=='0' and newb[i]=='1') or (newa[i]=='1' and newb[i]=='0'):
                answer+=(2**(len(newa)-i-1))
        print(answer)

main()

### FIXED CODE ###

def yabai(a):
    al=''
    a2=a
    amarin=a2%4
    if amarin==0 or amarin==3:
        al='00'
    elif amarin%4==2:
        al='11'
    else:
        al='01'
    
    kaisu_a=0
    while a2>0:
        if a2%2==0:
            #pass
            a2=a2/2
            #al='0'+al
        else:
            #pass
            a2=(a2-1)/2
            #al='1'+al
        kaisu_a+=1
    #print(kaisu_a)
    #print('1!')
    for a_i in range(kaisu_a-2):
        amari=a%(2**(a_i+3))
        if amari>=2**(a_i+2) and amari%2==0:
            al='1'+al
        else:
            al='0'+al
    #print(al)
    return al

def main():
    list=input().split(' ')
    a=int(list[0])
    b=int(list[1])
    newa=yabai(a-1)
    #print(newa)
    newb=yabai(b)
    for sa in range(len(newb)-len(newa)):
        newa='0'+newa
    #print(newb)
    answer=0
    #print(newa, newb)
    for i in range(len(newa)):
        if (newa[i]=='0' and newb[i]=='1') or (newa[i]=='1' and newb[i]=='0'):
            answer+=(2**(len(newa)-i-1))
    print(answer)

main()
### BUGGY CODE ###

number=10**9+7

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

c.sort(reverse=True)
sum=0
for i in range(1, n+1):
    sum=(sum+(4**(n-1))*(i+1)*c[i-1])%number
print(sum)


### FIXED CODE ###


number=10**9+7

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

c.sort(reverse=True)
sum=0
for i in range(1, n+1):
    sum=(sum+(pow(4, (n-1), number))*(i+1)*c[i-1])%number
print(sum)
### BUGGY CODE ###

import sys,io
from functools import lru_cache
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
N,W=reads()
weight,value=[0]*N,[0]*N
for i in range(N):
    weight[i],value[i]=reads()
dp=[[ 0 for _ in  range(W+1) ] for _ in range(N+1)]
for i in range(N):
  for k in range(1,W+1):
    if (k >= weight[i]) :dp[i+1][k] = max(dp[i][k-weight[i]] + value[i], dp[i][k])
    else :dp[i+1][k] = dp[i][k]
print("{}".format(dp[N][W]))

### FIXED CODE ###

# D問題とほぼ同じだが計算量が問題になる．
# 前回と違い重さの制約が，W<10^9なので，重さのノードを作ってしまうと，計算量がどう仕様もなくなる
# なので，価値に対してノードを作ってあげて，最小の重さを計算するようにする

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

W = []
V = []

for i in range(N):
    w,v = map(int,input().split())
    W.append(w)
    V.append(v)
# dp[v][i] := 商品iまで選択して，価値がv以下となった場合について，最小の重さ
import math
import numpy as np
dp = np.ones((10**3*(N+10))) * np.inf
dp[0] = 0
for v,w in zip(V,W):
    np.minimum(dp[:-v]+w, dp[v:],out=dp[v:])
print(np.where(dp<=W_max)[0][-1])