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

from collections import defaultdict
import os, sys
# def debug(*args): print(*args, file=sys.stderr)# os.environ.get("USER")
def debug(*args): os.environ.get("USER")
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
#print(dd)
B=sorted(A,reverse=True)
ans=0
for x in B:
    debug(A)
    #print(x)
    if dd.get(x,-1)==0:
        continue
    s=len(bin(x))-3
    if x==1<<s:
        t=dd.get(x,-1)
        if t!=-1:
            ans+=t//2
            dd[x]-=(t//2)*2
            #print(ans)
            #print(dd)
    else:
        s+=1
        #print((1<<s)-x)
        t=dd.get((1<<s)-x,-1)
        if t>=1:
            ans+=1
            dd[x]-=1
            dd[(1<<s)-x]-=1
            #print(ans)
            #print(dd)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
m = 0
while True:
    if 2**m > max_a:
        break
    m += 1
used = [False] * n


def bisect(val, start, end):
    if start >= end:
        return None
    elif start + 1 == end:
        if a[start] == val:
            if used[start]:
                return None
            used[start] = True
            return start
        else:
            return None
    mid = (start + end) // 2
    if a[mid] == val:
        if used[mid]:
            res = bisect(val, start, mid)
            return res
        else:
            res = bisect(val, mid+1, end)
            if res is not None:
                return res
            used[mid] = True
            return mid
        # if used[mid]:
        #     res = bisect(val, mid+1, end)
        #     if res is not None:
        #         return res
        #     res = bisect(val, start, mid)
        #     return res
        # else:
        #     used[mid] = True
        #     debug("fuga", used)
        #     return mid
    elif a[mid] > val:
        return bisect(val, start, mid)
    else:
        return bisect(val, mid, end)
    # for i in reversed(range(end)):
    #     if (not used[i]) and (a[i]  == val):
    #         used[i] = True
    #         return i
    return None


def _find(b, end, e):
    "slow!!!!"
    # debug(b, end, e)
    val = 2**e - b
    if val <= 0:
        return None
    return bisect(val, 0, end)
    # for i in reversed(range(end)):
    #     if (not used[i]) and (a[i] + b == 2**e):
    #         used[i] = True
    #         return i
    # return None


def find(b, end):
    for e in reversed(range(m+1)):
        res = _find(b, end, e)
        if res is not None:
            return True
    return False


ans = 0
for j in reversed(range(n)):
    if used[j]:
        continue
    b = a[j]
    used[j] = True
    res = find(b, j)
    if res:
        ans += 1


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

# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush
from random import randint
from collections import defaultdict
from itertools import accumulate
from fractions import gcd
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
A = inpl()
#N = 10**4
#A = [randint(0, 10**6) for _ in range(10**4)]

lcm = 1
for a in A:
    lcm = a * lcm // gcd(a, lcm)
ans = 0
for i in range(N):
    ans = (ans + lcm // A[i])%MOD
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush
from random import randint
from collections import defaultdict
from itertools import accumulate
from fractions import gcd
from collections import defaultdict
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


P = primes(10**3)

size = 10**6 + 1
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 

N = int(input())
A = inpl()

#N = 10**4
#A = [randint(0, 10**6) for _ in range(10**4)]
D = defaultdict(int)
for a in A:
    for p in P:
        tmp = 0
        while a%p == 0:
            tmp += 1
            a //= p
        if tmp:
            D[p] = max(D[p], tmp)
        if a == 1:
            break
    if a != 1:
        D[a] = 1

lmc = 1
for k, v in D.items():
    lmc = lmc * pow(k, v, MOD)%MOD

ans = 0
for a in A:
    ans = (ans + lmc*inverse[a])%MOD
print(ans)
### BUGGY CODE ###

from itertools import product, compress

N = int(input())
Ss = input()

ans = 0
for sels in product([0, 1], repeat=N):
    Fs = list(compress(Ss[:N], sels))[::-1]
    Gs = list(compress(Ss[:N], map(lambda x: 1-x, sels)))[::-1]

    lenF = len(Fs)
    lenG = N - lenF
    dp = [[0] * (lenF + 1) for i in range(N + 1)]
    dp[0][0] = 1
    for i, s in enumerate(Ss[N:], 1):
        for j in range(lenF + 1):
            if 0 <= j-1 and s == Fs[j-1]:
                dp[i][j] += dp[i-1][j-1]
            if 0 <= i-j-1 < lenG and s == Gs[i-j-1]:
                dp[i][j] += dp[i-1][j]

    ans += dp[N][lenF]

print(ans)


### FIXED CODE ###

from itertools import product, compress

N = int(input())
Ss = input()

Fss = [list(compress(Ss[:N], sels))[::-1] for sels in product([0, 1], repeat=N)]

ans = 0
for iFs in range(2 ** N):
    Fs = Fss[iFs]
    Gs = Fss[2 ** N - 1 - iFs]

    lenF = len(Fs)
    lenG = N - lenF
    dp = [1] + [0] * lenF
    for i, s in enumerate(Ss[N:]):
        dp2 = [0] * (lenF + 1)
        for j in range(lenF + 1):
            if dp[j] == 0: continue
            if j < lenF and s == Fs[j]:
                dp2[j+1] += dp[j]
            if 0 <= i-j < lenG and s == Gs[i-j]:
                dp2[j] += dp[j]
        dp = dp2

    ans += dp[lenF]

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

n = int(input())
A = list( int(x) for x  in input().split() )

fumidai = 0

for i in range(n):
    x_list = A[0:i+1]
    max_list = max(x_list)
    if max_list > A[i]:
        fumidai += max_list - A[i]

print(fumidai)

### FIXED CODE ###

n = int(input())
A = list( int(x) for x  in input().split() )

fumidai = 0
great = A[0]

for i in range(n):
    if great > A[i]:
        fumidai += great - A[i]
    else:
        great = A[i]

print(fumidai)
### BUGGY CODE ###

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

import sys
import numpy as np

def main():
    n,k = map(int,(input().split()))
    items=[np.array((input().split()),int) for _ in range(n)]
    dp = np.zeros((n,k+1))
    for i in range(n):
        for j in range(k+1):
            if i==0 and j>=items[0][0]:
                dp[0][j]=items[0][1]
            elif i>0 and j>=items[i][0]:
                dp[i][j]=max(dp[i-1][j],items[i][1]+dp[i-1][j-items[i][0]])
            elif j < items[i][0] and i > 0:
                dp[i][j]=dp[i-1][j]
    print (int(dp.max()))

if __name__ == "__main__":
    main()

### FIXED CODE ###

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

import sys

def main2():
    n,k = map(int,(input().split()))
    items=[list(map(int,input().split())) for _ in range(n)]
    dp = [[0 for _ in range(k+1)] for _ in range(n)]
    for i in range(n):
        for j in range(k+1):
            if i==0 and j>=items[0][0]:
                dp[0][j]=items[0][1]
            elif i>0 and j>=items[i][0]:
                dp[i][j]=max(dp[i-1][j],items[i][1]+dp[i-1][j-items[i][0]])
            elif j < items[i][0] and i > 0:
                dp[i][j]=dp[i-1][j]
    print (dp[-1][-1])

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

import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)
    bi.sort()
    bi = np.hstack((bi - 2*T, bi))
    tmp=0
    left1 = bl(bi, T - ai)
    right1 = bl(bi, 2*T - ai)
    left2 = bl(bi, 3*T - ai)
    right2 = bl(bi, 4*T - ai)
    
    if np.sum(-left1 + right1) % 2: ans+=T

"""
    for j in range(N):
        x=a[j]%(2*T)
        tmp+= -bl(bi,T-x)+bl(bi,2*T-x)-bl(bi,3*T-x)+bl(bi,4*T-x)
"""


print(ans)

### FIXED CODE ###

import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)
    bi.sort()

    tmp=0
    left1 = bl(bi, T - ai)
    right1 = bl(bi, 2*T - ai)
    left2 = bl(bi, 3*T - ai)
    right2 = bl(bi, 4*T - ai)    
    if np.sum(-left1 + right1 -left2 +right2) % 2: ans+=T

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

N = int(input())
count = 0

for i in range(1,N):
    for j in range(1,int(N/i)+1):
        if N - i*j > 0:
            count += 1

print(count)

### FIXED CODE ###

N = int(input())
count = 0

for i in range(1,N):
    count += int((N-1)/i)

print(count)
### BUGGY CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect
import statistics
mod = 10**9+7

N = int(input())
al = [[] for i in range(N+1)]

for i in range(N-1):
    a, b = list(map(int, input().split()))

    al[a].append(b)
    al[b].append(a)

b = [0 for i in range(N + 1)]
w = [0 for i in range(N + 1)]
seen = [0 for i in range(N + 1)]

@functools.lru_cache(None)
def bfs(u):
    seen[u] = 1

    b[u] = 1
    w[u] = 1

    for v in al[u]:
        if seen[v] == 0:
            seen[v] = 1
            bfs(v)
            b[u] = (b[u] * w[v]) % mod
            w[u] = (w[u] * ((b[v] + w[v]) % mod)) % mod
            flag = 1

bfs(1)

print((b[1] + w[1]) % mod)






### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect
import statistics
mod = 10**9+7

N = int(input())
al = [[] for i in range(N+1)]

for i in range(N-1):
    a, b = list(map(int, input().split()))

    al[a].append(b)
    al[b].append(a)

b = [0 for i in range(N + 1)]
w = [0 for i in range(N + 1)]
seen = [0 for i in range(N + 1)]

@functools.lru_cache(None)
def bfs(u):
    seen[u] = 1

    b[u] = 1
    w[u] = 1

    for v in al[u]:
        if seen[v] == 0:
            seen[v] = 1
            bfs(v)
            b[u] = (b[u] * w[v]) % mod
            w[u] = (w[u] * ((b[v] + w[v]) % mod)) % mod

bfs(1)

print((b[1] + w[1]) % mod)
### BUGGY CODE ###

from collections import Counter

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

# 階上の計算
from math import factorial

def prime_decomposition(n):
  i = 2
  table = []

  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1

  if n > 1:
    table.append(n)

  return list(Counter(table).values())

def nHr(n, r):
    return factorial(n+r-1) // (factorial(r) * factorial(n-1))


mod = 10 ** 9 + 7

ans = 1

prim_d_num = prime_decomposition(M)

for p in prim_d_num:
    ans *= nHr(p+1, N-1)

print(ans % mod)


### FIXED CODE ###

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

# 階上の計算
from math import factorial
from collections import defaultdict

def prime_decomposition(n):
  i = 2
  table = defaultdict(int)

  while i * i <= n:
    while n % i == 0:
      n /= i
      table[i] += 1
    i += 1

  if n > 1:
    table[n] += 1

  return list(table.values())


def nHr(n, r):
    return factorial(n+r-1) // (factorial(r) * factorial(n-1))


mod = 10 ** 9 + 7

ans = 1

prim_d_num = prime_decomposition(M)

for p in prim_d_num:
    ans *= nHr(p+1, N-1)

print(ans % mod)
### BUGGY CODE ###

# coding: utf-8
from collections import defaultdict, deque


def popcount(x):
    count = 0
    for i in range(int.bit_length(x)):
        count += (x >> i) & 1
    return count


def solve(*args: str) -> str:
    n = int(args[0])
    x = int(args[1], 2)

    ret = []
    dp = defaultdict(int)
    for i in range(n):
        m = x ^ (1 << (n-i-1))
        count = 0
        deq = deque()
        while m:
            deq.append(m)
            if 0 < dp[m]:
                count += dp[m]
                break

            m = m % popcount(m)
            count += 1
        ret.append(str(count))

        while deq:
            dp[deq.popleft()] = count
            count -= 1

    return '\n'.join(ret)


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


### FIXED CODE ###

# coding: utf-8
from collections import defaultdict, deque


def popcount(x):
    assert x.bit_length() <= 32
    x -= (x >> 1) & 0x55555555
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x += x >> 8
    x += x >> 16
    return x & 0x3f


def solve(*args: str) -> str:
    n = int(args[0])
    x = args[1]

    ret = []
    dp = defaultdict(int)
    x_count = x.count('1')
    x_dec = int(x, 2)

    x_mod_set = x_dec % (x_count+1)
    xor_set = 1 % (x_count+1)
    if 1 < x_count:
        x_mod_reset = x_dec % (x_count-1)
        xor_reset = 1 % (x_count-1)

    for i in range(n):
        bitcount = x_count + (1 if x[-1-i] == '0' else -1)
        if bitcount == 0:
            ret.append(str(0))
            continue

        m = (x_mod_set + xor_set
             if x[-1-i] == '0' else
             x_mod_reset - xor_reset) % bitcount
        deq = deque([m])

        count = 1
        while m:
            deq.append(m)
            if 0 < dp[m]:
                count += dp[m]
                break

            m = m % popcount(m)
            count += 1

        ret.append(str(count))

        while deq:
            dp[deq.popleft()] = count
            count -= 1

        xor_set = (xor_set << 1) % (x_count+1)
        if 1 < x_count:
            xor_reset = (xor_reset << 1) % (x_count-1)

    return '\n'.join(ret[::-1])


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

import numpy as np
N = int(input())
As = np.array(list(map(int, input().split())))

res = np.zeros_like(As)
for idx, ai in zip(np.arange(N-1, -1, -1), As[::-1]):
    oe = res[idx::(idx+1)].sum() % 2
    res[idx] = ai ^ oe

idxs = np.where(res)[0] + 1
print(len(idxs))
print(" ".join(idxs.astype(str)))

### FIXED CODE ###

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

res = [0] * N
for idx, ai in zip(range(N-1, -1, -1), As[::-1]):
    oe = sum([res[i] for i in range(idx, N, idx+1)]) % 2#
    res[idx] = ai ^ oe

print(sum(res))
idxs = []
for i, val in enumerate(res):
    if val:
        idxs += [i + 1]
print(*idxs)
### BUGGY CODE ###

def is_prime(x):
    if x==1:
        return False
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True
    
def like2017_1tox(x):
    cnt=0
    for i in range(1,x+1,+2):
        if is_prime(i):
            if is_prime((i+1)//2):
                cnt+=1
        
    return cnt
    
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    print(like2017_1tox(b)-like2017_1tox(a-1))


### FIXED CODE ###

from functools import lru_cache
@lru_cache(maxsize=None)
def is_prime(x):
    if x==1:
        return False
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

# @lru_cache(maxsize=None)
def like2017(x):
    return is_prime(i) and is_prime((i+1)//2)
    
table=[0,0]
for i in range(2,10**5):
    table+=table[i-1]+like2017(i),
        
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    print(table[b]-table[a-1])
# print(table)
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
b = []
if N > 10 ** 5:
  for i in range(N, 10 ** 5, -1):
    if a[i - 1] == 1:
      b.append(i)
for i in range(min(10 ** 5, N), 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
b = list(map(str, b))
print(" ".join(b))


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)
### BUGGY CODE ###

input_len = int(input())
ans = 1
for i in range(1, input_len+1):
    ans *= i

ans = ans % ((10 ** 9) + 7)
print(ans)

### FIXED CODE ###

input_len = int(input())
ans = 1
for i in range(1, input_len+1):
    ans = (i * ans) % (10 ** 9 + 7)

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

n = int(input())

arr=[]

for i in range(n):
	z = [str(x) for x in input()]
	z.sort()
	#print(z)
	arr.append(z)

cnt = 0
#print(arr)

for i in range(n):
	for j in range(i+1,n):
		if arr[i] == arr[j]:
			cnt+=1

print(cnt)



### FIXED CODE ###

N = int(input())
 
S = {}
count = 0
for i in range(N):
  sorted_string = ''.join(sorted(input()))
  if sorted_string in S:
    S[sorted_string] += 1
    count += S[sorted_string]
  else:
    S[sorted_string] = 0
 
print(count)
### BUGGY CODE ###

n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())

r = [0]*(n+1)
r[0] = 1
if 1 in a:
  r[1] = 0
else:
  r[1] = 1
for i in range(2, n+1):
  if i in a:
    continue
  r[i] = (r[i-1] + r[i-2])%1000000007

print(r[n])

### FIXED CODE ###

n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())

up = [0]*(m+1)
if m == 0:
  up[0] = n
else:
  up[0] = a[0]-1
  up[m] = n - a[m-1]-1
  for i in range(m-1):
    up[i+1] = a[i+1]-a[i]-2

ans = 1
if -1 in up:
  ans = 0
else:
  f = [0]*(max(up)+1)
  f[0] = 1
  if max(up) > 0:
    f[1] = 1
    for i in range(2, max(up)+1):
      f[i] = f[i-1] + f[i-2]
  for i in range(m+1):
    ans *= f[up[i]]

print(ans % 1000000007)
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
t = []
c = 0
for i in p:
    t += [i]
    if i <= min(t):
        c += 1
print(c)


### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
t = n
c = 0
for i in range(n):
    t = min(t, p[i])
    if p[i] <= t:
        c += 1
print(c)
### BUGGY CODE ###

N,Q=map(int, input().split())
node_lst=[list(map(int, input().split())) for i in range(N-1)]
ope_lst=[list(map(int, input().split())) for i in range(Q)]
cnt_lst=[0 for i in range(N)]
child_rel={}
parent_rel={}
for l in node_lst:
    src, dst = l[0], l[1]
    if src not in child_rel.keys():
        child_rel[src]=[dst]
    else:
        child_rel[src].append(dst)
    if src in parent_rel.keys():
        for e in parent_rel[src]:
            child_rel[e].append(dst)
    if dst not in parent_rel.keys():
        parent_rel[dst]=[src]
    else:
        parent_rel[dst].append(src)
for ope in ope_lst:
    p, x = ope[0], ope[1]
    cnt_lst[p-1]+=x
    if p in child_rel.keys():
        for e in child_rel[p]:
            cnt_lst[e-1]+=x
print(" ".join([str(c) for c in cnt_lst]))

### FIXED CODE ###

N,Q=map(int, input().split())
node_lst=[list(map(int, input().split())) for i in range(N-1)]
ope_lst=[list(map(int, input().split())) for i in range(Q)]
cnt_lst=[0 for i in range(N)]
for ope in ope_lst:
    p, x = ope[0], ope[1]
    cnt_lst[p-1]+=x
node_lst=sorted(node_lst, key=lambda x:x[0])
for l in node_lst:
    src, dst = l[0]-1, l[1]-1
    cnt_lst[dst]+=cnt_lst[src]
print(" ".join([str(c) for c in cnt_lst]))
### BUGGY CODE ###

import copy
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

for ai in a:
    ans = 0
    temp = copy.copy(c)
    temp[ai] = temp[ai] - 1
    for v in temp.values():
        # print(v)
        if v >= 2:
            ans += cmb(v, 2)
    print(ans)
temp = copy.copy(c)
temp[1] = temp[1] - 1
# print(c)
# print(temp)

### FIXED CODE ###

import copy
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
total = 0
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
for v in c.values():
    if v >= 2:
        total += cmb(v, 2)
# print(total)

for ai in a:
    if c[ai] >= 2:
        # print('Y')
        ans = total - cmb(c[ai], 2)
        if c[ai] - 1 >= 2:
            ans += cmb(c[ai] - 1, 2)
    else:
        ans = total
    print(ans)
    # ans = 0
    # temp = copy.copy(c)
    # temp[ai] = temp[ai] - 1

    # for v in temp.values():
    #     # print(v)
    #     if v >= 2:
    #         ans += cmb(v, 2)
    # print(ans)
# temp = copy.copy(c)
# temp[1] = temp[1] - 1
# print(c)
# print(temp)
### BUGGY CODE ###

import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
for j in range(k):
  b = np.array([0]*n)
  for i in range(n):
    b[max(0, i-a[i]):min(n, i+a[i]+1)] += 1
  a = b
  if np.count_nonzero(a == n) == n:
    break
print(" ".join(list(map(str, a))))
      
  

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for j in range(min(k, 41)):
  b = [0]*n
  for i in range(n):
    l = max(0, i-a[i])
    r = min(n, i+a[i]+1)
    b[l] += 1
    if r < n:
      b[r] -= 1
  for i in range(1, n): 
    b[i]+=b[i-1]
  a = b

print(" ".join(list(map(str, a))))
### BUGGY CODE ###

n=int(input())
s=str(input())
ans=0
i=0
while i<1000:
  temp=i//100
  #temp.append(i//100)
  #temp.append((i-(i//100)*100)//10)
  #temp.append(i%10)
  cnt=0
  k=0
  for j in range(0,n):
    if temp==int(s[j]):
      cnt=cnt+1
      k=j
      break
  if cnt==0:
    i=i+100
  else:
    temp=(i-(i//100)*100)//10
    for j in range(k+1,n):      
      if temp==int(s[j]):
        cnt=cnt+1
        k=j
        break
    if cnt==1:
      i=i+10
    else:
      temp=i%10
      i=i+1
      for j in range(k+1,n):
        if temp==int(s[j]):
          ans=ans+1
          break
print(ans)

### FIXED CODE ###

n=int(input())
s=str(input())
ans=0
i=0
while i<1000:
  temp=i//100
  cnt=0
  k=0
  for j in range(0,n):
    if temp==int(s[j]):
      cnt=cnt+1
      k=j
      break
  if cnt==0:
    i=i+100
  else:
    temp=(i-(i//100)*100)//10
    for j in range(k+1,n):      
      if temp==int(s[j]):
        cnt=cnt+1
        k=j
        break
    if cnt==1:
      i=i+10
    else:
      temp=i%10
      i=i+1
      for j in range(k+1,n):
        if temp==int(s[j]):
          ans=ans+1
          break
print(ans)