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

#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, A):
    allxor = 0
    for a in A:
        allxor ^= a

    B = [0] * N

    ans = 0
    bcount = 0
    for bit in range(61, -1, -1):
        mask = 1 << bit
        if allxor & mask:
            ans <<= 1
            ans |= 1
            continue

        bset = set()
        for i in range(N):
            b = B[i]
            b <<= 1
            b |= (A[i] & mask) >> bit
            B[i] = b
            bset.add(b)
        bcount += 1

        full_bit = (1 << bcount) - 1
        rset = set([0])
        for b in bset:
            for c in set(rset):
                rset.add(b ^ c)
            if full_bit in rset:
                break

        best = full_bit if full_bit in rset else full_bit - 1
        assert best in rset
        bestb = best & 1
        ans <<= 1
        ans |= bestb

        if bestb == 0:
            for i in range(N):
                B[i] >>= 1
            bcount -= 1

    return ans + (ans ^ allxor)


def main():
    N = int(inp())
    A = [int(e) for e in inp().split()]
    print(solve(N, A))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, A):
    allxor = 0
    for a in A:
        allxor ^= a

    while len(A) < 61:
        A.append(0)
    M = len(A)

    row = 0
    ans = 0
    for bi in range(61, -1, -1):
        b = 1 << bi
        if b & allxor:
            ans |= b
            continue

        if not (A[row] & b):
            j = -1
            for i in range(row + 1, M):
                if A[i] & b:
                    j = i
                    break
            if j == -1:
                continue

            A[row], A[j] = A[j], A[row]

        assert A[row] & b
        if not (ans & b):
            ans ^= A[row]

        for i in range(row + 1, M):
            if A[i] & b:
                A[i] ^= A[row]
            assert not (A[i] & b)

        row += 1

    return ans + (ans ^ allxor)


def main():
    N = int(inp())
    A = [int(e) for e in inp().split()]
    print(solve(N, A))


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

s = input()
Q = int(input())

rev_count = 0
for i in range(Q):
    que = input()
    if que[0] == '1':
        rev_count +=1
    elif que[0] == '2':
        if (rev_count + int(que[2]))%2 == 0:
            s = s + que[4]
        else:
            s = que[4] + s

print(s if rev_count %2 == 0 else s[-1::-1])


### FIXED CODE ###

s = input()
Q = int(input())

rev_count = 0
sbf=''
saf=''
for i in range(Q):
    que = input()
    if que[0] == '1':
        rev_count +=1
    elif que[0] == '2':
        if (rev_count + int(que[2]))%2 == 0:
            saf = saf + que[4]
        else:
            sbf = que[4] + sbf

print(sbf+s+saf if rev_count %2 == 0 else (sbf+s+saf)[-1::-1])
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
t = []
mod = (10 ** 9) + 7
count = 0
max_a = max(a)
for _ in range(len(bin(max(a))) - 2):
    t.append(sum([1 & i for i in a]))
    a = [i >> 1 for i in a]
    count += 1
ans = 0
for i, j in zip(t, range(count)):
    ans += i * (n - i) * (2 ** j)
    ans = ans % mod
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
mod = (10 ** 9) + 7
max_a = max(a)
ans = 0
for j in range(len(bin(max(a))) - 2):
    t = sum([1 & i for i in a]) 
    ans += (2 ** j) * t * (n - t)
    a = [i >> 1 for i in a]
    ans = ans % mod
print(ans)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

H, N = MAP()
A, B = [0]*N, [0]*N
for i in range(N):
	A[i], B[i] = MAP()


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


for i in range(N):
	for j in range(H+1):
		if j < A[i]:
			dp[i+1][j] = min(dp[i][j], B[i])
		else:
			dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i])

#for i in range(0, N+1):
#	print(dp[i])

print(dp[N][H])

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

def main():
	H, N = MAP()
	A, B = [0]*N, [0]*N
	for i in range(N):
		A[i], B[i] = MAP()

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


	for i in range(N):
		for j in range(H+1):
			if j < A[i]:
				dp[i+1][j] = min(dp[i][j], B[i])
			if j>= A[i]:
				dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i])
			

	#for i in range(N+1):
	#	print(dp[i])

	print(dp[N][H])

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

from sys import stdin
input = stdin.readline
def BFS(K,path,N):
  """リストのリスト道順path,頂点の個数Nが与えられたとき, 頂点Kから各頂点までの距離をlistで返す"""
  dist=[-1]*N
  dist[K]=0
  que=[K]
  while que:
    label=que.pop(0)
    for i,c in path[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        que+=[i]
  return dist
 
N=int(input())
path=[ [] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  path[a-1]+=[[b-1,c]]
  path[b-1]+=[[a-1,c]]
Q,K=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(Q)]
distance=BFS(K-1,path,N)
for i in range(Q):
  print(distance[xy[i][0]-1]+distance[xy[i][1]-1])

### FIXED CODE ###

from sys import stdin
input = stdin.readline
from collections import deque
def BFS(K,path,N):
  """リストのリスト道順path,頂点の個数Nが与えられたとき, 頂点Kから各頂点までの距離をlistで返す"""
  dist=[-1]*N
  dist[K]=0
  que=deque()
  que.append(K)
  while que:
    label=que.popleft()
    for i,c in path[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        que+=[i]
  return dist
 
N=int(input())
path=[ [] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  path[a-1]+=[[b-1,c]]
  path[b-1]+=[[a-1,c]]
Q,K=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(Q)]
distance=BFS(K-1,path,N)
for i in range(Q):
  print(distance[xy[i][0]-1]+distance[xy[i][1]-1])
### BUGGY CODE ###

def main():
    n, m = map(int, input().split())
    w = [0] * n
    v = [0] * n
    for i in range(n):
        wt, vt = list(map(int, input().split()))
        w[i] = wt
        v[i] = vt
    l = [0] * (m + 1)
    for i in range(n):
        l= [max(v[i] + l[j-w[i]], l[j]) if j - w[i] >= 0 else l[j] for j in range(m+1)]
    print(l[-1])
main()


### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    w = [0] * n
    v = [0] * n
    for i in range(n):
        w[i], v[i] = list(map(int, input().split()))
    l = [0] * (m + 1)
    for i in range(n):
        for j in range(m, w[i] - 1, -1):
            x = v[i] + l[j-w[i]]
            if x > l[j]:
                l[j] = x
    print(l[-1])
main()
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
for i in range(N):
    for j in range(i):
        if i - j == A[i] + A[j]:
            cnt += 1
print(cnt)


### FIXED CODE ###

from collections import defaultdict
d_i = defaultdict(list)
d_j = defaultdict(list)

N = int(input())
A = [int(a) for a in input().split()]

for i in range(N):
    d_i[i-A[i]].append(i)
    d_j[i+A[i]].append(i)

cnt = 0
for key in d_j.keys():
    arr_i = d_i[key]
    arr_j = d_j[key]
    cnt += len(arr_j) * len(arr_i)
print(cnt)
### BUGGY CODE ###

#coding:utf-8

import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

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

lcmv = 1
b_bar = []
for num in a:
    lcmv = lcm(num, lcmv)

ans = 0
for num in a:
    if num > lcmv:
        lcmv += 1000000007
    ans += lcmv // num
    ans %= 1000000007
print(ans)

### FIXED CODE ###

#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, mod-2, mod)
    ans %= mod
print(ans % mod)
### BUGGY CODE ###

from collections import Counter
N = int(input())
S =[Counter(input()) for i in range(N)]
ans = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    if S[i] == S[j]:
      ans += 1
print(ans)

### FIXED CODE ###

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

N = int(input())
lst = list(map(int, input().split()))
lst.sort()
lst.append(10**10)
total = 0
for i in range(N-1):
    for j in range(i+1, N-1):
        cnt = 0
        k = j+1
        while lst[j]+lst[i] > lst[k]:
            cnt += 1
            k += 1
        total += cnt
print(total)

### FIXED CODE ###

import bisect
N = int(input())
lst = list(map(int, input().split()))
lst.sort()
total = 0
for i in range(N-1):
    for j in range(i+1, N-1):
        x = bisect.bisect_left(lst, lst[i]+lst[j])
        total += x-j-1
print(total)
### BUGGY CODE ###

N = int(input())
a = input().split(" ")
b= []

flag = True
for i in range(N):

    if a[i] in b:
        flag = False
    b.append(a[i])


if flag:
    print("YES")

else:
    print("NO")


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split(" ")))
b=a
b.sort()

flag = True
s =0
e =N-1
for i in range(N-1):
    if b[i] == b[i+1]:
        flag = False
        break
        



if flag:
    print("YES")

else:
    print("NO")
### BUGGY CODE ###


from collections import defaultdict
from functools import lru_cache
itl = lambda: list(map(int, input().strip().split()))


def solve():
    N = int(input())
    nums = itl()
    S = input().strip()
    @lru_cache(None)
    def dp(i, target):
        if i == N:
            return (target == 0)
        if S[i] == '0':
            return dp(i + 1, target ^ nums[i]) or dp(i + 1, target)
        else:
            return dp(i + 1, target ^ nums[i]) and dp(i + 1, target)
    return 0 if dp(0, 0) else 1


T = int(input())
for _ in range(T):
    print(solve())

### FIXED CODE ###

from collections import defaultdict
itl = lambda: list(map(int, input().strip().split()))


def solve():
    N = int(input())
    nums = itl()
    S = input().strip()

    basis = []
    for i in range(N - 1, -1, -1):
        v = nums[i]
        for b in basis:
            v = min(v, v ^ b)
        if v:
            if S[i] == '1':
                return 1
            basis.append(v)
    return 0    


T = int(input())
for _ in range(T):
    print(solve())
### BUGGY CODE ###

from heapq import heappush, heappushpop


def main():
    x, y, z, k = map(int, input().split())
    aa = sorted(map(int, input().split()), reverse=True)
    bb = sorted(map(int, input().split()), reverse=True)
    cc = sorted(map(int, input().split()), reverse=True)

    heap = []
    for a in aa:
        if len(heap) == k and a + bb[0] + cc[0] < heap[0]:
            break
        for b in bb:
            if len(heap) == k and a + b + cc[0] < heap[0]:
                break
            for c in cc:
                v = a + b + c
                if len(heap) < k:
                    heappush(heap, v)
                    continue
                if v < heap[0]:
                    break
                heappushpop(heap, v)

    for v in sorted(heap, reverse=True):
        print(v)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from heapq import heappop, heappush


def main():
    x, y, z, k = map(int, input().split())
    aa = sorted(map(int, input().split()))
    bb = sorted(map(int, input().split()))
    cc = sorted(map(int, input().split()))
    v = aa[-1] + bb[-1] + cc[-1]
    t = (len(aa) - 1, len(bb) - 1, len(cc) - 1)
    q = [(-v, t)]
    vs = []
    ts = set()
    while len(vs) < k:
        nv, t = heappop(q)
        if t in ts:
            continue
        vs.append(-nv)
        ts.add(t)
        if t[0] > 0:
            heappush(q, (-(aa[t[0] - 1] + bb[t[1]] + cc[t[2]]), (t[0] - 1, t[1], t[2])))
        if t[1] > 0:
            heappush(q, (-(aa[t[0]] + bb[t[1] - 1] + cc[t[2]]), (t[0], t[1] - 1, t[2])))
        if t[2] > 0:
            heappush(q, (-(aa[t[0]] + bb[t[1]] + cc[t[2] - 1]), (t[0], t[1], t[2] - 1)))
    for v in vs:
        print(v)


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

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


### FIXED CODE ###

import collections
N = int(input())
strA = input().split()
ans = collections.Counter(strA)
for i in range(1, N+1):
    print(ans[str(i)])
### BUGGY CODE ###

import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


def solve():

    S = ['0'] + list(reversed(input()))
    N = len(S) - 1
    dp = np.full((N + 1, 13), -1, dtype='i8')
    dp[0][0] = 1

    for i in range(1, N + 1):
        if S[i] == '?':
            for j in range(13):
                if dp[i - 1][j] != -1:
                    for k in range(10):
                        n = k * (10 ** (i - 1))
                        r = n % 13
                        jj = (j + r) % 13
                        if dp[i][jj] == -1:
                            dp[i][jj] = dp[i - 1][j]
                        else:
                            dp[i][jj] = (dp[i][jj] + dp[i - 1][j]) % mod

        else:
            for j in range(13):
                if dp[i - 1][j] != -1:
                    n = int(S[i]) * (10 ** (i - 1))
                    r = n % 13
                    jj = (j + r) % 13
                    dp[i][jj] = dp[i - 1][j]

    ans = dp[N][5] if dp[N][5] != -1 else 0
    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

mod = 10 ** 9 + 7

S = input()
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= mod
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= mod
    mul = mul * 10 % 13

print(dp[len(S)][5])
### BUGGY CODE ###

# coding: utf-8
def check(a, b, c):
    return (a < b + c) and (b < a + c) and (c < a + b)
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        for k in range(j+1, N):
            c = L[k]
            if check(a, b, c):
                ans += 1
print(ans)

### FIXED CODE ###

# coding: utf-8
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        ans += bisect_left(L, a+b) - 1 - j
print(ans)
### BUGGY CODE ###

import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
shortest_path_dict = nx.shortest_path(G, target=1)
if len(shortest_path_dict)<room:
  print('No')
else:
  print('Yes')
  for i in range(2,room+1):
    print(shortest_path_dict[i][1])


### FIXED CODE ###

import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])
### BUGGY CODE ###

import sys
input=sys.stdin.readline   #input高速化 １文字の時の改行文字に注意+

d={i:0 for i in range(3001)}
db={i:0 for i in range(3001)}

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

x=sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda xxx:xxx[0])
dp=[]
dp2=[]
for time,value in x:
    for k,v in d.copy().items():
        if k+time<t:
            if d[k+time]<v+value:
                d[k+time]=v+value
        else:
            break
    l=[0]
    for i in range(1,t+1):
        if d[i]>l[-1]:
            l.append(d[i])
        else:
            l.append(l[-1])

    dp.append(l)    
        
for time,value in x[::-1]:
    for k,v in db.copy().items():
        if k+time<t:
            if db[k+time]<v+value:
                db[k+time]=v+value
        else:
            break

    l=[0]
    for i in range(1,t+1):
        if db[i]>l[-1]:
            l.append(db[i])
        else:
            l.append(l[-1])
        
    dp2.append(l)
dp=[[0]*t,[0]*t]+dp
dp2=([[0]*t,[0]*t]+dp2)[::-1]

ans=0

for i in range(len(dp)):
    for j in range(t):
        if i==0 or i==len(dp)-1:
            tmp=dp[i][j]+dp2[i][t-j-1]
            if ans<tmp:
                ans=tmp
        else:
            tmp=dp[i][j]+dp2[i][t-j-1]+x[i-1][1]
            if tmp>ans:
                ans=tmp
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline   #input高速化 １文字の時の改行文字に注意+

d={i:0 for i in range(3001)}
db={i:0 for i in range(3001)}

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

x=[tuple(map(int,input().split()))for i in n*[0]]
x.sort()
dp=[]
dp2=[]
for time,value in x:
    for k,v in d.copy().items():
        if k+time<t:
            if d[k+time]<v+value:
                d[k+time]=v+value
        else:
            break
    l=[0]
    for i in range(1,t+1):
        if d[i]>l[-1]:
            l.append(d[i])
        else:
            l.append(l[-1])

    dp.append(l)    
        
for time,value in x[::-1]:
    for k,v in db.copy().items():
        if k+time<t:
            if db[k+time]<v+value:
                db[k+time]=v+value
        else:
            break

    l=[0]
    for i in range(1,t+1):
        if db[i]>l[-1]:
            l.append(db[i])
        else:
            l.append(l[-1])
        
    dp2.append(l)
dp=[[0]*t,[0]*t]+dp
dp2=([[0]*t,[0]*t]+dp2)[::-1]

ans=0

for i in range(len(dp)):
    for j in range(t):
        if i==0 or i==len(dp)-1:
            tmp=dp[i][j]+dp2[i][t-j-1]
            if ans<tmp:
                ans=tmp
        else:
            tmp=dp[i][j]+dp2[i][t-j-1]+x[i-1][1]
            if tmp>ans:
                ans=tmp
print(ans)
### BUGGY CODE ###

R, C, K = map(int, input().split())
goods = [[0] * C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    goods[r-1][c-1] = v

dp = [[[0] * 4 for _ in range(C)] for _ in range(R)]
dp[0][0][1] = goods[0][0]
for i in range(R):
    for j in range(C):
        for k in range(4):
            if i < R - 1:
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
                dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + goods[i+1][j])
        
            if j < C - 1:
                dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
                if k < 3:
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + goods[i][j+1])

print(max(dp[R-1][C-1]))

### FIXED CODE ###

R, C, K = map(int,input().split())
MAP = [[0 for i in range(C)] for j in range(R)]
DP = [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)]
 
for _ in range(K):
    r, c, v = map(int,input().split())
    MAP[r-1][c-1] = v
 
for i in range(R):
    for j in range(4):
        for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v)

print(DP[R][3][C])
### BUGGY CODE ###

from functools import reduce
from math import gcd

K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            total += reduce(gcd, [a,b,c])
print(total)

### FIXED CODE ###

import math 
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
 
a = int(input())
 
ans = 0
 
for i in range(1,a+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j and i == k:
                ans += gcd(i,j,k)
            elif i == j or i == k or j == k:
                ans += gcd(i,j,k)*3
            else:
                ans += gcd(i,j,k)*6
print(ans)
### BUGGY CODE ###

import sys
X = int(input())
S = int(X ** (1/5) + 1)

for i in range(10000):
    for j in range(10000):
        a = i ** 2
        b = j ** 2
        c = i * j
        if (i - j) * (a * (a ** 2 + c + b) + b * (c + b)) == X:
            print(i,j)
            sys.exit()
        elif (i + j) * (a * (a ** 2 - c + b) + b * (-c + b)) == X:
            print(i,-j)
            sys.exit()


### FIXED CODE ###

import sys
X = int(input())
# for i in range(1000):
#     for j in range(1000):
#         a = i ** 2
#         b = j ** 2
#         c = i * j
#         if (i - j) * (a * (a ** 2 + c + b) + b * (c + b)) == X:
#             print(i,j)
#             sys.exit()
#         elif (i + j) * (a * (a ** 2 - c + b) + b * (-c + b)) == X:
#             print(i,-j)
#             sys.exit()

for i in range(-118,120):
    for j in range(-118,120):
        if i ** 5 - j ** 5 == X:
            print(i,j)
            sys.exit()
### BUGGY CODE ###

import collections
def main(): 
    N = int(input())
    A = list(map(int, input().split()))

    for i in range(N):
        ans = 0
        a = A[:i]+A[i+1:]
        C = collections.Counter(a)
        for v in C.values():
            ans += (v*(v-1))//2
        print(ans)
        
main()

### FIXED CODE ###

import collections

def main(): 
    N = int(input())
    A = list(map(int, input().split()))
    cnt = [0]*(N+1)
    C = collections.Counter(A)
    
    for k, v in C.items():
        cnt[k] = v*(v-1)//2
    S = sum(cnt)
    
    for i in A:
        print(S - cnt[i] + (C[i]-1)*(C[i]-2)//2)
        
main()