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

S=list(input())
from collections import defaultdict
D = defaultdict(int)
ans=0
for i in range(len(S)):
    d=defaultdict(int)
    d[int(S[i])]=1
    for k,v in D.items():
        d[(k*10+int(S[i]))%2019]+=v
    ans+=d[0]
    D=d
print(ans)

### FIXED CODE ###

S=input()

mod=2019
D={}
S=S[::-1]
now=0

for i in range(len(S)):
    if (int(S[i])*pow(10,i,mod)+now)%mod not in D:
        D[(int(S[i])*pow(10,i,mod)+now)%mod]=1
    else:
        D[(int(S[i])*pow(10,i,mod)+now)%mod]+=1
    now=(int(S[i])*pow(10,i,mod)+now)%mod
#print(D)
ans=0
for k,v in D.items():
    if k==0:
        v+=1
    ans+=v*(v-1)//2
print(ans)
### BUGGY CODE ###

N = input()
A = map(int, raw_input().split())
 
MOD = 10 ** 9 + 7

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x/gcd(x, y)*y
 
l = A[0]
for a in A:
    l = lcm(l, a)
 
res = 0

for a in A:
    res = (res + l / a) % MOD

print(res)



### FIXED CODE ###

N = input()
A = map(int, raw_input().split())
 
MOD = 10 ** 9 + 7

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x/gcd(x, y)*y
 
l = A[0]
for a in A:
    l = lcm(l, a)
 
res = 0
for a in A:
    res = (res + (l * pow(a, MOD - 2, MOD)) % MOD) % MOD
 
print(res)
### BUGGY CODE ###

N = int(input())
for i in range(1,3501):
  for j in range(1,3501):
    over = N*i*j
    under = 4*i*j-i*N-j*N
    if under>0 and over%under==0:
      w = over//under
      h = i
      n = j
      break
print(h,n,w)

### FIXED CODE ###

N = int(input())
for i in range(1,3501):
  for j in range(1,3501):
    over = N*i*j
    under = 4*i*j-i*N-j*N
    if under>0 and over%under==0:
      w = over//under
      h = i
      n = j
      break
print(h,n,w)
### BUGGY CODE ###

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

C = []
for _ in range(M):
  b,c = map(int,input().split())
  for _ in range(b):
    C.append(c)
C.sort(reverse=True)

curj = 0
res = sum(A)
for i,a in enumerate(A):
  while curj+1 < len(C) and C[curj] <= a:
    curj += 1

  if curj < len(C):
    c = C[curj]
    if c > a:
      res = res - a + c
      curj += 1
    else:
      break
  else:
    break

print(res)


### FIXED CODE ###

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

cards = []
for _ in range(M):
  b,c = map(int,input().split())
  cards.append([c,b])
cards.sort(key=lambda x: -x[0])

res = 0
idx = 0
left = cards[idx][1]
for i,a in enumerate(A):
  if a > cards[idx][0]:
    res += sum(A[i:])
    break
  else:
    res += cards[idx][0]

    left -= 1
    if left <= 0:
      idx += 1
      if idx >= M:
        if i+1 < N:
          res += sum(A[i+1:])
        break
      else:
        left = cards[idx][1]

print(res)
### BUGGY CODE ###

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

count = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        if a%b >= K:
            count += 1

print (count)


### FIXED CODE ###

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

ans = 0
for b in range(1, N+1): #bを全探索
    amari = max(b-K, 0)
    count = N // b
    # print ('b=', b)
    # print (count * amari + max(N%b - K + 1, 0))
    ans += count * amari + max(N%b - K + 1, 0)

if K == 0:
    ans -= N
print (ans)





#以下単純な全探索O(N^2)となり間に合わない
# count = 0
# for a in range(1,N+1):
#     for b in range(1,N+1):
#         if a%b >= K:
#             count += 1

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

n,ma,mb=map(int,input().split())
A,B,C=[],[],[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a/b>ma/mb:
    A.append([a,b,c])
  elif a/b<ma/mb:
    B.append([a,b,c])
  else:
    C.append([a,b,c])
ans=float("inf")
na,nb,nc=len(A),len(B),len(C)
for i in range(1,2**na):
  for j in range(1,2**nb):
    for k in range(2**nc):
      key_a=str(bin(i))[2:].zfill(na)
      key_b=str(bin(j))[2:].zfill(nb)
      key_c=str(bin(k))[2:].zfill(nc)
      x,y,price=0,0,0
      for ii in range(na):
        if key_a[ii]=="1":
          x+=A[ii][0]
          y+=A[ii][1]
          price+=A[ii][2]
      for jj in range(nb):
        if key_b[jj]=="1":
          x+=B[jj][0]
          y+=B[jj][1]
          price+=B[jj][2]
      for kk in range(nc):
        if key_c[kk]=="1":
          x+=C[kk][0]
          y+=C[kk][1]
          price+=C[kk][2]
      if x*mb-y*ma==0:
        ans=min(ans,price)
print(-1 if ans==float("inf") else ans)

### FIXED CODE ###

n,ma,mb=map(int,input().split())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  A.append([a,b,c])
DP=[[[float("inf")]*(10*n+1) for _ in range(10*n+1)] for _ in range(n+1)]
DP[0][0][0]=0
for i in range(n):
  a,b,c=A[i][0],A[i][1],A[i][2]
  for j in range(10*(i+1)+1):
    for k in range(10*(i+1)+1):
      if j>=a and k>=b:
        DP[i+1][j][k]=min(DP[i][j-a][k-b]+c,DP[i][j][k])
      else:
        DP[i+1][j][k]=DP[i][j][k]
ans=float("inf")
for i in range(10*n+1):
  for j in range(10*n+1):
    if i*mb==j*ma and i*j!=0:
      ans=min(ans,DP[n][i][j])
print(ans if ans!=float("inf") else -1)
### BUGGY CODE ###

N, M = map(int, input().split())
lis = []
for index in range(M):
	p, y = map(int, input().split())
	lis.append((p, y, index))

n_lis = []
for unique_p in range(1, N+1):
	tmp = [(p, y, index) for p, y, index in lis if p == unique_p]
	tmp = sorted(tmp, key=lambda x: x[1])
	for born, val in enumerate(tmp, start=1):
		p, y, index = val
		n_lis.append((p, y, index, born))

n_lis = sorted(n_lis, key=lambda x: x[2])

for p, _, _, born in n_lis:
	print('{}{}'.format(str(p).zfill(6), str(born).zfill(6)))

### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    citys = []
    for _ in range(M):
        p, y = map(int, input().split())
        citys.append((p, y))
    
    ### citysdict作成
    temp= [[] for _ in range(N)]
    for city in citys:
        p, y = city
        temp[p-1].append((p, y))
    sortedcitys = []
    for pre in temp:
        sortedcitys.append(sorted(pre, key=lambda x:x[1]))
    citysdict = {}
    for pre in sortedcitys:
        ban = 1
        for city in pre:
            citysdict[city] = ban
            ban += 1
    
    ## 出力
    for city in citys:
        up = city[0]
        down = citysdict[city]
        print('{:0>6}'.format(up) + '{:0>6}'.format(down))

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

import numpy as np

N=int(input())
A=np.array(input().split(" "),dtype=np.int64)

s=0
for i in range(N-1):
    for j in range(i+1,N):
        s+=A[i]*A[j]

print(s%(pow(10,9)+7))

### FIXED CODE ###

import numpy as np

N=int(input())
A=np.array(input().split(" "),dtype=np.int64)

mod=1000000007

# 累積和
s=0
for i in range(N):
    s+=A[i]
    s=s%mod

ans=0
for i in range(N):
    s=s-A[i]
    if(s<0):
        s+=mod
    
    ans+=A[i]*s
    ans=ans%mod
    

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

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 23 11:18:48 2018

@author: natsukiiwano
"""

_in_ = list(map(int,input().split(" ")))
H,W,D = _in_[0],_in_[1],_in_[2]
dic = {}
for h in range(H):
    _in_ = list(map(int,input().split(" ")))
    for w in range(W):
        dic[_in_[w]]=h+w*1j


for n in range(H*W-D):
    dic[n+1] = int(abs(dic[n+1].real-dic[n+1+D].real)+abs(dic[n+1].imag-dic[n+1+D].imag))

dic2={}    

for q in range(int(input())):
    _in_ = list(map(int,input().split(" ")))
    (_from_,_to_) = (_in_[0],_in_[1])
    if (_from_,_to_) not in dic2:
        _sum_=0
        for j in range(int((_to_-_from_)/D)):
            _sum_ = _sum_ + dic[_from_+j*D]
        print(_sum_)
        dic2[(_from_,_to_)] = _sum_
    else:
        print(dic2[(_from_,_to_)])

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 23 12:24:26 2018

@author: natsukiiwano
"""
import numpy as np

_in_ = input().split(" ")
H,W,D = int(_in_[0]),int(_in_[1]),int(_in_[2])

px,py= np.zeros(90001),np.zeros(90001)
d=np.zeros(90001)
for i in range(H):
    _in_ = list(map(int,input().split(" ")))
    for j in range(W):
        px[_in_[j]]=i
        py[_in_[j]]=j

for i in range(D+1,H*W+1):
    d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D])

Q = int(input())
for i in range(Q):
    _in_ = input().split(" ")
    L,R = int(_in_[0]),int(_in_[1])
    print(int(d[R]-d[L]))
### BUGGY CODE ###

a,b,x=map(int,input().split())
ans=0
for i in range(a,b+1):
    if i%x==0:
        ans+=1
print(ans)

### FIXED CODE ###

a,b,x=map(int,input().split())
ans=b//x-a//x
if a%x==0:
    ans+=1
print(ans)
### BUGGY CODE ###

S = input()
q = int(input())
Q = []
sw = 1
for i in range(q):
  e = list(map(str, input().split()))
  Q.append(e)
  t = int(e[0])

  if t == 1:
    sw = sw * -1
  elif t == 2:
    f = int(e[1])
    if (sw == 1 and f == 1) or (sw == -1 and f == 2):
      S = e[2] + S
    elif (sw == -1 and f == 1) or (sw == 1 and f == 2):
      S = S + e[2]

if sw == -1:
  S = S[::-1]

print(S)

### FIXED CODE ###

S=input()
Q=int(input())
L=list()
B=True
X=''
Y=''
for i in range(Q):
  L=list(input().split())
  if L[0]=='1':
    B=not(B)
  else:
    if ((L[1]=='1' and B) or (not(L[1]=='1' or B))):
      Y=Y+L[2]
    else:
      X=X+L[2]
S=S[::-1]
S=S+Y
S=S[::-1]
S=S+X
if not(B):
  S=S[::-1]
print(S)
### BUGGY CODE ###

from math import *

def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list

a,b = map(int,input().split())
upper = 10**8
ans = set(eratosthenes(upper)) & make_divisors(a) & make_divisors(b)
print(len(ans) + 1)


### FIXED CODE ###

def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct
a,b = map(int,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1)
### BUGGY CODE ###

import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit
# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    xs = sum(a) // 2
    res = [0] * n

    for i in range(n):
        sub = 0
        for j in range(n // 2):
            sub += a[(i + 1 + j * 2) % n]
        res[i] = 2 * (xs - sub)

    print(*res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit
# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    res = [0] * n
    xs = sum(a)
    res[0] = xs - 2 * (sum(a[1::2]))

    for i in range(1, n):
        res[i] = 2 * a[(i - 1) % n] - res[(i - 1) % n]

    print(*res)


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

x = int(input(""))
l = list()
flag = 0
temp= [int(x) for x in input().split()]
for i in range(0, x):
     
    if temp[i] in l:
        flag = 1
    if temp[i] not in l:
        l.append(temp[i])
if flag == 1:
    print("NO")
else:
    print("YES")



### FIXED CODE ###

x = int(input(""))
l = list()
flag = 0
arr = [int(x) for x in input().split()]
arr2=set(arr)
l=len(arr)
l2=len(arr2)
if l!=l2:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

H, W = map( int, input().split())
d = dict()

S = [["#"]*(W+2)]+[ "#"+input()+"#" for _ in range(H)]+ [["#"]*(W+2)]
H += 2
W += 2
L = [[0]*(W+2) for _ in range(H+2)]
R = [[0]*(W+2) for _ in range(H+2)]
D = [[0]*(W+2) for _ in range(H+2)]
U = [[0]*(W+2) for _ in range(H+2)]
cnt = 0
for i in range(W):
    d[(0,i)] = 1
    d[(H-1,i)] = 1
for i in range(1,H-1):
    for j in range(W):
        if S[i][j] == "#":
            d[(i,j)] = 1
            cnt = 0
        else:
            d[(i,j)] = 0
            cnt += 1
            R[i][j] = cnt
            
for i in range(1,H-1):
    for j in range(W-1,-1,-1):
        if d[(i,j)] == 1:
            cnt = 0
        else:
            cnt += 1
            L[i][j] = cnt

for j in range(1,W-1):
    for i in range(H):
        if  d[(i,j)] == 1:
            cnt = 0
        else:
            cnt += 1
            D[i][j] = cnt

for j in range(1,W-1):
    for i in range(H-1,-1,-1):
        if d[(i,j)] == 1:
            cnt = 0
        else:
            cnt += 1
            U[i][j] = cnt

ans = 0
for i in range(1,H-1):
    for j in range(1,W-1):
        if ans < L[i][j] + R[i][j] + U[i][j] + D[i][j]:
            ans =  L[i][j] + R[i][j] + U[i][j] + D[i][j]
print(ans-3)


### FIXED CODE ###

H, W = map( int, input().split())
S = [["#"]*(W+2)]+[ "#"+input()+"#" for _ in range(H)]+ [["#"]*(W+2)]
H += 2
W += 2
L = [[0]*(W+2) for _ in range(H+2)]
R = [[0]*(W+2) for _ in range(H+2)]
D = [[0]*(W+2) for _ in range(H+2)]
U = [[0]*(W+2) for _ in range(H+2)]
cnt = 0

for i in range(1,H-1):
    for j in range(W):
        if S[i][j] == "#":
            cnt = 0
        else:
            cnt += 1
            R[i][j] = cnt
            
for i in range(1,H-1):
    for j in range(W-1,-1,-1):
        if S[i][j] == "#":
            cnt = 0
        else:
            cnt += 1
            L[i][j] = cnt

for j in range(1,W-1):
    for i in range(H):
        if S[i][j] == "#":
            cnt = 0
        else:
            cnt += 1
            D[i][j] = cnt

for j in range(1,W-1):
    for i in range(H-1,-1,-1):
        if S[i][j] == "#":
            cnt = 0
        else:
            cnt += 1
            U[i][j] = cnt

ans = 0
for i in range(1,H-1):
    for j in range(1,W-1):
        if ans < L[i][j] + R[i][j] + U[i][j] + D[i][j]:
            ans =  L[i][j] + R[i][j] + U[i][j] + D[i][j]
print(ans-3)
### BUGGY CODE ###

N = int(input())
ans = 0
for i in range(N):
    ans += i
print(ans)

### FIXED CODE ###

N = int(input())
print(int((N*(N-1))//2))
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in a:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
b=set(a)
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in b:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))
### BUGGY CODE ###

n, m = map(int, input().split())
row = [1 for i in range(m)]
field = [row for i in range(n)]

dc = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
dr = [-1, -1, -1, 0, 0, 0, 1, 1, 1]

for i in range(n):
    for j in range(m):
        for k in range(9):
            r = i + dr[k]
            c = j + dc[k]

            if r < 0 or r > n-1 or c < 0 or c > m-1:
                continue

            field[r][c] *= -1

ans = 0
for x in field:
    for y in x:
        if y == -1:
            ans += 1

print(ans)


### FIXED CODE ###

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

n -= 2
m -= 2

ans = 0

if n == 0 or m == 0:
    ans = 0

elif n == -1 and m == -1:
    ans = 1

elif n == -1 or m == -1:
    ans = max(n, m)

else:
    ans = n * m

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

n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(60), a))
mod = 10**9 + 7
ans = 0
for i in range(60):
    cnt = 0
    for j in a:
        cnt += int(j[-1*(i+1)])
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= mod
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

N = int(input())

if N <= 1:
    print("0")
    exit()

cnt = 0
for i in range(2,N+1):
    cnt += (i-1)

print(cnt)


### FIXED CODE ###

N = int(input())
print((N-1)*(N)//2)
### BUGGY CODE ###

n=int(input())

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            bp[j] = i

def fact(n):
    arr=[]
    while n>1:
        now=n
        cnt=0
        p=bp[now]
        while now % p == 0:
            now//=p
            cnt+=1
        arr.append([p,cnt])
        n=now
    return arr

ans=1 # for "1"
for i in range(2,n+1):
    cnt=1
    for p,c in fact(i):
        cnt*=(c+1)
    ans += (i*cnt)

print(ans)

### FIXED CODE ###

n=int(input())

x=[-1]*(10**7+5)
x[0]=0
x[1]=1
i=2
prime=[]
while i<=10**7+1:

    if x[i]==-1:
        x[i]=i
        prime.append(i)

    for j in prime:
        if i*j>10**7+1 or j>x[i]:break
        x[j*i]=j
    i+=1



def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
ans=0
for i in range(1,n+1):
    #print(i,f(i))
    ans += i*f(i)

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

import numpy as np
N, K, Q = input().split()
A = []
for i in range(int(Q)):
  A.append(int(input()))

Answers = np.zeros(int(N))
ones = np.ones(int(N))
if int(K) > int(Q):
  for i in range(int(N)):
    print("Yes")
else:
  for i in A:
    ones[i-1] = 0
    Answers += ones
    ones[i-1] = 1
  for i in Answers:
    if i < int(K):
      print("Yes")
    else:
      print("No")

### FIXED CODE ###

import numpy as np
_N, _K, _Q = input().split()
N, K, Q = int(_N), int(_K), int(_Q)
A = []
for i in range(Q):
  A.append(int(input()))

if K > Q:
  for i in range(N):
    print("Yes")
else:
  score = K * np.ones(N) - Q
  for i in A:
    score[i-1] += 1
  for i in score:
    if i > 0:
      print("Yes")
    else:
      print("No")
### BUGGY CODE ###

n=int(input())

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

t.sort()

if len(t) == 1:
    print(1)
    exit()

ans = 0

for i in range(n-1):  
    move = i+1
    memo = 1
    while t[i]+2 >= t[move]:
        memo += 1
        move += 1
        if move > n-1:
            break
    ans = max(memo, ans)

print(ans)

### FIXED CODE ###

n=int(input())

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

memo = [0]*(2+10**5)

for a in t:
    memo[a-1] += 1
    memo[a] += 1
    memo[a+1] += 1
print(max(memo))
### BUGGY CODE ###

n = int(input())
arr = []
for i in range(n-1):
    arr.append([int(s) for s in input().split(" ")])

mmk = [[0 for i in range(n+1)] for i in range(n+1)]

childNodeNums = [0 for i in range(n)]
childNodeStatus = [-1 for i in range(n)]
nodeLines = [0 for i in range(n - 1)]


def prepare(n, arr):
    s = [[] for i in range(n)]
    for ar in arr:
        s[ar[0] - 1].append(ar[1] - 1)
        s[ar[1] - 1].append(ar[0] - 1)
    return s


# x为记录入边的颜色
def dfs(currentNode, arr, x):
    childNodes = arr[currentNode]
    if len(childNodes) == 0:
        return

    childNodeNums[currentNode] = childNodeNums[currentNode] + len(arr[currentNode])
    childNodeStatus[currentNode] = 1

    kk = 0
    for i, childNodeIndex in enumerate(childNodes):

        if childNodeStatus[childNodeIndex] == -1:
            kk = kk + 1
            if x == kk:
                kk = kk + 1
            mmk[currentNode+1][childNodeIndex+1] = kk
            dfs(childNodeIndex, arr, kk)




data = prepare(n, arr)
dfs(0, data, -1)

print(max(childNodeNums))

for ar in arr:
    a0 = ar[0]
    a1 = ar[1]
    print(mmk[a0][a1])


### FIXED CODE ###

from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])
### BUGGY CODE ###

N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

maxsum=0

for i in range(len(S)):
    try:
        t=S[i]-S[i+K]
    except IndexError:
        t=0
    if t<0:
        pass
    else:
        tempsum=sum(S[i:i+K])
        if maxsum<tempsum:
            maxsum=tempsum
        else:
            pass

print(maxsum)

### FIXED CODE ###

N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

maxsum=sum(S[0:K])
tempsum=maxsum

for i in range(N-K):
    tempsum=tempsum-S[i]+S[i+K]
    if maxsum<tempsum:
        maxsum=tempsum
    else:
        pass

print(maxsum)
### BUGGY CODE ###

A,B,C,K = map(int,input().split())
a = 0
b = 0
c = 0
for i in range(K):
  a = B + C
  b = A + C
  c = A + B
  A = a
  B = b
  C = c
if (abs(A - B) > 10**18):
  print("Unfair")
else:
  print(str(A - B))

### FIXED CODE ###

A,B,C,K = map(int,input().split())
if(K == 0):
  ans = A - B
elif(K % 2 == 1):
  ans = B - A
else:
  ans = A - B
if(ans > 10 ** 18):
  print("Unfair")
else:
  print(str(ans))
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

p_0 = np.hstack((p, np.array([0] * (K-1))))

ps = [np.roll(p_0,i) for i in range(K)]

s = sum(ps)
max = max(s)

print((max + K) / 2)

### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

begin = 0
till = K

max = np.sum(p[0:K])
partial = max
for i in range(N-K):
    partial = partial - p[begin] + p[till]
    if(max < partial):
        max = partial

    begin += 1
    till += 1

print((max + K) / 2)
### BUGGY CODE ###

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

def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v

def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))

from collections import Counter
acnt = dict(Counter(a))
value = list(acnt.values())
sv = 0
for i in range(len(value)):
    if value[i] > 1:
        sv += comb(value[i], 2)
for i in range(n):
    cur = a[i]
    cursv = sv
    if acnt[cur] > 2:
        cursv = cursv - acnt[cur] + 1
    elif acnt[cur] == 2:
        cursv -= 1
    print(cursv)


### FIXED CODE ###

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

def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v

def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))

from collections import Counter
acnt = dict(Counter(a))
value = list(acnt.values())
sv = 0
for i in range(len(value)):
    if value[i] > 1:
        sv += (value[i]*(value[i]-1))//2
for i in range(n):
    cur = a[i]
    cursv = sv
    if acnt[cur] > 2:
        cursv = cursv - acnt[cur] + 1
    elif acnt[cur] == 2:
        cursv -= 1
    print(cursv)