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

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    temp = H[i:i+K]
    ans = min(ans, temp[-1] - temp[0])
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = sorted(H)
ans = 10**10
for i in range(N - K + 1):
    ans = min(ans, H[i+K-1] - H[i])
print(ans)
### BUGGY CODE ###

c = input()

m = map(int, raw_input().split())
conte = 0
while(True):
	entrou = False
	
	for i in range(c):
		if (not entrou and m[i]%2==0):
			entrou = True;
			conte += 1
			m[i] /= 2
		else:
			m[i] *= 3
	
	if(not entrou):
		print conte
		break
			

### FIXED CODE ###

n = int(raw_input())
m = map(int, raw_input().split())
total = 0
for i in m:
	while i % 2 == 0:
		total += 1
		i /= 2
print total
### BUGGY CODE ###

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

C = [a1^a2 for a1, a2 in zip(A, A[1:])] + [A[0]^A[-1]]
D = [b1^b2 for b1, b2 in zip(B, B[1:])] + [B[0]^B[-1]]

K = []
k = 0
while k < N:
  next_k = k
  is_first = True
  for i in range(N):
    if i > 0 and is_first and C[(k+i)%N] == D[0]:
      next_k = k + i
      is_first = False
    if C[(k+i)%N] != D[i]:
      if next_k == k:
        k = k + i + 1
      else:
        k = next_k
      break
  
  if i == N-1:
    K.append(k)
    if next_k == k:
      break
    else:
      k = next_k

for k in K:
  print(k, A[k]^B[0])

### FIXED CODE ###

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

C = [a1^a2 for a1, a2 in zip(A, A[1:])] + [A[0]^A[-1]]
C = C + C
D = [b1^b2 for b1, b2 in zip(B, B[1:])] + [B[0]^B[-1]]

K = []
k = 0
while k < N:
  next_k = k
  is_first = True
  for i in range(N):
    if is_first and i>0 and C[k+i]==D[0]:
      next_k = k + i
      is_first = False
    if C[k+i] != D[i]:
      if next_k == k:
        k = k + i + 1
      else:
        if D[k+i-next_k] == C[k+i]:
          k = next_k
        else:
          k = k + i + 1
      break
  
  if i == N-1:
    K.append(k)
    if next_k == k:
      break
    else:
      k = next_k
      if len(K) == 2:
        diff = K[1] - K[0]
        while K[-1] < N:
          K.append(K[-1]+diff)
      
        _ = K.pop()
        break

for k in K:
  print(k, A[k]^B[0])
### BUGGY CODE ###

"""
最小公倍数LCMを求めて、LCMを各Aで除した商を合計すればよい
"""
from math import gcd
mod = 10**9 +7
N = int(input())
A = list(map(int,input().split()))
l = A[0]
for i in range(1,N):
    l = (l*A[i])//gcd(l,A[i])

ans = 0
for a in A:
    ans += l//a
    ans %= mod
print(ans)

### FIXED CODE ###

from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()
### BUGGY CODE ###

from fractions import gcd
N=int(input())
A=list(map(int,input().split(' ')))
ans = 0
l = 1
mod = 10**9+7
def lcm(x,y):
    g = gcd(x,y)
    return x*y//g
for i in A:
    l = lcm(l,i)
for i in A:
    ans += l//i
    ans %=mod
print(ans)

### FIXED CODE ###

from fractions import gcd
N=int(input())
A=list(map(int,input().split(' ')))
ans = 0
l_1 = 1
l_2 = 1
mod = 10**9+7
def lcm(x,y):
    return x*y//gcd(x,y)
for i in A[:N//2]:
    l_1 = lcm(l_1,i)
for j in A[N//2:]:
    l_2 = lcm(l_2,j)
l = lcm(l_1,l_2)
out1 = sum([l_1//i for i in A[:N//2]])
out2 = sum([l_2//i for i in A[N//2:]])
out1 *= l//l_1
out2 *= l//l_2
print((out1+out2)%mod)
### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N, M = LI()
S = input()
T = input()

#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(N, M)
L = X
XS = ['X' for i in range(L+1)]
XT = ['X' for i in range(L+1)]
count = 0
LN = L/N
while True:
    XS[int(count*LN)] = S[count]
    count += 1
    if count > N-1:
        break

count = 0
LM = L/M
while True:
    XT[int(count*LM)] = T[count]
    count += 1
    if count > M-1:
        break

#  print(XS, XT)
for i in range(0, L+1):
    if XS[i] != 'X' and XT[i] != 'X':
        if XT[i] != XS[i]:
            print(-1)
            exit()
print(L)


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N, M = LI()
S = input()
T = input()

#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(N, M)
L = X
#  XS = ['X' for i in range(L+1)]
#  XT = ['X' for i in range(L+1)]
XS, XT = {}, {}
count = 0
LN = L/N
while True:
    XS[int(count*LN)] = S[count]
    count += 1
    if count > N-1:
        break

count = 0
LM = L/M
while True:
    XT[int(count*LM)] = T[count]
    count += 1
    if count > M-1:
        break

for key, value in XS.items():
    #  print(key, value)
    if key in XT:
        if value != XT[key]:
            print(-1)
            exit()
#  print(XS, XT)
#  for i in range(0, L+1):
#      if XS[i] != 'X' and XT[i] != 'X':
#          if XT[i] != XS[i]:
#              print(-1)
#              exit()
print(L)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

for n in range(N):
    print(max(A[:n] + A[n+1:]))

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
max_a = max(A)
count = A.count(max_a)

if count > 1:
    for n in range(N):
        print(max_a)
else:
    for n in range(N):
        if A[n] == max_a:
            print(max(A[:n] + A[n+1:]))
            continue
        print(max_a)
### BUGGY CODE ###

def inpl(): return [int(i) for i in input().split()]
import numpy as np
N, x = inpl()
a = np.array(inpl())
b = np.copy(a)
for i in range(N**2-N):
    if a[i%N]+x < a[(i+1)%N]:
        a[(i+1)%N] = a[i%N]+x
        b[(i+1)%N] = b[i%N]
print(np.max(a-b)+sum(b))


### FIXED CODE ###

def inpl(): return [int(i) for i in input().split()]
import numpy as np
N, x = inpl()
a = np.array(inpl())
b = np.copy(a)
ans = float('inf') 
for i in range(N):
    c = np.roll(a,i)
    b = np.minimum(b,c)
    ans = min(ans, sum(b)+i*x)
print(ans)
### BUGGY CODE ###

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  for f in make_divisors(i):
    if f in a:
      if f == i and a.count(f) > 1:
        b += 1
        break
      elif f != i:
        b += 1
        break
print(num - b)     


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0] * a[-1]
c = Counter(a)
for i in a:
    for j in range(i, a[-1]+1, i):
        dp[j-1] += 1
ans = 0
for i in a:
    if dp[i-1] == 1 and c[i]:
        ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
total = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        for k in range(j+1, N):
            c = L[k]
            if b + c > a and a + b > c and a + c > b:
                total += 1

print(total)


### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
total = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        # j以降の項で、初めてL[k] < a-bとなるkを二分探索する
        if L[-1] > a - b:  # 一番最後の項でもOKな場合(j+1以降全部OK)
            total += N - j - 1
        elif L[j+1] <= a - b:  # 一番最初の項からNGな場合
            continue
        else:
            head = j+1  # head はL[head] > a - bを満たす(OK側)
            tail = N-1  # tail はL[tail] <= a - bを満たす(NG側)
            while head+1 != tail:
                if L[(head + tail)//2] > a - b:  # 中間地点はOK側
                    head = (head + tail) // 2
                else:  # 中間地点はNG側
                    tail = (head + tail) // 2
            total += head - j

print(total)
### BUGGY CODE ###


S = input()
N = len(S) + 1
settingIndex = 0
result = [ -1 for i in range(N) ]

def countContinueChar(slice):
    startChar = slice[0]
    count = 0
    for c in slice:
        if c != startChar:
            break
        count += 1
    return count

def getValueOfIndex(slice, current, prev = ''):
    if slice[0] == '<':
        if prev == '>':
            return 0
        else:
            return current + 1
    else:
        if prev == '<':
            v = countContinueChar(slice)
            if v < current + 1:
                return current + 1
            else:
                return v
        else:
            return countContinueChar(slice)

current = -1
prev = ''
sum = 0
for i in range(N):
    if i == N-1:
        if S[-1] == '<':
            result[i] = current + 1
            sum += current + 1
        else:
            result[i] = 0
        break
    if i > 0:
        prev = S[i - 1]
    current = getValueOfIndex(S[i:], current, prev)
    result[i] = current
    sum += current

print(sum)

### FIXED CODE ###


S = input()
N = len(S) + 1
result = [ -1 for i in range(N) ]

def countContinueChar(index):
    startChar = S[index]
    count = 0
    for i in range(index, N-1):
        if S[i] != startChar:
            break
        count += 1
    return count

def getValueOfIndex(index, current, prev = '', preprev = ''):
    if S[index] == '<':
        if prev == '>':
            return 0
        else:
            return current + 1
    else:
        if prev == '<':
            v = countContinueChar(index)
            if v < current + 1:
                return current + 1
            else:
                return v
        else:
            if preprev == '<' and prev == '>':
                return countContinueChar(index)
            else:
                if prev != '>':
                    return countContinueChar(index)
                else:
                    return current - 1

current = -1
prev = ''
preprev = ''
sum = 0
for i in range(N):
    if i == N-1:
        if S[-1] == '<':
            result[i] = current + 1
            sum += current + 1
        #else:
            #result[i] = 0
        break
    if i > 0:
        prev = S[i - 1]
    if i > 1:
        preprev = S[i - 2]
    current = getValueOfIndex(i, current, prev, preprev)
    #result[i] = current
    sum += current

#print(result)
print(sum)
### BUGGY CODE ###

#AGC030 B - Powers of two
beki=[]
for i in range(1,32):
    beki.append(2**i)#bekiは２のべき乗の配列
def tasitekesu(data,n):#dataの中で足したらnになるやつを消し、消した結果とペア数を報告する
    result=[]
    kosu=0
    for i in range(len(data)):
        if i in result:
            continue
        for j in range(i):
            if j in result:
                continue
            if data[i]+data[j]==n:
                result.append(i)
                result.append(j)
                kosu=kosu+1
                break
    result.sort(reverse=True)
    for i in result:
        del data[i]
    return [data,kosu]

N=int(input())
A=input().split()
ans=0
for i in range(N):
    A[i]=int(A[i])
for i in (reversed(beki)):
    R=tasitekesu(A,i)
    A=R[0]
    ans=ans+R[1]
print(ans)

### FIXED CODE ###

#AGC030 B - Powers of two
import collections
import math
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
cnter=collections.Counter(A)
ans=0
for a in A:
    inv=2**(int(math.log2(a))+1)
    if cnter[a]==0:
        continue
    if inv==2*a and cnter[inv-a]<=1:
      	continue
    if cnter[inv-a]>0:
        cnter[inv-a]=cnter[inv-a]-1
        cnter[a]=cnter[a]-1
        ans=ans+1
print(ans)
### BUGGY CODE ###

n=int(input())
import math
from functools import reduce
def gcd_list(*numbers):#引数はリスト
    return reduce(math.gcd, numbers)
ans=n**2
for i in range(2,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd_list(i,j,k)
print(ans)

### FIXED CODE ###

n=int(input())
import math
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        ij=math.gcd(i,j)
        if ij==1:
            ans+=n
        else:
            for k in range(1,n+1):
                ans+=math.gcd(ij,k)
print(ans)
### BUGGY CODE ###

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque()
now.append([x1-1,y1-1])
def bfs(d):
    global h,w,k,dp,now,x2,y2
    l=len(now)
    if l==0:
        return
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp[x][y+j]=d
                now.append([x,y+j])
            if dp[x][y+j]==-1:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp[x][y-j]=d
                now.append([x,y-j])
            if dp[x][y-j]==-1:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp[x+j][y]=d
                now.append([x+j,y])
            if dp[x+j][y]==-1:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp[x-j][y]=d
                now.append([x-j,y])
            if dp[x-j][y]==-1:
                break
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)

### FIXED CODE ###

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque()
now.append([x1-1,y1-1])
dp[x1-1][y1-1]=0
#kの更新が遅い
def bfs(d):
    global h,w,k,dp,now,x2,y2
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub.append([x,y+j,d])
                #dp[x][y+j]=d
                cand.add((x,y+j))
                #now.append([x,y+j])
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub.append([x,y-j,d])
                #dp[x][y-j]=d
                cand.add((x,y-j))
                #now.append([x,y-j])
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub.append([x+j,y,d])
                #dp[x+j][y]=d
                cand.add((x+j,y))
                #now.append([x+j,y])
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub.append([x-j,y,d])
                #dp[x-j][y]=d
                cand.add((x-j,y))
                #now.append([x-j,y])
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now.append(i)
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

sys.setrecursionlimit(100000)

class Solver(object):
    def __init__(self,N:int,W:int,values:list,weights:list):
        self.N = N   ## MAX number of item
        self.values = values  ## list of item value
        self.weights = weights ## list of item weight
        self.dp = [[None]*(W+1) for _ in range(N+1)] ## memorize the result

    ## i番目以降から重さがj以下になるように選ぶ時に価値が最大になるようにする。
    def solve(self,i:int,j:int) -> int:
        if self.dp[i][j] != None:
            return self.dp[i][j]
        if i == self.N:
            res = 0
        elif j < self.weights[i]:
            res = self.solve(i+1,j)
        else:
            res = max(self.solve(i+1,j),self.solve(i+1,j-self.weights[i])+self.values[i])
        self.dp[i][j] = res
        return res

def main():
    N,W = [int(i) for i in input().split()]
    items = [[int(i) for i in input().split()] for _ in range(N)]
    weights = [item[0] for item in items]
    values = [item[1] for item in items]
    solver = Solver(N,W,values,weights)
    ans = solver.solve(0,W)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

class Solver():
    def __init__(self, N, W, items):
        self.N = N
        self.W = W
        self.items = items

    def solve(self):
        dp = [[0 for _ in range(self.W+1)] for _ in range(self.N+1)]
        for i in range(self.N):
            for w in range(self.W+1):
                if w - self.items[i][0] >= 0:
                    dp[i+1][w] = max(dp[i+1][w], dp[i][w - self.items[i][0]] + self.items[i][1])

                dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])
        return dp[self.N][self.W]


def main():
    N, W = [int(i) for i in input().split()]
    items = [[int(i) for i in input().split()] for _ in range(N)]
    solver = Solver(N, W, items)
    print(solver.solve())


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

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])


### FIXED CODE ###

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])
### BUGGY CODE ###

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

ans = []
for i in range(1,N+1):
    # ans.append(A.index(i)+1)
    print(A.index(i)+1,end=' ')


### FIXED CODE ###

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

ans = [0]*N
# ans = [A.index(i)+1 for i in range(1,N+1)]
for i in range(N):
    ans[A[i]-1] = i+1

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

import sys
sys.setrecursionlimit(100000)
def dfs(A,N,M,i,j,visited):
    visited[i][j]=1
    rn=[-1,-1,-1,0,0,1,1,1]
    cn=[-1,0,1,-1,1,-1,0,1]
    for s in range(8):
        r=i+rn[s]
        c=j+cn[s]
        if r>=0 and r<N and c>=0 and c<M and not visited[r][c] and A[r][c]:
            dfs(A,N,M,r,c,visited)

from collections import defaultdict
n,m=map(int,input().split())
A=[[0 for i in range(n)] for i in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    A[a-1][b-1]=1
    A[b-1][a-1]=1
count=0
visited=[[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        if A[i][j] and not visited[i][j]:
            count+=1
            dfs(A,n,n,i,j,visited)
        
print(count)


### FIXED CODE ###

from collections import deque
n,m=map(int,input().split())
road=[[] for i in range(n)]
flag=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
count=0
for i in range(n):
    if flag[i]!=0:
        continue
    count+=1
    q=deque([i])
    while q:
        p=q.popleft()
        flag[p]=1
        for z in road[p]:
            if flag[z]==0:
                q.append(z)
print(count-1)
### BUGGY CODE ###

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

D = [0]*(max(A)+1)
for i in A:
    # ダブってる値は2以上に
    D[i] += 1

U = []
for i in range(max(A)+1):
    # ダブってる値は2以上に
    if D[i] == 1:
        U.append(i)

A = list(set(A))

T = [0]*(max(A)+1)
for i in A:
    # iの2以上の倍数の値は1に
    for j in range(2*i, max(A)+1, i):
        T[j] = 1

# Tが0かつDが1の数を数える
ans = 0
for i in U:
    if T[i] == 0:
        ans += 1

print(ans)

### FIXED CODE ###

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

cnt = [0] * ((10 ** 6) + 1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10 ** 6) + 1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10 ** 6) + 1)

a = list(set(a))

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

ans = 0
        
for elem in unique:
    if cnt[elem] == 0:
        ans += 1

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

n = int(input())
top = sorted(list(map(int, input().split())))
mid = sorted(list(map(int, input().split())))
bot = sorted(list(map(int, input().split())))

midc = [0]*n
for i in range(n):
    cnt = 0
    for j in range(n):
        if mid[i]>top[j]: cnt += 1
    midc[i] = cnt

botc = [0]*n
for i in range(n):
    cnt = 0
    for j in range(n):
        if bot[i]>mid[j]: cnt += 1
    botc[i] = cnt

ans = 0
for i in range(n):
    ans += sum(midc[:botc[i]])
print(ans)

### FIXED CODE ###

def lowerBound(arr, n):
    low, high = -1, len(arr)
    while high-low>1:
        mid = (low+high)//2
        if arr[mid]>=n: high = mid
        else: low = mid
    return high

def upperBound(arr, n):
    low, high = -1, len(arr)
    while high-low>1:
        mid = (low+high)//2
        if arr[mid]>n: high = mid
        else: low = mid
    return low+1

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ans = 0
for i in b:
    cnt_a = lowerBound(a, i)
    cnt_b = n - upperBound(c,i)
    ans += cnt_a * cnt_b
print(ans)
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path
N, X, Y = map(int, input().split())

G = np.full((N, N), np.inf, dtype=float)
for i in range(N - 1):
    G[i][i + 1] = 1
    G[i + 1][i] = 1
G[X - 1][Y - 1] = 1
G[Y - 1][X - 1] = 1

G = shortest_path(G)
for cnt in range(1, N):
    print(np.sum(G == cnt) // 2)


### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] * N
for i in range(N):
    for j in range(i+1, N):
        ans[ min(j - i, abs(X - i) + 1 + abs(Y - j))] += 1
for i in range(1, N):
    print(ans[i])
### BUGGY CODE ###

import copy
import itertools
N = int(input())
A_list = list(map(int, input().split()))

divided = []
for i in range(N):
    divided.append(A_list.count(i + 1))

for k in range(1, N + 1):
    tmp_divided = copy.deepcopy(divided)
    tmp_divided[A_list[k - 1] - 1] -= 1

    ans = 0
    for j in tmp_divided:
        ans += len(list(itertools.combinations(range(j), 2)))

    print(ans)

### FIXED CODE ###

import collections
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

counts = collections.Counter(A_list)
ans = 0
for _, v in counts.items():
    # ans += len(list(itertools.combinations(range(v), 2)))
    if v > 1:
        ans += combinations_count(v, 2)

for k in range(1, N + 1):
    n = counts[A_list[k - 1]]
    ans_k = ans
    if n > 1:
        ans_k -= n - 1

    print(int(ans_k))