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

N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
for h in range(N):
    H_dict.append([h+1, H[h]])
cnt = 0
for h in range(N):
    tmp_h = H_dict[h][1]
    edge_h = []
    cnt2 = 0
    for ab in AB:
        if h+1 in ab:
            left = [i for i in ab if i != h + 1]
            z = left[0]
            if H_dict[z-1][1] >= tmp_h:
                cnt2 += 1
    if cnt2 == 0:
        cnt += 1
print(cnt)

### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))
### BUGGY CODE ###

K = int(input())
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)


def function(K):
    list = []
    sum = 0
    for i in range(1,K+1):
        for j in range(1, K+1):
            list.append(gcd(i,j))
    return list

list = function(K)
sum = 0
new_list = []
for i in range(1,K+1):
    new_list+= [gcd(i,elm) for elm in list]


for i in new_list:
    sum += int(i)


print(sum)


### FIXED CODE ###

K = int(input())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
sum=0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            sum += gcd(gcd(i,j),k)

print(sum)
# print(gcd(2,6))
### BUGGY CODE ###

import numpy as np
from itertools import combinations_with_replacement

def gcd_memo(memo, a, b):
    if memo[a][b] > 0:
        return memo[a][b]
    res = np.gcd(a, b)
    memo[a][b] = res
    memo[b][a] = res
    return res

def main():
    k = int(input())
    res = 0
    memo = np.zeros((k+1, k+1), int)
    for c in combinations_with_replacement(range(1,k+1), 3):
        ab = gcd_memo(memo, c[0], c[1])
        abc = gcd_memo(memo, ab, c[2])
        l = len(set(c))
        mul = 1
        if l == 2:
            mul = 3
        elif l == 3:
            mul = 6
        res += abc * mul
    print(res)


if __name__ == '__main__':
    main()



### FIXED CODE ###

import numpy as np
from itertools import combinations

def main():
    k = int(input())
    res = 0
    memo = np.zeros((k+1, k+1), int)
    for i in range(1, k+1):
        for j in range(i, k+1):
            tmp = np.gcd(i,j)
            memo[i][j] = tmp
            memo[j][i] = tmp

    for i in range(1, k+1):
        res += i 

    for c in combinations(range(1,k+1),2):
        ab = memo[c[0], c[1]]
        res += ab * 6

    for c in combinations(range(1,k+1), 3):
        ab = memo[c[0], c[1]]
        abc = memo[ab, c[2]]
        res += abc * 6
    print(res)


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

s = list(input())
ln = len(s)

abc = ["A", "B", "C"]
bca = ["B", "C", "A"]

ans = 0
for i in range(ln - 2):
    if s[i:i+3] == abc:
        s[i:i+3] = bca
        ans += 1
        j = i - 1
        while j >= 0 and s[j:j+3] == abc:
            s[j:j+3] = bca
            ans += 1
            j -= 1

print(ans)


### FIXED CODE ###

s = input()

s = s.replace("BC", "D")

ans = 0
a_cnt = 0
for e in s:
    if e == "A":
        a_cnt += 1

    elif e == "D":
        ans += a_cnt

    else:
        a_cnt = 0

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

from collections import deque
_in = list(open(0))
h, w = list(map(int, _in[0].split()))

s = deque()
for i, y in enumerate(_in[1:]):
    for j, x in enumerate(y):
        if x == '#':
            s.append((i,j,0))

a = [[False]*w for _ in range(h)]

while s:
    i,j,k = s.popleft()
    if a[i][j]:
        continue
    
    a[i][j] = True
    ans = k
    
    if i>0:
        s.append((i-1, j, k+1))
    if i<h-1:
        s.append((i+1, j, k+1))
    if j>0:
        s.append((i, j-1, k+1))
    if j<w-1:
        s.append((i, j+1, k+1))
        
print(ans)

### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    m = []
    m.append([True] * (W + 2))
    for _ in range(H):
        m.append([True] + [c == '#' for c in input()] + [True])
    m.append([True] * (W + 2))
    queue = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if m[i][j]:
                queue.append((i, j))
    ans = -1
    while queue:
        ans += 1
        tmp = []
        for x, y in queue:
            if not m[x - 1][y]:
                m[x - 1][y] = True
                tmp.append((x - 1, y))
            if not m[x + 1][y]:
                m[x + 1][y] = True
                tmp.append((x + 1, y))
            if not m[x][y - 1]:
                m[x][y - 1] = True
                tmp.append((x, y - 1))
            if not m[x][y + 1]:
                m[x][y + 1] = True
                tmp.append((x, y + 1))
        queue = tmp
    print(ans)

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

import sys
input = sys.stdin.readline
from collections import deque
import copy

N, M, K = map(int, input().split())
friend = [deque() for _ in range(N)]
status = [-1]*N
numList = [0]*N

for _ in range(M):
    a, b = map(int, input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)

def DFS(graph, v, num):
    global numList
    cnt = 1
    stack = [v]
    status[v] = num
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if status[w] == -1:
                status[w] = num
                cnt += 1
                stack.append(w) 
        else:
            stack.pop() 
    numList[num] = cnt

cnt = 0
for i in range(N):
    if status[i] == -1:
        DFS(copy.deepcopy(friend), i, cnt)
        cnt += 1

ans = [0]*N
for i in range(N):
    ans[i] = numList[status[i]] - 1 - len(friend[i])
for i in range(K):
    a, b = map(int, input().split())
    if status[a-1] == status[b-1]:
        ans[a-1] -= 1
        ans[b-1] -= 1
print(" ".join(map(str, ans)))


### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque
import copy

N, M, K = map(int, input().split())
friend = [deque() for _ in range(N)]
status = [-1]*N
numList = [0]*N
ans = [0]*N

for _ in range(M):
    a, b = map(int, input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
    ans[a-1] -= 1
    ans[b-1] -= 1

def DFS(graph, v, num):
    cnt = 0
    stack = [v]
    status[v] = num
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if status[w] == -1:
                status[w] = num
                cnt += 1
                stack.append(w) 
        else:
            stack.pop() 
    numList[num] = cnt

cnt = 0
for i in range(N):
    if status[i] == -1:
        DFS(friend, i, cnt)
        cnt += 1

for i in range(N):
    ans[i] += numList[status[i]]

for i in range(K):
    a, b = map(int, input().split())
    if status[a-1] == status[b-1]:
        ans[a-1] -= 1
        ans[b-1] -= 1

print(" ".join(map(str, ans)))
### BUGGY CODE ###

import sys,os,io
#input = sys.stdin.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
mod = 10**9+7
def comb_mod(n,r):
  ans = 1
  for i in range(r):
    ans *= (n-i)*pow(i+1,mod-2,mod)
    ans %= mod
  return ans

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        part_num[v] += part_num[u]
        ans[v] *= comb_mod(part_num[v]-1,part_num[u])*ans[u]
        ans[v] %= mod
    if marker==0:
      stack.pop()
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  while stack:
    v = stack.pop()
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u]=v
      p_value[u] = ans[v]*pow(ans[u]*comb_mod(N-1, part_num[u]),mod-2,mod)%mod
      ans[u] *= comb_mod(N-1,part_num[u]-1)*p_value[u]
      ans[u] %= mod
      stack.append(u)
    ans[v] %= mod
  return

ans = [1]*N
part_num = [1]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')

### FIXED CODE ###

import sys,os,io
input = sys.stdin.readline
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
mod = 10**9+7

def fact(N):
  ans = [1]*(N+1)
  for i in range(1,N+1):
    ans[i] = ans[i-1]*i%mod
  return ans

def combs_mod(n,k):
  #nC0からnCkまで
  inv = [1]*(k+1)
  for i in range(1,k+1):
    inv[i] = pow(i,mod-2,mod)
  ans = [1]*(k+1)
  for i in range(1,k+1):
    ans[i] = ans[i-1]*(n+1-i)*inv[i]%mod
  return ans

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  fac = fact(N)
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u] = v
        stack.append(u)
      else: #子から吸い上げる
        part_num[v] += part_num[u]
        ans[v] *= pow(fac[part_num[u]],mod-2,mod)*ans[u]%mod
        ans[v] %= mod
    if marker==0:
      stack.pop()
      ans[v] *= fac[part_num[v]-1]
      ans[v] %= mod
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  combs = combs_mod(N-1,N-1)
  while stack:
    v = stack.pop()
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u]=v
      p_value[u] = ans[v]*pow(ans[u]*combs[part_num[u]],mod-2,mod)%mod
      ans[u] *= combs[part_num[u]-1]*p_value[u]
      ans[u] %= mod
      stack.append(u)
  return

ans = [1]*N
part_num = [1]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')
### BUGGY CODE ###

h,w = map(int, input().split( ))
a = []
b = []
for i in range(h):
    ai = list(map(int, input().split( )))
    a.append(ai)
for i in range(h):
    bi = list(map(int, input().split( )))
    for j in range(w):
        a[i][j]-=bi[j]
        a[i][j] = abs(a[i][j])
###差のmaxまでをlistで確保する代わりに可能な値をsetで保持
dp = [[set() for j in range(w)] for i in range(h)]
dp[0][0].add(a[0][0])

for j in range(1,w):
    for k in dp[0][j-1]:
        dp[0][j].add(abs(k-a[0][j]))
        dp[0][j].add(k+a[0][j])

for i in range(1,h):
    for j in range(w):
        for k in dp[i-1][j]:
            dp[i][j].add(abs(k-a[i][j]))
            dp[i][j].add(k+a[i][j])
        if j:
            for k in dp[i][j-1]:
                dp[i][j].add(abs(k-a[i][j]))
                dp[i][j].add(k+a[i][j])
#print(dp)
ans = 10**10
for k in dp[h-1][w-1]:
    ans = min(ans,k)
        
print(ans)





### FIXED CODE ###


h,w = map(int, input().split( ))
a = []
for i in range(h):
    ai = list(map(int, input().split( )))
    a.append(ai)
for i in range(h):
    bi = list(map(int, input().split( )))
    for j in range(w):
        a[i][j]-=bi[j]
        a[i][j] = abs(a[i][j])
###差のmaxまでをlistで確保する代わりに可能な値をsetで保持
###値が小さいのでsetからbitで保持に変更
dp = [[0 for j in range(w)] for i in range(h)]
a2 = [a[i][j] for i in range(h) for j in range(w)]
mxa = max(a2)
###中心を取る
###間違えやすいし最大値決め打ちか
tmp=1<<mxa*(h+w)+10

dp[0][0]|=tmp<<a[0][0]
dp[0][0]|=tmp>>a[0][0]

for j in range(1,w):
    dp[0][j]=dp[0][j-1]<<a[0][j]
    dp[0][j]|=dp[0][j-1]>>a[0][j]

for i in range(1,h):
    for j in range(w):###ループ一つ抜けてるわw
        dp[i][j]=dp[i-1][j]<<a[i][j]
        dp[i][j]|=dp[i-1][j]>>a[i][j]
        if j:
            dp[i][j]|=dp[i][j-1]<<a[i][j]
            dp[i][j]|=dp[i][j-1]>>a[i][j]

tmp1 = dp[h-1][w-1]

tmp1>>=mxa*(h+w)+10

###mxa=0でrange(0)になる式だと答えが出ない
for k in range(mxa*(h+w)+10):
    if tmp1&1:
        print(k)
        exit()
    tmp1>>=1
### BUGGY CODE ###

# C - 高橋君とカード / Tak and Cards

#import numpy as np
import math

N, A = map(int, input().split())
#x = np.array(list(map(int, input().split())))
x = list(map(int, input().split()))

# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数
def partial_sum(a,A):
    n = len(a)
    dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数
    dp[0][0] = 1
    
    for i in range(n):
        for j in range(A+1):
            if j >= a[i]:
                dp[i+1][j] = dp[i][j-a[i]] + dp[i][j]
            else:
                dp[i+1][j] = dp[i][j]
                
    return dp[n][A]

#x_diff = x - np.array(A) # ここから合計0になるように取る。負の数列についてpartial_sumが動かないことに注意
x_diff = [a - A for a in x]
x_diff_negative = [-a for a in x_diff if a < 0]
x_diff_positive = [a for a in x_diff if a > 0]

ans = 0
for i in range(1, sum(x)):
    ans += partial_sum(x_diff_negative,i) * partial_sum(x_diff_positive,i) 

# 0の選び方
n_pattern_0 = 0
#n_0 = np.count_nonzero(x_diff == 0)
n_0 = x_diff.count(0)
if n_0 > 0:
    for i in range(1, n_0+1):
        n_pattern_0 += math.factorial(n_0) // (math.factorial(n_0-i) * math.factorial(i))

# ここまで数えた全てのパターンそれぞれについて、x_diff中の0をいくつか含めた別パターンがある
# 0単体で選ぶ方法もある
ans += (ans+1) * n_pattern_0
    
print(ans)

### FIXED CODE ###

# C - 高橋君とカード / Tak and Cards

#import numpy as np
import math

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

# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数
def partial_sum(a,A):
    n = len(a)
    dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数
    dp[0][0] = 1
    
    for i in range(n):
        for j in range(A+1):
            if j >= a[i]:
                dp[i+1][j] = dp[i][j-a[i]] + dp[i][j]
            else:
                dp[i+1][j] = dp[i][j]
                
    return dp[n][A]

x_diff = [a - A for a in x] # ここから合計0になるように取る。負の数列についてpartial_sumが動かないことに注意
x_diff_negative = [-a for a in x_diff if a < 0]
x_diff_positive = [a for a in x_diff if a > 0]

ans = 0
for i in range(1, min(sum(x_diff_negative), sum(x_diff_positive)) + 1):
    ans += partial_sum(x_diff_negative,i) * partial_sum(x_diff_positive,i) 

# 0の選び方
n_pattern_0 = 0
n_0 = x_diff.count(0)
if n_0 > 0:
    for i in range(1, n_0+1):
        n_pattern_0 += math.factorial(n_0) // (math.factorial(n_0-i) * math.factorial(i))

# ここまで数えた全てのパターンそれぞれについて、x_diff中の0をいくつか含めた別パターンがある
# 0単体で選ぶ方法もある
ans += (ans+1) * n_pattern_0
    
print(ans)
### BUGGY CODE ###

import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
result=-10000000000
for i in range(1,n+1):
    m=find(i,i,n,c[p[i-1]-1],0,0,0)
    if m[2]>=k:
        m=find(i,i,k,c[p[i-1]-1],0,0,0)
        if m[0]>result:
            result=m[0]
    elif m[1]<=0:
        if m[0]>result:
            result=m[0]
    else:
        w=k%m[2]
        if w==0:
            w=m[2]
        spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
        if m[1]+spe>m[0] and m[1]*(k-w)//m[2]+spe>result:
            result=m[1]*(k-w)//m[2]+spe
        elif m[1]+spe<=m[0] and m[1]*((k-w)//m[2]-1)+m[0]>result:
            result=m[1]*((k-w)//m[2]-1)+m[0]
print(result)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
now=-100000000000
for i in range(1,n+1):
    retu=[]
    sum1=0
    sum2=0
    sum3=0
    max1=-1000000000000
    max2=-1000000000000
    flag=0
    x=i
    while(flag==0):
        x=p[x-1]
        sum1+=c[x-1]
        retu.append(c[x-1])
        if x==i:
            flag=1
    if len(retu)>=k: #操作回数が周期未満
        for j in range(k):
            sum2+=retu[j]
            if sum2>max1:
                max1=sum2
        ans=max1
    elif sum1<=0: #周期和が負
        for j in range(len(retu)):
            sum3+=retu[j]
            if sum3>max2:
                max2=sum3
        ans=max2
    else:
        w=k%len(retu)
        
        if w==0:
            w=len(retu)
        for j in range(w):
            sum2+=retu[j]
            if sum2>max1:
                max1=sum2
        for j in range(len(retu)):
            sum3+=retu[j]
            if sum3>max2:
                max2=sum3
        if max1+sum1>max2:
            ans=sum1*(k-w)//len(retu)+max1
        else:
            ans=sum1*((k-w)//len(retu)-1)+max2
    now=max(now,ans)
print(now)
### BUGGY CODE ###

import numpy as np
N,K,Q = map(int, input().split(" "))

List = np.array([K]*N)

for i in range(Q):
  diff = np.array([1]*N)
  n = int(input())
  diff[n-1] = 0
  List-=diff

for i in range(N):
  if List[i]>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

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

List = [K-Q]*N

for i in range(Q):
  n = int(input())
  List[n-1]+=1

for i in range(N):
  if List[i]>0:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]

ma = 90*90
DP = [[[0]*(2*ma) for j in range(w+1)] for i in range(h+1)]
mid = ma
DP[0][0][mid] = 1

for i in range(h):
    for j in range(w):
        k = abs(a[i][j]-b[i][j])
        for l in range(2*ma):
            if not DP[i][j][l]:
                continue
            if 0<=l-k:
                DP[i+1][j][l-k] = 1
                DP[i][j+1][l-k] = 1
            if l+k<2*ma:
                DP[i+1][j][l+k] = 1
                DP[i][j+1][l+k] = 1

ans = float("Inf")
for i, j in [(h,w-1),(h-1,w)]:
    for k in range(2*ma):
        if DP[i][j][k]:
            ans = min(ans, abs(mid-k))

print(ans)

### FIXED CODE ###

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
ma = 80*2*80
DP = [[[0]*ma for i in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        k = abs(a[i][j]-b[i][j])
        if i==0 and j==0:
            DP[i][j][k] = 1
            continue
        elif i == 0:
            up = min((i+j+1)*80+1, ma-k)
            for l in range(up):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k]
        elif j == 0:
            for l in range(up):
                DP[i][j][l] = DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
        else:
            for l in range(up):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k] | DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
for i in range(ma):
    if DP[-1][-1][i]:
        print(i)
        exit()
### BUGGY CODE ###

k,s = map(int, input().split())
flg = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                flg += 1
print(flg)         

### FIXED CODE ###

k,s = map(int, input().split())
flg = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z>= 0 and z <= k:
                flg += 1
print(flg)
### BUGGY CODE ###

N=int(input())
S=[]
for i in range(N):
    a = input()
    if not a in S:
        S.append(a)
print(len(S))

### FIXED CODE ###

N=int(input())
S=[]
for i in range(N):
    S.append(input())
print(len(set(S)))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(m):
  a[a.index(max(a))] //= 2
print(sum(a))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import heapq as hp

n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
hp.heapify(a)
tmp = 0

for i in range(m):
  tmp = hp.heappop(a)
  hp.heappush(a,(-tmp//2)*(-1))
#
print(-sum(a))
### BUGGY CODE ###

from math import factorial

N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

results = {}

for n in counts:
  results[n] = 0
  for m in counts:
    count = counts[m]
    if m == n:
      count -= 1
    if count > 1:
      results[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

for n in l:
  print(results[n])

### FIXED CODE ###

from math import factorial
N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

comb = {}

for n in counts:
  comb[n] = 0
  count = counts[n]
  if count > 1:
    comb[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

total = sum([comb[n] for n in comb])

for n in l:
  count = counts[n]
  result = total - comb[n]
  if count - 1 > 1:
    result += comb[n] * (count - 2) // count
  print(result)
### BUGGY CODE ###

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

class RangeUpdate:
    def __init__(self, n):
        self.p = Bit(n + 1)
        self.q = Bit(n + 1)
    def add(self, s, t, x):
        t += 1
        self.p.add(s, -x * s)
        self.p.add(t, x * t)
        self.q.add(s, x)
        self.q.add(t, -x)
    def sum(self, s, t):
        t += 1
        return self.p.sum(t) + self.q.sum(t) * t - \
               self.p.sum(s) - self.q.sum(s) * s

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

ys = []
for _ in range(N):
    X, H = map(int, input().split())
    ys.append((X, 0, -(-H//A)))
    ys.append((X+2*D, 1, -(-H//A)))

ys.sort()
d1 = dict()
d2 = dict()
ls = []
c = 0
hs = [0]
for i, (y, f, h) in enumerate(ys):
    if f:
        d1[y-2*D] = c
    else:
        c += 1
        d2[y] = c
        ls.append(y)
        hs.append(h)

lls = []
for i in range(N):
    lls.append(d1[ls[i]]-d2[ls[i]]+1)

X = Bit(N+1)

r = 0
for i in range(N):
    n = lls[i]
    x = hs[i+1] + X.sum(i+1)
#    print(x,n)
    if x <=0:
        continue
    r += x
    X.add(i+1, -x)
    X.add(i+1+n, x)
print(r)


### FIXED CODE ###

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
N, D, A = map(int, input().split())

ys = []
for _ in range(N):
    X, H = map(int, input().split())
    ys.append((2*X, -(-H//A)))
    ys.append((2*X+4*D+1, -(-H//A)))

ys = sorted(ys, key=lambda x : x[0])
d1 = dict()
d2 = dict()
ls = []
c = 0
hs = [0]
for i, (y, h) in enumerate(ys):
    if y%2:
        d1[y-1-4*D] = c
    else:
        c += 1
        d2[y] = c
        ls.append(y)
        hs.append(h)

lls = []
for i in range(N):
    lls.append(d1[ls[i]]-d2[ls[i]]+1)

X = Bit(N+1)

r = 0
for i in range(N):
    n = lls[i]
    x = hs[i+1] + X.sum(i+1)
    if x <=0:
        continue
    r += x
    X.add(i+1, -x)
    X.add(i+1+n, x)
print(r)
### BUGGY CODE ###

def main():

    N = int(input())
    S = []
    cnt = 0
    for _ in range(N):
        s = input()
        S.append(sorted(s))
    for i in range(N - 1):
        for j in range(i + 1, N):
            if S[i] == S[j]:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():

    N = int(input())
    S = {}
    cnt = 0
    for _ in range(N):
        s = list(input())
        s.sort()
        s = "".join(s)
        if s not in S:
            S[s] = 0
        else:
            S[s] += 1
            cnt += S[s]
    print(cnt)

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

N = int(input())
A = [int(i) for i in input().split()]

dict_A = {A[i]:(i+1) for i in range(N)}
ans=''
for i in range(1,N):
  ans = ans + str(dict_A[i])+' '
ans = ans + str(dict_A[N])
print(ans)

### FIXED CODE ###

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