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

from collections import Counter

N = int(input())
S = []
ans = [1] * N
for _ in range(N):
    s = input()
    s = Counter(s)
    for i in range(len(S)):
        if s == S[i]:
            ans[i] += 1
            break
    else:
        S.append(s)

answer = 0

for a in ans:
    if a > 1:
        answer += a * (a-1) / 2

print(int(answer))

### FIXED CODE ###

from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))
### BUGGY CODE ###

import numpy as np
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

# 横
A = np.array([[-10000] * W for i in range(H)])
B = np.array([[-10000] * W for i in range(H)])

S = np.array(S)
S2 = S.T


A2 = A.T
for j in range(H):
    ii = 0
    s = 0
    for i in range(W+1):
        if i == W or S2[i, j] == '#':
            A2[ii:i, j] = s
            s = 0
            ii = i + 1
        else:
            s += 1
A = A2.T

for j in range(W):
    ii = 0
    s = 0
    for i in range(H+1):
        if i == H or S[i, j] == '#':
            B[ii:i, j] = s
            s = 0
            ii = i + 1
        else:
            s += 1

X = A + B - 1
print(np.max(X))        


### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

# 横
A = [[-10000] * W for i in range(H)]
B = [[-10000] * W for i in range(H)]

for i in range(H):
    jj = 0
    s = 0
    for j in range(W+1):
        if j == W or S[i][j] == '#':
            for x in range(jj, j):
                A[i][x] = s
            s = 0
            jj = j + 1
        else:
            s += 1


for j in range(W):
    ii = 0
    s = 0
    for i in range(H+1):
        if i == H or S[i][j] == '#':
            for y in range(ii, i):
	            B[y][j] = s
            s = 0
            ii = i + 1
        else:
            s += 1

m = 0
for i in range(H):
    for j in range(W):
        m = max(A[i][j] + B[i][j] - 1, m)
            
print(m)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(n - k + 1):
    x = 0
    for j in range(k):
        pj = p[i + j]
        x += (1 + pj) / 2
    ans = max(ans, x)
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0 for _ in range(n + 1)]
for i, pi in enumerate(p):
    a[i + 1] = a[i] + (1 + pi) / 2

ans = 0
for i in range(n - k + 1):
    ans = max(ans, a[i + k] - a[i])
print(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, sep=" ")


### FIXED CODE ###

a, b, k = map(int, input().split())

# TEだった
# for _ in range(k):
#     if a >= 1:
#         a -= 1
#     elif b >= 1:
#         b -= 1

ans_a = 0
ans_b = 0

if a >= k:
    ans_a = a - k
    ans_b = b
else:
    ans_a = 0
    if b >= (k - a):
        ans_b = b - (k - a)
    else:
        ans_b = 0

print(ans_a, ans_b, sep=" ")
### BUGGY CODE ###

if __name__ == '__main__':
    N = int(input())
    ans = 1
    for i in range(1,N+1) :
        ans *= i
    ans %= 1000000007
    print(ans)


### FIXED CODE ###

if __name__ == '__main__':
    N = int(input())
    ans = 1
    for i in range(1,N+1) :
        ans *= i
        # 剰余演算の分配則
        ans %= 1000000007
    ans %= 1000000007
    print(ans)
### BUGGY CODE ###

n = input()
p = input().split()
cnt = 0
cn = 0

for i in range(len(p)):
	cn = int(p[i])
	for j in range(i + 1):
		if cn > int(p[j]):
			break
		if i == j:
			cnt += 1

print(cnt)

### FIXED CODE ###

n = input()
p = input().split()
cnt = 0
tmin = 9999999999999999999999999999

for i in range(len(p)):
	tmin = min(tmin,int(p[i]))
	if tmin >= int(p[i]):
		cnt += 1

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

N = int(input())
S = input()
ans = 3 * 10 ** 5

for i in range(N):
	left = S[:i]
	right = S[i+1:]
	ans = min(ans, left.count('W') + right.count('E'))

print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 3 * 10 ** 5
w = S.count('W')
w_r = 0

for i, a in enumerate(S):
	if a == 'W':
		w_r += 1
		ans = min(ans, 2*w_r+N-w-i-2)
	else:
		ans = min(ans, 2*w_r+N-w-i-1)
	

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

N = int(input())
D = {}
for i in range(N):
    s = input()
    if s in D:
        D[s] += 1
    else:
        D[s] = 0
print(*[j[0] for j in sorted(D.items()) if j[1] == max(D.values())], sep="\n")

### FIXED CODE ###

import collections
N = int(input())
D = collections.Counter(input() for i in range(N))
maximum = max(D.values())
sort = sorted(key for key,value in D.items() if value == maximum)
for s in sort:
    print(s)
### BUGGY CODE ###

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

for i in range(1,N+1):
    print(A.count(i))

### FIXED CODE ###


N = int(input())
A = list(map(int, input().split())) 
l = [0] * N


for i in range(N-1):
    l[A[i]-1] += 1
for j in l:
    print(j)
### BUGGY CODE ###

import math
k = int(input())
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=math.gcd(math.gcd(i,j),l)
print(sum)

### FIXED CODE ###

import math
k = int(input())
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=math.gcd(math.gcd(i,j),l)
print(sum)
### BUGGY CODE ###

import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = fractions.gcd(a, b)
sqmin = min(int(math.sqrt(a)), int(math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  if i > sqmin and i != a and i != b:
    pass
  else:
    flag = False
    while (a % i == 0) and (b % i == 0):
      a = a // i
      b = b // i
      flag = True
    if flag:
      cnt += 1
   
print (cnt+1)

### FIXED CODE ###

import fractions
import math
from collections import deque

def prime(x):
  px = []
  limit = int(math.sqrt(x))
  for i in range(2, limit+1):
    flag = False
    while x % i == 0:
      flag = True
      x = x // i
    if flag:
      px.append(i)
  if x != 1:
    px.append(x)
  return px

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

pa = prime(a)
pb = prime(b)

cnt = 1
j = 0

for i in range(len(pa)):
  while j < len(pb) and pb[j] < pa[i]:
    j += 1
  if j == len(pb):
    break
  elif pb[j] == pa[i]:
    cnt += 1
  
print (cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

n = int(input())
s = input()


counter = 0

for p in range(n):
    for q in range(n - p):
        a = s[p]
        b = s[p + q]
        if a == b:
            continue
        rgb_list = ['R', 'G', 'B']
        rgb_list.remove(a)
        rgb_list.remove(b)
        # current_list = [a, b]
        # diff_list = list(set(rgb_list) - set(current_list))
        c = rgb_list[0]
        nokori = s[p + q:]
        counter += nokori.count(c)
        if q < len(nokori) and nokori[q] == c:
            counter -= 1
print(counter)

### FIXED CODE ###

# -*- coding: utf-8 -*-

n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

counter = r_cnt * g_cnt * b_cnt

for i in range(n):
    for p in range(n):
        j = i + p
        k = j + p
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            counter -= 1
print(counter)
### BUGGY CODE ###

N, W = (int(n) for n in input().split())
w, v = [], []
for _ in range(N):
    w_, v_ = (int(n) for n in input().split())
    w.append(w_)
    v.append(v_)

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for w_ in range(W + 1):
        if w_ >= w[i]:
            dp[i + 1][w_] = max(dp[i][w_], dp[i][w_ - w[i]] + v[i])
        else:
            dp[i + 1][w_] = dp[i][w_]

print(dp[N][W])

### FIXED CODE ###

N, W = (int(n) for n in input().split())
w, v = [], []
for _ in range(N):
    w_, v_ = (int(n) for n in input().split())
    w.append(w_)
    v.append(v_)

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for w_ in range(W + 1):
        if w_ >= w[i]:
            dp[i + 1][w_] = max(dp[i][w_], dp[i][w_ - w[i]] + v[i])
        else:
            dp[i + 1][w_] = dp[i][w_]

print(dp[N][W])
### BUGGY CODE ###

from collections import deque

N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))
# N, M, K = map(int, "3 4 1000000000".split())
# A = deque(map(int, "600000000 90 120".split()))
# B = deque(map(int, "800000000 150 80 150".split()))

result = 0

while (A != deque() and K >= A[0]) or (B != deque() and K >= B[0]):
    a, b = 0, 0
    na, nb = 0, 0
    for i in A:
        if a+i <= K:
            a += i
            na += 1
        else:
            break
    for i in B:
        if b+i <= K:
            b += i
            nb += 1
        else:
            break


    if na > nb:
        result += 1
        na -= 1
        K -= A.popleft()
    elif na < nb:
        result += 1
        nb -= 1
        K -= B.popleft()
    elif na == nb:
        result += 1
        if A[0] <= B[0]:
            na -= 1
            K -= A.popleft()
        else:
            nb -= 1
            K -= B.popleft()
print(result)


### FIXED CODE ###

from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

a_accum = [0] + list(accumulate(a))
b_accum = [0] + list(accumulate(b))

j = m
for i in range(n+1):
  while k < a_accum[i] + b_accum[j] and j >= 1:
    j -= 1
  if k >= a_accum[i] + b_accum[j] and ans < i + j:
    ans = i + j

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

def main():
  n,k = map(int, input().split())
  l = [0] + list(map(int, input().split()))
  for i in range(n):
    l[i+1] += l[i]
  a = [l[j]-l[i] for i in range(n) for j in range(i+1,n+1)]
  x = 0
  for i in range(40,-1,-1):
    t = 2**i
    if sum(y&(t+x)==t+x for y in a) >= k:
      x += t
  return x

if __name__ == "__main__":
  print(main())


### FIXED CODE ###

n,k = map(int, input().split())
l = [0] + list(map(int, input().split()))
a = list()
for i in range(n):
  l[i+1] += l[i]
a = [l[j]-l[i] for i in range(n) for j in range(i+1,n+1)]
x = 0
for i in range(40,-1,-1):
  t = 2**i 
  if sum(map(lambda y:((y&(t+x)) == t+x),a)) >= k:
    x += t
print(x)
### BUGGY CODE ###

n = int(input())
s = [input() for i in range(n)]

ans = []
for i in range(n):
    if not s[i] in ans:
        ans.append(s[i])

print(len(ans))


### FIXED CODE ###

import collections
n = int(input())
s = [input() for i in range(n)]

ans = collections.Counter(s)
print(len(ans))
### BUGGY CODE ###

H, W = map(int, input().split())
l = [list(input()) for _ in range(H)]

from collections import deque
q = deque()
for i, r in enumerate(l):
    for j, c in enumerate(r):
        if c == '#':
            l[i][j] = 0
            q.append((i, j))
d = [(0, 1), (0, -1), (1, 0), (-1, 0)]

while q:
    y, x = q.popleft()
    for dy, dx in d:
        if (0 <= y+dy < H) and (0 <= x+dx < W) and l[y+dy][x+dx] == '.':
            l[y+dy][x+dx] = l[y][x] + 1
            q.append((y+dy, x+dx))

m = 0
for r in l:
    for c in r:
        if m < c:
            m = c
print(m)

### FIXED CODE ###

H, W = map(int, input().split())
l = [list(input()) for _ in range(H)]

from collections import deque
q = deque()
for i, r in enumerate(l):
    for j, c in enumerate(r):
        if c == '#':
            l[i][j] = 0
            q.append((i, j))
d = [(0, 1), (0, -1), (1, 0), (-1, 0)]

while q:
    y, x = q.popleft()
    for dy, dx in d:
        if (0 <= y+dy < H) and (0 <= x+dx < W) and l[y+dy][x+dx] == '.':
            l[y+dy][x+dx] = l[y][x] + 1
            q.append((y+dy, x+dx))

m = 0
for r in l:
    for c in r:
        if m < c:
            m = c
print(m)
### BUGGY CODE ###

#import sys
#input = sys.stdin.readline
N=int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  S=input()
  d[S]+=1
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for a in max_k_list:
  print(a)

### FIXED CODE ###

N=int(input())
S = [input() for i in range(N)]
S.sort()
import itertools
gr = itertools.groupby(S)
ans=[]
n=0
for key, group in gr:
  a=len(list(group))
  if a>n:
    ans=[]
    n=a
    ans.append(key)
  elif a==n:
    ans.append(key)
for a in ans:
  print(a)
### BUGGY CODE ###

S = input()
s = len(S)
a = []
ans = 0
for i in range(0, s-3):
  for j in range(i+3, s+1):
    if int(S[i:j]) % 3 == 0:
      a.append([i,j])
for t in range(len(a)):
  i, j = a[t]
  if int(S[i:j]) % 673 == 0:
    ans += 1
print(ans)

### FIXED CODE ###

S = input()
amari = [0]*2019
ans = 0
amari[0] = 1
A = 0
for i in range(len(S)):
    A += pow(10, i, 2019)*(int(S[len(S)-1-i]))
    amari[A % 2019] += 1
for i in amari:
    if i >= 2:
        ans += i*(i-1)/2
print(int(ans))
### BUGGY CODE ###

#Satoooh 
H, W = map(int, input().split())
S = [input() for _ in range(H)]
# そのマスを含めてLeft, Right, Up, Downに
#それぞれ何マス分明かりを照らせるかを配列に記録
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):#全マスを走査
		if S[i][j] == ".":
			if j == 0:#一番左側のマスについて
				L[i][j] = 1
			else:#それ以外
				L[i][j] = L[i][j - 1] + 1
                #累積和のように、１個左側の値にプラス１

for i in range(H):
	for j in range(W - 1, -1, -1):#右側からの連続をチェック
		if S[i][j] == ".":
			if j == W - 1:#一番右側のマスについて
				R[i][j] = 1
			else:
				R[i][j] = R[i][j + 1] + 1

for j in range(W):
	for i in range(H - 1, -1, -1):#下からの連続
		if S[i][j] == ".":
			if i == H - 1:#一番下のマスについて
				D[i][j] = 1
			else:
				D[i][j] = D[i + 1][j] + 1

for j in range(W):
	for i in range(H):
		if S[i][j] == ".":
			if i == 0:#一番上のマスについて
				U[i][j] = 1
			else:
				U[i][j] = U[i - 1][j] + 1


ans = 0
X = [[0] * W for _ in range(H)]#全マスを０で初期化
for i in range(H):
	for j in range(W):
		X[i][j] = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        #自分自身のマスは上記４回足している
	ans = max(ans, max(X[i]))
    #最大値で更新。配列Xは元々２次元だが、
    #ここでは横１次元をまとめて見ている

print(ans)#最も多くのマスを照らせる場合のマスの個数

### FIXED CODE ###

import numpy as np
H,W = map(int,input().split())
S=np.array([list(input().rstrip("\n")) for _ in range(H)]) == '.'
D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)
for i in range(H):# 上下
  U[i] = (U[i-1] + 1) * S[i]
  D[-i-1] = (D[-i] + 1) * S[-i-1]
for i in range(W):# 左右
  L[:,i] = (L[:,i-1] + 1) * S[:,i]
  R[:,-i-1] = (R[:,-i] + 1) * S[:,-i-1]
print(np.max(U+D+L+R)-3)
### BUGGY CODE ###

#全探索(多分TLE)
K, S = map(int, input().split())

ans = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                ans += 1
print(ans)

### FIXED CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S >= x+y and S-(x+y) <= K:
            ans += 1
print(ans)
### BUGGY CODE ###

import itertools
N, M = map(int, input().split())
x = [0]*N
y = [0]*N
z = [0]*N
for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())

a = list(itertools.combinations(range(N), M))

sumabs = []
for i in a:
    sumtmp = [0, 0, 0]
    for j in i:
        sumtmp[0] += x[j]
        sumtmp[1] += y[j]
        sumtmp[2] += z[j]
    sumabs.append(sum(list(map(abs, sumtmp))))

print(max(sumabs))


### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())
x = [0]*N
y = [0]*N
z = [0]*N
for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())
x = np.array(x)
y = np.array(y)
z = np.array(z)


r = np.zeros((N,8))
r[:,0] =  x[:] +y[:] +z[:]
r[:,1] =  x[:] -y[:] +z[:]
r[:,2] =  x[:] +y[:] -z[:]
r[:,3] =  x[:] -y[:] -z[:]
r[:,4] = -x[:] +y[:] +z[:]
r[:,5] = -x[:] -y[:] +z[:]
r[:,6] = -x[:] +y[:] -z[:]
r[:,7] = -x[:] -y[:] -z[:]

print(int(max(np.sum(np.sort(r, axis=0)[::-1][:M,:],axis=0))))
### BUGGY CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n, m = IN()
	vl=[]
	for n in range(n):
		a,b = IN()
		vl.append((a,b))
		
	vl.sort(key=lambda x:-x[1])
	ret = 0
	nwdl=[-1]*(m+1) #list(range(m+1))
	for a,b in vl:
		j=m-a
		while j >= 0:
			if nwdl[j]==-1:
				nwdl[j]=0
				ret+=b
				break
			j-=1
		#pa((a,b,m-a,nwdl))
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)


### FIXED CODE ###

import sys
import queue

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

class node:
	def __init__(self,a_val, a_parent=None):
		self.val=a_val
		self.parent=a_parent
		self.right=None
		self.left=None

def main2():
	n, m = IN()
	vl=[]
	for n in range(n):
		a,b = IN()
		vl.append((a,b))
		
	vl.sort(key=lambda x:-x[1])
	ret = 0
	nwdl=[-1]*(m+1) #list(range(m+1))
	for a, b in vl:
		j=m-a
		while j >= 0:
			if nwdl[j]==-1:
				nwdl[j]=0
				ret+=b
				break
			j-=1
		#pa((a,b,m-a,nwdl))
	print(ret)
	
	
def main():
	n, m = IN()
	st_day=[[] for _ in range(m+1)]
	for n in range(n):
		duration, pay = IN()
		if duration > m:
			continue
		st_day[m-duration].append(pay)
	
	pq=queue.PriorityQueue()
	ret = 0
	for di in range(m+1):
		day=m-di
		for pay in st_day[day]:
			pq.put(-pay)
		if not pq.empty():
			v = pq.get()
			ret -= v
	print(ret)
			
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

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

hcnt = [0] * w
wcnt = [0] * h
field = {}
for i in range(m):
    y, x = map(int, input().split())
    y -= 1; x -= 1
    wcnt[y] += 1
    hcnt[x] += 1
    row = field.get(y, {})
    row[x] = True
    field[y] = row
def f(y, x):
    return bool(field.get(y, {}).get(x))
# print(wcnt)
# print(hcnt)
hmax = max(hcnt)
wmax = max(wcnt)
ans = hmax + wmax - 1
for i in np.argsort(hcnt)[::-1]:
    if hcnt[i] != hmax:
        break
    for j in np.argsort(wcnt)[::-1]:
        if wcnt[j] != wmax:
            break
        if not f(j, i):
            print(ans + 1)
            __import__("sys").exit()
print(ans)


### FIXED CODE ###

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

hcnt = [0] * w
wcnt = [0] * h
field = {}
for i in range(m):
    y, x = map(int, input().split())
    y -= 1; x -= 1
    wcnt[y] += 1
    hcnt[x] += 1
    row = field.get(y, {})
    row[x] = True
    field[y] = row
def f(y, x):
    return bool(field.get(y, {}).get(x))
# print(wcnt)
# print(hcnt)
hmax = max(hcnt)
wmax = max(wcnt)
ans = hmax + wmax - 1
harg = np.argsort(hcnt)[::-1]
warg = np.argsort(wcnt)[::-1]
for i in harg:
    if hcnt[i] != hmax:
        break
    for j in warg:
        if wcnt[j] != wmax:
            break
        if not f(j, i):
            print(ans + 1)
            __import__("sys").exit()
print(ans)
### BUGGY CODE ###

n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]
a = list(filter(lambda x: x in s, t))
print(len(a))


### FIXED CODE ###

def binarySearch(array, key):
    left = 0
    right = len(array)
    while left < right:
        mid = int((left + right) / 2)
        if key == array[mid]:
            return True
        elif key > array[mid]:
            left = mid + 1
        elif key < array[mid]:
            right = mid
        else:
            print("ERROR")
    return False


n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]
a = [x for x in t if binarySearch(s, x)]
print(len(a))
### BUGGY CODE ###

count = int(input())
zenbu = []

for x in range(count):
    keihin = str(input())

    if not keihin in zenbu:
        zenbu.append(keihin)
print(len(zenbu))

### FIXED CODE ###

count = int(input())
zenbu = set()
 
for x in range(count):
    keihin = input()
    zenbu.add(keihin)
print(len(zenbu))
### BUGGY CODE ###

def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,a):
    MOD=10**9+7
    hist=[0]*61
    bs=[]
    for i in range(n):
        # s=list(reversed(bin(a[i])[2:]))
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[j]+=1
        # bs.append(s)

        # s=bin(a[i])[2:]
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[len(s)-j-1]+=1
        j=0
        ai=a[i]
        while ai>0:
            if ai&1==1:
                hist[j]+=1
            ai = ai >> 1
            j+=1


    #print(bs)
    #print(hist)
    sum=0
    # for i in range(n-1):
    #     s=bs[i]
    #     b=1
    #     for j in range(len(s)):
    #         if s[j]=='0':
    #             sum=(sum+hist[j]*b)%MOD
    #         else:
    #             sum=(sum+( n-i-hist[j] )*b)%MOD
    #             hist[j]-=1
    #         b*=2
    #     for j in range(len(s),61):
    #         sum=(sum+hist[j]*b)%MOD
    #         b*=2
    b=1
    for j in range(61):
        sum=(sum+( hist[j]*(n-hist[j])*b )%MOD )%MOD
        b*=2

    return sum

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)


### FIXED CODE ###

def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,a):
    MOD=10**9+7
    hist=[0]*61
    bs=[]
    for i in range(n):
        # s=list(reversed(bin(a[i])[2:]))
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[j]+=1
        # bs.append(s)
        s=bin(a[i])[2:]
        for j in range(len(s)):
            if s[j]=='1':
                hist[len(s)-j-1]+=1

    #print(bs)
    #print(hist)
    sum=0
    # for i in range(n-1):
    #     s=bs[i]
    #     b=1
    #     for j in range(len(s)):
    #         if s[j]=='0':
    #             sum=(sum+hist[j]*b)%MOD
    #         else:
    #             sum=(sum+( n-i-hist[j] )*b)%MOD
    #             hist[j]-=1
    #         b*=2
    #     for j in range(len(s),61):
    #         sum=(sum+hist[j]*b)%MOD
    #         b*=2
    b=1
    for j in range(61):
        sum=(sum+( hist[j]*(n-hist[j])*b )%MOD )%MOD
        b*=2

    return sum

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
c=1
if m<2*n:
    print(1)
else:
    for i in range(m//n,0,-1):
        if m%i==0:
            print(i)
            break

### FIXED CODE ###

n, m = list(map(int,input().split()))
def solve():
    for i in range(m//n, 0, -1):
        if m % i == 0:
            if m//i>= n:
                print(i)
                break
solve()
### BUGGY CODE ###

N = int(input())
l = list(map(int, input().split()))
set_N = set(l)

for i in range(N):
  cnt = 0
  for sn in set_N:
    num = l.count(sn)
    if l[i]==sn:
      num -= 1
    cnt += num*(num-1)/2
  print(int(cnt))


### FIXED CODE ###

from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))