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

S = list(input())
size = len(S)
to_remove = []
last_size = len(S)
while True:
    i = 0
    while i < len(S)-1:
        if S[i] != S[i+1]:
            to_remove.append(i)
            to_remove.append(i+1)
            i+=1
        i+=1
    to_remove.reverse()
    for t in to_remove:
        del S[t]
    to_remove = []
    if last_size == len(S) or len(S) == 0:
        break
    else:
        last_size = len(S)
print(size-len(S))

### FIXED CODE ###

s = input()
print(2*(min(s.count("0"), s.count("1"))))
### BUGGY CODE ###

x1 = input()
x2 = [int(s) for s in input().strip().split(" ") ]
 
result =  1
for xv in x2:
  result = xv * result

if 10**18 < result : result = -1
print(result) 


### FIXED CODE ###

x1 = input()
x2 = [int(i) for i in input().split(" ")]

result = 0
if 0 in x2:
  None 
else:
  result = 1
  for xv in x2:
     result = xv * result
  
     if 10**18 < result : 
        result = -1
        break


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

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

cnt = 0
while True:
  if N >= 1:
    N -= 1
  elif M >= 2:
    M -= 2
  else:
    break

  if M >= 2:
    cnt += 1
    M -= 2
  else:
    break

print(cnt)


### FIXED CODE ###

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

cnt = min(N, M // 2)
N -= cnt
M -= cnt * 2

if M > 0:
  cnt += M // 4

print(cnt)
### BUGGY CODE ###

import bisect
import numpy as np
from scipy.ndimage.interpolation import shift


def judge(e):
    ae = aaa[e]
    dp = np.zeros(k, np.uint8)
    dp[0] = 1
    for i, a in enumerate(aaa):
        if i == e:
            continue
        dp |= shift(dp, a)
    return dp[-ae:].any()


def solve(k, aaa):
    l = 0
    r = bisect.bisect_left(aaa, k) - 1
    m = (l + r) // 2
    while l <= r:
        if judge(m):
            r = m - 1
        else:
            l = m + 1
        m = (l + r) // 2

    return l


n, k = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort()
print(solve(k, aaa))


### FIXED CODE ###

import bisect


def solve(k, aaa):
    aaa = aaa[:bisect.bisect_left(aaa, k)]

    dp = [False] * k
    dp[0] = True
    curr_max = 0
    ans = len(aaa)
    for i, a in reversed(list(enumerate(aaa))):
        if curr_max + a >= k:
            ans = i
        f = True
        for j in range(min(curr_max, k - a - 1), -1, -1):
            if dp[j]:
                dp[j + a] = True
                if f:
                    curr_max = max(curr_max, j + a)
                    f = False
    return ans


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

print(solve(k, aaa))
### BUGGY CODE ###

class SegmentTree:
    def __init__(self, N, f, e=None):
        self.N = 1<<(N-1).bit_length()
        self.seg = [e] * (self.N*2)
        self.e = e
        self.f = f

    def build(self, A):
        for i,a in enumerate(A):
            self.seg[i+self.N] = a
        for i in range(self.N-1,0,-1):
            self.seg[i] = self.f(self.seg[i<<1], self.seg[i<<1|1])

    def update(self, i, x): # a_i += x
        i += self.N
        self.seg[i] = x
        while i > 1:
            self.seg[i>>1] = self.f(self.seg[i], self.seg[i^1])
            i >>= 1

    def query(self, a, b): # f [a, b)
        L = R = self.e
        a += self.N
        b += self.N
        while a < b:
            if a&1:
                L = self.f(L, self.seg[a])
                a += 1
            if b&1:
                b -= 1
                R = self.f(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.f(L, R)

from collections import Counter
def main():
    N,K,*P=map(int, open(0).read().split())
    Mseg=SegmentTree(N, max, 0)
    mseg=SegmentTree(N, min, float("inf"))
    Mseg.build(P)
    mseg.build(P)
    D=Counter(P[:K])
    ans=1
    als=1
    for i in range(1,K):
        als=als+1 if P[i]>P[i-1] else 1
    iss=als==K
    for i in range(N-K):
        als=als+1 if P[i+K]>P[i+K-1] else 1
        mp=mseg.query(i, i+K)
        Mp=Mseg.query(i+1,i+K+1)
        if not (mp==P[i] and Mp==P[i+K]) and not (iss and als==K):
            ans+=1
        iss|=als==K
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

class SegmentTree:
    def __init__(self, N, f, e=None):
        self.N = 1<<(N-1).bit_length()
        self.seg = [e] * (self.N*2)
        self.e = e
        self.f = f

    def build(self, A):
        for i,a in enumerate(A):
            self.seg[i+self.N] = a
        for i in range(self.N-1,0,-1):
            self.seg[i] = self.f(self.seg[i<<1], self.seg[i<<1|1])

    def update(self, i, x): # a_i += x
        i += self.N
        self.seg[i] = x
        while i > 1:
            self.seg[i>>1] = self.f(self.seg[i], self.seg[i^1])
            i >>= 1

    def query(self, a, b): # f [a, b)
        L = R = self.e
        a += self.N
        b += self.N
        while a < b:
            if a&1:
                L = self.f(L, self.seg[a])
                a += 1
            if b&1:
                b -= 1
                R = self.f(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.f(L, R)

from collections import Counter
def main():
    N,K,*P=map(int, open(0).read().split())
    Mseg=SegmentTree(N, max, 0)
    mseg=SegmentTree(N, min, float("inf"))
    Mseg.build(P)
    mseg.build(P)
    D=Counter(P[:K])
    ans=1
    als=1
    for i in range(1,K):
        als=als+1 if P[i]>P[i-1] else 1
    iss=als==K
    for i in range(N-K):
        als=als+1 if P[i+K]>P[i+K-1] else 1
        mp=mseg.query(i, i+K)
        Mp=Mseg.query(i+1,i+K+1)
        if not (mp==P[i] and Mp==P[i+K]) and not (iss and als==K):
            ans+=1
        iss|=als==K
    print(ans)

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

# coding: utf-8
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
minus = 0
for i in range(M):
    b, c = map(int, input().split())
    for j in range(b):
        if A[0] < c:
            tmp = heapq.heappop(A)
            heapq.heappush(A, c)
print(sum(A))

### FIXED CODE ###

# coding: utf-8
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
minus = 0
l = []
for i in range(M):
    b, c = map(int, input().split())
    l.append([b, c])
l.sort(key=lambda x: x[1], reverse=True)
A.sort(reverse=False)
idx = 0
i = 0
ans = 0
while i < N and idx < M:
    if l[idx][0] == 0:
        idx += 1
    if idx >= M:
        ans += A[i]
        i += 1
        continue
    if A[i] < l[idx][1]:
        ans += l[idx][1]
        l[idx][0] -= 1
        i += 1
    else:
        ans += A[i]
        i += 1
    # print("ans =", ans)
for j in range(i, N):
    ans += A[j]
print(ans)
### BUGGY CODE ###

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

ans, u = 0, set()
for i in range(n-1):
    c = set()
    if i not in u:
        for j in range(i+1, n):
            if s[i] == s[j]:
                c.add(i)
                c.add(j)
                u.add(i)
                u.add(j)
        ans += (len(c) * (len(c) - 1)) // 2
print(ans)

### FIXED CODE ###

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

ans, d = 0, {}
for i in range(n):
    if s[i] in d.keys():
        ans += d[s[i]]
        d[s[i]] = d[s[i]] + 1
    else:
        d[s[i]] = 1
print(ans)
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
n,m = na()
a = na()
for i in range(m):
    b,c = na()
    for j in range(b):
        a.append(c)

aa = sorted(a)

print(sum(aa[len(aa)-n:]))

### FIXED CODE ###

import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = na()

bc = [na() for i in range(m)]
bc.sort(key=lambda x:x[1])

for b,c in bc[::-1]:
  a.extend([c]*b)
  if len(a)>2*n:
    break

a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

k = int(input())
s = input()

length = len(s)
MOD = 10**9 + 7

dp = [[0] * (k + 1) for _ in range(2)]
dp[0][0] = pow(26, k, MOD)
dp[1][0] = pow(26, k, MOD)

div = pow(26, -1, MOD)

for i in range(1, k + 1):
    dp[0][i] = dp[0][i - 1] * 25 * div * (length + i - 1) * pow(i, -1, MOD) % MOD
    dp[1][i] = (dp[1][i - 1] + dp[0][i]) % MOD

print(dp[-1][-1])

### FIXED CODE ###

def solve(k, length, MOD, div, dp):
    for i in range(1, k + 1):
        dp[0] = dp[0] * 25 * div * (length + i - 1) * pow(i, -1, MOD) % MOD
        dp[1] = (dp[1] + dp[0]) % MOD

    return(dp[1])


k = int(input())
s = input()
length = len(s)
MOD = 10**9 + 7
div = pow(26, -1, MOD)

dp = [pow(26, k, MOD)] * 2

print(solve(k, length, MOD, div, dp))
### BUGGY CODE ###

from collections import Counter
MOD = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


prime = [0] * (10**6 + 1)
for i in range(N):
    c = Counter(prime_factorize(A[i]))
    for j in c.items():
        prime[j[0]] = max(j[1], prime[j[0]])
lcm = 1
for i in range(10**6):
    if prime[i] > 0:
        lcm *= pow(i, prime[i], MOD)

ans = 0
for i in range(N):
    ans += lcm // A[i]
    ans %= MOD
print(ans)


### FIXED CODE ###

import math
import sys
input = sys.stdin.readline

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

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

mod = 10**9 + 7
# A全体の最小公倍数
a_lcm = 1
for a in A:
    a_lcm = lcm(a_lcm, a)

# Bの総和
b_sum = 0
for i in range(N):
    b_sum += a_lcm // A[i]

print(b_sum % mod)
### BUGGY CODE ###

MOD = 10**9 + 7

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

res = 0

for i in range(N)[:-1]:
  res += A[i] * sum(A[i+1:])
  res %= MOD

print(res)

### FIXED CODE ###

MOD = 10**9 + 7

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

res = 0
sumA = sum(A)
for i in range(N)[:-1]:
  sumA -= A[i]
  res += A[i] * sumA
  res %= MOD

print(res)
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())

ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i+1 == j+1 and j+1==k+1 and i+1 == k+1:
                ans += i+1
  
            elif i+1 == 1 or j+1 == 1 or k+1 == 1:
             
                ans +=1
            else:
               
                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)

### FIXED CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())
 
 
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
           
 
                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)
### BUGGY CODE ###

import sys
import string

alphabets=list(string.ascii_lowercase)

s=input()

l=len(s)

hm = lambda a,string: sum([x==a for x in string])

for x in range(l-1):
  if s[x]==s[x+1]:
    print('{} {}'.format(x+1, x+2))
    sys.exit()

for m in range(3,l,2):
  for n in range(l-m):
    for a in alphabets:
      if hm(a,s[n:n+m])> m//2:
        print('{} {}'.format(n+1,n+m))
        sys.exit()
print('-1 -1')

### FIXED CODE ###

import sys
import string
 
alphabets=list(string.ascii_lowercase)
 
s=input()
 
l=len(s)
 
hm = lambda a,string: sum([x==a for x in string])
 
for x in range(l-1):
  if s[x]==s[x+1]:
    print('{} {}'.format(x+1, x+2))
    sys.exit()
 
 
for n in range(l-3):
  for a in alphabets:
    if hm(a,s[n:n+3])> 1:
      print('{} {}'.format(n+1,n+3))
      sys.exit()
print('-1 -1')
### BUGGY CODE ###

n = int(input())
a = map(int, input().split())
digits = [0]*60
for i in a:
  for j in range(60):
    digits[j] += i%2
    i//=2
    if i==0:
      break
ans = 0
for i in range(60):
  ans += digits[i]*(n-digits[i])*(2**i)
  ans %= 10**9+7
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(60):
  tmp = sum([1 for j in a if (j>>i)&1])
  ans += tmp*(n-tmp)*(2**i)
  ans %= 10**9+7
print(ans)
### BUGGY CODE ###

#import heapq
#import itertools
#import math
#import numpy as np
#import sys

#N = int(input())
N, K, Q = list(map(int, input().split()))
A = [input() for _ in range(Q)]

for i in range(1,N+1) :
    s = 0
    for a in A :
        if i == int(a) :
            s += 1
    if s > Q - K :
        print('Yes')
    else :
        print('No')


#T = [list(map(int,input().split())) for _ in range(N)]
#H = [K] * N
#print(A)
#print(H)
#for a in A :
#    for i in range(N) :
#        if i == int(a) :
#            pass
#        else :
#            H[i -1] -= 1
#for h in H :
#    if h > 0 :
#        print('Yes')
#    else :
#        print('No')
#ans = ['Yes' if h > 0 else 'No' for h in H]
#for a
#print(ans)

### FIXED CODE ###

#import heapq
#import itertools
#import math
#import numpy as np
#import sys

#N = int(input())
N, K, Q = list(map(int, input().split()))
A = [int(input()) for _ in range(Q)]
S = [0] * N
for i in A :
    S[i - 1] += 1
for s in S :
    if s > Q - K :
        print('Yes')
    else :
        print('No')


#for i in range(1,N+1) :
#    s = 0
#    for a in A :
#        if i == a :
#            s += 1
#    if s > Q - K :
#        print('Yes')
#    else :
#        print('No')


#T = [list(map(int,input().split())) for _ in range(N)]
#H = [K] * N
#print(A)
#print(H)
#for a in A :
#    for i in range(N) :
#        if i == int(a) :
#            pass
#        else :
#            H[i -1] -= 1
#for h in H :
#    if h > 0 :
#        print('Yes')
#    else :
#        print('No')
#ans = ['Yes' if h > 0 else 'No' for h in H]
#for a
#print(ans)
### BUGGY CODE ###

MOD = 10 ** 9 + 7
ans = 1

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

#全部取る
if n == k:
    for x in a:
        ans *= x
    print(ans % MOD)

#全部負かつ奇数個取る
elif max(a) < 0 and k % 2:
    a.sort()
    for i in range(1, k+1):
        ans *= a[-i]
    print(ans % MOD)

else:
    pos = []
    neg = []
    
    for x in a:
        if x >= 0:
            pos.append(x)
        else:
            neg.append(x)
    
    pos.sort(reverse=True)
    neg.sort()
    
    
    if k % 2:
        ans *= pos.pop(0)
        k -= 1
     
    #2個ずつ取る
    num = []
    for x, y in zip(pos[::2], pos[1::2]):
        num.append(x * y)
    for x, y in zip(neg[::2], neg[1::2]):
        num.append(x * y)

    num.sort(reverse=True)

    for i in range(k // 2):
        ans *= num[i]
        ans %= MOD
    
    print(ans % MOD)
    

### FIXED CODE ###

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

MOD = 10 ** 9 + 7
ans = 1

#全部取る
if n == k:
    for x in a:
        ans *= x
        ans %= MOD
    print(ans % MOD)

#全部負かつ奇数個取る
elif max(a) < 0 and k % 2:
    a.sort()
    for i in range(1, k+1):
        ans *= a[-i]
        ans %= MOD
    print(ans % MOD)

else:
    pos = []
    neg = []
    
    for x in a:
        if x >= 0:
            pos.append(x)
        else:
            neg.append(x)
    
    pos.sort(reverse=True)
    neg.sort()
    
    
    if k % 2:
        ans *= pos.pop(0)
        k -= 1
     
    #2個ずつ取る
    num = []
    for x, y in zip(pos[::2], pos[1::2]):
        num.append(x * y)
    for x, y in zip(neg[::2], neg[1::2]):
        num.append(x * y)

    num.sort(reverse=True)

    for i in range(k // 2):
        ans *= num[i]
        ans %= MOD
    
    print(ans % MOD)
### BUGGY CODE ###

import numpy as np

n,m = map(int,input().split())
a_list = []
li = [[0 for i in range(n)] for j in range(m)]

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c = list(map(int,input().split()))
    for j in range(b):
        c[j] -= 1
    for k in c:
        li[i][k] = 1

li = np.array(li)
min_coin = 10**10
for i in range(2**m):
    coin = 0
    bool_list = np.array([0]*n)
    for j in range(m):
        if (i >> j)&1:
            for k in li[j]:
                bool_list = li[j] | bool_list
            coin += a_list[j]
    if np.count_nonzero(bool_list) != n:
        continue
    min_coin = min(min_coin,coin)

if min_coin == 10**10:
    print(-1)
else:
    print(min_coin)

### FIXED CODE ###

n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])
### BUGGY CODE ###

from collections import deque

h,w = [int(x) for x in input().split()]
m = []
for _ in range(h):
    m.append(list(input()))

def bfs(sy,sx,gy,gx):
    res = [[-1]*(w) for i in range(h)]
    res[sy][sx] = 0
    q = deque()
    q.append([sy,sx])
    while q:
        z = q.popleft()
        if z[0]==gy and z[1]==gx:
            break
        for dy,dx in [[1,0],[-1,0],[0,1],[0,-1]]:
            ny = z[0] + dy
            nx = z[1] + dx
            if 0<=ny<h and 0<=nx<w and m[ny][nx]=="." and res[ny][nx]==-1:
                q.append([ny,nx])
                res[ny][nx] = res[z[0]][z[1]] + 1
    return res[gy][gx]

ans = []
for i in range(h):
    for j in range(w):
        for ii in range(h):
            for jj in range(w):
                if i==ii and j==jj:
                    continue
                if (m[i][j]=="." and m[ii][jj]=="."):
                    xxx = bfs(i,j,ii,jj)
                    if xxx != -1:
                        ans.append(xxx)

print(max(ans))

### FIXED CODE ###

from collections import deque

h,w = [int(x) for x in input().split()]
m = []
for _ in range(h):
    m.append(list(input()))

def bfs(sy,sx):
    res = [[-1]*(w) for i in range(h)]
    res[sy][sx] = 0
    q = deque()
    q.append([sy,sx])
    dis = 0
    while q:
        z = q.popleft()
        for dy,dx in [[1,0],[-1,0],[0,1],[0,-1]]:
            ny = z[0] + dy
            nx = z[1] + dx
            if 0<=ny<h and 0<=nx<w and m[ny][nx]=="." and res[ny][nx]==-1:
                q.append([ny,nx])
                res[ny][nx] = res[z[0]][z[1]] + 1
                dis = res[ny][nx]
    return dis

ans = -1
for i in range(h):
    for j in range(w):
        if m[i][j] == ".":
            ret = bfs(i,j)
            if ret > ans:
                ans = ret
print(ans)
### BUGGY CODE ###

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def use_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            if (n//i)%2:
                divisors.append(i)
            if i != n//i:
                if (n//(n//i))%2:
                    divisors.append(n//i)
    divisors.sort()
    return divisors

N = I()
X = str(input())

ans = 0
divisors = use_divisors(2*N)

C = defaultdict(int)
for d in divisors:
    C[d] = 0

for d in divisors:
    T = X[:d//2]
    Tr = ''.join('1' if c=='0' else '0' for c in T)
    Tc = T+Tr
    count = int(T,2)
    if int(Tc*(N//d)+Tc[:N-d*(N//d)],2) <= int(X,2):
        count += 1
    C[d] = count
    for d1 in divisors:
        if d%d1==0 and d!=d1:
            C[d] -= C[d1]

ans = 0
for d in divisors:
    ans += d*C[d]
    ans %= mod

print(ans)

### FIXED CODE ###

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def use_divisors(n):
    l_divisors, r_divisors = [], []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            if (n//i)%2:
                l_divisors.append(i)
            if i != n//i:
                if (n//(n//i))%2:
                    r_divisors.append(n//i)
    return l_divisors + r_divisors[::-1]
 
N = I()
X = str(input())
Xr = ''.join('1' if c=='0' else '0' for c in X)

ans = 0
divisors = use_divisors(2*N)
C = dict.fromkeys(divisors,0)

for d in divisors:
    T = X[:d//2]
    Tr = Xr[:d//2]
    Tc = T+Tr
    count = int(T,2)
    if int(Tc*(N//d)+Tc[:N-d*(N//d)],2) <= int(X,2):
        count += 1
    C[d] = count
    for d1 in divisors:
        if d%d1==0 and d!=d1:
            C[d] -= C[d1]

ans = 0
for d in divisors:
    ans += d*C[d]
    ans %= mod

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

n=int(input())
ans=1

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

### FIXED CODE ###

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

N = int(input())
goods = []
for i in range(N):
  good = str(input())
  if good not in goods:
    goods.append(good)
    
print(len(goods))

### FIXED CODE ###

N = int(input())
goods = {}
count = 0
for i in range(N):
  good = input()
  goods[good] =1
    
    
print(len(goods))
### BUGGY CODE ###

n = int(raw_input())
a = map(int, raw_input().split())
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
for i in range(len(b)):
    print b[i],

### FIXED CODE ###

n = int(raw_input())
a = map(int, raw_input().split())

i = n-1
while i >= 0:
    print a[i],
    i -= 2

i = n % 2
while i < n:
    print a[i],
    i +=2
### BUGGY CODE ###

N,K = map(int,input().split(' '))

H = [int(input()) for i in range(N)]
H.sort()
ans = float('inf')
for i in range(N-K+1):
  frag = H[i:i+K]
  ans = min(ans,frag[-1] - frag[0])
  
print(ans)

### FIXED CODE ###

N,K = map(int,input().split(' '))

H = [int(input()) for i in range(N)]
H.sort()
  
print(min(H[i+K-1] - H[i] for i in range(N-K+1)))
### BUGGY CODE ###

import numpy as np

n,m,q = map(int,input().split())
li = [[0 for i in range(n+1)]for j in range(n+1)]

for i in range(m):
    l,r = map(int,input().split())
    li[l][r] += 1
    li[r][l] += 1

li = np.array(li)
for i in range(n+1):
    li[i] = np.cumsum(li[i])
li = li.tolist()
for i in range(q):
    l,r = map(int,input().split())
    point = 0
    for j in range(l,r+1):
        point += li[j][r]-li[j][l-1]
    print(point//2)

### FIXED CODE ###

import numpy as np

n,m,q = map(int,input().split())
li = [[0 for i in range(n+1)]for j in range(n+1)]

for i in range(m):
    l,r = map(int,input().split())
    li[l][r] += 1

li = np.array(li)
c = np.cumsum(li,axis=1).cumsum(axis=0).tolist()

for i in range(q):
    l,r = map(int,input().split())
    l -= 1
    point = c[r][r]
    point -= c[r][l]
    point -= c[l][r]
    point += c[l][l]
    print(point)
### BUGGY CODE ###

#073_C
n=int(input())
s=set()
for _ in range(n):
    s=s^{input()}
print(len(s))

### FIXED CODE ###

N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))
### BUGGY CODE ###

N = int(input())
list = list(map(int,input().split()))
kosuu = [0] * N
total = 0
for i in range(N):
    a = list.count(i+1)
    kosuu[i] = a
    total += ( a * (a-1) ) //2
for i in range(N):
    a = kosuu[list[i]-1]
    print(total-a*(a-1)//2 + (a-1)*(a-2)//2)

### FIXED CODE ###

N = int(input())
list = list(map(int,input().split()))
kosuu = [0] * N
kosuuu = [0] * N
total = 0
listed = sorted(list)
listed.append(-1)
i = 0
count = 1
while i < N:
    a = listed[i]
    if a == listed[i+1]:
        count += 1
    else:
        kosuu[a-1] = count
        total += ( count * (count-1) ) //2
        count = 1
    i += 1
for i in range(N):
    a = kosuu[list[i]-1]
    print(total-a*(a-1)//2 + (a-1)*(a-2)//2)