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

N, K = list(map(int, input().split()))
arr = list(map(int, input().split()))
mx_sum = 0
idx = 0
for i in range(N):
    if N <= i + K - 1:
        break
    val = sum(arr[i:i+K])
    if mx_sum <= val:
        mx_sum = val
        idx = i

ans = 0
for i in range(idx, idx+K):
    ans += (arr[i] + 1) / 2
print(ans)


### FIXED CODE ###

class NumArray:
    def __init__(self, nums):
        if len(nums)>0:
            self.length = len(nums)
            self.tree = [0 for _ in range(2*self.length)]
            
            # build tree 
            n = self.length
            i = n
            j = 0
            while i<2*n:
                self.tree[i] = nums[j]
                i += 1
                j += 1
            for i in range(n-1, 0, -1):
                self.tree[i] = self.tree[i*2] + self.tree[i*2 + 1]

    def update(self, pos, val):
        # 0 <= pos < n
        n = self.length
        pos += n
        self.tree[pos] = val
        while (pos > 0):
            left = pos
            right = pos
            if pos%2==0:
                right = pos + 1
            else:
                left = pos - 1
            self.tree[pos//2] = self.tree[left] + self.tree[right]
            pos //= 2
        
    def sumRange(self, l, r):
        if l > r:
            l, r = r, l
        # 0 <= l,r < n
        n = self.length
        l += n
        r += n
        res = 0
        while l<=r:
            # check l is right child
            if l%2==1:
                res += self.tree[l]
                l += 1
            # check r is left child
            if r%2==0:
                res += self.tree[r]
                r -= 1
            l //= 2
            r //= 2
        return res
       


N, K = list(map(int, input().split()))
arr = list(map(int, input().split()))
seg_sum_tree = NumArray(arr)

mx_sum = 0
idx = 0
for i in range(N):
    if N <= i + K - 1:
        break
    val = seg_sum_tree.sumRange(i, i+K-1)
    if mx_sum <= val:
        mx_sum = val
        idx = i

ans = 0
for i in range(idx, idx+K):
    ans += (arr[i] + 1) / 2
print(ans)
### BUGGY CODE ###

k,s=map(int,input().split())
ac=[]
nums=[]
for i in range(k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if i+j+l==s:
        ac.append((i,j,l))
for i in range(len(ac)):
  if len(set(ac[i]))==1:
    nums.append(1)
  elif len(set(ac[i]))==2:
    nums.append(3)
  else:
    nums.append(6)
print(sum(nums))

### FIXED CODE ###

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

N=int(input())
A=list(map(int,input().split()))
#437235829 mod(10^9+7)
sumA=0
for i in range(N-1):
  for j in range(1,N-i):
    sumA+=A[i]*A[i+j]

print(sumA % (10**9+7))



### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
#437235829 mod(10^9+7)
sumAcol=0
sumA=0
sumtr=0
for i in range(N):
  sumtr+=A[i]**2
  sumAcol+=A[i]
  sumtr=sumtr % (10**9+7)
  sumAcol=sumAcol % (10**9+7)

for i in range(N):
  sumA+=(sumAcol*A[i])%(10**9+7)
  
sumA=(sumA-sumtr)+10**9+7

print(sumA*(5*10**8+4) % (10**9+7))
### BUGGY CODE ###

import itertools

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

count = 0
for l in list(itertools.combinations(L, 3)):
    if l[0] < l[1] + l[2] and l[1] < l[0] + l[2] and l[2] < l[0] + l[1]:
        count += 1

print(count)

### FIXED CODE ###

import itertools
import bisect

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

L = sorted(L)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        limit = x + y
        index = bisect.bisect_left(L, limit)
        count += max(0, index - j - 1)

print(count)
### BUGGY CODE ###

import heapq


N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

for i in range(Q):
  event_list.append([int(input()), 2, 0])

event_list.sort()
event_list.append([10**10, 1, 10**10])

x_set = set()
x_list = []
for time, event, x in event_list:
  if event == 1:
    x_set.add(x)
    heapq.heappush(x_list, x)
  elif event == -1:
    x_set.remove(x)
  else:
    while x_list and x_list[0] not in x_set:
      heapq.heappop(x_list)
    if x_list:
      print(x_list[0])
    else:
      print(-1)

### FIXED CODE ###

import sys
from heapq import heappop, heappush

input = sys.stdin.readline
N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

for i in range(Q):
  event_list.append([int(input()), 2, 0])

ans = []
event_list.sort()
x_set = set()
x_list = []
for time, event, x in event_list:
  if event == 1:
    x_set.add(x)
    heappush(x_list, x)
  elif event == -1:
    x_set.remove(x)
  else:
    while x_list and x_list[0] not in x_set:
      heappop(x_list)
    if x_list:
      ans.append(x_list[0])
    else:
      ans.append(-1)

print(*ans, sep='\n')
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())

m = [[0 for _ in range(W)] for _ in range(H)]
root = []
for i in range(H):
    for j, c in enumerate(input()):
        if c == "#":
            m[i][j] = 1
            root.append([i, j])

queue = deque(root)
def bfs():
    new_queue = deque([])
    while queue:
        p = queue.popleft()
        for i, j in ([-1, 0], [1, 0], [0, 1], [0, -1]):
            next_p = [p[0] + i, p[1] + j]
            if (0 <= next_p[0] < H) and (0 <= next_p[1] < W):
                if not m[next_p[0]][next_p[1]]:
                    m[next_p[0]][next_p[1]] = 1
                    new_queue.append(next_p)
    return new_queue

ans = 0
if len(root) != H*W:
    while queue:
        queue = bfs()
        ans += 1
    ans -= 1

print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())

m = [[0 for _ in range(W)] for _ in range(H)]
root = []
for i in range(H):
    # m.append(list(map(lambda x: 0 if x=="#" else 1, input()))）
    for j, c in enumerate(input()):
        if c == "#":
            m[i][j] = 1
            root.append((i, j))

# print(m)
# print(root)

queue = deque(root)
visited = deque(root)
visited_extend = visited.extend
ans = 0
while len(visited) < H*W:
    # print(visited)
    ans += 1
    new_queue = deque([])
    while queue:
        p = queue.popleft()
        for i, j in ([-1, 0], [1, 0], [0, 1], [0, -1]):
            next_p = (p[0] + i, p[1] + j)
            if (0 <= next_p[0] < H) and (0 <= next_p[1] < W):
                if not m[next_p[0]][next_p[1]]:
                    m[next_p[0]][next_p[1]] = 1
                    new_queue.append(next_p)
    visited_extend(new_queue)
    queue = new_queue
print(ans)
### BUGGY CODE ###

n, p = map(int, input().split())
i = 1
while i ** n <= p:
    i += 1
for j in reversed(range(i)):
    if (p / j ** n) % 1 == 0:
        print(j)
        break


### FIXED CODE ###

n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)
### BUGGY CODE ###

N = int(input())
A = sorted([int(x) for x in input().split()])
ans = []

for i in range(N-1):
    if (N-i) % 2 == 0:
        ans += [A[-1],A[0]]
        n = A[-1] - A[0]
        j = 0
        while n > A[j]:
            j += 1
            if j == (N-i)-1:    break
        A = A[1:j] + [n] + A[j:(N-i)-1]

    else:
        ans += [A[0],A[-1]]
        n = A[0] - A[-1]
        j = (N-i)-1
        while n < A[j]:
            j -= 1
            if j == 0:    break
        A = A[1:j] + [n] + A[j:(N-i)-1]

print(A[0])          
for i in range(N-1):
    print(ans[2*i],ans[2*i+1])



### FIXED CODE ###

N = int(input())
A = sorted([int(x) for x in input().split()])
ans = []

if A[-1] <= 0:
    print(A[-1] - sum(A[:-1]))
    a = A[-1]
    for i in range(N-1):
        print(a,A[i])
        a -= A[i]

elif A[0] >= 0:
    print(sum(A[1:])-A[0])
    a = A[0]
    for i in range(1,N-1):
        print(a,A[i])
        a -= A[i]
    print(A[N-1],a)

else:
    i = 0
    while A[i] < 0:
        i += 1
    print(sum(A[i:]) - sum(A[:i]))
    a,b = A[i-1],A[i]

    if i != N-1:
        for j in range(N-i-1):
            print(a,A[i+j+1])
            a -= A[i+j+1]
    if i != 1:
        for j in range(i-1):
            print(b,A[j])
            b -= A[j]

    print(b,a)
### BUGGY CODE ###

N,K = map(int,input().split())
H = list(map(int,input().split()))
 
dp = [0]*N
for i in range(1,N):
	L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
	dp[i] = min(L)
print(dp[-1])


### FIXED CODE ###

N,K = map(int,input().split())
H = [int(x) for x in input().split()]
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)
### BUGGY CODE ###

def nth_element(array, will):
    will -= 1
    n = len(array)
    left = 0
    right = n-1
    while right > left:
        i = left-1
        j = right
        v = array[right]
        while True:
            i += 1
            j -= 1
            while array[i]<v:i+=1
            while array[j]>v:j-=1
            if i>=j:break
            array[i],array[j] = array[j],array[i]
        array[i],array[right] = array[right],array[i]
        if i == will:break
        if i > will:
            right = i-1
        else:
            left = i+1
    return array

# from random import randrange
# for i in range(100):

n = int(input())
A = list(map(int,input().split()))
# n = randrange(2,10)
# A = [0]*n
# for j in range(n):
#     A[j] = randrange(1,1000)
k = 1 + (n-1)//2

nth_element(A,n-k+1)
# B = sorted(A)
ans = 0
M = 0
# m = B[-1]
for i in range(-1,n-1):
    ans += A[n - (i+1)//2 - 1]
    M = max(M, A[n- (i+1)//2 - 1])
    # ans -= B[n-(i+1)//2 - 1]
ans -= M
# ans += m
# if ans != 0:
#     print(n,A)
print(ans)


### FIXED CODE ###

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

A.sort(reverse = True)

ans = 0
can = 1
last = 0
for i in range(n-1):
    ans += A[last]
    can -= 1
    if can == 0:
        can = 2
        last += 1
print(ans)
### BUGGY CODE ###

N = int(input())
c = 0

for i in range(1,N):
  for j in range(1,N):
    if i*j >= N:
      break
    else:
      c += 1
print(c)

### FIXED CODE ###

N = int(input())
c = 0
for i in range(1,N):
  if i**2 >= N:
    break
  c += 1
for i in range(1,N):
  for j in range(i+1,N):
    if i*j >= N:
      break
    c += 2
print(c)
### BUGGY CODE ###

import heapq
import sys
def solve():
    input = sys.stdin.readline

    N, M = map(int, input().rstrip('\n').split())
    A = list(map(int, input().rstrip('\n').split()))
    BC = []
    for i in range(M):
        tmp = list(map(int, input().rstrip('\n').split()))
        BC.append(tmp)
    BC.sort(reverse=True, key=lambda x: x[1])
        
    heapq.heapify(A)
    for i in range(M):
        for j in range(BC[i][0]):
            if BC[i][1] < A[0]:
                break
            heapq.heapreplace(A, BC[i][1])
    
    print(sum(A))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    N, M = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    operate = []
    for _ in range(M):
        b, c = map(int,input().split())
        operate.append([b,c])
    operate.sort(reverse=True, key=lambda x:x[1])    

    rewrite = [0] * N
    idx = 0
    for b,c in operate:
        for i in range(b):
            rewrite[idx] = c
            idx += 1
            if idx == N:
                break
        if idx == N:
            break
    
    ans = 0
    for i in range(N):
        ans += max(A[i],rewrite[i])
    
    print(ans)

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

# -*- coding: utf-8 -*-
from collections import deque

H,W = list(map(int, input().rstrip().split()))
A_list = [list(input().rstrip()) for i in range(H)]
#-----

def check(matrix):
    # queue = [ ( (row, column),step ) ]
    # deque = [ ( (int, int   ),int ) ]
    queue = deque()
    
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            if matrix[i][j] == "#":
                queue.append(  ( (i, j), 0 )  )
    
    delta = [(1,0),(-1,0),(0,1),(0,-1)]
    visited = set()
    max_step = 0
    
    while queue:
        (r,c),step = queue.popleft()
        
        for d in delta:
            next_r = r + d[0]
            next_c = c + d[1]
            
            if (0 <= next_r < H) and (0 <= next_c < W) and \
               (next_r, next_c) not in visited  and \
               matrix[next_r][next_c] == ".":
            
                matrix[next_r][next_c] = "#"
                queue.append( ( (next_r, next_c), step+1 ) )
                visited.add( (next_r, next_c) )
                max_step = max(max_step, step+1)


    return max_step
#-----

ans = check(A_list)
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque

H,W = list(map(int, input().rstrip().split()))
A_list = [list(input().rstrip()) for i in range(H)]
#-----

def check(matrix):
    for i in range(len(matrix)):
        matrix[i] = ["#"] + matrix[i][:] + ["#"]
    
    matrix = [["#"]*(W+2)] + matrix[:] + [["#"]*(W+2)]
    
    
    # queue = [ (row, column) ]
    # deque = [ (int, int   ) ]
    queue = deque()
    
    for i in range(1,H+1):
        for j in range(1, W+1):
            if matrix[i][j] == "#":
                queue.append( (i, j) )
    
    
    delta = [(1,0),(-1,0),(0,1),(0,-1)]
    step = -1
    
    while queue:
        step += 1
        
        for _ in range(len(queue)):
            r,c = queue.popleft()
            
            for d in delta:
                next_r = r + d[0]
                next_c = c + d[1]
                
                if matrix[next_r][next_c] == ".":
                    matrix[next_r][next_c] = "#"
                    queue.append( (next_r, next_c) )


    return step

#-----

ans = check(A_list)
print(ans)
### BUGGY CODE ###

# Range Minimum Query
n,q = map(int,raw_input().split())
A = [2**31-1]*n
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi:
        print min(A[xi:yi+1])
    else:
        A[xi]=yi

### FIXED CODE ###

# coding: utf-8

n, q = map(int,raw_input().split())
A = [(1<<31) - 1 for i in xrange(100000)]
B = [(1<<31) - 1 for i in xrange(101)]
 
def update(i,x):
    if A[i] == (1<<31) - 1:
        A[i] = x
        B[i/1000] = min(x, B[i/1000])
    else:
        A[i] = x
        MIN = (1<<31) - 1
        for j in xrange(i/1000 * 1000, (i/1000 + 1) * 1000):
            if A[j] < MIN:
                MIN = A[j]
        B[i/1000] = MIN
 
def find(s,t):
    MIN = (1<<31) - 1
    if s/1000 == t/1000 or s/1000 + 1 == t/1000:
        for i in xrange(s, t+1):
            if A[i] < MIN:
                MIN = A[i]
    else:
        #left range
        for i in xrange(s, (s/1000 + 1) * 1000):
            if A[i] < MIN:
                MIN = A[i]
        #middle range
        for j in xrange(s/1000 + 1, t/1000):
            if B[j] < MIN:
                MIN = B[j]
         
        #right range
        for i in xrange(t/1000 * 1000, t+1):
            if A[i] < MIN:
                MIN = A[i]
    print MIN   
     
for i in xrange(q):
    com, s, t = map(int,raw_input().split())
    if com: #find
        find(s,t)
    else: #update
        update(s,t)
### BUGGY CODE ###

from collections import deque
import itertools

n,m,x=map(int, input().split())

li = deque()

sum = -1
ans = 0
for i in range(n):
    li.append(list(map(int, input().split())))

for i in range(1,n+1):
    for v in itertools.permutations(li, i):
        ok = True
        for j in range(1,m+1):
            ans = 0
            for k in v:
                ans += k[j]
                if ans >= x:
                    break
            if ans < x:
                ok = False
                break

        if ok == True:
            s=0
            for j in range(i):
                s+=v[j][0]
            if sum > s or sum == -1:
                sum=s


print(sum)

### FIXED CODE ###

from collections import deque
import itertools

n,m,x=map(int, input().split())

li = deque()

sum = -1
ans = 0
for i in range(n):
    li.append(list(map(int, input().split())))

for i in range(1,n+1):
    for v in itertools.combinations(li, i):
        ok = True
        for j in range(1,m+1):
            ans = 0
            for k in v:
                ans += k[j]
                if ans >= x:
                    break
            if ans < x:
                ok = False
                break

        if ok == True:
            s=0
            for j in range(i):
                s+=v[j][0]
            if sum > s or sum == -1:
                sum=s


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

n = int(input())
ans = 0
def num(n):
    i = 1
    a = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            a.append(i)
            if i != n//i:
                a.append(n//i)
    return len(a)

for i in range(1, n+1):
    ans += i*num(i)
print(ans)


### FIXED CODE ###

n = int(input())
ans = 0

for j in range(1, n+1):
    a = n//j
    ans += a*(a+1)*j//2
print(ans)
### BUGGY CODE ###

reverseFlag = False

S = input()
Q = int(input())

for i in range(Q):
    TFC = input().split(' ')
    if TFC[0] == '1':
        if reverseFlag == False:
            reverseFlag = True
        else:
            reverseFlag = False
    else:
        if TFC[1] == '1':
            if reverseFlag == False:
                S = TFC[2] + S
            else:
                S = S + TFC[2]
        else:
            if reverseFlag == True:
                S = TFC[2] + S
            else:
                S = S + TFC[2]
if reverseFlag == True:
    print(S[::-1])
else:
    print(S)

### FIXED CODE ###

reverseFlag = False

S = input()
Q = int(input())
S_mae = ''
S_ato = ''

for i in range(Q):
    TFC = input().split(' ')
    if TFC[0] == '1':
        reverseFlag = not reverseFlag
    else:
        if TFC[1] == '1':
            if reverseFlag:
                S_ato = S_ato + TFC[2]
            else:
                S_mae = TFC[2] + S_mae
        else:
            if reverseFlag:
                S_mae = TFC[2] + S_mae
            else:
                S_ato = S_ato + TFC[2]
if reverseFlag:
    print(S_ato[::-1] + S[::-1] + S_mae[::-1])
else:
    print(S_mae + S + S_ato)
### BUGGY CODE ###

N = int(input())
*A, = map(int, input().split())
dp = [[-1]*(N+1-i) for i in range(N+1)]
for i in range(N+1):
    dp[0][i] = 0
t = (N & 1)
for l in range(1, N+1):
    S = dp[l-1]; T = dp[l]
    t ^= 1
    T[:] = (min(S[i+1] - A[i], S[i] - A[i+l-1]) for i in range(N-l+1)) if t else  (max(S[i+1] + A[i], S[i] + A[i+l-1]) for i in range(N-l+1))
print(T[0])

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
dp = [[-1]*(N+1-i) for i in range(N+1)]
for i in range(N+1):
    dp[0][i] = 0
t = (N & 1)
for l in range(1, N+1):
    S = dp[l-1]; T = dp[l]
    t ^= 1
    if t:
        T[:] = (min(S[i+1] - A[i], S[i] - A[i+l-1]) for i in range(N-l+1))
    else:
        T[:] = (max(S[i+1] + A[i], S[i] + A[i+l-1]) for i in range(N-l+1))
print(dp[N][0])
### BUGGY CODE ###

import fractions
import collections
import copy

n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()

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

pri_li = []

for i in range(n):
    pri_li.append(collections.Counter(prime_factorize(ai[i])))

pri_li0 = copy.copy(pri_li[0])

for i in range(n-1):
    pri_li[0] += pri_li[i+1]

b_li = [pri_li[0]-pri_li0]

for i in range(1,n):
    b_li.append(pri_li[0]-pri_li[i])

com = copy.copy(b_li[0])
#print(com)
for i in range(1,n):
    com &= b_li[i]
#print(com)
#exit()
for i in range(n):
    b_li[i] -= com

ans = 0

for i in range(n):
    tmp = 1
    #print(len(b_li[i]))
    keys = b_li[i].keys()
    #print(keys)
    for j in keys:
        #print(b_li[i][j])
        #exit()
        tmp *= pow(j, b_li[i][j],mod)
        tmp %= mod
    ans += tmp
    ans %= mod

print(ans%mod)


### FIXED CODE ###

import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)
    kari %= mod

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    kari *= pow(ai[i],mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)
### BUGGY CODE ###

N,M=map(int, input().split())
lis={}
ly=[]
for i in range(M):
    t1,t2 =list(map(int,input().split()))
    lis[t2]=t1
    ly.append(t2)
d={}
for i in sorted(lis):
    d[lis[i]]=d.get(lis[i],0)+1
    ly[ly.index(i)]='{:0=6}{:0=6}'.format(lis[i],d[lis[i]])
for i in ly:print(i)

### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    lines = [input() for j in range(m)]
 
    cities = {}
    for i in range(m):
        p, y = map(int, lines[i].split())
        if p in cities:
            cities[p].append((i, y))
        else:
            cities[p] = [(i, y)]
 
    outputs = [None] * m
    for pref, city_list in cities.items():
        city_list.sort(key=lambda x: x[1])
        #print(pref, city_list)
        city_no = 1
        for city in city_list:
            outputs[city[0]] = "{:06d}{:06d}".format(pref, city_no)
            city_no += 1
 
    for output in outputs:
        print(output)
    return
 
 
main()
### BUGGY CODE ###

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

    def combinations_count(n, r):
        """ 組み合わせ総数を計算 """
        import math
        ret = 0 if n < r else math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
        return ret

    unique_values = set(A)

    all_sum = 0  # 総数
    # all_sumを作成
    for u in unique_values:
        cnt = A.count(u)
        all_sum += combinations_count(cnt, 2)

    for i in range(N):
        cnt = A.count(A[i])
        ans = all_sum - combinations_count(cnt, 2) + combinations_count(cnt - 1, 2)
        print(ans)


if __name__ == '__main__':
    q4()


### FIXED CODE ###

def q4():
    import collections
    N = int(input())
    A = [int(i) for i in input().split()]

    def n_C_2(n):
        """ n個から2個選ぶ組み合わせ総数を計算 """
        ret = 0 if n < 2 else n * (n - 1) / 2
        return ret

    all_sum = 0  # 総数
    counter = collections.Counter(A)
    # all_sumを作成
    for v in counter.values():
        all_sum += n_C_2(v)

    for i in range(N):
        cnt = counter[A[i]]  # i番目の値の出現回数を取得
        ans = all_sum - n_C_2(cnt) + n_C_2(cnt - 1)
        print(int(ans))


if __name__ == '__main__':
    q4()