Harryxun/stf_run huggingface dataset:
from functools import reduce

mod = 10**9+7

def modcumprod(*args):
    return reduce(lambda x, y: x*y%mod, args)

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

if n == k:
    print(modcumprod(*a))
elif max(a) < 0 and k % 2 == 1:
    a.sort(reverse=True)
    print(modcumprod(*a[:k]))
else:
    a.sort(key=abs, reverse=True)
    res = 1
    cnt_neg = 0
    pos1 = neg1 = 0
    for e in a[:k]:
        res *= e
        res %= mod
        if e > 0:
            pos1 = e
        else:
            cnt_neg += 1
            neg1 = e

    if res == 0 or cnt_neg % 2 == 0:
        print(res)
    else:
        pos2 = neg2 = 0
        for e in a[k:]:
            if e > 0 and not pos2:
                pos2 = e
            elif e < 0 and not neg2:
                neg2 = e
            if pos2 and neg2:
                break
        if abs(pos1 * pos2) < abs(neg1 * neg2):
            res *= pow(pos1, -1, mod)
            res *= neg2
            res %= mod
        else:
            res *= pow(neg1, -1, mod)
            res *= pos2
            res %= mod
        print(res)


### FIXED CODE ###

from functools import reduce

mod = 10**9+7

def modcumprod(*args):
    return reduce(lambda x, y: x*y%mod, args)

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

if n == k:
    print(modcumprod(*a))
elif max(a) < 0 and k % 2 == 1:
    a.sort(reverse=True)
    print(modcumprod(*a[:k]))
else:
    a.sort(key=abs, reverse=True)
    res = 1
    cnt_neg = 0
    pos1 = neg1 = 0
    for e in a[:k]:
        res *= e
        res %= mod
        if e > 0:
            pos1 = e
        else:
            cnt_neg += 1
            neg1 = e

    if res == 0 or cnt_neg % 2 == 0:
        print(res)
    else:
        pos2 = neg2 = 0
        for e in a[k:]:
            if e > 0 and not pos2:
                pos2 = e
            elif e < 0 and not neg2:
                neg2 = e
            if pos2 and neg2:
                break
        if abs(pos1 * pos2) < abs(neg1 * neg2) and pos1:
            res *= pow(pos1, -1, mod)
            res *= neg2
            res %= mod
        else:
            res *= pow(neg1, -1, mod)
            res *= pos2
            res %= mod
        print(res)
string,sub_string=map(str,input().split())
results = 0
sub_len = len(sub_string)
for i in range(len(string)):
  if string[i:i+sub_len] == sub_string:
    if len(sub_string)-len(string) ==1:
      print('Yes')
  else:
    print('No')

### FIXED CODE ###

string,string2=input(),input()
string2=string2[0:len(string2)-1]
print("Yes" if string==string2 else "No")
N=int(input())

sum=0
while a in range(N+1):
  if a%3 !=0 and a%5 !=0:
    sum=sum+a
    a = a + 1
  else:a=a+1
print(sum)


### FIXED CODE ###

N=int(input())
a=1
sum=0
while a in range(N+1):
  if a%3 !=0 and a%5 !=0:
    sum=sum+a
    a = a + 1
  else:a=a+1
print(sum)
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values() if i == n]))


### FIXED CODE ###

n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {i:0 for i in range(1,m+1)}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values() if i == n]))
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


import numpy as np
dp = np.zeros((X, Y, Z), dtype=int)
dp[0, 0, 0] = A[0] + B[0] + C[0]

from itertools import product
for a, b, c in product(range(X), range(Y), range(Z)):
    if a + 1 != X:
        dp[a+1, b, c] = dp[a, b, c] - A[a]+A[a+1]
    if b + 1 != Y:
        dp[a, b+1, c] = dp[a, b, c] - B[b]+B[b+1]
    if c + 1 != Z:
        dp[a, b, c + 1] = dp[a, b, c] - C[c] + C[c + 1]

K = min(K, X*Y*Z)
ls = sorted(dp.reshape(-1), reverse=True)
for ans in ls[:K]:
    print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

from itertools import product

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

ABC = ABC[:K]

print(*ABC, sep='\n')
m = map(int,raw_input().split())
if m[0] < m[1]:
 print a + " < " + b
elif m[0] == m[1]:
 print a + " == " + b
elif m[0] > m[1]:
 print a + " > " + b

### FIXED CODE ###

m = map(int,raw_input().split())
if m[0] < m[1]:
 print "a" + " < " + "b"
elif m[0] == m[1]:
 print "a" + " == " + "b"
elif m[0] > m[1]:
 print "a" + " > " + "b"
[A,B,C]=[int(i) for i in input().split()]
if A==B:
	if B!=C:
		print("Yes")
	else:
		print("No")
else:
	if B==C:
		print("No")
	else:
		if A=C:
			print("Yes")
		else:
			print("No")

### FIXED CODE ###

[A,B,C]=[int(i) for i in input().split()]
if A==B:
	if B!=C:
		print("Yes")
	else:
		print("No")
else:
	if B==C:
		print("Yes")
	else:
		if A==C:
			print("Yes")
		else:
			print("No")
list = map(int, raw_input().split())
a = list[0]
b = list[1]
print a*b + " " + (a+b)*2

### FIXED CODE ###

a, b = map(int, raw_input().split())
print a*b,
print (a+b)*2
_=input()
A=eval('*'.join(input().split()))
print(-1 if A>10**18 else A)

### FIXED CODE ###

#169B
N=int(input())
As=list(map(int,input().split()))

if min(As)==0:
    num=0
else:
    num=1
    for i in range(N):
        num *= As[i]
        if num>10**18:
            num=-1
            break

print(num)
list1=[]
for i in range(1,160):
    if i<=9:
        list1.append(i)
    elif i%10==0:
        pass
    elif i<=19:
        a=(i-10)*10+9
        list1.append(a)
    elif i<=29:
        a=(i-20)*100+99
        list1.append(a)
    elif i<=39:
        a=(i-30)*1000+999
        list1.append(a)
    elif i<=49:
        a=(i-40)*10000+9999
        list1.append(a)
    elif i<=59:
        a=(i-50)*100000+99999
        list1.append(a)
    elif i<=69:
        a=(i-60)*1000000+999999
        list1.append(a)
    elif i<=79:
        a=(i-70)*10000000+9999999
        list1.append(a)
    elif i<=89:
        a=(i-80)*100000000+99999999
        list1.append(a)
    elif i<=99:
        a=(i-90)*1000000000+999999999
        list1.append(a)
    elif i<=109:
        a=(i-100)*10000000000+9999999999
        list1.append(a)
    elif i<=119:
        a=(i-110)*100000000000+99999999999
        list1.append(a)
    elif i<=129:
        a=(i-120)*1000000000000+999999999999
        list1.append(a)
    elif i<=139:
        a=(i-130)*10000000000000+9999999999999
        list1.append(a)
    elif i<=149:
        a=(i-140)*100000000000000+99999999999999
        list1.append(a)
    elif i<=159:
        a=(i-150)*1000000000000000+999999999999999
        list1.append(a)
#print(list1[143])
K=int(input())
for j in range(K):
    print(list1[j])

### FIXED CODE ###

K=int(input())
D={}
for i in range(1,10**4):
    for j in range(12):
        Sunuke=str(i)+("9"*j)
        if len(Sunuke)<=15 and Sunuke not in D:
            S=0
            for k in range(len(Sunuke)):
                S+=int(Sunuke[k])
            D[int(Sunuke)]=S
D=list(D.items())
D.sort()
#print(D[:10])
import bisect

d=[10**16 for i in range(len(D))]
d[0]=0
ans=[0 for i in range(len(D))]
for i in range(len(D)):
    ans[bisect.bisect_right(d,D[i][0]/D[i][1])]=D[i][0]
    d[bisect.bisect_right(d,D[i][0]/D[i][1])]=D[i][0]/D[i][1]
    
#print(ans[:50])
ANS=[]
MAX=0
for i in range(len(ans)):
    if ans[i]>MAX:
        ANS.append(ans[i])
        MAX=ans[i]
#print(ANS[:100])
for i in range(K):
    print(ANS[i])
#print(d[:10])
H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start]=0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start]=1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)

### FIXED CODE ###

H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall and left > 0:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start] = 0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start] = 1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)
i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    print "Case %d : %d" % (i,x)
    i += 1

### FIXED CODE ###

i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    else:
        print ("Case {}: {}".format(i,x))
        i += 1
H,W,K = map(int, input().split())
cnt = 0
ans = []
z = 1
for i in range(H):
    f = list(input())
    if f.count("#") == 0: 
        z += 1
    elif f.count("#") == 1:
        cnt += 1
        for i in range(z):
            ans.append([cnt]*W)
        z = 1
    else:
        _c = 0
        cnt += 1
        row = []
        for j,s in enumerate(f):
            if s == "#":
                if _c == 0:
                    _c += 1
                else:
                    _c += 1
                    cnt += 1
            row.append(cnt)
        for i in range(z):
            ans.append(row)
        z = 1

for z in range(z-1):
    ans.append(row)

for i in range(H):
    print(*ans[i])

### FIXED CODE ###

H,W,K = map(int, input().split())
fields = [list(input()) for i in range(H)]
bins = []
hs = [] #区切る位置
ws = []
for i,f in enumerate(fields):
    if "#" in f:
        hs.append(i)
hs = hs+[H]
cnt = 0
ans = []
h_fr = 0
for i in range(1,len(hs)):
    h_to = hs[i]
    if h_fr - h_to == 0:continue
    f = fields[h_fr:h_to]
    # print(i,h_fr,h_to,f)
    ws = []
    for j in range(W):
        for i in range(h_fr,h_to):
             if fields[i][j] == "#":
                 ws.append(j)
    ws += [W]
    cnts = []
    w_fr = 0
    for j in range(1,len(ws)):
        w_to = ws[j]
        if w_to-w_fr > 0:
            cnt += 1
            cnts.extend([cnt]*(w_to-w_fr))
            w_fr = w_to
    for i in range(h_to-h_fr):
        ans.append(cnts)
    h_fr = h_to
# print(ans)
for f in ans:
    print(*f)
import fractions
a, b, c, d = map(int, input().split())

#
c_d = c * d / fractoins.gcd(c, d)

def check(cc):
    if a%cc == 0:
        tmp_a = a
    else:
        tmp_a = cc*(a//cc+1)
    if b%cc == 0:
        tmp_b = b
    else:
        tmp_b = cc*(b//cc)

    #print('a, b')
    #print(tmp_a, tmp_b)
    if tmp_a > b:
        return 0
    elif tmp_b < a:
        return 0
    tmp = tmp_b-tmp_a

    return (tmp // cc) + 1

# c
tmp_1 = check(c)
#d
tmp_2 = check(d)

tmp_3 = check(c_d)


#print(tmp_1, tmp_2, tmp_3)

print(int((b-a)-(tmp_1+tmp_2-tmp_3*2)))


### FIXED CODE ###

import fractions

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

c_d = (c * d) // fractions.gcd(c, d)

a -= 1

tmp_b = b - (b//c + b//d - b//c_d)
tmp_a = a - (a//c + a//d - a//c_d)

print(tmp_b-tmp_a)
height =[]
inp = ""
while True:
    inp = input()
    if inp == "":break
    else: height.append(int(inp))

height.sort(reverse=True)
for j in range(0,3):
    print(str(height[j]))

### FIXED CODE ###

height =[]
inp = ""
for i in range(0,10):
    inp = input()
    height.append(int(inp))
height.sort(reverse=True)
for i in range(0,3):
    print(str(height[i]))
import numpy as np

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

if 0 in l:
    result = 0
else:
    arr = np.asarray(l)
    p = np.prod(arr)

    if p > 10 **18:
        p = -1

print(p)

### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int,input().split()))
    
    if 0 in a:
        print(0)
        return
    
    prod = 1
    for i in a:
        prod *= i
        if prod > 10 ** 18:
            print(-1)
            return
    
    print(prod)
    
    return

main()
n,m = map(int,input().split())
card =[[0]*n for _ in range(m)]
for i in range(m):
    switch = list(map(int,input().split()))[1:]
    for k in switch:
        card[i][k-1] = 1
##どこに繋がっているかを配列で表現

#print(card)


ans =list(map(int,input().split()))
cnt=0
from itertools import combinations
##全通りを調べる
for epoch in range(1,n+1):
    
    for j in combinations(range(1,n+1),epoch):
        sco =[]
        for lisa in card:##一つずつの照明について調べる
            score =0
            for l in j:
                score += lisa[l-1]
                
            sco.append(score)
        #print(sco)
        if list(np.array(sco)%2) == ans:
            cnt+=1
            
print(cnt)

### FIXED CODE ###

import numpy as np
from itertools import combinations
n,m = map(int,input().split())
card =[[0]*n for _ in range(m)]
for i in range(m):
    switch = list(map(int,input().split()))[1:]
    for k in switch:
        card[i][k-1] = 1
##どこに繋がっているかを配列で表現

#print(card)


ans =list(map(int,input().split()))
cnt=0
from itertools import combinations
##全通りを調べる
for epoch in range(1,n+1):
    
    for j in combinations(range(1,n+1),epoch):
        sco =[]
        for lisa in card:##一つずつの照明について調べる
            score =0
            for l in j:
                score += lisa[l-1]
                
            sco.append(score)
        #print(sco)
        if list(np.array(sco)%2) == ans:
            cnt+=1
    

if ans == [0]*m:
    cnt+=1
        
print(cnt)
N=int(input())
Hi=list(map(int,input().split()))

ans=[0]*N

for i in range (N):
    a=0
    # if Hi[i]<Hi[i-1]:
    #     continue
    for j in range(N-i-1):
        if Hi[i+j]>=Hi[i+j+1]:
            a+=1
        else:
            break
    ans[i]=a
    i=i+j

print(max(ans))

### FIXED CODE ###

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

# ans=[0]*N

# for i in range (N):
#     a=0
#     # if Hi[i]<Hi[i-1]:
#     #     continue
#     for j in range(N-i-1):
#         if Hi[i+j]>=Hi[i+j+1]:
#             a+=1
#         else:
#             break
#     ans[i]=a

# print(max(ans))

ans=0
temp=0

for i in range(1,N):
    if Hi[i]<=Hi[i-1]:
        temp+=1
    else:
        if temp>ans:
            ans=temp
        else:
            pass
        temp=0
else:
    if temp>ans:
        ans=temp

print(ans)
n = input()
a = list(map((int%10**9+7), input().split()))
sum = 0

for i in range(len(a)):
    for j in range(len(a)):
        if i<j:
            sum += (a[i]) * (a[j])
    
print(sum % 10**9+7)

### FIXED CODE ###

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

for i in range(len(a)):
    b -= a[i]
    sum += a[i]*b   

print(sum%(10**9+7))
#from collections import Counter

import numpy as np

n = int(input())
nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    #print(l)
    nums[l] += 1

set_vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

#cumsum = np.cumsum(nums)

#print(set_vals)
len_set = len(set_vals)
out = 0
for i in range(len_set):
    val1 = set_vals[i]
    num_i = nums[val1]
    if num_i >= 3:
        out += (num_i * (num_i-1) * (num-2) // 6)
    
    if num_i >= 2:
        val2 = set_vals[i]
        for j in range(i+1, len_set):
            val3 = set_vals[j]
            num_j = nums[val3]
            if 2 * val1 <= val3:
                break

            out += ((num_i * (num_i-1)) // 2) * num_j

    for j in range(i+1, len_set):
        val2 = set_vals[j]
        num_j = nums[val2]

        if num_j >= 2:
            out += (num_i *  num_j * (num_j - 1) // 2 )

        for h in range(j+1, len_set):
            val3 = set_vals[h]
            #print(val1, val2, val3)
            num_h = nums[val3]
            if val1 + val2 <= val3:
                break

            #print("num", num_i, num_j, num_h)
            out += (num_i * num_j * num_h)

print(out)        

### FIXED CODE ###

#from collections import Counter

#import numpy as np

input = raw_input
n = int(input())
#nums = np.zeros(2001, dtype=int)
nums = [0] * 2001
#nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    #print(l)
    nums[l] += 1

set_vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

#cumsum = np.cumsum(nums)

#print(set_vals)
len_set = len(set_vals)
out = 0
for i in range(len_set):
    val1 = set_vals[i]
    num_i = nums[val1]
    if num_i >= 3:
        out += (num_i * (num_i-1) * (num_i-2) // 6)
    
    if num_i >= 2:
        val2 = set_vals[i]
        for j in range(i+1, len_set):
            val3 = set_vals[j]
            num_h = nums[val3]
            if 2 * val1 <= val3:
                break

            out += ((num_i * (num_i-1)) // 2) * num_h

    for j in range(i+1, len_set):
        val2 = set_vals[j]
        num_j = nums[val2]

        if num_j >= 2:
            out += (num_i *  num_j * (num_j - 1) // 2 )

        for h in range(j+1, len_set):
            val3 = set_vals[h]
            #print(val1, val2, val3)
            num_h = nums[val3]
            if val1 + val2 <= val3:
                break

            #print("num", num_i, num_j, num_h)
            out += (num_i * num_j * num_h)

print(out)
a,b = list(map(int,input().split()))
ls = [['#']*100 for i in range(50)] + [['.']*100 for i in range(50)]
i,j = 0,0
for c in range(a - 1):
    ls[i][j] = '.'
    if i >= 98:
        j = 0;i += 2
    else:
        j += 2
i,j = 51,0
for c in range(b - 1):
    ls[i][j] = '#'
    if i >= 98:
        j = 0;i += 2
    else:
        j += 2

for j in range(100):
    print(''.join(ls[j]))

### FIXED CODE ###

a,b = list(map(int,input().split()))
ls = [['#']*99 for i in range(49)] + [['.']*99 for i in range(49)]
i,j = 0,0
for c in range(a - 1):
    ls[i][j] = '.'
    if j >= 97:
        j = 0;i += 2
    else:
        j += 2
i,j = 51,0
for c in range(b - 1):
    ls[i][j] = '#'
    if j >= 97:
        j = 0;i += 2
    else:
        j += 2
print(98,99)
for j in range(98):
    print(''.join(ls[j]))
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

N, K = [int(x) for x in stdin.readline().rstrip().split()]
V = list(map(int,stdin.readline().rstrip().split()))

getV_num = min(N, K)

ans = 0

for i in range(getV_num//2+1, getV_num+1):
    toru = i
    sute = K-i

    #print(toru)
    #print(sute)
    
    for j in range(toru+1):
        leftn = j
        rightn = (toru - j)*-1

        #print(leftn, rightn)

        if rightn == 0:
            data = V[:leftn]
        elif leftn == 0:
            data = V[rightn:]
        else:
            data = V[:leftn] + V[rightn:]
        #print(data)

        for _ in range(sute):
            data.sort()
            if data[0] < 0:
                del data[0]

        #print(data)

        ans = max(ans, sum(data))

print(ans)


### FIXED CODE ###

from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

N, K = [int(x) for x in stdin.readline().rstrip().split()]
V = list(map(int,stdin.readline().rstrip().split()))

getV_num = min(N, K)

ans = 0

for i in range(getV_num+1):
    toru = i
    sute = K-i

    #print(toru)
    #print(sute)
    
    for j in range(toru+1):
        leftn = j
        rightn = (toru - j)

        data = []


        for k in range(leftn):
            data.append(V[k])

        for k in range(rightn):
            data.append(V[N-1-k])

        data.sort()
        for _ in range(sute):
            if data:
                if data[0] < 0:
                    del data[0]
                else:
                    break
            else:
                break

        ans = max(ans, sum(data))

print(ans)
n = int(input())
A = list(map(int, input().split())
from collections import Counter
L = list(Counter(A))
LV = L.values()

ans = 0
for x in LV:
    ans += x*(x-1)//2

for k in range(n):
    print(ans-(A[k]-1)) 

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
from collections import Counter
D = Counter(A)
L = list(D.values())

ans = 0
for x in L:
    ans += x*(x-1)//2

for k in range(n):
    print(ans-(D[A[k]]-1))