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

import numpy as np
import bisect

def position_in_neg(x):
    # y=n_pos-np.searchsorted(A_pos,x//A_neg,side='right')
    res=0
    for y in x//A_neg:
        res+=n_pos-bisect.bisect_right(A_pos, y)
    return res

def position_in_pos(x):
    # z=np.searchsorted(A_pos,-(-x//A_pos),side='left')
    # w=np.searchsorted(A_neg2,-(-x//A_neg2),side='left')
    res=0
    for y in -(-x//A_pos):
        res+=bisect.bisect_left(A_pos, y)
    for y in -(-x//A_neg2):
        res+=bisect.bisect_left(A_neg2, y)
    tmp=len(A_pos[A_pos**2<x])+len(A_neg2[A_neg2**2<x])
    return (res-tmp)//2

def position(x):
    if x<0:
        return position_in_neg(x)
    elif x==0:
        return n_pos*n_neg
    else:
        return position_in_pos(x)+n_pos*n_neg+(n_pos+n_neg)*n_zero+n_zero*(n_zero-1)//2


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

    A=np.array(A)
    global A_pos,A_neg,A_neg2,n_pos,n_neg,n_zero
    A_pos=np.sort(A[A>0])
    A_neg=np.sort(A[A<0])
    A_neg2=-A_neg[::-1]
    n_pos=len(A_pos)
    n_neg=len(A_neg)
    n_zero=N-n_pos-n_neg


    l=-pow(10,18)
    r=pow(10,18)
    while(r-l>1):
        mid=(l+r)//2
        if position(mid)<K:
            l=mid
        else:
            r=mid
    print(l)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))

A=np.array(A)

A_pos=np.sort(A[A>0])
A_neg=np.sort(A[A<0])
A_neg2=-A_neg[::-1]
n_pos=len(A_pos)
n_neg=len(A_neg)
n_zero=N-n_pos-n_neg

def position_in_neg(x):
    y=n_pos-np.searchsorted(A_pos,x//A_neg,side='right')
    return y.sum()

def position_in_pos(x):
    z=np.searchsorted(A_pos,-(-x//A_pos),side='left')
    w=np.searchsorted(A_neg2,-(-x//A_neg2),side='left')
    tmp=len(A_pos[A_pos**2<x])+len(A_neg2[A_neg2**2<x])
    return (z.sum()+w.sum()-tmp)//2

def position(x):
    if x<0:
        return position_in_neg(x)
    elif x==0:
        return n_pos*n_neg
    else:
        return position_in_pos(x)+n_pos*n_neg+(n_pos+n_neg)*n_zero+n_zero*(n_zero-1)//2

l=-pow(10,18)
r=pow(10,18)
while(r-l>1):
    mid=(l+r)//2
    if position(mid)<K:
        l=mid
    else:
        r=mid
print(l)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
mi_A=min(A)
count=0
bad=0
for j in range(N-1,-1,-1):
  if A[j]%mi_A==0:
    count=count+1
  elif bad==1:
    break
  else:
    bad=bad+1
if count>=N-1:
  ans=mi_A 
else:
  for i in range(mi_A//2+1,0,-1):
    if mi_A%i==0:
      count=0
      bad=0
      for j in range(N-1,-1,-1):
        if A[j]%i==0:
          count=count+1
        elif bad==1:
          break
        else:
          bad=bad+1
      if count>=N-1:
        ans=i
        break
A.remove(min(A))
if len(A)==N-1:
  mi_A=min(A)
  count=0
  bad=0
  for j in range(0,N-1):
    if A[j]%mi_A==0:
      count=count+1
    else:
      break
  if count>=N-1:
    ans=mi_A    
  else:
    for i in range(mi_A//2+1,ans,-1):
      if mi_A%i==0:   
        count=0
        bad=0
        for j in range(0,N-1):        
          if A[j]%i==0:
            count=count+1         
          else:
            break
        if (count>=N-1) and (i>ans):
          ans=i
          break
print(ans)


### FIXED CODE ###

def gcd(a,b):
  if a==b:
    return a 
  elif a<b:
    a,b=b,a
    while a%b!=0:
      a,b=b,a%b
    return b
  else:
    while a%b!=0:
      a,b=b,a%b
    return b
 

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

data_ans=[]
data1=[A[0]]
data2=[A[N-1]]
l=A[0]
m=A[N-1]
for i in range(1,N-2):
  l=gcd(l,A[i])
  m=gcd(m,A[N-i-1])
  data1.append(l)
  data2.append(m)
l=gcd(l,A[N-2])
m=gcd(m,A[1])
data_ans.append(l)
data_ans.append(m)
for i in range(0,N-2):
  data_ans.append(gcd(data1[i],data2[N-3-i]))
print(max(data_ans))
### BUGGY CODE ###

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

aa = map(int, input().split())

old = aa

for _ in range(k):
    new = [0] * n
    for i, a in enumerate(old):
        low = max(0, i-a)
        hi = min(n-1, i+a)+1
        for j in range(low, hi):
            new[j] += 1
    old = new

new = list(map(str, new))

print(' '.join(new))

### FIXED CODE ###

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

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

from itertools import accumulate

aa

for _ in range(k):
    d = [0] * n

    for i, a in enumerate(aa):
        d[max(i-a, 0)] += 1
        end = i+1+a
        if end < n:
            d[end] -= 1

    d = list(accumulate(d))
    if aa == d:
        break
    aa = d


print(' '.join(str(a) for a in aa))
### BUGGY CODE ###

def remove(data):
    global result
    pos = min(len(data), max(data))
    for n in range(pos-1, -1, -1):
        if data[n] == n + 1:
            result.append(n + 1)
            if len(data) == 1:
                #print('OK')
                return True
            else:
                #print('remove {0} '.format(n + 1), end='')
                #print(data[:n] + data[n+1:])
                if remove(data[:n] + data[n+1:]):
                    return True
    else:
        #print('try again')
        if len(result) > 0:
            result.pop(-1)
        return False

_ = input()
B = list(map(int, input().split()))

result = []

if remove(B):
    result.reverse()
    for res in result:
        print(res)
else:
    print(-1)


### FIXED CODE ###

_ = input()
data = list(map(int, input().split()))

result = []
pos = min(len(data), max(data)) - 1

while pos >= 0:
    if data[pos] == pos + 1:
        x = data.pop(pos)
        #print('remove {0} {1}'.format(x, data))
        result.append(x)
        if len(data) == 0:
            break
        pos = min(len(data), max(data)) - 1
    else:
        pos -= 1

if len(data) == 0:
    result.reverse()
    for res in result:
        print(res)
else:
    print(-1)
### BUGGY CODE ###

import math
from collections import deque
S = input()
index = []
L_kyoukai = []
R_kyoukai = [0]
flag = False
for i in range(1, len(S)):
    if flag is False and S[i] == "L":
        L_kyoukai.append(i)
        R_kyoukai.append(i - 1)
        index.append(i - 1)
        index.append(i)
        flag = True
    if flag is True and S[i] == "R":
        L_kyoukai.append(i - 1)
        R_kyoukai.append(i)
        flag = False
ans = [0 for _ in range(len(index))] 
L_kyoukai.append(len(S) - 1)
r_diff = [R_kyoukai[i + 1] - R_kyoukai[i] + 1 for i in range(0, len(R_kyoukai), 2)]
l_diff = [L_kyoukai[i + 1] - L_kyoukai[i] + 1 for i in range(0, len(L_kyoukai), 2)]
for j, (r, l) in enumerate(zip(r_diff, l_diff)):
    tmp_1 = math.ceil(r / 2)
    tmp_2 = math.ceil(l / 2)
    ans[2 * j] += tmp_1 + l - tmp_2
    ans[2 * j + 1] += r - tmp_1 + tmp_2
q = deque(ans)    
for i in range(len(S)):
    if i in index:
        print(q.popleft(), end = " ")
    else:
        print(0, end =" ")

### FIXED CODE ###

import math
from collections import deque
S = input()
L_kyoukai = []
R_kyoukai = [0]
flag = False
for i in range(1, len(S)):
    if flag is False and S[i] == "L":
        L_kyoukai.append(i)
        R_kyoukai.append(i - 1)
        flag = True
    if flag is True and S[i] == "R":
        L_kyoukai.append(i - 1)
        R_kyoukai.append(i)
        flag = False
ans = []
L_kyoukai.append(len(S) - 1)
r_diff = [R_kyoukai[i + 1] - R_kyoukai[i] + 1 for i in range(0, len(R_kyoukai), 2)]
l_diff = [L_kyoukai[i + 1] - L_kyoukai[i] + 1 for i in range(0, len(L_kyoukai), 2)]
for r, l in zip(r_diff, l_diff):
    tmp_1 = math.ceil(r / 2)
    tmp_2 = math.ceil(l / 2)
    ans.append(tmp_1 + l - tmp_2)
    ans.append(r - tmp_1 + tmp_2)
q = deque(ans)    
answer = ""

for i in range(len(S)):
    if 1 <= i <= len(S) - 2:
        if (S[i] == "L" and S[i - 1] == "R") or (S[i] == "R" and S[ i + 1] == "L"):
            answer += str(q.popleft())
            answer += " "
        else:
            answer += "0 "
    elif i == 0:
        if S[i + 1] == "L":
            answer += str(q.popleft())
            answer += " "
        else:
            answer += "0 "
    elif i == len(S) - 1:
        if S[i - 1] == "R":
            answer += str(q.popleft())
            answer += " "
        else:
            answer += "0 "

print(answer)
### BUGGY CODE ###

def int_bitmap(n: int, size=32) -> list:
    table = [0] * size
    for i in range(size):
        table[i] = (n >> i) & 1
    return table


def add_array(A: list, B: list) -> list:
    if len(A) != len(B):
        return -1
    else:
        return [a + b for a, b in zip(A, B)]


def sub_array(A: list, B: list) -> list:
    if len(A) != len(B):
        return -1
    else:
        return [a - b for a, b in zip(A, B)]


def bin_search(A, start, end):
    left, right = start, end
    while left < right:
        mid = (left + right) // 2
        if max(sub_array(A[end], A[mid])) < 2:  # midが条件を満たすとき、左をmidに置き換える
            right = mid
        elif max(sub_array(A[end], A[mid])) > 1:  # midを満たさないとき、左をmidに置き換える
            left = mid + 1
    return left


n = int(input())
_A = [int_bitmap(int(i), 20) for i in input().split()]

cusum = [int_bitmap(int(0), 20) for _ in range(n + 1)]

ans = 0

# pre-processsing for cul_sum
for i in range(1, n + 1):
    cusum[i] = add_array(cusum[i - 1], _A[i - 1])

for i in range(1, n + 1):
    # 右端をiとしたときに条件を満たす最長区間を２分探索する
    p = bin_search(cusum, 0, i)
    ans += (i - p)

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline


n = int(input())
A = [int(i) for i in input().split()]
_sum = 0
_xor = 0
l, r = 0, 0
ans = 0
while l < n:
    while r < n and _sum + A[r] == _xor ^ A[r]:
        _sum += A[r]
        _xor ^= A[r]
        r += 1
    ans += r - l
    _sum -= A[l]
    _xor ^= A[l]
    if l == r:
        r += 1
    l += 1

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

import collections

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

nums = [[0] * 3 for i in range(N)]

roll = [-1,0,1]

for i in range(N):
  for j in range(3):
    d = A[i] + roll[j]
    nums[i][j] = d

B = sum(nums,[])
B = collections.Counter(B).most_common()
print(B[0][1])

### FIXED CODE ###

import collections

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

nums = []
roll = [-1,0,1]

for i in range(N):
  for j in range(3):
    d = A[i] + roll[j]
    nums.append(d)

num = collections.Counter(nums).most_common()
print(num[0][1])
### BUGGY CODE ###

def D_11(x):
    n = x[0]  # 整数の数
    a = x[1:]  # 数列
    M = 10**9 + 7  # 求めた解の剰余をこれで取る

    # aの中から重複した要素のインデックス(それぞれl,rとする)を求める
    freq = [0] * (n + 1)
    for i in a:
        freq[i] += 1  # i番目の要素は整数iの個数
    index = [i for i, x in enumerate(a) if x == freq.index(
        max(freq))]  # 重複した数のインデックスを取得
    l, r = index[0] + 1, index[1] + 1  # +1するのは数列が1スタートのため

    # 組み合わせの計算
    def power(x, n, m):
        # 冪乗(powだと時間がかかりすぎるため)+剰余つき
        y = 1
        while n > 0:
            if n % 2 == 0:
                x = (x * x) % m
                n = n // 2
            else:
                y = (y * x) % m
                n -= 1
        return y

    # この部分は関数の外に出しておかないと、呼び出しのたびに計算して遅い
    factrial = [1] * (n + 2)
    inverse = [1] * (n + 2)
    for i in range(1, n + 2):
        factrial[i] = (factrial[i - 1] * i) % M
    inverse[n + 1] = power(factrial[n + 1], M - 2, M)  # フェルマーの小定理からの帰結
    for i in range(n, -1, -1):
        inverse[i] = (inverse[i + 1] * (i + 1)) % M

    def mod_combination(n, r, m):
        if r > n or n < 0 or r < 0:
            return 0
        else:
            return (factrial[n] * inverse[r] * inverse[n - r]) % m
    for k in range(1, n + 2):
        all_comb = mod_combination(n + 1, k, M) % M
        duplication = mod_combination(l + n - r, k - 1, M) % M
        print(all_comb - duplication)

n = int(input())
l = [int(i) for i in input().split()]
x = [n] + l
D_11(x)

### FIXED CODE ###

def D_11(x):
    n = x[0]  # 整数の数
    a = x[1:]  # 数列
    M = 10**9 + 7  # 求めた解の剰余をこれで取る

    s = set()
    result = [x for x in a if x in s or s.add(x)]
    # for x in a:
    # if x in s:
    #     result.append(x)
    # s.add(x) と同じ書き方
    index = [i for i, x in enumerate(a) if x == result[0]]
    l = index[0] + 1
    r = index[1] + 1

    # フェルマーの小定理を用いてコンビネーションを効率よく計算
    factrial = [1] * (n + 2)
    for k in range(1, n + 2):
        factrial[k] = (factrial[k - 1] * k) % M
    fact_inv = [1] * (n + 2)
    fact_inv[n + 1] = pow(factrial[n + 1], M - 2, M)
    for k in range(n, -1, -1):
        fact_inv[k] = (fact_inv[k + 1] * (k + 1)) % M

    def nCr(n, r, M):
        if n < 0 or r < 0 or n < r:
            return 0
        else:
            return (factrial[n] * fact_inv[r] * fact_inv[n - r]) % M

    for k in range(1, n + 2):
        print((nCr(n + 1, k, M) - nCr((l - 1) + (n + 1 - r), k - 1, M)) % M)

n = int(input())
l = [int(i) for i in input().split()]
x = [n] + l
D_11(x)
### BUGGY CODE ###

N, K = map(int, input().split())
q, mod = divmod(N, K)
if mod == 0:
    print(0)
else:
    while True:
        sub = abs(N-K)
        if sub < N:
            N = sub
        else:
            print(min(sub, N))
            break

### FIXED CODE ###

N, K = map(int, input().split())
q, mod = divmod(N, K)
if mod == 0:
    print(0)
else:
    if mod*2 > K:
        print(abs(mod-K))
    else:
        print(mod)
### BUGGY CODE ###

n, w = map(int, input().split())
dp = [-1] * (w + 1)
dp[w] = 0
for i in range(n):
    input_w, input_v = map(int, input().split())
    for i in range(input_w, w + 1):
        if dp[i] == -1:
            continue
        if dp[i - input_w] < dp[i] + input_v:
            dp[i - input_w] = dp[i] + input_v
print(max(dp))

### FIXED CODE ###

def main():
    n, w = map(int, input().split())
    dp = [-1] * (w + 1)
    dp[w] = 0
    for i in range(n):
        input_w, input_v = map(int, input().split())
        for i in range(input_w, w + 1):
            if dp[i] == -1:
                continue
            if dp[i - input_w] < dp[i] + input_v:
                dp[i - input_w] = dp[i] + input_v
    print(max(dp))

main()
### BUGGY CODE ###

from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    spam = [0] * (N + 1)
    for i, x in enumerate(A):
        spam[i + 1] = spam[i] + x
    count = 0
    for i, value in enumerate(spam):
        count += len([x for x in spam[i + 1:] if x == value])
    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
from functools import lru_cache
from sys import stdin


@lru_cache(maxsize=None)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    spam = {0: 1}
    temp = 0
    for x in A:
        temp += x
        spam[temp] = spam.get(temp, 0) + 1
    print(sum([combinations_count(value, 2) for key, value in spam.items() if value > 1]))


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

n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
for i in range(q):
    bi,ci = map(int, input().split())
    b.append(bi)
    c.append(ci)
for i in range(q):
    for j in range(n):
        if a[j] == b[i]:
            a[j] = c[i]
    print(sum(a))

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
s = []

ans = sum(a)
s = Counter(a)
for i in range(q):
    bi,ci = map(int, input().split())
    b.append(bi)
    c.append(ci)
for i in range(q):
    ans += s[b[i]] * (c[i]-b[i])
    s[c[i]] += s[b[i]]
    s[b[i]] = 0
    print(ans)
### BUGGY CODE ###

from heapq import *
import sys
input=sys.stdin.readline
def main():
  N,M=map(int,input().split())
  G=[set() for i in range(N)]
  for i in range(M):
      u,v=map(int,input().split())
      u,v=u-1,v-1
      G[u].add(v)
  S,T=map(int,input().split())
  A=[set() for i in range(N)]
  for i in range(N):
      for v in G[i]:
          A[i]=A[i] | G[v]
  B=[set() for i in range(N)]
  for i in range(N):
      for v in G[i]:
          B[i]=B[i] | A[v]
  C=[[] for i in range(N)]
  for i in range(N):
      for j in B[i]:
          C[i].append([j,1])
  INF=10**9+7
  def dijkstra(G,s):

    d=[INF]*N
    d[s]=0
    visited={s}
    que=[(0,s)]
    while(que):
      p=heappop(que)
      v=p[1]
      visited.add(v)
      for node,cost in G[v]:
        if (node not in visited) and d[node]>d[v]+cost:
          d[node]=d[v]+cost
          heappush(que,(d[node],node))
    return d
  d=dijkstra(C,S-1)
  if d[T-1]==INF:
    print(-1)
  else:
    print(d[T-1])
if __name__=='__main__':#おまじない
  main()


### FIXED CODE ###

from heapq import *
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
G=[[] for i in range(3*N)]
for i in range(M):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    G[3*u+0].append([3*v+1,0])
    G[3*u+1].append([3*v+2,0])
    G[3*u+2].append([3*v+0,1])
S,T=map(int,input().split())
INF=10**9+7
def dijkstra(G,s):

  d=[INF]*(3*N)
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,(d[node],node))
  return d
d=dijkstra(G,(S-1)*3)
if d[(T-1)*3]==INF:
  print(-1)
else:
  print(d[(T-1)*3])
### BUGGY CODE ###

import itertools
N = int(input())
zahyo =[list(map(int,input().split())) for _ in range(N)]
N_list = [i for i in range(N)]
P = itertools.permutations(N_list,N)
P = list(P)
L = []
for i in range(len(P)):
    for j in range(N-1):
        I = P[i][j]
        J = P[i][j+1]
        xi = zahyo[I][0]
        xj = zahyo[J][0]
        yi = zahyo[I][1]
        yj = zahyo[J][1]
        L.append(((xi-xj)**2+(yi-yj)**2)**0.5)
    Lsum = sum(L)
print(Lsum/len(P))

### FIXED CODE ###

import itertools
N = int(input())
zahyo =[list(map(int,input().split())) for _ in range(N)]
N_list = [i for i in range(N)]
P = itertools.permutations(N_list,N)
P = list(P)
sm = 0
for p in P:
    for i,j in zip(p,p[1:]):
        xi,yi = zahyo[i]
        xj,yj = zahyo[j]
        sm += (((xi-xj)**2+(yi-yj)**2)**0.5)
print(sm/len(P))
### BUGGY CODE ###

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

b=a[:]
for i in range(n):
    if i%2:b[i]=min(-sum(b[j] for j in range(i))-1,b[i])
    else: b[i]=max(-sum(b[j] for j in range(i))+1,b[i])
s=sum(abs(b[i]-a[i]) for i in range(n))

c=a[:]
for i in range(n):
    if i%2:c[i]=max(-sum(c[j] for j in range(i))+1,c[i])
    else: c[i]=min(-sum(c[j] for j in range(i))-1,c[i])
t=sum(abs(c[i]-a[i]) for i in range(n))

print(min(s,t))

### FIXED CODE ###

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

s1=c1=s2=c2=0
for i in range(n):
    if i%2:
        c1+=max(0,a[i]+s1+1); s1+=min(-s1-1,a[i])
        c2+=max(0,-s2+1-a[i]); s2+=max(-s2+1,a[i])
    else:
        c1+=max(0,-s1+1-a[i]); s1+=max(-s1+1,a[i])
        c2+=max(0,a[i]+s2+1); s2+=min(-s2-1,a[i])
print(min(c1,c2))
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]
b = []

for i in range(n):
    b.append(a[i])
    b.reverse()

for i in range(n):
    print(str(b[i]) + " ", end="")
print()


### FIXED CODE ###

from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

for i in range(n):
    if n%2!=0:
        i=n-i-1
    print(str(b[i]) + " ", end="")
print()
### BUGGY CODE ###

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

ans = 0
for x in range(n + 1):
    ans = max(ans, int(a * x / b) - a * int(x / b))

print(ans)

### FIXED CODE ###

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

x = min(n, b - 1)

print(int(a * x / b) - a * int(x / b))
### BUGGY CODE ###

from collections import deque

def bfs(start):
    queue = deque([start])
    visited = []

    while queue:
        label = queue.pop()

        #if label == goal:
        #    visited.append(label)
        #    return tekazu[goal]

        if label not in visited:
            visited.append(label)

            for v in d[label]:
                if v not in visited:
                    tekazu[v] = tekazu[label] + 1
                    queue.appendleft(v)

    return

n = int(input())
d = {i: [] for i in range(n)}

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

tekazu = [0 for _ in range(n)] # nは頂点数
bfs(0)
tekazu_Fennec = tekazu

tekazu = [0 for _ in range(n)] # nは頂点数
bfs(n - 1)
tekazu_Snuke = tekazu

Fennec = 0
Snuke = 0

for i in range(n):
    if tekazu_Fennec[i] <= tekazu_Snuke[i]:
        Fennec += 1
    else:
        Snuke += 1

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###

from collections import deque

def bfs(start):
    queue = deque([start])
    visited = []

    while queue:
        label = queue.pop()

        #if label not in visited:
        visited.append(label)

        for v in d[label]:
            if tekazu[v] == float("inf"):
                tekazu[v] = tekazu[label] + 1
                queue.appendleft(v)

    return

n = int(input())
d = [[] for _ in range(n)]

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

tekazu = [float("inf") for _ in range(n)] # nは頂点数
tekazu[0] = 0
bfs(0)
tekazu_Fennec = tekazu

tekazu = [float("inf") for _ in range(n)] # nは頂点数
tekazu[-1] = 0
bfs(n - 1)
tekazu_Snuke = tekazu

Fennec = 0
Snuke = 0

for i in range(n):
    if tekazu_Fennec[i] <= tekazu_Snuke[i]:
        Fennec += 1
    else:
        Snuke += 1

#print(tekazu_Fennec, tekazu_Snuke)

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")
### BUGGY CODE ###

MOD = int(1e9 + 7)

N,M = list(map(int, input().split()))
A = []
for i in range(M):
  A.append(int(input()))
  
for i in range(M-1):
  if A[i+1] - A[i] == 1:
    print(0)
    exit(0)
    
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
  if i-1 < 0 or i-1 in A:
    dp[i+1] = dp[i] % MOD
  elif i in A:
    dp[i+1] = dp[i-1] % MOD
  else:
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
    
print(dp[N])

### FIXED CODE ###

MOD = int(1e9 + 7)

N,M = list(map(int, input().split()))
A = list()
for i in range(M):
  A.append(int(input()))

A.sort(reverse=True)

for i in range(M-1):
  if A[i+1] - A[i] == 1:
    print(0)
    exit(0)
  
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
  if len(A) > 0 and i+1 == A[-1]:
    A.pop()
  else:  
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
'''
  if len(A) < 1:
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
  elif i-1 < 0 or i-1 == A[-1]:
    dp[i+1] = dp[i] % MOD
  elif i == A[-1]:
    dp[i+1] = dp[i-1] % MOD
  else:
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
'''
print(dp[N])
#print(dp)
### BUGGY CODE ###

n=int(input())
mod=10**9+7
ans=1
for i in range(1,n+1):
    ans*=i
print(ans%mod)

### FIXED CODE ###

n=int(input())
mod=10**9+7
ans=1
for i in range(1,n+1):
    ans=ans*i%mod
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
h = []
ans = 1000000001
for i in range(n):
    h.append(int(input()))
h.sort()
for j in range(n-(k-1)):
    x = []
    for l in range(j,j+k):
        x.append(h[l])
        if len(x) == k:
            y = x[-1]-x[0]
            if ans > y:
                ans = y
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
h = []
ans = 1000000001
for i in range(n):
    h.append(int(input()))
h.sort()
for j in range(n-(k-1)):
    if ans == 0:
        break
    elif ans > h[j+k-1]-h[j]:
        ans = h[j+k-1]-h[j]
print(ans)
### BUGGY CODE ###

import collections

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

c = collections.Counter(A)

sum = 0

for a in A:
    for key in c.keys():
        if key == a:
            value_k = c[key] - 1
            sum += value_k * (value_k - 1) // 2
        else:
            value_k = c[key]
            sum += value_k * (value_k - 1) // 2
    print(sum)
    sum = 0


### FIXED CODE ###

import collections

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

c = collections.Counter(A)

sum_dict = {}
sum_dict_n = {}

sum = 0
sum_n = 0

for key in c.keys():
    coll = c[key] * (c[key] - 1) // 2
    sum_dict[key] = coll
    sum += coll
    value_k = c[key] - 1
    coll_n = value_k * (value_k - 1) // 2
    sum_dict_n[key] = coll_n

for a in A:
    ans = sum
    ans = ans - sum_dict[a] + sum_dict_n[a]
    print(ans)