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

v,e,s=map(int,input().split())
edge=[]
inf =1000000100
for i in range(v):
    edge.append([])

for i in range(e):
    vs,vt,d=map(int,input().split())
    edge[vs].append((vt,d))
    
dis=[]
for i in range(v):
    dis.append(inf)

dis[s]=0

for j in range(v):
    for i in range(v):
        for (t,d) in edge[i]:
            if dis[t]>dis[i]+d:
                dis[t]=dis[i]+d

for i in range(v):
    if dis[i]>=inf:
        print("INF")
    else:
        print(dis[i])

### FIXED CODE ###

'''
????????£????????????1??????????????????
??\???C++??§????????????????§£?±???????????????????????????????????????§???
??????python??§??????????????????Accept??§??????????????????
????????£??¨optimization??????????????§??????
??§????????????Wrong Answer??§?????????
???????????????????????????????????????????????????
Online Judge???????????????Public Solutions??§
????????????nanae?????????python3????????????????????????
????????£??¨?????????????????????
???????????????????????????0.06?§????????????§??????
'''

import queue
v,e,s=map(int,input().split())
edge=[]
inf =1000000100
for i in range(v):
    edge.append([])

for i in range(e):
    vs,vt,d=map(int,input().split())
    edge[vs].append((vt,d))
    
dis=[]
for i in range(v):
    dis.append(inf)

dis[s]=0

q = queue.PriorityQueue()
q.put((0,s))


while(not q.empty()):
    now=q.get()
    nowv=now[1]
    for (vt,d) in edge[nowv]:
        if dis[vt]>dis[nowv]+d:
            dis[vt]=dis[nowv]+d
            q.put((dis[vt],vt))
'''

finished=0
while(finished<v and not q.empty()):
    now=q.get()
    nowv=now[1]
    if now[0]>dis[nowv]: continue
    for (vt,d) in edge[nowv]:
        if dis[vt]>dis[nowv]+d:
            dis[vt]=dis[nowv]+d
            q.put((dis[vt],vt))
    finished+=1       '''

for i in range(v):
    if dis[i]>=inf:
        print("INF")
    else:
        print(dis[i])
### BUGGY CODE ###

import bisect
import sys
input = sys.stdin.readline
def main():
    N,M = map(int,input().split())
    A= list(map(int,input().split()))
    A = sorted(A)

    BC=[list(map(int,input().split())) for i in range(M)]
    BC = sorted(BC, key=lambda x: x[1],reverse=True)

    for B,C in BC:
        index = bisect.bisect_right(A,C)
        if index==0:
            break
        if index > B:
            A = A[B:index] + [C] *B + A[index:]
        else:
            A = [C]*index + A[index:]

    print(sum(A))
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N,M = map(int,input().split())
    A= list(map(int,input().split()))
    A = sorted(A)

    BC=[list(map(int,input().split())) for i in range(M)]
    BC = sorted(BC, key=lambda x: x[1],reverse=True)
    index=0
    max_index=len(A)
    
    for B,C in BC:
        temp = [C]*B
        for t in temp:
            if max_index>index and  t>A[index]:
                A[index] = t
            else:
                return A
            index+=1
    return A
    
if __name__ == '__main__':
    A=main()
    print(sum(A))
### BUGGY CODE ###

# import numpy as np
import copy
import queue


q = queue.Queue()

n, m = map(int, input().split())
l = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    l[a-1][b-1] = 1
    l[b-1][a-1] = 1


# l = np.array(l)
lc = copy.deepcopy(l)
li = [-1 for _ in range(n)]

def search(x):
    if sum(lc[x]) == 0:
        q.queue = False
        return
    
#     ind_lis = np.where(lc[x] == 1)[0]
#     ind_lis = [e for e in ind_lis if li[e] == -1]
#     print(li)
#     print(lc[x])
    for i,e in enumerate(lc[x]):
#         print(i,e)
        if li[i] != -1 or e == 0:
            continue
        li[i] = x
#         print('q', i+1)
        q.put(i)
x = 0
search(x)
while q.queue:
    search(q.get())

if li[1:].count(-1) == 0:
    print('Yes')
    for e in li[1:]:
        print(e+1)
else:
    print('No')


### FIXED CODE ###

# import numpy as np
# import copy
from collections import defaultdict
import queue


q = queue.Queue()

n, m = map(int, input().split())
graph = defaultdict(list)
for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)


# l = np.array(l)
# lc = copy.deepcopy(l)
li = [-1 for _ in range(n)]
li[0] = 1

def search(x):
#     if sum(l[x]) == 0:
#         q.queue = False
#         return
    
#     ind_lis = np.where(lc[x] == 1)[0]
#     ind_lis = [e for e in ind_lis if li[e] == -1]
#     print(li)
#     print(lc[x])
    for e in graph[x]:
#         print(e)
        if li[e-1] != -1:
            continue
        li[e-1] = x
#         print('q', i+1)
        q.put(e)
x = 1
search(x)
while q.queue:
    search(q.get())

if li[1:].count(-1) == 0:
    print('Yes')
    for e in li[1:]:
        print(e)
else:
    print('No')
### BUGGY CODE ###

import bisect
N, M = list(map(int, input().split(' ')))
As = list(map(int, input().split(' ')))
#  sortしていちばん大きいのをとって半額にしてAsに戻してもう一回ソートするのをM回やれば1e5 にN log N +alpha
As = sorted(As)
while M:
    hoge = As.pop(-1) // 2
    M -= 1
    while M and As and hoge >= As[-1]:
        hoge = hoge // 2
        M -= 1
    bisect.insort(As, hoge)
print(sum(As))

### FIXED CODE ###

import math
import heapq
n, k = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
aaa = [-a for a in aaa]
heapq.heapify(aaa)
for i in range(k):  # TLE?
    t = heapq.heappop(aaa)
    t = math.ceil(t/2)
    heapq.heappush(aaa, t)
print(-sum(aaa))
### BUGGY CODE ###

import math

k = int(input())


ans = 0
for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
            ans += math.gcd(math.gcd(x,y),z)

print(ans)


### FIXED CODE ###

from math import gcd

k = int(input())


ans = 0
for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
            ans += gcd(gcd(x,y),z)

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

N,X = map(int,input().split())
S = list(map(int,input().split()))
S.sort()
mod = 10**9+7

dp = [[0]*(N+1) for i in range(X+1)]
for x in range(X+1):
    for n in range(N+1):
        if n == 0:
            dp[x][n] = x
        else:
            dp[x][n] = (dp[x%S[n-1]][n-1] + (n-1)*dp[x][n-1])%mod

print(dp[X][N])

### FIXED CODE ###

from collections import defaultdict
N,X = map(int,input().split())
S = list(map(int,input().split()))
S.sort()
mod = 10**9+7

fact_memo = [0]*201
fact_memo[0] = 1
def fact(n):
    if fact_memo[n] == 0:
        fact_memo[n] = n*fact(n-1)%mod
    return fact_memo[n]

fact_inv_memo = [0]*201
fact_inv_memo[0] = 1
def fact_inv(n):
    if fact_inv_memo[n] == 0:
        fact_inv_memo[n] = pow(fact(n),mod-2,mod)
    return fact_inv_memo[n]

dp = defaultdict(lambda :[-1]*(X+1))
for n in range(N):
    for x in range(X+1):
        if n == 0:
            dp[n][x]=x%S[0]
        else:
            dp[n][x]=(dp[n-1][x%S[n]]+n*dp[n-1][x])%mod

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

L, R= map(int, input().split())

hasamu=R-L
kotae=10000
if hasamu>2017:
  kotae=0

for i in range(L,R):
  for j in range(i+1,R+1):
    seki=i*j
    amari=seki%2019
    if amari<kotae:
      kotae=amari
print(kotae)
  


### FIXED CODE ###

L2, R2= map(int, input().split())

L=L2%2019
R=R2%2019

hasamu=R2-L2
kotae=10000
if hasamu>2017:
  kotae=0
if L>R:
  kotae=0
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      seki=i*j
      amari=seki%2019
      if amari<kotae:
        kotae=amari
print(kotae)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

list_ = []
for i in range(1, N):
  print(A.count(i))
print(0)

### FIXED CODE ###

import numpy as np

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

A.append(0)

for i in range(0, N-1):
  ans[A[i]] += 1
for i in range(1, N):
  print(ans[i])
print(0)
### BUGGY CODE ###

def sol():
    n,m=map(int,input().split())
    d={}
    for i in range(m):
        u,v=map(int,input().split())
        if u in d:
            d[u].append(v)
        else:
            d[u]=[v]
    s,t=map(int,input().split())
    ans=chk=0
    w={s}
    n*=3
    ans=0
    while n:
        tmp=set()
        p=w
        n-=1
        ans+=1
        for i in p:
            if i in d:
                for j in d[i]:
                    tmp.add(j)
        if t in tmp and ans%3==0:
            print(ans//3)
            exit()
        w=tmp
    print(-1)

if __name__=="__main__":
    sol()


### FIXED CODE ###

from collections import deque
def sol():
    n,m=map(int,input().split())
    d={}
    for i in range(m):
        u,v=map(int,input().split())
        if u in d:
            d[u].append(v)
        else:
            d[u]=[v]
    s,t=map(int,input().split())
    ans=chk=0
    w=deque([0,s])
    #tmp=[0]*(n+1)
    tmp=[[0,0,0] for i in range(n+1)]
    ans=1
    n+=n//2
    n*=2
    while n:
        x=w.pop()
        if x==0:
            ans+=1
            n-=1
            w.appendleft(0)
        elif x in d:
            for j in d[x]:
                if ans%3==0 and j==t:
                    print(ans//3)
                    exit()
                if tmp[j][ans%3]==0:
                    w.appendleft(j)
                    tmp[j][ans%3]=1
    print(-1)

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

import numpy as np
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp=[np.inf]*n
dp[0]=0
for i in range(1,n):
  for j in range(k):
    if i > j:
      dp[i] = min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]))
print(dp[-1])

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp=[100000000000000000]*n
dp[0]=0
for i in range(1,n):
  for j in range(k):
    if i > j:
      dp[i] = min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]))
print(dp[-1])
### BUGGY CODE ###

while 1:
    try:
        s1 = raw_input()
    except: break
    s2 = raw_input()
    l = len(s1)
    f = False
    for i in range(l,0,-1):
        for j in range(0,l-i+1):
            if j+i > l: break
            x = s2.find(s1[j:j+i])
            if x != -1:
                f = True
                print i
                break
        if f: break
    if i == 1 and not f: print 0

### FIXED CODE ###

while 1:
    try:
        s1 = raw_input()
        s2 = raw_input()
        if len(s1) < len(s2): s1,s2 = s2,s1
        l = sum(min(s1.count(i), s2.count(i)) for i in set(list(s1)) & set(list(s2)))
        if l == 0: print 0; continue
        ans = 0
        for i in range(len(s2)):
            if len(s2) - i <= ans: break
            for j in range(ans+1, min(l + 1,len(s2)-i+1)):
                if s2[i:i+j] in s1:
                    ans = j
                else: break
        print ans
    except:
        break
### BUGGY CODE ###

import sys
flush = sys.stdout.flush
write = sys.stdout.write

N = int(input())

bb_1,bb_2 = "..##",".#.#"
res_1,res_2 = "",""

def ask(s1,s2):
    write(res_1)
    write(res_2)
    result = input()
    flush()
    if result=="end":
        exit()
    return result=="T"

# 右側に伸ばしていく
while 1:
    for i in range(4):
        if ask(res_1+bb_1[i],res_2+bb_2[i]):
            res_1 += bb_1[i]
            res_2 += bb_2[i]
            break
    else:
        break

# 左側に伸ばしていく
while 1:
    for i in range(4):
        if ask(bb_1[i]+res_1,bb_2[i]+res_2):
            res_1 = bb_1[i] + res_1
            res_2 = bb_2[i] + res_2
            break
    else:
        break


### FIXED CODE ###

import sys
flush = sys.stdout.flush
write = sys.stdout.write

N = int(input())

bb_1,bb_2 = "..##",".#.#"
res_1,res_2 = "",""

def ask(s1,s2):
    write(s1+'\n'+s2+'\n')
    result = input()
    flush()
    if result=="end":
        exit()
    return result=="T"

# 右側に伸ばしていく
while 1:
    for i in range(4):
        if ask(res_1+bb_1[i],res_2+bb_2[i]):
            res_1 += bb_1[i]
            res_2 += bb_2[i]
            break
    else:
        break

# 左側に伸ばしていく
while 1:
    for i in range(4):
        if ask(bb_1[i]+res_1,bb_2[i]+res_2):
            res_1 = bb_1[i] + res_1
            res_2 = bb_2[i] + res_2
            break
    else:
        break
### BUGGY CODE ###

N = int(input())
dp = [0] * (1 << N)
dp[0] = 1
MOD = 10 ** 9 + 7
now = {0}
for _ in range(N):
    mat = [1<<i for i, v in enumerate(input().split()) if v == '1']
    nxt = set()
    for k in now:
        p = dp[k] % MOD
        for m in mat:
            if k & m: # 1101 & 0100 3番目の人はすでにペアになっているためはじく
                continue
            dp[k | m] += p # 1001 | 0010 = 1101
            nxt.add(k | m)
    now = nxt
print(dp[-1] % MOD) #dp[11...11]が答えになる

### FIXED CODE ###

N = int(input())
dp = [0] * (1 << N)
dp[0] = 1
MOD = 10 ** 9 + 7
now = {0}
for _ in range(N):
    mat = [1<<i for i, v in enumerate(input().split()) if v == '1']
    nxt = set()
    for k in now:
        p = dp[k] % MOD
        for m in mat:
            if k & m: # 1101 & 0100 3番目の人はすでにペアになっているためはじく
                continue
            dp[k | m] += p # 1001 | 0010 = 1101
            nxt.add(k | m)
    now = nxt
print(dp[-1] % MOD) #dp[11...11]が答えになる
### BUGGY CODE ###

def main():
    import sys
    import time
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    g = A[0]

    S = 1
    for x in A:
        S *= x
    start = time.time()

    def factorization(n):
        ret = set()
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                ret.add(i)

        if temp != 1:
            ret.add(temp)

        if len(ret) == 0 and n != 1:
            ret.add(n)

        return ret

    flag = True
    s = factorization(A[0])
    for x in A[1:]:
        tmp = 0
        now = time.time()
        if now - start > 2:
            break
        for y in s:
            if x % y == 0:
                flag = False
                break
        if flag:
            s |= factorization(x)
            continue
        else:
            break

    if flag:
        print("pairwise coprime")
    else:
        g = A[0]
        for i, x in enumerate(A[::-1]):
            g = gcd(g, x)
        if g == 1:
            print("setwise coprime")

        else:
            print("not coprime")


main()


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    g = A[0]
    M = max(A)
    X = [i for i in range(M+1)]
    S = [True for i in range(M+1)]
    S[0] = False
    S[1] = False

    for i in range(1, M+1):
        if S[i]:
            for j in range(i, M+1, i):
                if S[j]:
                    S[j] = False
                    X[j] = i
    flag = True
    s = set()
    ls = 0
    for x in A:
        tmp = set()
        while(X[x] != 1):
            tmp.add(X[x])
            x //= X[x]
        l = len(tmp)
        s |= tmp
        if len(s) == ls + l:
            ls += l
            continue
        else:
            flag = False
            break

    if flag:
        print("pairwise coprime")
    else:
        for x in A[1:]:
            g = gcd(g, x)
        if g == 1:
            print("setwise coprime")

        else:
            print("not coprime")


main()
### BUGGY CODE ###

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

a_m=[i for i in a if i<0]
a_z=[i for i in a if i==0]
a_p=[i for i in a if i>0]

a_minus=len(a_m)
a_zero=len(a_z)
a_plus=len(a_p)

ans_minus=a_minus*a_plus
ans_zero=a_zero*(a_minus+a_plus)+a_zero*(a_zero-1)//2
ans=[]
if ans_minus>=k:
    for i in range(a_minus):
        for j in range(a_plus):
            ans.append(a_m[i]*a_p[j])
    ans.sort()
    print(ans[k-1])
elif ans_zero+ans_minus>=k:
    print(0)
else:
    for i in range(a_plus):
        for j in range(a_plus):
            if i>j:
                ans.append(a_p[i]*a_p[j])
    for m in range(a_minus):
        for n in range(a_minus):
            if m>n:
                ans.append(a_m[m]*a_m[n])
    ans.sort()
    print(ans[k-1-ans_zero-ans_minus])

### FIXED CODE ###

import numpy as np
n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))
a.sort()
posi = a[a>0]
zero = a[a==0]
nega = a[a<0]

def cnt(x):
    c = 0
    if x >= 0:
        c += len(zero)*n
    c += np.searchsorted(a, x // posi, side = 'right').sum()
    c += (n-np.searchsorted(a, (- x - 1) // (-nega), side = 'right')).sum()
    c -= np.count_nonzero(a * a <= x)
    return c // 2

l = - 10 ** 18
r = 10 ** 18
while l + 1 < r:
    m = (l + r) // 2
    if cnt(m) < k:
        l = m
    else:
        r = m
print(r)
### BUGGY CODE ###

n = int(input())
s = input()

memo = [0]*1000
counter = 0

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if memo[int(s[i])*100+int(s[j])*10+int(s[k])] == 0:
                memo[int(s[i])*100+int(s[j])*10+int(s[k])] = 1
                counter += 1
print(counter)

### FIXED CODE ###


n = int(input())
s = input()

imemo = [0]*10
memo = [0]*100
counter = 0

for i in range(n):
    if imemo[int(s[i])] == 0:
        imemo[int(s[i])] = 1
    else:
        continue
        
    for j in range(i+1,n):
        if memo[int(s[i])*10+int(s[j])] == 0:
                memo[int(s[i])*10+int(s[j])] = 1
                counter += len(set(s[j+1:]))
print(counter)
### BUGGY CODE ###

N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

AB = sorted([[A[i] + B[i], i] for i in range(N)])[::-1]
indexes = sorted([AB[i][1] for i in range(0, N, 2)])[::-1]
ans = 0

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

### FIXED CODE ###

N = int(input())
AB, ans = [], 0
for _ in range(N):
    a, b = map(int, input().split())
    AB.append([a+b, a, b])    
AB = sorted(AB, reverse=True)

for i in range(N):
    ans += (-1)**(i%2) * AB[i][i%2 + 1]
print(ans)
### BUGGY CODE ###

N, M, *X = map(int, open(0).read().split())
A = []
for a in zip(*[iter(X)]*M):
  A.append(a)
log = set(range(1,M+1))
ans = N
while log:
  dic = {}
  for i in range(N):
    for j in range(M):
      if A[i][j] in log:
        dic[A[i][j]] = dic.get(A[i][j],0)+1
        break
  ans = min(ans,max(dic.values()))
  c = max(dic.keys(),key=lambda x:dic[x])
  log.remove(c)
print(ans)

### FIXED CODE ###

N, M, *X = map(int, open(0).read().split())
A = []
for a in zip(*[iter(X)]*M):
  A.append(a)
log = set(range(1,M+1))
ans = []
while log:
  dic = {}
  for i in range(N):
    for j in range(M):
      if A[i][j] in log:
        dic[A[i][j]] = dic.get(A[i][j],0)+1
        break
  ans.append(max(dic.values()))
  c = max(dic.keys(),key=lambda x:dic[x])
  log.remove(c)
print(min(ans))
### BUGGY CODE ###

N = int(input())
lis = []
indexes = []
cou = 1
ans = []
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append(999)
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[sum(indexes[:k])])
  print(*ans)
else:
  print(*lis)

### FIXED CODE ###

N = int(input())
lis = []
indexes = []
cou = 1
ans = []
c_p = 0
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append("zzzzzzzzzzzzzz")
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[c_p])
    c_p += indexes[k]
  print(*ans)
else:
  print(*lis)
### BUGGY CODE ###

from sys import stdin
input = stdin.readline

N = int(input())

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

[print(l.count(i+1)) for i in range(N)]

### FIXED CODE ###

from sys import stdin
input = stdin.readline

import collections

N = int(input())

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

c = collections.Counter(l)

[print(c[i+1]) for i in range(N)]
### BUGGY CODE ###

n,m=(int(i) for i in input().split(' '))
i=m//n
while True:
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1

### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
### BUGGY CODE ###

import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans*=a[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
 
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()

for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        sys.exit()
 
print(ans)
### BUGGY CODE ###

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

counters = {}
cevap_list = {}
sayilar = set(numbers)
for i in sayilar:
    count = numbers.count(i)
    counters[i] = count

sonuc = 0
for sayi in counters:
    count = counters[sayi]
    sonuc += int(count * (count - 1) / 2)


for i in range(n):
    print(sonuc-counters[numbers[i]]+1)

### FIXED CODE ###

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

counters = {}
cevap_list = {}
sayilar = set(numbers)
for i in numbers:
    if i in counters:
        counters[i] += 1
    else:
        counters[i] = 1

sonuc = 0
for sayi in counters:
    count = counters[sayi]
    sonuc += int(count * (count - 1) / 2)


for i in range(n):
    print(sonuc-counters[numbers[i]]+1)
### BUGGY CODE ###

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

prev = 0
point = 1
ans = []
for i in range(N):
    if i < K:
        point *= A[i]
    else:
        prev = point
        point *= A[i]
        point /= A[i-K]
        if prev < point:
            ans.append(True)
        else:
            ans.append(False)
for i in range(N-K):
    if ans[i]:
        print("Yes")
    else:
        print("No")
    


### FIXED CODE ###

from sys import stdin
readline = stdin.readline

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

prev = 0
point = 1
ans = []
for i in range(N):
    if i >= K:
        if A[i-K] < A[i]:
            ans.append("Yes")
        else:
            ans.append("No")
print(*ans, sep='\n')
### BUGGY CODE ###

n = int(input())
sl = list(input() for _ in range(n))


dict = {}
for s in sl:
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 1

# max_num = max(dict.values())
#
# dict = sorted(dict.items())
# for k, v in dict.items():
#     if v == max_num:
#         print(k)


# dict_s2 = sorted(dict.items(), key=lambda x:x[1], reverse=True)

ans = [k for k, v in dict.items() if v == max(dict.values())]
ans = sorted(ans)
ans_ = '\n'.join(ans)
print(ans_)


### FIXED CODE ###

from collections import Counter

n = int(input())
sl = list(input() for _ in range(n))

cnt = Counter(sl)
# print('cnt:', cnt)
maxNum = max(cnt.values())
# print('maxNum:', maxNum)

ans = []
for k, v in cnt.items():
    if v == maxNum:
        ans.append(k)

ans.sort()
print('\n'.join(ans))
### BUGGY CODE ###

import math
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            num = math.gcd(i, j)
            ans += math.gcd(num, l)
print(ans)

### FIXED CODE ###

import math
k = int(input())
ans = 0
list_gcd = [[0]*202 for _ in range(202)]

for i in range(1, 201):
    for j in range(i, 201):
        num = math.gcd(i, j)
        list_gcd[i][j] = num
        list_gcd[j][i] = num

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            num = list_gcd[i][j]
            ans += list_gcd[num][l]

print(ans)