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

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m//gcd(n,m)

n,m = LI()
a = LI()
b = [i//2 for i in a]
if n == 1:
    lb = b[0]
else:
    lb = lcm(b[0],b[1])

for i in range(2,n):
    lb = lcm(lb,b[i])

for i in range(n):
    if lb//b[i] % 2 == 0:
        print(0)
        quit() 
if lb > m:
    print(0)
    quit()

ans = m//lb//2 + (m // lb) %2
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m // gcd(n,m)


n,m = LI()
a = LI()
b = [i//2 for i in a]

lb = 1
for i in b:
    lb = lcm(lb,i)
    if lb > m:
        print(0)
        quit()

for i in b:
    if lb//i % 2 == 0:
        ans = 0
        break
else:
    if lb > m:
        ans = 0
    else:
        ans = (m//lb + 1)//2
print(ans)
### BUGGY CODE ###

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

R = [0] * N
G = [0] * N
B = [0] * N

for i in range(N):
    if S[i] == 'R':
        R[i] = 1
    elif S[i] == 'G':
        G[i] = 1
    else:
        B[i] = 1

cnt = 0
for i in range(N):
    sum_r = sum(R) - sum(R[:(i + 1)])
    sum_g = sum(G) - sum(G[:(i + 1)])
    sum_b = sum(B) - sum(B[:(i + 1)])
    for j in range(i + 1, N):
        sum_r -= R[j]
        sum_g -= G[j]
        sum_b -= B[j]
        if S[j] == 'R':
            if S[i] == 'B':
                cnt += sum_g
                if j + (j - i) < N:
                    cnt -= G[j + (j - i)]
            if S[i] == 'G':
                cnt += sum_b
                if j + (j - i) < N:
                    cnt -= B[j + (j - i)]
        elif S[j] == 'G':
            if S[i] == 'R':
                cnt += sum_b
                if j + (j - i) < N:
                    cnt -= B[j + (j - i)]
            if S[i] == 'B':
                cnt += sum_r
                if j + (j - i) < N:
                    cnt -= R[j + (j - i)]
        else:
            if S[i] == 'R':
                cnt += sum_g
                if j + (j - i) < N:
                    cnt -= G[j + (j - i)]
            if S[i] == 'G':
                cnt += sum_r
                if j + (j - i) < N:
                    cnt -= R[j + (j - i)]
                    
print(cnt)

### FIXED CODE ###

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

R = [0] * N
G = [0] * N
B = [0] * N

for i in range(N):
    if S[i] == 'R':
        R[i] = 1
    elif S[i] == 'G':
        G[i] = 1
    else:
        B[i] = 1

sumR = sum(R)
sumG = sum(G)
sumB = sum(B)

cnt = 0
for i in range(N):
    sumR -= R[i]
    sumG -= G[i]
    sumB -= B[i]
    sum_r = sumR
    sum_g = sumG
    sum_b = sumB
    for j in range(i + 1, N):
        sum_r -= R[j]
        sum_g -= G[j]
        sum_b -= B[j]
        check_index = j + (j - i)
        if S[j] == 'R':
            if S[i] == 'B':
                cnt += sum_g
                if check_index < N:
                    cnt -= G[check_index]
            if S[i] == 'G':
                cnt += sum_b
                if check_index < N:
                    cnt -= B[check_index]
        elif S[j] == 'G':
            if S[i] == 'R':
                cnt += sum_b
                if check_index < N:
                    cnt -= B[check_index]
            if S[i] == 'B':
                cnt += sum_r
                if check_index < N:
                    cnt -= R[check_index]
        else:
            if S[i] == 'R':
                cnt += sum_g
                if check_index < N:
                    cnt -= G[check_index]
            if S[i] == 'G':
                cnt += sum_r
                if check_index < N:
                    cnt -= R[check_index]
print(cnt)
### BUGGY CODE ###

l=input()
a=len(l)
ans=3**a
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=3**(a-i)*(2**(t+1))
    else:
        t+=1
print(ans%(10**9+7))

### FIXED CODE ###

l=input()
a=len(l)
mod=10**9+7
ans=3**a%mod
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=pow(3,a-i,mod)*pow(2,t+1,mod)
    else:
        t+=1
print(ans%(10**9+7))
### BUGGY CODE ###

S=list(input())

rS=list(reversed(S))

digit_n=(10**len(S)-5)//13

cnt=0
tryc=[]
for i in range(digit_n+1):
    trya=13*i+5
    tryb=[0]*len(S)
    tryc=list(reversed(list(str(trya))))
    for j in range(len(tryc)):
        tryb[j]+=int(tryc[j])
    for j in range(len(rS)):
        if rS[j]!="?":
            if int(rS[j])!=tryb[j]:
                break
        if j==len(rS)-1:
            cnt+=1
print(cnt)
        
        


### FIXED CODE ###

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
 
s = input()
l = len(s)
MOD = 10**9+7
 
dp = [0]*13
dp[0] = 1
for i in s:
    new = [0]*13
    if i == "?":
        for i in range(10):
            for j in range(13):
                new[(10*j+i)%13] += dp[j]
    else:
        i = int(i)
        for j in range(13):
            new[(i+10*j)%13] += dp[j]
    
    for i in range(13):
        new[i] %= MOD
    dp,new = new,dp
#    print(dp)
 
print(dp[5]%MOD)
### BUGGY CODE ###

n = int(input())
h = [int(i) for i in input().split() if i != 0]


def main():
    print("Yes" if detect() else "No")


def detect():
    m = min(h)+1
    for i in range(n):
        if h[i] <= m:
            continue
        if (h[i] - min(h[i::])) > 1:
            return False
    return True


main()


### FIXED CODE ###

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


def main():
    h[0] -= 1
    print("Yes" if detect() else "No")


def detect():
    for i in range(1, n):
        if h[i] > h[i-1]:
            h[i] -= 1
        elif h[i] < h[i-1]:
            return False

    return True


main()
### BUGGY CODE ###

n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

sq = [[0] * n for _ in range(n)]

for i in range(m):
    l = lr[i][0]
    r = lr[i][1]
    sq[l-1][r-1] += 1

c = [[0] * n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if j == 0:
            c[i][j] = sq[i][j]
        else:
            c[i][j] = sq[i][j] + c[i][j-1]
            
for i in range(q):
    p = pq[i][0]
    q = pq[i][1]
    ans = 0
    for j in range(p, q + 1):
        if p != 1:
            ans += c[j-1][q-1] - c[j-1][p-2]
        else:
            ans += c[j-1][q-1]
    print(ans)



### FIXED CODE ###

n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

sq = [[0] * n for _ in range(n)]

for i in range(m):
    l = lr[i][0]
    r = lr[i][1]
    sq[l-1][r-1] += 1

c = [[0] * n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if j == 0:
            c[i][j] = sq[i][j]
        else:
            c[i][j] = sq[i][j] + c[i][j-1]
            
for i in range(q):
    p = pq[i][0]
    q = pq[i][1]
    ans = 0
    for j in range(p, q + 1):
        if p != 1:
            ans += c[j-1][q-1] - c[j-1][p-2]
        else:
            ans += c[j-1][q-1]
    print(ans)
### BUGGY CODE ###

s = list(input())
len_s = len(s)
list_s = []
list_2019 = ['2019', '4038', '6057', '8076', '10095', '12114', '14133', '16152', '18171', '20190', '22209', '24228',
             '26247', '28266', '30285', '32304', '34323', '36342', '38361', '40380', '42399', '44418', '46437',
             '48456', '50475', '52494', '54513', '56532', '58551', '60570', '62589', '64608', '66627', '68646',
             '70665', '72684', '74703', '76722', '78741', '80760', '82779', '84798', '86817', '88836', '90855',
             '92874', '94893', '96912', '98931', '100950', '102969', '104988', '107007', '109026', '111045',
             '113064', '115083', '117102', '119121', '121140', '123159', '125178', '127197', '129216', '131235',
             '133254', '135273', '137292', '139311', '141330', '143349', '145368', '147387', '149406', '151425',
             '153444', '155463', '157482', '159501', '161520', '163539', '165558', '167577', '169596', '171615',
             '173634', '175653', '177672', '179691', '181710', '183729', '185748', '187767', '189786', '191805',
             '193824', '195843', '197862', '199881']
ans = 0
for i in range(4, len_s):
    for j in range(len_s):
        if j + i <= len_s:
            list_s.append(''.join(s[j:j + i]))

for k in list_2019:
    ans += list_s.count(k)
print(ans)

### FIXED CODE ###

from collections import Counter
s = input()[::-1]
cnt = [0]
d = 0
mod = 2019

for i in s:
    tmp = int(i) * pow(10, d, mod) % mod
    tmp = cnt[-1] + tmp
    cnt.append(tmp % mod)
    d += 1

cnt = Counter(cnt)
ans = sum(j * (j - 1) // 2 for j in cnt.values())
print(ans)
### BUGGY CODE ###

import sys

#+++++


def aaa(ll,a,b,c):
	ret=a+b+c
	for i,v1 in enumerate(ll):
		if v1==0:
			continue
		t1=abs(a-v1)
		if ret < t1:
			continue
		for j,v2 in enumerate(ll):
			if v2==0:
				continue
			if i==j:
				continue
			t2=t1 + abs(b-v2)
			if ret < t2:
				continue
			for k,v3 in enumerate(ll):
				if v3==0:
					continue
				if i==k or j==k:
					continue
				t3 = t2 + abs(c-v3)
				ret=min(ret, t3)
	return ret		
		
def main():
	n , a, b, c = map(int, input().split())
	bb=[]
	for i in range(n):
		bb.append(int(input()))
	ans=a+b+c
	for i in range(4**n-1):
		la=[]
		lb=[]
		lc=[]
		l=[]
		for j in range(n):
			sd=(i%(4 ** (j+1)))//(4**j)
			kk=bb[j]
			pp=0
			if sd == 0:
				la.append(kk)
			elif sd==1:
				lb.append(kk)
			elif sd==2:
				lc.append(kk)
			else:
				l.append(kk)
		pp=max(0,len(la)-1)+max(len(lb)-1,0)+max(0,len(lc)-1)
		l=l+[sum(la),sum(lb),sum(lc)]
		#print(l)
		ans=min(ans,aaa(l,a,b,c)+pp*10)
				
	
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys
import queue

#+++++


def aaa(ll,a,b,c):
	ret=a+b+c
	for i,v1 in enumerate(ll):
		if v1==0:
			continue
		t1=abs(a-v1)
		if ret < t1:
			continue
		for j,v2 in enumerate(ll):
			if v2==0:
				continue
			if i==j:
				continue
			t2=t1 + abs(b-v2)
			if ret < t2:
				continue
			for k,v3 in enumerate(ll):
				if v3==0:
					continue
				if i==k or j==k:
					continue
				t3 = t2 + abs(c-v3)
				ret=min(ret, t3)
	return ret		

def mk_str(ll):
	ll.sort()
	return '_'.join([str(v) for v in ll])


def main():
	n , a, b, c = map(int, input().split())
	est=lambda ll:aaa(ll,a,b,c)
	
	bb=[]
	for i in range(n):
		bb.append(int(input()))
	
	cl=set()
	ol=queue.PriorityQueue()
	

	
	st=bb
	ee=est(st)
	cc=0
	cl.add(mk_str(bb))
	ol.put((ee+cc, (cc, bb)))	
	while True:
		if ee == 0:
			return cc
		
		#to goal no join
		rr=cc+ee
		ol.put((rr, (rr, [a,b,c])))
		
		
		
		#join 1
		if len(st) > 3:
			cc+=10
			for i, v in enumerate(st):
				kk=st[:]
				m=kk.pop(i)
				for j, _ in enumerate(kk):
					kkk=kk[:]
					kkk[j]+=m
					stk=mk_str(kkk)
					if stk not in cl:
						cl.add(stk)
						ol.put((cc, (cc, kkk)))
		v,(cc, st) = ol.get()
		ee = est(st)
				
	print(ans)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(50000)
def dfs(s):
    global t
    if s == t:
        return True
    DP[s]=1
    for i in F[s]:
        if not DP[i]:
            if dfs(i):
                return True
    return False
    
n,m = [int(i) for i in input().split()]
F = [{} for i in range(n)]
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
    F[j][i] = 1
q = int(input())
for i in range(q):
    DP = [0]*n
    s,t = [int(i) for i in input().split()]
    if dfs(s):
        print("yes")
    else:
        print("no")


### FIXED CODE ###

from collections import deque
n,m = [int(i) for i in input().split()]
F = [{} for i in range(n)]
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
    F[j][i] = 1
q = int(input())
DP = [0 for i in range(n)]
c = 1
d = deque()
for i in range(n):
    if DP[i]:
        continue
    else:
        d.append(i)
    while(len(d)>0):
        tmp = d.pop()
        DP[tmp] = c
        for i in F[tmp]:
            if not DP[i]:
                d.append(i)
    c+=1

for i in range(q):
    s,t = [int(i) for i in input().split()]
    if DP[s] == DP[t]:
        print("yes")
    else:
        print("no")
### BUGGY CODE ###

import copy

N=int(input())

li=list(map(int,input().split()))

ans=copy.copy(li)

for n in range(N):
  ans.pop(li[n]-1)
  ans.insert(li[n]-1,n+1)

print(*ans)

### FIXED CODE ###

import copy

N=int(input())

li=list(map(int,input().split()))

ans=copy.copy(li)

ans=sorted(range(N), key=lambda k: li[k])

for n in range(N):
  ans[n]+=1
      
print(*ans)
### BUGGY CODE ###

N,W=map(int,input().split())
weights,profits = [0]*N, [0]*N
def solve_knapsack(profits, weights, capacity):
    # basic checks
    n = len(profits)
 
    dp = [0 for x in range(capacity+1)]
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit

    dp[0] = 0
    for c in range(0, capacity+1):
        if weights[0] <= c: dp[c] = profits[0]
    for i in range(1, n):
        for c in range(capacity, weights[i], -1):
            if weights[i] <= c:
                dp[c] = max(profits[i] + dp[c - weights[i]], dp[c])
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    for i in range(N):
        weights[i],profits[i] = map(int,input().split())
    res = solve_knapsack(profits, weights, W)
 
    print(res)
if __name__ == "__main__":
	main()

### FIXED CODE ###

def main():
  n, w = [int(e) for e in input().split()]
  t = [-1 for i in range(w + 1)]
  t[w] = 0
  for _ in range(n):
    nw, nv = [int(e) for e in input().split()]
    for i in range(nw, w + 1):
      if t[i] == -1:
        continue
      if t[i - nw] < t[i] + nv:
        t[i - nw] = t[i] + nv
  print(max(t))
main()
### BUGGY CODE ###

import sys
import numpy as np
from itertools import combinations_with_replacement as cwr
input = sys.stdin.readline


N,M,Q = map(int,input().split())
A,B,C,D = [],[],[],[]
for i in range(Q):
    a,b,c,d = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)
# ind = np.argsort(np.array(D))
# A,B,C,D = np.array(A)[ind],np.array(B)[ind],np.array(C)[ind],np.array(D)[ind]
# A,B,C,D = A[::-1],B[::-1],C[::-1],D[::-1]
# Array = [0]*(N+1)
ans = 0
combs = list(cwr(np.arange(1,M+1),N))
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b-1] - comb[a-1] ==c:
            ans[i] += d
print(max(ans))
# for i,d in enumerate(D):
#     a,b,c,d= A[i],B[i],C[i],D[i]
#     if Array[a] ==0:
#         Array[a] = a
#     if Array[b] == 0:
#         Array[b] = a+c
#     if Array[b] - Array[a] == c:
#         ans += d


### FIXED CODE ###

import sys
from itertools import combinations_with_replacement as cwr
input = sys.stdin.readline

N,M,Q = map(int,input().split())
A,B,C,D = [],[],[],[]
for i in range(Q):
    a,b,c,d = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

ans = 0
combs = list(cwr(range(1,M+1),N))
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b-1] - comb[a-1] ==c:
            ans[i] += d
print(max(ans))
### BUGGY CODE ###

S = input()

mod = 10 ** 9 + 7
N = len(S)
dp = [[0 for _ in range(13)] for _ in range(10 ** 5 + 5)]
dp[0][0] = 1

for i in range(N):
    c = 0
    if S[i] == "?":
        c = -1
    else:
        c = int(S[i])
    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i+1][(k * 10 + j) % 13] += dp[i][k]
    for j in range(13):
        dp[i+1][j] %= mod

print(dp[N][5])


### FIXED CODE ###

S = input()

mod = 10 ** 9 + 7
N = len(S)
dp = [[0 for _ in range(13)] for _ in range(10 ** 5 + 5)]
dp[0][0] = 1

for i in range(N):
    c = 0
    if S[i] == "?":
        c = -1
    else:
        c = int(S[i])
    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i+1][(k * 10 + j) % 13] += dp[i][k]
    for j in range(13):
        dp[i+1][j] %= mod

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

from heapq import heapify,heappop,heappush
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
S,T=map(int,input().split())
Graph=[set() for i in range(N)]
Edge=[]
mod=10**9+7
inf=float("inf")
for i in range(M):
  a,b,c=map(int,input().split())
  Graph[a-1].add((c,b-1))
  Graph[b-1].add((c,a-1))
  Edge.append((a-1,b-1,c))
  Edge.append((b-1,a-1,c))
def dijkstra(s,n,links):
  Visited=[False]*n
  cost=[inf]*n
  P=[0]*n
  P[s]=1
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if Visited[hp]:
      continue
    Visited[hp]=True
    for c,p in links[hp]:
      if Visited[p]:
        continue
      if c+hc<cost[p]:
        cost[p]=c+hc
        P[p]=P[hp]
        heappush(heap,(cost[p],p))
      elif c+hc==cost[p]:
        P[p]=(P[p]+P[hp])%mod
  return cost,P

cost_S,P_S=dijkstra(S-1,N,Graph)
cost_T,P_T=dijkstra(T-1,N,Graph)
print
D=cost_S[T-1]
Pat=P_S[T-1]
ans=(Pat**2)%mod
for a,b,c in Edge:
  if cost_S[a]+cost_T[b]+c==D:
    if 2*cost_S[a]<D and 2*cost_T[b]<D:
      ans-=((P_S[a]*P_T[b])**2)%mod
for i in range(N):
  if 2*cost_S[i]==2*cost_T[i]==D:
    ans-=((P_S[i]*P_T[i])**2)%mod
print(ans%mod)



      
  
  
  
  


### FIXED CODE ###

from heapq import heapify,heappop,heappush
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
S,T=map(int,input().split())
Graph=[set() for i in range(N)]
Edge=[]
mod=10**9+7
inf=float("inf")
for i in range(M):
  a,b,c=map(int,input().split())
  Graph[a-1].add((c,b-1))
  Graph[b-1].add((c,a-1))
  Edge.append((a-1,b-1,c))
  Edge.append((b-1,a-1,c))
def dijkstra(s,n,links):
  Visited=[False]*n
  cost=[inf]*n
  P=[0]*n
  P[s]=1
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if Visited[hp]:
      continue
    Visited[hp]=True
    for c,p in links[hp]:
      if Visited[p]:
        continue
      if c+hc<cost[p]:
        cost[p]=c+hc
        P[p]=P[hp]
        heappush(heap,(cost[p],p))
      elif c+hc==cost[p]:
        P[p]=(P[p]+P[hp])%mod
  return cost,P

def dp(s,n,links,d):
  Visited=[False]*n
  cost=[inf]*n
  P=[0]*n
  P[s]=1
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if 2*hc>d:
      break
    if Visited[hp]:
      continue
    Visited[hp]=True
    for c,p in links[hp]:
      if Visited[p]:
        continue
      if c+hc<cost[p]:
        cost[p]=c+hc
        P[p]=P[hp]
        heappush(heap,(cost[p],p))
      elif c+hc==cost[p]:
        P[p]=(P[p]+P[hp])%mod
  return cost,P

cost_S,P_S=dijkstra(S-1,N,Graph)
D=cost_S[T-1]
cost_T,P_T=dp(T-1,N,Graph,D)
Pat=P_S[T-1]
ans=(Pat**2)%mod
for a,b,c in Edge:
  if cost_S[a]+cost_T[b]+c==D:
    if 2*cost_S[a]<D and 2*cost_T[b]<D:
      ans-=((P_S[a]*P_T[b])**2)%mod
for i in range(N):
  if 2*cost_S[i]==2*cost_T[i]==D:
    ans-=((P_S[i]*P_T[i])**2)%mod
print(ans%mod)
### BUGGY CODE ###

def resolve():
	# N: 足場の個数, K: 1回で右にジャンプできる足場の数
	N, K = map(int, input().split())
	# h: 各足場の高さ
	h = list(map(int, input().split()))
	# dpテーブル宣言: dp[今いる足場の番号-1]=最小コスト
	dp = [0] * N

	# k-1個左の足場からジャンプして来た時の最小コストを調べる
	for n in range(N):
		for k in range(K):
			n_prev = n-k-1
			if n_prev >= 0:
				cost = abs(h[n] - h[n_prev]) + dp[n_prev]
				if dp[n]>0:
					dp[n] = min(dp[n], cost)
				else:
					dp[n] = cost
	print(dp[N-1])
    
resolve()

### FIXED CODE ###

def resolve():
	# N: 足場の個数, K: 1回で右にジャンプできる足場の数
	N, K = map(int, input().split())
	# h: 各足場の高さ
	# dpテーブル宣言: dp[今いる足場の番号-1]=[最小コスト, 足場の高さ]
	dp = [
		[float('inf'), int(h_)]
		for h_ in input().split()
	]
	dp[0][0] = 0
	dp[1][0] = abs(dp[0][1] - dp[1][1])

	# k個左の足場からジャンプして来た時の最小コストを調べる
	for n in range(2, N):
		index_0 = max(0, n-K)
		h_ = dp[n][1]
		dp[n][0] = min(
			[
				abs( h_ - dp_[1] ) + dp_[0]
				for dp_ in dp[index_0:n]
			]
		)
	print(dp[N-1][0])

resolve()
### BUGGY CODE ###

def main():
    def f(n):
        n = int(''.join(n), 2)
        c = 0
        while n != 0:
            n %= sum(list(map(int, bin(n)[2:])))
            c += 1
        print(c)
    rev = lambda x: '1' if x == '0' else '0'
    n = int(input())
    X = list(input())
    X[0] = rev(X[0])
    f(X)
    for i in range(n - 1):
        X[i] = rev(X[i])
        X[i + 1] = rev(X[i + 1])
        f(X)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    def f(n):
        if n == 0: return 0
        return f(n % bin(n).count('1')) + 1
    n = int(input())
    X = list(input())
    c = sum(list(map(int, X)))
    m = int(''.join(X), 2)
    mp, mm = m % (c + 1), m % (c - 1) if c - 1 != 0 else 0
    jp, jm = 1, 1
    ans = [0] * n
    for i in range(n - 1, -1, -1):
        if X[i] == '0':
            mod = c + 1
            ans[i] = f((mp + jp) % mod) + 1
        else:
            ans[i] = f((mm - jm + mod) % mod) + 1 if (mod := c - 1) != 0 else 0
        jp, jm = (jp << 1) % (c + 1), (jm << 1) % (c - 1) if c - 1 != 0 else 0
    [print(a) for a in ans]
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
 
import collections
from functools import reduce
from operator import mul

def combinations_count2(n, r):
    if n < 2:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

c = collections.Counter(A)

dic = {}
for i in c:
    dic[i]= [combinations_count2(c[i], 2), combinations_count2(c[i] - 1, 2)]
dic_ans = {}
for ai in A:
    if ai in dic_ans:
        print(dic_ans[ai])
        continue
    ans = 0
    for i in dic:
        if i == ai:
            ans += dic[i][1]
        else:
            ans += dic[i][0]
    print(ans)


### FIXED CODE ###

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

d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

s = 0
for k in d:
    s += d[k] * (d[k] - 1) // 2

for i in range(N):
    t = d[A[i]]
    print(s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2)