Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
# coding=utf-8

import sys

import numpy as np

n, k = map(int, sys.stdin.readline().strip().split(" "))
xyc = [l.strip().split(" ") for l in sys.stdin.readlines()]
xy = [tuple((int(_x), int(_y) if _c == "W" else int(_y) + k)) for (_x, _y, _c) in xyc]
xy = [tuple((_x % (2 * k), _y % (2 * k))) for (_x, _y) in xy]

ans = np.zeros((n, 2 * k, 2 * k), dtype=np.uint8)
for _x, _y in xy:
    check = np.zeros((n, 2 * k, 2 * k), dtype=np.uint8)
    check[_x:_x + k] = 1
    if _x > k:
        check[:_x - k] = 1
    check[:, _y:_y + k] = 1 - check[:, _y:_y + k]
    if _y > k:
        check[:, :_y - k] = 1 - check[:, :_y - k]
    check = 1 - check
    ans += check
print(np.max(ans))


### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
ub = K * 2
b = [[0 for j in range(ub + 1)] for i in range(ub + 1)]
ADD = {"B": 0, "W": K}


def create_bound(p, K, ub):
    if p - K + 1 >= 0:
        return [(p - K + 1, p + 1)]
    else:
        return [(0, p + 1), ((p - K + 1) % ub, ub)]


for i in range(N):
    x, y, c = input().split()
    nx = int(x) % ub
    ny = (int(y) + ADD[c]) % ub
    for add in [0, K]:
        for xlb, xub in create_bound((nx + add) % ub, K, ub):
            for ylb, yub in create_bound((ny + add) % ub, K, ub):
                b[xlb][ylb] += 1
                b[xlb][yub] -= 1
                b[xub][ylb] -= 1
                b[xub][yub] += 1

b_arr = np.array(b)
for i in range(ub):
    b_arr[i + 1, :] += b_arr[i, :]
for j in range(ub):
    b_arr[:, j + 1] += b_arr[:, j]
print(b_arr.max())
W, H, x, y, r = map(int, raw_input().split())
if 2*r <= W and 2*r <= H:
    if W > 0 and H > 0 and r <= 100:
        if x, y >= -100 and x, y <= 100:
            if x >= r and x <= W-r and y >= r and y <= H-r:
                print 'Yes' 
print 'No'

### FIXED CODE ###

W, H, x, y, r = map(int, raw_input().split())
if x-r >= 0 and y-r >= 0 and x+r <= W and y+r <= H:
    print 'Yes'
else: print 'No'
n=int(input())
a=list(map(int,input().split()))


if n==0:
    if a[0]==1:
        print(1)
    else:
        print(-1)
    exit()

if a[0]==1 and n!=0:
    print(-1)
    exit()

suma=sum(a)
node=1
cnt=0
for i,aa in enumerate(a[::-1]):
    cnt+=min(cnt+aa,2**(i-1))

print(cnt)
    
        


                    
        


    
print(cnt)

    
    
    





### FIXED CODE ###

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


if n==0:
    if a[0]==1:
        print(1)
    else:
        print(-1)
    exit()

if a[0]==1 and n!=0:
    print(-1)
    exit()

suma=sum(a)

cnt=1
bk=1

for i,aa in enumerate(a[1:]):
    node=min(suma,bk*2)
    cnt+=node
    #print(i,aa,node)
    bk=node-aa
    suma-=aa

if bk==0:
    print(cnt)
else:
    print(-1)
n, m = map(int, input().split())
 
A = []
for i in range(m):
    A.append(int(input()))
    
dp = [0 for i in range(n + 1)]
dp[0] = 1
 
count = 0
for i in range(n+1):
    if  i !=  A[min(count, len(A)-1)]:
        if i >= 2:
            dp[i] += (dp[i-2] + dp[i-1]) % (10 ** 9 + 7)
        elif i == 1:
            dp[i] += dp[i-1] % (10 ** 9 + 7)
    else:
            count += 1
            
print(dp[-1] % (10 ** 9 + 7))

### FIXED CODE ###

n, m = map(int, input().split())
mod = 10 ** 9 + 7
A = []
for i in range(m):
    A.append(int(input()))
    
dp = [None for i in range(n + 1)]
dp[0] = 1

for a in A:
    dp[a] = 0
    
for i in range(1,n+1):
    if dp[i] != 0:
        dp[i] = 0
        if i >= 2:
            dp[i] += (dp[i-2] + dp[i-1]) % mod
        elif i == 1:
            dp[i] += dp[i-1] % mod
            
print(dp[-1])
from collections import Counter

word = input()
c = Counter(word)
counts = c.values()
if all(map(lambda x: x % 2 == 0, counts)) print('Yes') else print('No')

### FIXED CODE ###

from collections import Counter

word = input()
c = Counter(word)
counts = c.values()
print('Yes') if all(map(lambda x: x % 2 == 0, counts)) else print('No')
N = int(input())
ans = []
n = N//2
if N == 3:
    ans = [2,3,63]
elif 4 <= N <= 15000:
    for i in range(1,n):
        ans.append(2*i)
        x = 30000 - 2*i
        ans.append(x)
    if N % 2 == 1:
        ans.append(30000)
    ans.append(3)
    ans.append(9)
else:
    for i in range(1,15000):
        ans.append(2*i)
    x = N - 14999
    for j in range(x-1):
        y = 6*j + 3
        ans.append(y)
    if x % 2 == 1:
        ans.append(30000)
    else:
        ans.append(6*x - 3)
print(*ans)
    


### FIXED CODE ###

S = input()
L = [i for i in range(97,123)]
n = len(S)
for i in range(n):
    L.remove(ord(S[i]))
if n <= 25:
    X = L[0]
    ans = S + chr(X)
else:
    T = []
    x = S[-1]
    T.append(x)
    for i in range(2,27):
        y = S[-i]
        if y > x:
            x = y
            T.append(y)
        else:
            break
    m = 26 - len(T)
    if m > 1:
        ans = S[0]
        for i in range(1,m-1):
            ans += S[i]
        for t in T:
            if t > S[m-1]:
                ans += t
                break
    elif m == 0:
        ans = -1
    else:
        for t in T:
            if t > S[m-1]:
                ans = t
                break
print(ans)
N, T = list(map(int, input().split()))

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

if N == 1:
    print(T)
    exit(T)

# t.pop(0)
ans = 0
buff = 0
for i in range(N):
    if t[i] <= T:
        buff = t[i] + T

        if N - 1 > i:
            if t[i+1] < buff:
                buff = t[i+1]

    elif t[i] > T:
        ans += buff + T
        buff = 0

print(max(ans, buff))

### FIXED CODE ###

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

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

if N == 1:
    print(T)
    exit()

# t.pop(0)
ans = 0
buff = 0
for i in range(N):
    if i != 0:
        if t[i] - t[i-1] < T:
            ans += t[i] - t[i-1]
        else:
            ans += T

ans += T
print(ans)
s = input()
n = int(input())
query = []
for i in range(n):
    query.append(input().split())
cond = 1
s = deque(s)
for i in range(n):
    if query[i] == ['1']:
        cond *= -1
    else:
        if cond == 1:
            if query[i][1] == '1':
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1] == '2':
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])

result = ''.join(s)
if cond == -1:
    result = result[::-1]
print(result)


### FIXED CODE ###

from collections import deque
s = input()
n = int(input())
query = []
for i in range(n):
    query.append(input().split())
cond = 1
word = deque(s)
for i in range(n):
    if query[i] == ['1']:
        cond *= -1
    else:
        if cond == 1:
            if query[i][1] == '1':
                word.appendleft(query[i][2])
            else:
                word.append(query[i][2])
        else:
            if query[i][1] == '2':
                word.appendleft(query[i][2])
            else:
                word.append(query[i][2])

result = ''.join(word)
if cond == -1:
    result = result[::-1]
print(result)
def main():
    n = int(input())
    S = input()
    q = int(input())
    for _ in range(q):
        t, i, c = input().split()
        if t == '1':
            S[int(i)-1] = c
        else:
            print(len(set(S[int(i)-1:int(c)])))
        
if __name__ == "__main__":
    main()   

### FIXED CODE ###

def main():
    n = int(input())
    a = ord("a")
    orda = lambda x: ord(x)-a
    s = list(map(orda, list(input())))
    q = int(input())
    bits = [BIT(n) for _ in range(26)]
    for i, si in enumerate(s, 1):
        bits[si].add(i, 1)
    for _ in range(q):
        t, i, c = input().split()
        i = int(i)
        if t == "1":
            bits[s[i-1]].add(i, -1)
            bits[ord(c)-a].add(i, 1)
            s[i-1] = ord(c)-a
        else:
            c = int(c)
            cnt = 0
            for bit in bits:
                is_in = bit.sum_(c) - bit.sum_(i-1)
                if is_in:
                    cnt += 1
            print(cnt)
            
            
class BIT:
    __slots__ = ["length", "data"]
    def __init__(self, length):
        self.data = [0]*(length+1)
        self.length = length
    
    def add(self, i, x):
        while i < self.length+1:
            self.data[i] += x
            i += i&-i
    
    def sum_(self, i):
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i&-i
        return x


if __name__ == "__main__":
    main()
import sys
n, m = map(int, input().split())

ans = 0
li = [list(map(int, input().split())) for i in range(m)] 

for i in range(m):
    for j in range(i+1, m):
        if (li[i][0] == li[j][0]) and (li[i][1] != li[j][1]):
            print(-1)
            sys.exit()

for i in range(m):
    if (li[i][1] == 1) and (n != 1):
        print(-1)
        sys.exit()
        
if n == 1:
    ans = li[i][1]
    print(ans)

elif n == 2:
    for i in range(m):
        if (li[i][0] == 1):
            ans -= (ans//10)*10
            ans += li[i][1]*10
        else:
            ans -= (ans%10)
            ans += li[i][1]
        
        if ans < 10:
            ans += 10
            
    print(ans)

else:
    for i in range(m):
        if (li[i][0] == 1):
            ans -= (ans//100)*100
            ans += li[i][1]*100
        elif (li[i][0] == 2):
            ans -= ((ans-(ans//100)*100)//10)*10
            ans += li[i][1]*10
        else:
            ans -= (ans%10)
            ans += li[i][1]
            
        if ans < 99:
            ans += 100
            
    print(ans)

### FIXED CODE ###

import sys
N, M = map(int, input().split())
li = [-1] * N
for i in range(M):
    s, c = map(int, input().split())
    if li[s-1] == -1 or li[s-1] == c:
        li[s-1] = c
    else:
        print(-1)
        sys.exit()
if N == 1:
    if li[0] == -1:
        ans = 0
    else:
        ans = li[0]
elif N == 2:
    if li[0] == 0:
        print(-1)
        sys.exit()
    else:
        if li[0] == -1:
            li[0] = 1
        if li[1] == -1:
            li[1] = 0
        ans = li[0]*10 + li[1]
else:
    if li[0] == 0:
        print(-1)
        sys.exit()
    else:
        if li[0] == -1:
            li[0] = 1
        if li[1] == -1:
            li[1] = 0
        if li[2] == -1:
            li[2] = 0
        ans = li[0]*100 + li[1]*10 + li[2]
print(ans)
from math import gcd

def cal(A,B,x):
    return int((A*x)/B) - A*int(x/B)

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        a,b = A//gcd(A,B),B//gcd(A,B)
        if N % B == 0:
            ans = cal(A,B,b*d-1)
        else:
            ans = cal(A,B,N)
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def cal(A,B,x):
    return int((A*x)/B) - A*int(x/B)

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        ans = cal(A,B,B-1)
    print(ans)

if __name__ == "__main__":
    main()
#94b
n,m,x=map(int,input().split())
ans=[0 for i in range(n+2)]
a=map(int,input().split())
for i in a:
    i=i+
    ans[i]=1

if x==n:
    print(0)
else:
    print(min(sum(ans[:x+1]),sum(ans[-x:])))
    

### FIXED CODE ###

#94b
n,m,x=map(int,input().split())
a=map(int,input().split())

up=0
down=0

for i in a:
    if i>x:
        up+=1
    else:
        down+=1
print(min(up,down))
A,B,C = [int(s) for s in input().split()]

print(C) if B B//A >= C else print(B//A)

### FIXED CODE ###

A,B,C = [int(s) for s in input().split()]
 
print(C) if B//A >= C else print(B//A)
n, m = map(int, input().split()) 
card = list(map(int, input().split()))
card.sort()
#command = [list(map(int, input().split())) for i in range(m)]
#command.sort(key=lambda x: x[1], reverse=True)

command = []

for i in range(m):
    b, c = map(int, input().split())
    command.append([c,b])

ind = 0
for i in command:
    for j in range(i[0]):
        if card[ind] > i[1]:
            break
        card[ind] = i[1]
        ind += 1
    else:
        continue
    break
print(sum(card))

### FIXED CODE ###

n, m = map(int, input().split()) 
card = list(map(int, input().split()))
card.sort()
command = [list(map(int, input().split())) for i in range(m)]
command.sort(key=lambda x: x[1], reverse=True)

ind = 0
maxNum = len(card)
for i in command:
    for j in range(i[0]):
        if maxNum < ind+1:
            break
        if card[ind] >= i[1]:
            break
        card[ind] = i[1]
        ind += 1
    else:
        continue
    break
print(sum(card))
s = input()
counter = 0
if(s[0]=="1"):
    ++counter
if(s[1]=="1):
    ++counter
if(s[2]=="1):
    ++counter

print(counter)


### FIXED CODE ###

s = input()
s = [int(i) for i in s]
ans = sum(s)
print(ans)
k,n=map(int,input().split())
lista=list(map(int,input().split())) 
ans=[]
for i in range(n):
  ans.append(lista[i+1]-lista[i])
print(k-max(ans))

### FIXED CODE ###

x=int(input())
goh=x//500
go=(x-goh*500)//5
print(1000*goh+go*5)
import math
N = int(input())
def greed(N, a):
    num = 0
    while True:
        if N == 0:
            return num
        p = int(math.log2(N) / math.log2(a))
        N -= a**p
        num += 1
A = []
for n in range(N+1):
    A.append(greed(n, 6) + greed(N-n, 9))
print(min(A))

### FIXED CODE ###

import math
N = int(input())
def greed(N, a):
    if a == 6:
        L = [6**i for i in range(7, -1, -1)]
    else:
        L = [9**i for i in range(6, -1, -1)]
    num = 0
    while True:
        if N == 0:
            return num
        for l in L:
            if l <= N:
                N -= l
                break
        num += 1
A = []
for n in range(N+1):
    A.append(greed(n, 6) + greed(N-n, 9))
print(min(A))
h = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

ans_L = [0] * (10**12 + 1)

i = 0
ans_L = [1]
while h!=1:
    h = h//2
    i += 1
    ans_L.append(2**i)

print(sum(ans_L)) 

### FIXED CODE ###

h = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

#ans_L = [0] * (10**12 + 1)

i = 0
ans_L = [1]
while h!=1:
    h = h//2
    i += 1
    ans_L.append(2**i)

print(sum(ans_L))
S=int(input())

h=S/3600

m=S%3600/60

s=S%3600%60

print(":".join(h,m,s))

### FIXED CODE ###

S=int(input())
 
h=S//3600
 
m=(S%3600)//60
 
s=(S%3600)%60
 
print('{0}:{1}:{2}'.format(h,m,s))
m,d=map(int,input())
if d>=m:
  print(m)
else:
  print(m-1)

### FIXED CODE ###

m,d=map(int,input().split())
if d>=m:
  print(m)
else:
  print(m-1)
import numpy as np

[N, K] = map(int, input().split())
num_of_perms = np.ones((K-1, K-1))
for n in range(1, K-1):
    for j in range(1, n):
        i = n - j
        num_of_perms[i][j] = num_of_perms[i-1][j] + num_of_perms[i][j-1]

[a1, b1] = map(int, input().split())
Es = [a1, b1]
for _ in range(1, N-1):
    [a, b] = map(int, input().split())
    Es.append(a)
    Es.append(b)

res = K * (K-1)
res %= 1000000007
for i in range(0, N):
    j = i + 1
    c = Es.count(j)
    if c > K-1:
        res = 0
        break
    res *= int(num_of_perms[(K-2)-(c-1)][c-1])
    res %= 1000000007

print(res)


### FIXED CODE ###

from itertools import groupby

[N, K] = map(int, input().split())

num_of_perms = [1] * (K-1)
for i in range(1, K-1):
    num_of_perms[i] = num_of_perms[i-1] * ((K - 2) - i + 1) % 1000000007

Es = []
for _ in range(0, N-1):
    [a, b] = input().split()
    Es.append(int(a))
    Es.append(int(b))

if N == 1:
    res = K
else:
    res = K * (K-1)
    res %= 1000000007
    for g in groupby(sorted(Es)):
        c = len(list(g[1]))
        if c > K-1:
            res = 0
            break
        res *= num_of_perms[c-1]
        res %= 1000000007

print(res)
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(n)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret2 = dfs(cur+1,a+l[cur],b,c)+10
    ret3 = dfs(cur+1,a,b+l[cur],c)+10
    ret4 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

### FIXED CODE ###

N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
a, b = map(int, input().split())
if product % 2 == 0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

import operator
import functools
number_list = list(map(int, input().split()))
product = functools.reduce(operator.mul, number_list)
if product % 2 == 0:
    print('Even')
else:
    print('Odd')
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h = map(int, input().split())

    ans, bef, cnt = 0, 0, 0

    for i in h:
        if i <= bef:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
        bef = i
    print(max(ans, cnt))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    s, t = input(), input()
    print(sum([1 for i in range(3) if s[i] == t[i]]))

if __name__ == '__main__':
    main()
import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  #print(a,b)
  #print(l[a])
  l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)

### FIXED CODE ###

import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  if a<=M:
  #print(a,b)
  #print(l[a])
    l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)
W,H,x,y= map(int,input().split())
big_square = W * H
square_1 = x * H
square_12 = big_square - square_1
if square_1 <= square_12:
  s = square_1
elif square_1> square_12:
  s = square_12

square_2 = W * y
square_22 = big_square - square_2
if square_2 <= square_22:
  t = square_2
elif square_2> square_22:
  t = square_22

if s<=t:
  big = t
else:
  big = s


  
if W == x *2 and H == y *2:
  way = 1
else:
  way = 0
  

print(big,way)

### FIXED CODE ###

X ,a = map(int,input().split())
if X < a:
  print(0)
if X >= a :
  print(10)
n = int(input())
a = input().split(' ')
b = []
for i in xrange(n):
    b.append(a[i])
    b = b[::-1]
print(' '.join(b))

### FIXED CODE ###

n = int(input())
a = input().split(' ')
b = []
inds = [0] * n

for i in range(int(n/2)):
    inds[i] = n-2*i
    inds[n-1-i] = n-2*i-1
if n % 2 == 1:
    inds[int(n/2)] = n-2*int(n/2)

for i, ind in enumerate(inds):
    print(a[ind-1], end="")
    if i != n-1:
        print(' ', end="")
print('')
i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
i = 1
 
for i in range(n):
  x = l + i - 1
  alist.append(x)
  
  
  
 
k = 0
m = 0
for k in range(n):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
  
  
print(sum(alist) - alist[m])
 

### FIXED CODE ###

i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
j = 0
 
for j in range(n):
  x = l + j
  alist.append(x)
  
   
k = 0
m = 0
for k in range(n-1):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
print(sum(alist) - alist[m])
N = int(input())
P = [int(input()) for _ in range(N)]

POINT = [False] * (10 ** 4 + 101)
POINT[0] = True
LP = len(POINT)

for p in P:
  for i in range(10**4+1,-1,-1):
    POINT[i+p] = POINT[i] | POINT[i+p]
  
ans = 0
for i in range(LP):
  if POINT[i] and i % 10 != 0:
    ans = max(i,ans)
    
print(ans)


### FIXED CODE ###

N = int(input())
P = [int(input()) for _ in range(N)]

POINT = [False] * (10 ** 4 + 101)
POINT[0] = True
LP = len(POINT)

for p in P:
  for i in range(10**4,-1,-1):
    POINT[i+p] = POINT[i] | POINT[i+p]
  
ans = 0
for i in range(LP):
  if POINT[i] and i % 10 != 0:
    ans = max(i,ans)
    
print(ans)
%%time
import math
import numpy as np
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
num_list =  input().split(' ')
num_list2 = [int(n) for n in num_list]
num_list3 = [0]*n
num_list4 = [0]*n
num_list5 = [0]*n
for i in range(len(num_list2)):
    num_list3[num_list2[i]-1] += 1
for i in range(len(num_list2)):
    if num_list4[num_list2[i]-1] == 0:
        size = max(0 , num_list3[num_list2[i]-1])
        if size >= 2:
            ans = comb(size,2)
        elif size == 1:
            ans = 0
        else :
            ans = 0 
        num_list4[num_list2[i]-1] = ans

    if num_list5[num_list2[i]-1] == 0:
        size = max(0 , num_list3[num_list2[i]-1]-1)
        if size >= 2:
            ans = comb(size,2)
        elif size == 1:
            ans = 0
        else :
            ans = 0 
        num_list5[num_list2[i]-1] = ans
for i in range(n):
    print(num_list5[num_list2[i]-1]-num_list4[num_list2[i]-1]+np.sum(num_list4))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
# coding: utf-8

import sys
import math


if __name__ == '__main__':
	input_list = sys.stdin.readlines()

	for num in input_list:
		target_number = int(num.replace('\n', ''))
		serial_number_list = [r for r in range(2, target_number + 1)]
		multiple_list = []

		while math.sqrt(target_number) >= serial_number_list[0]:
			serial_number = serial_number_list[0]
			i = 1
			multiple_list.append(serial_number)

			while target_number >= serial_number * i:
				
				if serial_number * i in serial_number_list:
					serial_number_list.pop(serial_number_list.index(serial_number * i))

				i += 1

		print(multiple_list)

### FIXED CODE ###

a = [True for i in range(1000000)]
i = 3
while i * i < 1000000:
    for j in range(3 * i, 1000000, 2 * i): a[j] = False
    i += 2
 
while True:
    try:
        n = int(input())
    except:
        break
 
    count = int(n >= 2) + sum(a[i] for i in range(3, n + 1, 2))
    print(count)
n,s=int(input()),input()
a=[s[0]=="E"]
for i in s[1:]:a.append(a[-1]+i=="E")
m=999999
for i in range(n):m=min(m,a[:i]+((n-i-1)-(a[-1]-a[i])))
print(m)

### FIXED CODE ###

n,s=int(input()),input()
a=[0]
for i in s:a.append(a[-1]+(i=="W"))
m=999999
for i in range(1,n+1):m=min(m,a[i-1]+((n-i)-(a[-1]-a[i])))
print(m)