peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b

n = int(input())

i = 1
while i * (i + 1) // 2 <= n:
    i += 1
ans = []
while n:
    if n >= i:
        n -= i
        ans.append(i)
    i -= 1
for a in ans:
    print(a)
# Judge status: Accepted
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
dst = [0]*(m-1)
for i in range(m-1):
  dst[i] = abs(a[i+1]-a[i])
dst.sort(reverse=True)
print(sum(dst[n-1::]))
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
count = 0
if a % x == 0:
    print((b-a)//x + 1)
else:
    print((b-a)//x)
# Judge status: Accepted
N, *T = map(int, open(0).read().split())
d_t, d_x, d_y = 0, 0, 0
for t, x, y in zip(T[::3], T[1::3], T[2::3]):
    dist = abs(d_x - x) + abs(d_y - y)
    if t - d_t - dist < 0 or (t - d_t - dist) % 2:
        print("No")
        break
    d_t, d_x, d_y = t, x, y
else:
    print("Yes")
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

ans = ''

if a % b == 0:
    if c == 0:
        ans = 'YES'
    else:
        ans = 'NO'
else:
    k = a % b
    for x in range(c+1):
        if (k * x) % b == c:
            ans = 'YES'
            break
    else:
        ans = 'NO'

print(ans)
# Judge status: Accepted
A, B, C = [int(n) for n in input().split()]
K = int(input())
ans = 'No'
for i in range(K+1):
    for j in range(K+1):
        if A < B<<i < C<<j and i+j<=K:
            ans = 'Yes'
            break
print(ans)
# Judge status: Accepted
from collections import *
N = int(input())
C = Counter([int(input()) for n in range(N)]) 
A = [1 for v in C.values() if v%2==1]
print(sum(A))
# Judge status: Wrong Answer
#!/usr/bin/env python3
import sys


def solve(S: str):
    for i in reversed(range(1, len(S) // 2)):
        if S[:i] == S[i:2 * i]:
            print(2 * i)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def resolve():
  base = 10**9+7
  S = int(input())
  dp = [0] * (S+1)
  dp[0] = 1

  for i in range(3, S+1):
    dp[i] = dp[i-1] + dp[i-3]
  # print(dp)
  print(dp[S]%base)

if __name__ == "__main__":
  resolve()
# Judge status: Wrong Answer
import  numpy as np
D = int(input())
c = np.array(list(map(int, input().split())))
s = [list(map(int, input().split())) for _ in range(D)]
last_d = np.array([0]*len(c))

ans = 0
for i in range(D):
  cc = c*(last_d+i+1)
  max_c = max(cc)
  index = np.argmax(cc)
  print(index + 1)
  last_d[index] = -(i+1)
  ans += s[i][index]
  cc[index] = 0
  for j in cc:
    ans -= j
print(ans)
# Judge status: Accepted
def LI():
    return list(map(int, input().split()))


L, R = LI()
ans = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        y = (i*j) % 2019
        ans = min(ans, y)
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)
# Judge status: Wrong Answer
n = int(input())

w = list(input() for i in range(n))

rule = "No"

if len(w) == len(set(w)):
  rule = "Yes"
else:
  rule = "No"
  print(rule)
  exit()

c = 0
for i in range(1,n):
  if w[i-1][-1] == w[i][0]:
    c += 1
    continue
  
if c == n-1:
  rule = "Yes"
else:
  print("No")
    
    



print(rule)
# Judge status: Accepted
S = input()
if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
_in = list(map(int, input().split()))
k = _in[0]
n = _in[1]
p = 0
_i = list(map(int, input().split()))
dis = 0
mdis = k - _i[n-1] + _i[0]
for i in range(1,n-2):
    dis = _i[i+1]- _i[i]
    if dis>mdis:
        mdis = dis
print(k-mdis)
# Judge status: Accepted
if __name__ == "__main__":
  n = int(input())
  ai = list(map(int, input().split()))
  li = []
  for i in range(n - 1):
    if ai[i] > ai[i + 1]:
      li.append(ai[i] - ai[i + 1])
      ai[i+1]=ai[i]
    else:
      pass
  print(sum(li))
# Judge status: Accepted
X = int(input())
print((X // 500) * 1000 + ((X % 500) // 5) * 5)
# Judge status: Accepted
n=int(input())
l=[1,6,36,6**3,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5]
l.sort(reverse=True)
dp=[float("inf")]*1000000
dp[0]=0
for i in range(1,n+1):
    for j in l:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)
print(dp[n])
# Judge status: Accepted
import fractions


def lcm(a, b):
    return a * b // fractions.gcd(a, b)


def div_count_by_2(x):
    count = 0
    while x % 2 == 0:
        count += 1
        x //= 2

    return count


n, m = map(int, input().split())
A = list(map(int, input().split()))

num = A[0]
count = div_count_by_2(num)
for a in A:
    if count == div_count_by_2(a):
        continue
    else:
        print(0)
        exit()

x = A[0]//2
for a in A:
    x = lcm(x, a//2)

ans = m//x - m//(2*x)
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
xy=[]
for _ in range(m):
    x,y=map(int,input().split())
    xy.append([x,y])

ball=[1]*n
red=[0]*n
red[0]+=1

for i in range(m):
    if red[xy[i][0]-1]>=1:
        if ball[xy[i][0]-1]==1:
            red[xy[i][0]-1]=0
        red[xy[i][1]-1]+=1
    ball[xy[i][0]-1]-=1
    ball[xy[i][1]-1]+=1

ans=len(red)-red.count(0) 
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
x = list(map(int,input().split()))

if n >= m :
  print(0)
else:
  y = [0] * (m-1)
  x.sort()
  for i in range(1,m):
    y[i-1] = abs(x[i] - x[i-1])
  y.sort(reverse=True)
  print(sum(y[n-1:]))
# Judge status: Accepted
A,B,C,K=map(int,input().split())

if K%2==0:
  ans = A-B
else:
  ans = B-A

if abs(ans) > 10**18:
  print('Unfair')
else:
  print(ans)
# Judge status: Accepted
N=int(input())
t = list(map(int,input().split()))

newLi = sorted(t, reverse=True)
ans = 0

for i in range(N):
  ans += newLi[i * 2 + 1]

print(ans)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N, A, B = map(int, input().split())

    all_sum = 0
    for i in range(1,N+1):
        keta_sum = sum(list(map(int, str(i))))
        if keta_sum >= A and keta_sum <= B:
            all_sum += i
    print(all_sum)

main()
# Judge status: Wrong Answer
a,b,x = [int(i) for i in input().split()]

N = int(b/x) - int(a/x) + 1

print(int(N))
# Judge status: Wrong Answer
n = int(input())
a = [bin(int(i)) for i in input().split(" ")]
max_len = len(str(max(a))[2:])

a = [str(i)[2:].zfill(max_len) for i in a]
count_list = []
for l in range(max_len):
    count_list.append(sum([int(one[l]) for one in a]))

answer_list = []
for k in range(n):
    string = ""
    for l in range(max_len):
        if (count_list[l] - int(a[k][l]))%2==0:
            string+="0"
        else:
            string+="1"
    answer_list.append(str(int("0b" + string, 0)))
print(" ".join(answer_list))
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = sorted(inpl())
print(max(0, a[n//2]-a[n//2-1]))
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(250000)

from scipy.special import comb
# a = comb(n, r)

def main():
    # a,b,c,d = map(int, input().split())
    n = int(input())

    # temp = (10 ** 9 + 7)
    # sum = 0
    # if n >= 2:
    #     for i in range(2, n+1):
    #         a = int(comb(i, 2)) * 2
    #         a = (a * 8**(i-2)) % temp
    #         sum = sum + a
    # else:
    #     print(0)

    print(10**n - 9**n*2 + 8**n % (10 ** 9 + 7))

main()
# Judge status: Wrong Answer
n=int(input())
l=[1,6,36,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5]
l.sort(reverse=True)
dp=[float("inf")]*1000000
dp[0]=0
for i in range(1,n+1):
    for j in l:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)
print(dp[n])
# Judge status: Wrong Answer
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
if c==1:
  print(1)
else:
  res = 1
  d = math.floor(math.sqrt(c))
  for i in range(2,d+2):
    if c%i==0:
      res += 1
      while c%i==0:
        c = c//i
  if res == 1:
    res += 1
  print(res)
# Judge status: Accepted
import math
A, B, H, M = map(int, input().split())

A_ang = (60*H+M)*math.pi/ 360
B_ang = M*math.pi / 30

X_A = A*math.sin(A_ang)
Y_A = A*math.cos(A_ang)

X_B = B*math.sin(B_ang)
Y_B = B*math.cos(B_ang)

X_D = X_A - X_B
Y_D = Y_A - Y_B

ans = math.sqrt(X_D*X_D + Y_D*Y_D)

print(ans)
# Judge status: Accepted
import itertools
n = int(input())
L = tuple((map(int,input().split())))
M = tuple(map(int,input().split()))
a = 0
b = 0
K = [i for i in range(1,n+1)]
PER = list(itertools.permutations(K))
for i in range(len(PER)):
  if PER[i] == L:
    a = i
  if PER[i] == M:
    b = i
print(abs(a-b))
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))

for i in range(k):
  b=[0]*n
  cnt=0
  for j in range(n):
    if a[j]>=max(n-j,j):
      cnt+=1
  if cnt==n:
    for j in range(n):
      a[j]=(k-i)*n
    break
  for j in range(n):
    for m in range(j-a[j],j+a[j]+1):
      if 0<=m<=n-1:
        b[m]=b[m]+1
  a=b
for i in a:
  print(i,end=' ')
# Judge status: Accepted
from collections import deque


def main():
    n = int(input())
    s = input()
    left = 0
    stack = deque([])
    for ss in s:
        if ss == "(":
            stack.append("(")
        elif not stack:
            left += 1
        else:
            stack.pop()
    print(left * "(" + s + len(stack) * ")")


if __name__ == '__main__':
    main()
# Judge status: Accepted
import re
s = input()
m = re.fullmatch(r"(dreamer|dream|erase|eraser)+", s)

if m:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a,b,k=map(int,input().split())
print(a-k,b) if a>k else print(0,b-(k-a)) if a+b>k else print(0,0)
# Judge status: Accepted
n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append(i)
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==True:
        print("No")
# Judge status: Accepted
S=input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print('Bad')
else:
  print("Good")
# Judge status: Accepted
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for k, v in c.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)
# Judge status: Wrong Answer
import math

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

if (a - 1) * b <= a * n:
    print(a - 1)
    exit()

ans = math.floor(a * n / b)

print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

AB = abs(a - b)
BC = abs(b - c)
AC = abs(a - c)

if AB <= d and BC <= d:
    print("Yes")
elif AC <= d:
    print("YES")
else:
    print("No")
# Judge status: Accepted
N=int(input())
X=list(map(int,input().split()))
l=len(X)
s=10**10
for i in range(min(X),max(X)+1):
    x=[]
    for j in range(l):
        x.append((X[j]-i)**2)
    if s>sum(x):
        s=sum(x)
print(s)
# Judge status: Wrong Answer
N,M = map(int,input().split())
arr = []
pre_idx = '-1'
pre_s = 'start'
cnt = 0
errors = 0
ans = 0
for i in range(M):
  idx,s = input().split()
  arr.append([int(idx),s])
  
arr = sorted(arr)

flag = False
for idx,s in arr:
  if pre_idx != idx:
    cnt = 0
    flag = False
  if flag:
    continue
  else:
    if s=='WA':
      cnt += 1
    else:
      errors += cnt
      ans += 1
      flag = True
  pre_idx = idx
  pre_s = s
    
print(ans,errors)
# Judge status: Wrong Answer
import math
h,w = map(int, input().split())
a = math.ceil(h*w/2)
print(a)
# Judge status: Wrong Answer
import sys
N=int(input())
A=list(map(int,input().split()))
flag=True
for i in range(N):
    if A[i]%2==0:
        if A[i]%3!=0:
            flag=False
        elif A[i]%5!=0:
            flag=False
if flag==True:
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
import sys
input = sys.stdin.readline
import math

def main():
    big = 10 ** 9 + 7

    N = int(input())
    A = list(map(int, input().split()))
    num = A[0]
    for i in range(1, N):
        num = num * A[i] // math.gcd(num, A[i])

    res = 0
    for a in A:
        res += num // a

    print(res % big)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,x=map(int,input().split())
if a+b>=x and a<=x:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()
#A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]
#C = [list(map(int, input().split())) for i in range()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a 
ab = A+B
b = B
for s in S:
    if s == 'a' and ab > 0:
        print('Yes')
        ab -= 1
    elif s == 'b' and ab > 0 and b > 0:
        print('Yes')
        ab -= 1
        b -= 1
    else:
        print('No')
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
A.sort()
# print(A)
multiple = [0]*(A[-1]+1)
for i in range(n):
    now = A[i]
    while(now <= A[-1]):
        multiple[now] += 1
        now += A[i]
ans = 0
for i in range(n):
    if(multiple[A[i]] == 1):
        ans += 1
# print(multiple)
print(ans)
# Judge status: Wrong Answer
import math

n = int(input())
ans = 0
for i in range(105, n+1, 2):
    cnt = 0
    for j in range(2, int(math.sqrt(n))):
        if i % j == 0:
            cnt += 1
    if cnt == 3:
        ans += 1
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
print(N - N // K * K)
# Judge status: Accepted
N = int(input())
S = 0
if N == 1:
  print('0')
else:
  S0 = 10**N - 9**N
  S9 = 10**N - 9**N
  S09 = 8**N
  S = S0 + S9 + S09 - 10**N
  S = S % (10**9 + 7)
  print(S)
# Judge status: Accepted
L = float(input())
V = L**3 / 27
print(V)
# Judge status: Wrong Answer
import sys

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

A = [list(sys.stdin.readline().strip()) for _ in range(N)]
B = [list(sys.stdin.readline().strip()) for _ in range(M)]


def check(y, x):
    for i in range(y, y + M):
        if A[i][x:x + M] != B[i - y]:
            return False
    return True


for i in range(N - M):
    for j in range(N - M):
        if A[i][j] == B[0][0]:
            if check(i, j):
                print("Yes")
                exit()

print("No")
# Judge status: Wrong Answer
import sys
import math
A,B=map(int,input().split())
if A<B:
  A,B=B,A
if B%A==0:
  print(A)
  sys.exit()
L=[]
for i in range(1,math.ceil(A/2)):
  if A%i==0 and B%i==0:
    L.append(i)
print(int((A*B)/L[-1]))
# Judge status: Accepted
#045b
from collections import deque

card = dict()
card["a"] = deque(input())
card["b"] = deque(input())
card["c"] = deque(input())

#print(card)

next_person = card["a"].popleft()

while True:
    #print(next_person,card)
    if len(card[next_person]) == 0:
        print(next_person.upper())
        break
    else:
        next_person = card[next_person].popleft()
# Judge status: Accepted
# B - ... (Triple Dots)
def main():
    K = int(input())
    S = input().rstrip()
    print(S if len(S) <= K else S[:K] + "...")


if __name__ == "__main__":
    main()
# Judge status: Accepted
D,T,S = map(int,input().split())

if D > T*S :
  print("No")
else:
  print("Yes")
# Judge status: Accepted
a,b,c=sorted(map(int,input().split()))
print(a+b+pow(2,int(input())  )*c )
# Judge status: Accepted
s = input()
 
for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break
for i in range(-1,-len(s),-1):
    if s[i] == 'Z':
        b = len(s) + i
        break
 
print(b-a+1)
# Judge status: Accepted
import sys
input = sys.stdin.readline

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

for _ in range(K):
    Imos = [0]*(N+1)
    for i, a in enumerate(A):
        Imos[max(0, i-a)] += 1
        Imos[min(N, i+a+1)] -= 1
    B = [0]*(N)
    b = 0
    for i in range(N):
        b += Imos[i]
        B[i] = b
    if A == B:
        break
    A = B

print(*A)
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split()))
l_max=max(l)
l_other=[i for i in l if i!=l_max]
if l_max<sum(l_other):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,k=map(int,input().split())
d=input().split()

ans=0
flg=False
for i in range(n,10*n+1):
    for j in d:
        if j in str(i):
            break
        flg=True
    if flg:
        ans=i
        break
print(ans)
# Judge status: Wrong Answer
n,d = list(map(int,input().split()))

print(100**n * d)
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n=int(input())
c=0
for i in range(1,n+1,2):
    a=make_divisors(i)
    if len(a)==8:
        c+=1
print(c)
# Judge status: Wrong Answer
n, m = map(int, input().split())
k = []
for i in range(n):
    k.append(list(map(int, input().split())))
    k[i].pop(0)
ans = 0
cnt = 0
for i in k:
    for j in i:
        if j in i:
            cnt += 1
    if cnt == n:
        ans += 1
    cnt = 0
if n == 1:
    print(len(k[0]))
    exit(0)
print(ans)
# Judge status: Accepted
S = input()
nik = S[0:3]
print(nik)
# Judge status: Accepted
N = int(input())
ans = ((1+N-1)*(N-1))//2
print(ans)
# Judge status: Wrong Answer
N, X, Y = map(int, input().split())

ans = [0] * (N - 1)

for i in range(1, N + 1, 1):
    for j in range(i + 1, N + 1, 1):
        tmp = min(
            abs(j - i),
            abs(X - i) + 1 + abs(j - Y),
            abs(X - j) + 1 + abs(i - Y) # このパターンは
        )
        ans[tmp - 1] += 1

for a in ans:
    print(ans)
# Judge status: Wrong Answer
n = int(input())
n = n-1
s = (n/2)*((2*1)+(n-1))

print(int(s))
# Judge status: Accepted
a,b=map(int,input().split())
print(a*b if 1<=a<=9 and 1<=b<=9 else "-1")
# Judge status: Accepted
import math

ans = -1
n = int(input())

for i in range(1, n+1):
    if math.floor(i * 1.08) == n:
        ans = i
        break

print(ans if ans != -1 else ":(")
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *W = map(int, read().split())

    ans = INF
    for t in range(1, N):
        ans = min(ans, abs(sum(W[:t]) - sum(W[t:])))

    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
num_inputs = int(input())
max_pair = 0
for i in range(0, num_inputs):
  pair = input().split(" ")
  curr_x = int(pair[0])
  curr_y = int(pair[1])
  if i == 0:
    min_pair = curr_x + curr_y
  if (curr_x + curr_y) >= max_pair:
    max_pair = curr_x + curr_y
  elif (curr_x + curr_y) <= min_pair:
    min_pair = (curr_x + curr_y)
  print(min_pair, max_pair)
print(max_pair-min_pair)
# Judge status: Accepted
print(0 if int(input()) == 1 else 1)
# Judge status: Wrong Answer

n,k = map(int,input().split())
l = list(map(int,input().split()))
position = 1

town = ''
stayed = [1]
stayed_c = [0]*n
for i in range(n):
    position = l[position-1]
    if not position in stayed:
        stayed.append(position)
        stayed_c[position-1] = i+1
    else:
        c = i+1 - stayed_c[position-1]
        g = stayed_c[position-1]
        town = position
        break
m = (k -g) % c 
position = town
for i in range(m):
    position = l[position-1]
print(position)
# Judge status: Wrong Answer
import math
X = int(input())
def prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

Bool = False
p = X
while not(Bool):
    Bool = prime(p)
    p += 1
    
print(p + 1)
# Judge status: Accepted
# -*- coding: utf-8 -*-
n, l = map(int,input().split())
s = []
for i in range(n):
    s.append(str(input()))

s.sort()
print(''.join(s))
# Judge status: Accepted
a, b, c = map(int, input().split())
print('Yes' if a < c < b or b < c < a else 'No')
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))

if 2*max(L)<sum(L):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==0:
    print(max(a))
else:
    ans=0
    for i in a:
        d=-(-k*i//sum(a))
        if d>0:
            ans=max(ans,-(-i//(d+1)))
        else:
            ans=max(ans,i)
    print(ans)
# Judge status: Accepted
X = int(input())

tmp = 100
cnt = 0

while tmp < X:
    tmp = int(tmp * 1.01)
    cnt += 1
print(cnt)
# Judge status: Accepted
import math
[N, X, T] = input().split()

A = math.ceil(int(N)/int(X))

ans = A*int(T)
print(ans)
# Judge status: Accepted
def resolve():
    import collections

    N = int(input())
    A_list = [int(item) for item in input().split()]
    origin_dict = collections.Counter(A_list)

    twopair_in_N = 0
    for i in origin_dict.values():
        twopair_in_N += i*(i-1)//2

    for j in range(N):
        deff = origin_dict[A_list[j]] -1

        print(twopair_in_N - deff)
    

if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
A,B,C,X,Y = map(int, input().split())
ans = X*A + Y*B
for i in range(max(X,Y)+1):
    C = 2*C*i + max(0,X-i)*A + max(0,Y-i)*B
    ans = min(ans, C)
print(ans)
# Judge status: Accepted
N = int(input())

if N <= 999:
    print('ABC')

elif N <= 1998:
    print('ABD')
# Judge status: Accepted
import sys

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

answer = sys.maxsize
for x in range(N, 100000):
    s = str(x)
    if all([y not in s for y in D]):
        answer = min(answer, x)
print(answer)
# Judge status: Wrong Answer
import collections 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
x,y=0,0
b=list(set(a))[::-1]
for i in b:
  if c[i]>3 and x==y==0:
    print(i**2)
    exit()
  if c[i]>1:
    y=i if x>0 and y==0 else y
    x=i if x==0 else x
  if x*y>0:
    print(x*y)
    exit()
print(x*y)
# Judge status: Accepted
n = int(input())
aa = [int(x) for x in input().split()]
def ok(x):
    return x % 2 == 1 or (x % 3 == 0 or x % 5 == 0)
if all(ok(x) for x in aa):
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
n = int(input())
ans=""
while(n):
    n-=1
    ans += chr(ord('a')+(n%26))
    n = n//26

print(ans[::-1])
# Judge status: Accepted
N = int(input())
ans = 0
for a in range(1,N):
    ans += (N-1)//a
print(ans)
# Judge status: Wrong Answer
a=input().split()
nm=[]
for i in range(2):
  b=int(a[i])
  nm.append(b)
if nm[0]<9:
  nm[1]+=(100*(10-nm[0]))

print(nm[1])
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
  x[i] = [x[i], i]
x.sort(key=lambda x:x[0])
for i in range(n):
  if i < n//2:
    x[i] += [x[n//2][0]]
  else:
    x[i] += [x[n//2-1][0]]
# x[i] = [value, init_index, b_i]
x.sort(key=lambda x:x[1])
for i in range(n):
  print(x[i][2])
# Judge status: Wrong Answer
n, x, y = map(int, input().split())

net1 = list(range(1,n+1)) 
net2 = list(range(1,x+1)) + list(range(y,n+1))  

for a in range(1,n):
  lisa = []
  seta = set()

  for i in range(len(net1)-a):
    lisa.append(net1[i:i+a+1])

  for i in range(len(net2)-a):
    lisa.append(net2[i:i+a+1])

  for l in lisa:
    seta.add(tuple(l))

  print(len(seta))
# Judge status: Accepted
s = input()
if s[0] == "A" and  "C" in s[2:-1] and s[1:].replace("C","",1).islower():
    print("AC")
else:
    print("WA")
# Judge status: Accepted
k, x = map(int, input().split())
if (500 * k) >= x:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, N = map(int, input().split())
print(A*min(B-1, N)//B)
# Judge status: Accepted
import sys
input = sys.stdin.readline

A, B, C = map(int, input().split(' '))
ans = 'NO'
for i in range(1, B+1):
    if i * A % B == C:
        ans = 'YES'
print(ans)
# Judge status: Accepted
n = int(input())
lisw = list(map(int,input().split()))

total = 100000000
for i in range(1,n):
  total = min(total,abs(sum(lisw[:i])-sum(lisw[i:])))
  
print(total)