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

n=int(input())
N=[str(i) for i in range(1,n+1)]

count=0
for a in N:
  for b in N:
    if str(a)[0]==str(b)[-1] and str(a)[-1]==str(b)[0]:
      count+=1

print(count)


### FIXED CODE ###

N=int(input())
d=[[0]*10 for i in range(10)]
#10x10のグリッドを作る

#9x9パターンに分類されるため、各数字をグリッドに振り分ける
for i in range(1,N+1):
  n=str(i)
  d[int(n[0])][int(n[-1])]+=1

#組み合わせの数は[Aの数]x[Bの数] 先頭か語尾に0が付くものはカウントしない
r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)
### BUGGY CODE ###

Figures = []
N = int(input())
for _ in range(N):
  A = int(input())
  if A in Figures:
    Figures.remove(A)
  else:
    Figures.append(A)
Answer = len(Figures)
print(Answer)

### FIXED CODE ###

dic = {}
N = int(input())
for _ in range(N):
  x = int(input())
  if x in dic:
    dic[x] += 1
  else:
    dic[x] = 1
counter = 0
for i in dic.keys():
  if dic[i] %2 == 1:
    counter +=1
print(counter)
### BUGGY CODE ###

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

elems = set(seq)
rem = 0

for i in elems:
    c = seq.count(i)
    if (c < i):
        rem += c
    else:
        rem += c-i

print(rem)

### FIXED CODE ###

import math

line1 = int(input())
line2 = str(input()).split(" ")
for index in range(len(line2)):
    line2[index] = int(line2[index])

newList = []
counter = dict()
newLength = 0
for element in line2:
    try:
        counter[element] += 1
    except:
        counter[element] = 1
    if (counter[element] == element):
        newLength += element

print(line1 - newLength)
### BUGGY CODE ###

N, K = map(int, input().split())
S = []
for j in range(K):
    LRj = list(map(int, input().split()))
    for s in range(LRj[0], LRj[1] + 1):
        S.append(s)

m =  998244353

# print(S)

dp = [0] * N
dp[0] = 1
for i in range(1, N):
    for s in S:
        if s <= i:
            # print(i, i-s)
            dp[i] += dp[i - s] % m
            dp[i] %= m

ans = dp[N - 1]

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = []
for j in range(K):
    S.append(list(map(int, input().split())))

m =  998244353

# print(S)

dp = [0] * N
dp[0] = 1
sum_of_region = [0] * K
for i in range(1, N):
    for j in range(K):
        if i - S[j][0] >= 0:
            sum_of_region[j] += dp[i - S[j][0]]
        if i - S[j][1] - 1 >= 0:
            sum_of_region[j] -= dp[i - S[j][1] - 1]
        dp[i] += sum_of_region[j] % m
        dp[i] %= m
    # print(i, dp, sum_of_region)

ans = dp[N - 1]
print(ans)
### BUGGY CODE ###

mod=10**9+7
N,K=map(int,input().split())
Ans=[1 for k in range(K)]
c=K
for j in range(N):
    Ans[0]=Ans[0]*(K)%mod
for k in range(2,(K+1)//2+1):
    d=K//k
    if c==d:
        Ans[k-1]=Ans[k-2]
    else:
        Ans[k-1]=pow(d,N,mod)
        c=d
for j in range(K,1,-1):
    for l in range(j//2,0,-1):
        if j%l==0:
            Ans[l-1]-=Ans[j-1]
for j in range(K):
    Ans[j]*=j+1
print(sum(Ans)%mod)

### FIXED CODE ###

N, K = map(int, input().split())
mod = 10**9 + 7

  
fact_count = [0 for _ in range(K+1)]
for k in range(1, K+1):
  fact_count[k] = K//k

ans = 0
count = [0 for _ in range(K+1)]
for k in range(K, 0, -1):
  c = pow(fact_count[k], N, mod)
  j = 2*k
  l = 2
  while(j<=K):
    c -= count[j]
    l += 1
    j = k*l
  count[k] = c
  c = c*k%mod
  ans += c
  ans %= mod
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
a = [0] + a +[0]

for i in range(n):
    d = a[i+1]
    del(a[i+1])
    c = 0
    for j in range(n+1)[1:n+1]:
        c += abs(a[j]-a[j-1])
    print(c)
    a.insert(i+1,d)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a = [0] + a +[0]
s = 0

for i in range(1,n+2):
    s += abs(a[i]-a[i-1])

for i in range(1,n+1):
    print(s-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))
### BUGGY CODE ###

# soundhound2018_summer_qual_d
import networkx as nx
n, m, s, t = map(int, input().split())


Gy = nx.Graph()   # Yen
Gy.add_nodes_from(range(1, n+1))

Gs = nx.Graph()   # Snuuk
Gs.add_nodes_from(range(1, n+1))


for _ in range(m):
    u, v, a, b = map(int, input().split())
    Gy.add_edge(u, v, weight=a)
    Gs.add_edge(u, v, weight=b)

shortest_length_from_s = nx.shortest_path_length(Gy, source=s, weight='weight')
shortest_length_to_t = nx.shortest_path_length(Gs, target=t, weight='weight')


dist = [-1]
for i in range(1, n+1):
    dist.append(shortest_length_from_s[i]+shortest_length_to_t[i])
# print(dist)

for i in range(1, n+1):
    print(10**15-min(dist[i:]))

### FIXED CODE ###

import numpy as np
from heapq import heappush, heappop

n, m, s, t = map(int, input().split())
G = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G[u].append((v, a, b))
    G[v].append((u, a, b))


def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (n+1)
    dist[start] = 0
    q = [(0, start)]
    while q:
        d, v = heappop(q)
        if dist[v] < d:
            continue
        for w, *a in G[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1, w))
    return dist


d1 = np.array(dijkstra(s, 0))
d2 = np.array(dijkstra(t, 1))

# print(d1)


d = []
for i in range(n+1):
    d.append(d1[i]+d2[i])


ans = []
B = 10**15
for i in range(n):
    B = min(B, d[n-i])
    ans.append(B)
ans = ans[::-1]

for i in range(n):
    print(10**15-ans[i])
### BUGGY CODE ###

N,K = map(int,input().split())
from collections import deque

#期待値はΣ(from 1 to pi)/len(pi)
P = [(p+1)/2 for p in map(int,input().split()) ]

que = deque(P[:K])
counter = []
counter.append(sum(que))
for k in range(K,N):
    que.popleft()
    que.append(P[k])
    counter.append(sum(que))

print(max(counter))

### FIXED CODE ###

N,K = map(int,input().split())
#from collections import deque

#期待値はΣ(from 1 to pi)/len(pi)
P = list(map(int,input().split()))
cumsum = [0]*(N+1)
counter = []
for k in range(N):
    cumsum[k+1]=cumsum[k]+P[k]

for i in range(N-K+1):
    counter.append(cumsum[i+K]-cumsum[i])

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

class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self,x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root
    def unite(self,x,y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
        else:
            self.parents[yroot] = xroot
            
N,K,L=map(int,input().split())
ufroad = UnionFind(N)
uftrain = UnionFind(N)

for i in range(K):
    p,q = map(int,input().split())
    ufroad.unite(p-1,q-1)
for i in range(L):
    r,s = map(int,input().split())
    uftrain.unite(r-1,s-1)
uflist=[]
for i in range(N):
    uflist.append((ufroad.find(i), uftrain.find(i)))
ans=[uflist.count(uflist[i]) for i in range(N)]
print(' '.join(map(str, ans)))

### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self,x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root
    def unite(self,x,y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
        else:
            self.parents[yroot] = xroot
            
N,K,L=map(int,input().split())
ufroad = UnionFind(N)
uftrain = UnionFind(N)

for i in range(K):
    p,q = map(int,input().split())
    ufroad.unite(p-1,q-1)
for i in range(L):
    r,s = map(int,input().split())
    uftrain.unite(r-1,s-1)
uflist=[]
for i in range(N):
    uflist.append((ufroad.find(i), uftrain.find(i)))
counter={}
for i in range(N):
  if uflist[i] not in counter.keys():
    counter[uflist[i]]=1
  else:
    counter[uflist[i]]+=1
print(' '.join(map(str, [counter[uflist[i]] for i in range(N)])))
### BUGGY CODE ###

S = raw_input()

value = int(S, 2)

zero = 0
one = 0
for i in xrange(len(S)):
    if i % 2 == 0:
        zero += 2 ** i
    else:
        one += 2 ** i

count = bin(value ^ zero).count('1')
count_1 = bin(value ^ one).count('1')

if count <= count_1: print count
else: print count_1


### FIXED CODE ###

S = raw_input()

value = int(S, 2)

eval = ''
length = len(S)
if length % 2 == 0: val = 1
else: val = 0
for i in xrange(length):
    if i % 2 == val: eval += '1'
    else: eval += '0'

count = bin(value ^ int(eval,2)).count('1')

if count <= 0.5 * length: print count
else: print (length - count)
### BUGGY CODE ###


N,M,L = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]
Q = int(input())
st = [list(map(int,input().split())) for _ in range(Q)]

INF = 1<<30
dp = [[INF]*N for _ in range(N)]

for a,b,c in ABC:
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
        
d = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dp[i][j]<=L:
            d[i][j] = 1
        
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        
for s,t in st:
    if d[s-1][t-1]!=INF:
        print(d[s-1][t-1]-1)
    else:
        print(-1)

### FIXED CODE ###


N,M,L = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]
Q = int(input())
st = [list(map(int,input().split())) for _ in range(Q)]

INF = 1<<30
dp = [[INF]*N for _ in range(N)]

for a,b,c in ABC:
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
        
d = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dp[i][j]<=L:
            d[i][j] = 1
        
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        
for s,t in st:
    if d[s-1][t-1]!=INF:
        print(d[s-1][t-1]-1)
    else:
        print(-1)
### BUGGY CODE ###

import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)

list1 =sorted( [kv[0] for kv in c.items() if kv[1] == max(c.values())])
for i in range(len(list1)):
  print(list1[i])

### FIXED CODE ###

N = int(input())
dic = {}

for i in range (N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

sai = max(dic.values())

for j in sorted(k for k in dic if dic[k] == sai):
  print(j)
### BUGGY CODE ###

N=int(input())
a=list(map(int,input().split()))
ans=0
aa=list(set(a))

for i in range(len(aa)):
    cnt=a.count(aa[i])
    if cnt>aa[i]:
        ans+=cnt-aa[i]
    elif cnt<aa[i]:
        ans+=cnt

print(str(ans))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
ans=0
aa=list(set(a))
dict={}
for s in aa:
    dict[s]=0
for l in a:
    dict[l]+=1
for i in dict.items():
    num=i[0]
    amount=i[1]
    """                                                           
    cnt=a.count(i)                                                
    if cnt>i:                                                     
        ans+=cnt-i                                                
    elif cnt<i:                                                   
        ans+=cnt                                                  
    """
    if amount>num:
        ans+=amount-num
    elif amount<num:
        ans+=amount
print(str(ans))
### BUGGY CODE ###

import sys
from collections import Counter

input = sys.stdin.readline
def main():

  s=input()
  s=s.strip("\n")
  n=len(s)
  res=0
  t=[0]*(n+1)
  
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+(int(s[n-i])*10**(i-1))%2019)%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=int(i*(i-1)/2)
  print(res)

if __name__ == '__main__':
  main()


### FIXED CODE ###

from collections import Counter

def main():

  s=input()
  n=len(s)
  res=0
  t=[0]*(n+1)
  k=1
  for i in range(1,n+1):
      t[n-i]=(t[n-i+1]+int(s[n-i])*k)%2019
      k*=10
      k=k%2019
  d=Counter(t)
  for i in d.values():
      if i<2:
        continue
      res+=i*(i-1)/2
  print(int(res))

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

num = int(input())
input_data = input().split(' ')
data = [int(input_data[i]) for i in range(len(input_data))]
n = 1
key = 0
while(n in data):
    key = 1
    data = data[data.index(n):]
    n += 1

if(key == 0):
    print(-1)
else:
    print(num - n + 1)


### FIXED CODE ###

num = int(input())
input_data = input().split(' ')
if("1" in input_data):
    input_data = input_data[input_data.index('1'):]
    ref = 1
    for i in range(len(input_data)):
        if(int(input_data[i]) - ref == 1):
            ref += 1

    print(num - ref)
else:
    print('-1')
### BUGGY CODE ###

import copy
n = int(input())
a = list(map(int, input().split()))
mod_a = [i%(10**9 + 7) for i in a]
cop = copy.deepcopy(mod_a)
res = 0
for i in cop:
  b = i
  #print(b)
  #cop[i]
  #print(mod_a)
  if len(mod_a)!=1:
  	mod_a.remove(i)
  	mod_b = [j*b%(10**9 + 7) for j in mod_a]
  	res += (sum(mod_b))%(10**9 + 7)
  	#print(res)
print(res%(10**9 + 7))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
#mod_a = [i%(10**9 + 7) for i in a]
res = 0
sum_a = sum(a)
b = 0
t = 0
for i in range(0, len(a)-1):
  t = a[i]
  b += a[i]
  res += (sum_a - b)*t%(10**9 + 7)
print(res%(10**9 + 7))
### BUGGY CODE ###

n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
Table = []

for i in range(n):
    Table.extend([a[i][0]]*a[i][1])

print(sorted(Table)[k-1])


### FIXED CODE ###

from operator import itemgetter

n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=itemgetter(0))
m = 0

for i in range(n):
    m += a[i][1]
    if k <= m:
        print(a[i][0])
        break
### BUGGY CODE ###

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

# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow(a, m-2, m) % m


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


# M を素因数分解
m_nokori = M
ans = 1
for i in range(2, M+1):
    if m_nokori == 1:
        break
    cnt = 0
    while m_nokori % i == 0:
        cnt += 1
        m_nokori //= i
    # cnt が 2^X とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)


### FIXED CODE ###

# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

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

A,B,C,K = map(int,input().split())

s=-1*K*C

lc=[]
lc_=[]
for i in range(A+1):
  for j in range(K-i+1):
    lc.append([i,j,K-i-j])

#print(lc)

for i in range(len(lc)):
  if lc[i][0]<=A and lc[i][1]<=B and lc[i][2]<=C:
    # print(lc[i])
    s=max(s, lc[i][0]-lc[i][2])

print(s)


### FIXED CODE ###

A,B,C,K = map(int,input().split())

if A+B<K:
  print(A-(K-A-B))
else:
  print(min(A, K))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(1, n+1):
    j = a.count(i)
    if j != 0:
        b[i-1] = j
for i in b:
    print(i)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
l = [0]*n
for i in range(n-1):
    j = a[i]
    l[j-1] += 1
for i in range(n):
    print(l[i])
### BUGGY CODE ###


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

w = [0 for i in range(N+1)]
v = [0 for i in range(N+1)]
Wsum = [0 for i in range(N+1)]
Vsum = [0 for i in range(N+1)]

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

for i in range(N):
    Wsum[i+1] = Wsum[i] + w[i+1]
    Vsum[i+1] = Vsum[i] + v[i+1]

#i番目の品物まで含み制約W2のナップサック問題の最適解
def nap(i,W2):
    #品物0個のときはもちろん価値は0
    if i == 0:
        return 0
    #w[i]がW2を超えるときはi番目の品物は不必要
    if W2 < w[i]:
        return nap(i-1,W2)
    #品物１つで制約OK→品物一つの価値がnapの価値        
    if i == 1:
        return v[i]
    #品物の重さ全部足して制約以下なら全部足したものが価値
    if Wsum[i] <= W2:
        return Vsum[i]

    return max( nap(i-1,W2-w[i])+v[i] , nap(i-1,W2) )
    
            
print(nap(N,W))


### FIXED CODE ###


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

w = [0 for i in range(N)]
v = [0 for i in range(N)]
Wsum = [0 for i in range(N+1)]
Vsum = [0 for i in range(N+1)]

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

w.insert(0,"0")
v.insert(0,"0")


for i in range(N):
    Wsum[i+1] = Wsum[i] + w[i+1]
    Vsum[i+1] = Vsum[i] + v[i+1]


nap_memo = {}

#i番目の品物まで含み制約W2のナップサック問題の最適解
def nap(i,W2):
    #重複計算を避けるためnap(i,W2)を保持
    key = str(i) + ':' + str(W2)
    if key in nap_memo:
        return nap_memo[key]
    #品物0個のときは価値は0
    elif i == 0:
        r = 0
    #制約0のときも価値は0
    elif W2 < Wmin:
        r = 0
    #w[i]がW2を超えるときはi番目の品物は不必要
    elif W2 < w[i]:
        r = nap(i-1,W2)
    #品物の重さ全部足して制約以下なら全部足したものが価値で良い
    elif Wsum[i] <= W2:
        r = Vsum[i]
    #i番目の品物をナップサックに入れるか入れないか
    else:
        r = max( nap(i-1,W2-w[i])+v[i] , nap(i-1,W2) )
    
    nap_memo[key] = r
    return r
    
            
print(nap(N,W))
### BUGGY CODE ###

n = int(input())
A = [int(input()) for i in range(n)]
for j in range(n):
    B = A.copy()
    B.remove(B[j])
    print(max(B))

### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for i in range(n)]
B = sorted(A)
m1 = B[-1]
m2 = B[-2]

for a in A:
    if a == m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[int(j | c)] = min(dp[int(j | c)], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()


### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[j | c] = min(dp[j | c], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()
### BUGGY CODE ###

from collections import Counter
import math

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

if N == set(A):
    for _ in range(N):
        print(0)

c2 = math.factorial(2)
umemory = {}
dmemory = {}

count = Counter(A)

for k, v in count.items():
    umemory[k] = 0 if v < 2 else math.factorial(v) // (math.factorial(v - 2) * c2)
    dmemory[k] = 0 if v < 3 else math.factorial(v-1) // (math.factorial(v - 3) * c2)

for k in range(0, N):
    a = A[k]
    hoge = sum(map(lambda kv: kv[1], filter(lambda kv: kv[0] != a, umemory.items())))
    hoge += dmemory[a]
    print(hoge)

### FIXED CODE ###

from collections import Counter
import math

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

c = Counter(A)

all_ans = 0
for n in c.values():
    if n <= 1:
        continue
    all_ans += math.factorial(n)//(math.factorial(n-2)*math.factorial(2))

for n in A:
    print(all_ans - (c[n]-1))
### BUGGY CODE ###

S = input()
Q = int(input())

is_frontR = True
for i in range(Q):
    tmp_Q = input().split()

    if len(tmp_Q) == 1:
        is_frontR = not is_frontR
        
    else:
        if tmp_Q[1] == "1":
            if is_frontR:
                S = tmp_Q[2] + S
            else:
                S = S + tmp_Q[2]
        else:
            if is_frontR:
                S = S + tmp_Q[2]
            else:
                S = tmp_Q[2] + S

if is_frontR:
    print(S)
else:
    print(S[::-1])

### FIXED CODE ###

S = input()
Q = int(input())

is_reversed = False
head = ""

for i in range(Q):
    tmp_Q = input().split()

    if len(tmp_Q) == 1:
        is_reversed = not is_reversed
        
    else:
        if tmp_Q[1] == "1":
            if is_reversed:
                S = S + tmp_Q[2]
            else:
                head = head + tmp_Q[2]
        else:
            if is_reversed:
                head = head + tmp_Q[2]
            else:
                S = S + tmp_Q[2]

if is_reversed:
    print(S[::-1] + head)
else:
    print(head[::-1] + S)
### BUGGY CODE ###

s = list(input())
k = int(input())

arr = []

for i in range(len(s)):
    for j in range(i,len(s)):
        arr += [''.join(s[i:j+1])]

arr = list(set(arr))
arr.sort()
print(arr[k-1])

### FIXED CODE ###

s = list(input())
k = int(input())

arr = []

for i in range(len(s)):
    for j in range(i,i+5):
        arr += [''.join(s[i:j+1])]

arr = list(set(arr))
arr.sort()
print(arr[k-1])
### BUGGY CODE ###

K = int(input())

def calc(n):
    m = 0
    while n:
        n, d = divmod(n, 10)
        m += d
    return m

def find(xs, i):
    ri, rv = None, 10**20
    for j in range(i, len(xs)):
        if xs[j] < rv:
            ri = j
            rv = xs[j]
    return ri, rv

c = 0
i = 1
while 1:
    n = i
    r = 0
    k = 0
    vs = []
    while 1:
        n, m = divmod(n, 10)
        r += m
        if n == 0:
            break
        k += 1
        vs.append((n + 1) * 10**k - 1)
    if (not vs) or i / r <= min(v / calc(v) for v in vs):
        print(i)
        c += 1
        if c >= K:
            break
    i += 1


### FIXED CODE ###

K = int(input())

def calc(n):
    m = 0
    while n:
        n, d = divmod(n, 10)
        m += d
    return m

def find(xs, i):
    ri, rv = None, 10**20
    for j in range(i, len(xs)):
        if xs[j] < rv:
            ri = j
            rv = xs[j]
    return ri, rv

c = 0
i = 1
prev = 0
d = 1
while 1:
    n = i
    r = 0
    k = 0
    vs = []
    while 1:
        n, m = divmod(n, 10)
        r += m
        if n == 0:
            break
        k += 1
        vs.append((n + 1) * 10**k - 1)
    if (not vs) or i / r <= min(v / calc(v) for v in vs):
        print(i)
        d = max(d, i - prev)
        prev = i
        c += 1
        if c >= K:
            break
    i += d