Harryxun/stf_run huggingface dataset:
n, y = map(int,input().split())

ans = [-1,-1,-1]
for i in range(n,-1,-1):
    if i*10000 > y:
        continue
    else:
        yt = y-i*10000
        nt = n-i
        for j in range(min(yt//5000+1,nt+1)):
            yn = yt - j*5000
            nn = nt - j
            if nn*1000 == yn:
                ans = [i,j,nn]
                break
        if ans != [-1,-1,-1]:
            break
print(" ".join(ans))

### FIXED CODE ###

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

ans = [-1,-1,-1]
for i in range(n,-1,-1):
    if i*10000 > y:
        continue
    else:
        yt = y-i*10000
        nt = n-i
        for j in range(min(yt//5000+1,nt+1)):
            yn = yt - j*5000
            nn = nt - j
            if nn*1000 == yn:
                ans = [i,j,nn]
                break
        if ans != [-1,-1,-1]:
            break
ans = map(str,ans)
a = " ".join(ans)
print(a)
n = int(input())
p = list(map(int,input().split()))
ps = p.sort()

ans = ps[n/2] - ps[n/2-1]
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
p.sort()
 
ans = p[n//2] - p[n//2-1]
print(ans)
from bisect import bisect_left

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

a.sort()
z = a.count(0)
mc = bisect_left(a, 0)
pc = n - z - mc

if k <= mc * pc:
    d = a[:mc]
    u = a[mc + z:]
    H = 0
    L = d[0] * u[-1]
    D = len(d)
    while H - L > 1:
        M = (H + L) // 2
        count = 0
        P = 0
        for x in u:
            while P < D:
                if d[P] > M // x:
                    break
                P += 1
            count += P
        if count == k:
            break
        elif count < k:
            L = M
        else:
            H = M
    print(H)
    exit()
elif k <= mc * pc + z * (n - z) + z * (z - 1) // 2:
    print(0)
    exit()

d = list(map(lambda x: -x, reversed(a[:mc])))
u = a[mc + z:]
D = len(d)
U = len(u)

k -= mc * pc + z * (n - z) + z * (z - 1) // 2
L = 0
H = max(d[-1] * d[-1], u[-1] * u[-1])

while H - L > 1:
    M = (H + L) // 2
    count = 0
    P = 0
    for i in range(U-1, -1, -1):
        x = u[i]
        while P < U:
            if u[P] * x > M:
                break
            P += 1
        count += P
    for i in range(U):
        if u[i] ** 2 <= M:
            count -= 1
        else:
            break
    P = 0
    for i in range(D-1, -1, -1):
        x = d[i]
        while P < D:
            if d[P] * x > M:
                break
            P += 1
        count += P
    for i in range(D):
        if d[i] ** 2 <= M:
            count -= 1
        else:
            break
    count //= 2
    if count < k:
        L = M
    else:
        H = M
print(H)


### FIXED CODE ###

import numpy as np

n, k = map(int, input().split())
a = np.array(input().split(), np.int64)

a = np.sort(a)

u = a[a > 0]
d = a[a < 0]
z = len(a[a == 0])

if len(u) * len(d) < k <= len(u) * len(d) + z * (n-z) + z * (z-1) // 2:
    print(0)
    exit()

L = - 10 ** 18
H = 10 ** 18

while H - L > 1:
    M = (H + L) // 2
    count = 0
    if M > 0:
        count += z * n
    count += np.searchsorted(a, M // u, side='right').sum()
    count += (n - np.searchsorted(a, (- M - 1) // (- d), side='right')).sum()
    count -= np.count_nonzero(a * a <= M)
    count //= 2
    #print(count)
    if count >= k:
        H = M
    else:
        L = M

print(H)
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(1,n):
  if li[i] == li[i+1]:
    li[i] = 0
    a+=1
print(a)   

### FIXED CODE ###

n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(1,n):
  if li[i] == li[i-1]:
    li[i] = 0
    a+=1
print(a)
num = list(input().split(" "))
a = int(num[0])
b = int(num[1])

count = 1

while True:
  if count == 1:
  	plug = a
  else:
    plug = plug + (a - 1) 
  if plug >= b:
    break
  count += 1

print(count)

### FIXED CODE ###

s = input()
s2 = input()
cnt = 0
for st, st2 in zip(s, s2):
  if st == st2:
    cnt += 1
  
print(cnt)
#import itertools
from scipy.special import comb

def cmb_1(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

def main():
    x, y = map(int, input().split())

    if x < y:
        x_ = y
        y_ = x

        x = y_
        y = x_
    
    if (x+y) % 3 != 0:
        print(0)

    else:
        n = (x+y)//3
        r = x//2

        #a = len(list(itertools.combinations(range(n), r)))
        #a = comb(n, r, exact=True)
        #a = comb_1(n, r)
        def cmb(n, r, mod):
            if ( r<0 or r>n ):
                return 0
            r = min(r, n-r)
            return g1[n] * g2[r] * g2[n-r] % mod

        mod = 10**9+7 #出力の制限
        N = 10**6
        g1 = [1, 1] # 元テーブル
        g2 = [1, 1] #逆元テーブル
        inverse = [0, 1] #逆元テーブル計算用テーブル

        for i in range( 2, N + 1 ):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )

        a = cmb(n,r,mod)

        print(a)

if __name__ == '__main__':
    main()



### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



x, y = map(int, input().split())

if (2*y-x)%3 == 0 and (2*x-y)%3 == 0:
    m = (2*y-x)//3
    n = (2*x-y)//3

    if n >= 0 or m >= 0:
        print( str(int(cmb(n+m,n, mod) % (10e9+7)) ))
    else:
        print(0)
else:
    print(0)
import sys
sys.setrecursionlimit(100000)

N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

def dfs(d,h,pre):
    if d == N - 1:
        return h
    tmp = [0] 
    for idx,a in enumerate(A[d]):
        if idx != pre:
            res = dfs(d + 1,h + a,idx)
            tmp.append(res)
    return max(tmp)


print(dfs(-1,0,-1))

### FIXED CODE ###

N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

dp = [[0 for _ in range(3)] for _ in range(N)]
for i in range(N):
    for j in range(3):
        if i == 0:
            dp[i][j]= A[i][j]
        else:
            tmp = [0] 
            for k in range(3):
                if j !=k:
                    tmp.append(dp[i-1][k])
            dp[i][j] = max(tmp) + A[i][j]
print(max(dp[-1]))
N = int(input())
X = input().strip()
C = X.count("1")
D = int(X, 2)
Mm, Mp = 0, D % (C+1)
if C > 0:
    Mm = D % (C-1)

p = [0]*(2*10**5+2)
for i in range(1, len(p)):
    n = i
    while True:
        b = bin(n).count("1")
        if b <= 0:
            break
        p[i] += 1
        n = n % b

for i in range(1, N+1):
    c = C
    if X[i-1] == "1":
        c -= 1
        if c == 0:
            print(0)
            continue
        m = Mm
        d = pow(2, N-i, c)
        d = (m-d+c) % c
    else:
        c += 1
        m = Mp
        d = pow(2, N-i, c)
        d = (m+d) % c

    print(p[d]+1)


### FIXED CODE ###

N = int(input())
X = input().strip()
C = X.count("1")
D = int(X, 2)
Mm, Mp = 0, D % (C+1)
if C > 1:
    Mm = D % (C-1)

p = [0]*(2*10**5+2)
for i in range(1, len(p)):
    n = i
    while True:
        b = bin(n).count("1")
        if b <= 0:
            break
        p[i] += 1
        n = n % b

for i in range(1, N+1):
    c = C
    if X[i-1] == "1":
        c -= 1
        if c == 0:
            print(0)
            continue
        m = Mm
        d = pow(2, N-i, c)
        d = (m-d+c) % c
    else:
        c += 1
        m = Mp
        d = pow(2, N-i, c)
        d = (m+d) % c

    print(p[d]+1)
N = int(input())
A = input().split()
B = input().split()
for i in range(N+1):
    A[i] = int(A[i])
for i in range(N):
    B[i] = int(B[i])

Ans = 0

if (B[0]-A[0] > 0):
    if (B[0]-A[0] < A[1]):
        yojo = B[0]-A[0]
        Ans += A[0]
        chinpo = True
    else:
        yojo = B[1]
        Ans += A[0]
        chinpo = False
        #A[0]+for以下
else:
    yojo = 0
    Ans += B[0]
    chinpo = True
    #B[0]+for以下

for i in range(1,N-1):
    if chinpo:
        yoB = yojo + B[i]
        if yoB >= A[i]:
            yojo = yoB - A[i]
            Ans += A[i]
            if yojo >= A[i+1]:
                chinpo = False
        else:
            Ans += B[i]
            yojo = 0
    else:
        Ans += A[i]
        yojo = B[i]
        chinpo = True

if yojo > A[N]:
    Ans += A[N]
else:
    if yojo + B[N-1] > A[N]:
        Ans += A[N]
    else:
        Ans += yojo + B[N-1]

print(Ans)

　

### FIXED CODE ###

#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    if B[i]>A[i]:
        if B[i] >= A[i+1]+A[i]:
            ans += A[i]+A[i+1]
            A[i+1] = 0
        else:
            A[i+1] -= B[i]-A[i]
            ans += B[i]
    else:
        ans += B[i]

print(ans)
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N=[int(x) for x in input().split()]
if N[1]==1:
  sum1=0
else:
  sum1 = comb(N[1], 2)
if N[0]==1:
  sum2=0
else:
    sum2 = comb(N[0], 2)
print(sum1+sum2)

### FIXED CODE ###

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N=[int(x) for x in input().split()]
if N[1]==1 or N[1]==0:
  sum1=0
else:
  sum1 = comb(N[1], 2)
if N[0]==1 or N[0]==0:
  sum2=0
else:
    sum2 = comb(N[0], 2)
print(sum1+sum2)
from collections import deque
s = deque(input())
le = len(s)-1
cnt = 0
while le:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
else:
  print(cnt)

### FIXED CODE ###

from collections import deque
s = deque(input())
le = len(s)
cnt = 0
while le>1:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
else:
  print(cnt)
N = input()
R = N % 1000
if R = 0:
    print(0)
else:
    print(abs(R-1000))

### FIXED CODE ###

N = int(input())
R = N % 1000
if R == 0:
    print(0)
else:
    print(abs(R-1000))
import math
r = int(input())
s=r**2*math.pi
l=2*r*math.pi
print(s,l)

### FIXED CODE ###

import math
r = float(input())
s=r**2*math.pi
l=2*r*math.pi
print('{:.6f} {:.6f}'.format(s,l))
l = [list(map(int, input().split())) for i in range(3)]
d = [None]*3
d[i] = [l[i] - l[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) else 'No')

### FIXED CODE ###

d = [None]*3
for i in range(3):
  c = list(map(int, input().split()))
  d[i] = [c[i] - c[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) else 'No')
a,b,c=int(input().split())
print(a*b/2)

### FIXED CODE ###

a,b,c=map(int,input().split())
print(a*b//2)
a, b = map(int, input().split())

if abs(a-b) <= 1:
  print(a+b)
else print(max(a, b)*2-1)

### FIXED CODE ###

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

if abs(a-b) <= 1:
  print(a+b)
else:
  print(max(a, b)*2-1)
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
N_chr = str(N)
c = N_chr[0]

acc = int(c) + 9 *(len(N_chr)-1)
if N == acc:
    print(acc)
else:
    print(acc-1)
    


### FIXED CODE ###

#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

c, *N = str(int(readline())+1)
print(int(c) + 9 *len(N)- 1)
X = input()
flag = ['+','-']
for i in flag:
    if i == '+':
        ans = int(X[0]) + int(X[1])
    else:
        ans = int(X[0]) - int(X[1])
    for j in flag:
        if j == '+':
            ans += int(X[2])
        else:
            ans -= int(X[2])
        for k in flag:
            if k == '+':
                ans += int(X[3])
            else:
                ans -= int(X[3])
            if ans == 7:
                anslist = [X[0],i,X[1],j,X[2],k,X[3],'=','7']
print(''.join(anslist))

### FIXED CODE ###

X = input()
flag = ['+','-']
check = 0
for i in flag:
    if check == 1:
        break
    for j in flag:
        if check == 1:
            break
        for k in flag:
            ans = 0
            if i == '+':
                ans = int(X[0]) + int(X[1])
            else:
                ans = int(X[0]) - int(X[1])
            if i == '+':
                ans = int(X[0]) + int(X[1])
            else:
                ans = int(X[0]) - int(X[1])
            if j == '+':
                ans += int(X[2])
            else:
                ans -= int(X[2])
            if k == '+':
                ans += int(X[3])
            else:               
                ans -= int(X[3])
            if ans == 7:
                anslist = [X[0],i,X[1],j,X[2],k,X[3],'=','7']
                check = 1
print(''.join(anslist))
from collections import Counter

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

c = Counter(S)
tmp = c.most_common()
rgb = tmp[0][1] * tmp[1][1] * tmp[2][1]

count = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = 2 * j - i
        if j + 1 <= k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            count += 1

print(rgb - count)

### FIXED CODE ###

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

if N == 1 or N == 2:
    ans = 0
else:
    R = S.count('R')
    G = S.count('G')
    B = S.count('B')
    rgb = R * G * B

    count = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = 2 * j - i
            if k >= N:
                break 
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                count += 1
    ans = rgb - count

print(ans)
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 21 16:06:06 2018

@author: yusei
"""

h1=int(input())
a = h1**3
print (a)

h2=int(input())
b = h2**3
print (b)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Feb 21 16:06:06 2018

@author: yusei
"""

h1=int(input())

a = h1*h1*h1

print (a)
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
else:
    q = []
    r = []
    min_ = 1000
    for i in range(1, 101):
        if not i in p:
            q.append(i)

    for j in q:
        k = int(abs(x - j))
        if min_ == k:
            r.append(before_j)
            r.append(j)
        min_ = min(k, min_)
        if min_ == k:
            before_j = j

    print(min(r))

### FIXED CODE ###

X, N = map(int, input().split())
p = list(map(int, input().split()))

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break
K = int(input())

if K == 1:
  print(1)
  
def f(K):
  s =  0
  count = 0
  for i in range(2,K+1):
    if K % i != 1:
      s += i
      count += 1
  return 3*K + s - count  
  
else:
  ans = 0
  for i in range(2,K+1):
    ans += f(K)
  print(ans)

### FIXED CODE ###

K = int(input())
 
import math

ans = 0
a = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    a = math.gcd(i,j)
    for k in range(1,K+1):
      ans += math.gcd(a,k)
      
print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()
if k:
    print(sum(h[:-k]))
else
    print(sum(h))

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()

if k:
    print(sum(h[:-k]))
else:
    print(sum(h))
[a,b,c] = raw_input().split(' ')
a = int(a)
b = int(b)
c = int(c)
t = sort([a,b,c])
print t[0],t[1],t[2]

### FIXED CODE ###

[a,b,c] = raw_input().split(' ')
a = int(a)
b = int(b)
c = int(c)
t = 0
if a > b:
    t = a
    a = b
    b = t
if b > c:
    t = b
    b = c
    c = t
if a > b:
    t = a
    a = b
    b = t
print a,b,c
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = 10 ** 20


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n=I()
G=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=LI()
    G[a]+=[b]
    G[b]+=[a]

visited=[0]*n
a=[0]*n
visited[0]=1
print(G[2])
def f(x):
    ret=0
    cnt=0
    for v in G[x]:
        if visited[v]:
            continue
        visited[v] = 1
        r=f(v)
        ret+=r
        if r==0:
            cnt+=1
    if cnt>1:
        ret+=cnt-1
    a[x]=ret
    return ret

ans=f(0)
if len(G[0]) == 1:
    ans+=1
    
print(ans)


### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = 10 ** 20
sys.setrecursionlimit(2147483647)

def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n=I()
G=[[]for _ in range(n)]
r=-1
for _ in range(n-1):
    a,b=LI()
    G[a]+=[b]
    G[b]+=[a]
    if len(G[a])>2:
        r=a
    if len(G[b]) > 2:
        r=b

visited=[0]*n
visited[r]=1
def f(x):
    ret=0
    cnt=0
    for v in G[x]:
        if visited[v]:
            continue
        visited[v] = 1
        r=f(v)
        ret+=r
        if r==0:
            cnt+=1
    if cnt>1:
        ret+=cnt-1
    return ret

print(1 if r == -1 else f(r))
A,B=map(int(input().split()))
if B%A==0:
    print(A+B)
else:
    print(A-B)

### FIXED CODE ###

A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(B-A)
n = int(input())
a = list(int(x) for x in input().split())
x = 0
for i in range(n):
    if a[i] in a is True:
        print("NO")
        x = 1
        break
    a.pop(0)

if x == 0:
    print("YES")


### FIXED CODE ###

n = int(input())
a = list(int(x) for x in input().split())
x = 0
 
a.sort()
for i in range(n-1):
    if a[-1] - a[-2] == 0:
        print("NO")
        x = 1
        break
    a.pop()
 
if x == 0:
    print("YES")
import numpy as np
n = int(input())
a_n = list(map(int, input().split()))
def UF(num):
    if num==1:
        return 1
    else:
        return num*UF(num-1)
def comb(a1, a2):
    return UF(a1)/(UF(a2)*UF(a1-a2))
result = np.zeros([n, n])
for i in range(n):
    for ii in range(n):
        if a_n[i] > a_n[ii]:
            result[i, ii] = comb(a_n[i], a_n[ii])
a = np.argmax(result)
res1 = a//n
res2 = a%n

print(a_n[res1], a_n[res2])

### FIXED CODE ###

n = int(input())
a_n = list(map(int, input().split()))
result1 = max(a_n)
min_delta = max(a_n)
result2 = max(a_n)
for num in a_n:
    if num == result1:
        pass
    elif abs(num-result1/2)<=min_delta:
        min_delta = abs(num-result1/2)
        result2 = num
print('{} {}'.format(result1, result2))
import sys
from functools import lru_cache
sys.setrecursionlimit(10**10)

n, W = map(int, input().split())
w, v = [], []

for i in range(n):
    temp1, temp2 = map(int, input().split())
    w.append(temp1)
    v.append(temp2)

#print(w, v)
#dp[i] = max(dp[i-1], dp[i]) + dp[i-2]

@lru_cache(maxsize=None)
def solve(total, i):
    if i > n-1:
        return 0
    weight, val = w[i], v[i]
    if total + weight <= W:
        chose = val + solve(total + weight, i+1)
        unchose = solve(total, i+1)
        return max(chose, unchose)
    else:
        return 0

print(solve(0, 0))

### FIXED CODE ###

n, W = map(int, input().split())
w = [0]*(n+1)
v = [0]*(n+1)

#dp = [[None for i in range(W+1)] for j in range(n+1)]
dp = [[0 for i in range(W+1)] for j in range(n+1)]

for i in range(n):
    w[i], v[i] = map(int, input().split())

def knap(i, j):
    if dp[i][j] is not None:
        return dp[i][j]

    res = 0

    if i == n:
       	res = 0
    elif j < w[i]:
        res = knap(i+1, j)
    else:
        res = max(knap(i+1, j), knap(i+1, j-w[i]) + v[i])

    dp[i][j] = res
    return dp[i][j]

for i in reversed(range(n)):
    for j in range(W+1):
#        res = 0
        # if i == n-1:
        #     res = 0
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i])

#print(knap(0, W))
print(dp[0][W])
weekdays = ["", "SAT", "FRI", "THU", "WED","TUE","MON", "SUN"]
w = input()
print(weedays.index(w))


### FIXED CODE ###

weekdays = ["", "SAT", "FRI", "THU", "WED","TUE","MON", "SUN"]
w = input()
print(weekdays.index(w))
i=1
while 1:
 a=input()
 if a==0:break
 print(f'Case {i}: {a}')
 i+=1

### FIXED CODE ###

import sys
i=1
for e in sys.stdin:
 if'0\n'==e:break
 print(f'Case {i}: {e[:-1]}');i+=1
n = int(input())
s = input()
print(s.count('ABC')

### FIXED CODE ###

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

count = 0
for i in range(len(S) - 2):
    if S[i:i+3] == 'ABC':
        count += 1

print(count)
from collections import Counter


from operator import mul
from functools import reduce


def cmbf(n, r):
    if (n < r):
        return 0
    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


cmb = []
for i in range(0, 200001):
    cmb.append(cmbf(i, 2))

N = int(input())
A = list(map(int, input().split()))
c = Counter()
for i in A:
    c.update(str(i))
cmbL = {}
gsum = 0

for i in c.keys():
    tmp1 = cmb[int(c[i])]
    tmp2 = tmp1 - cmb[int(c[i])-1]
    cmbL[i] = [tmp1, tmp2]
    gsum += tmp1

for i in A:
    print(int(gsum - cmbL[str(i)][1]))


### FIXED CODE ###

from collections import Counter


from operator import mul
from functools import reduce


def cmbf(n, r):
    if (n < r):
        return 0
    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


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

for A_i in A:
    c[A_i] += 1

gsum = 0
for i in range(1, N + 1):
    if (c[i] != 0):
        gsum += cmbf(c[i], 2)

for i in A:
    print(gsum-(c[i]-1))