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

from sys import stdin
import numpy as np
def main():

    input = stdin.readline

    N,K = map(int,input().split())
    p_list = np.asarray(list(map(int,input().split())))

    max_sum = 0
    listN = list(range(N))
    for i in listN:
        tmp_sum = np.sum(p_list[i:i+K])
        if(max_sum < tmp_sum):
            max_sum = tmp_sum
            ichi = i

    kitaichi = ((p+1)/2 for p in p_list[ichi:ichi+K])

    print(sum(kitaichi))

if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin

def main():

    input = stdin.readline

    N,K = map(int,input().split())
    p_list = [(p+1)/2 for p in list(map(int,input().split()))]

    # Sを計算
    S = [0]
    for p in p_list:
        S.append(S[-1] + p)
        # print(S)

    # i:i+kを計算

    maxs = 0
    for i in range(N-K+1):
        p_num = S[i+K] - S[i]
        if(maxs < p_num):
            maxs = p_num
    
    print(maxs)

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

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

L = [0] * M
R = [0] * M

ans = set(range(1,N+1))

for i in range(M):
    L_tmp, R_tmp = map(int, input().split())
    ans = ans & set(range(L_tmp,R_tmp+1))

print(len(ans))


### FIXED CODE ###

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

L_max = 1
R_min = N

for i in range(M):
    L, R = map(int, input().split())
    L_max = max(L_max,L)
    R_min = min(R_min,R)

ans = set(range(L_max,R_min+1))

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

n = int(input())
num_list = []

for _ in range(n):
    cmd = (input().split())
    if   cmd[0] == 'insert':
        num_list.insert(0,cmd[1])
    elif cmd[0] == 'delete':
        if cmd[1] in num_list:
            num_list.remove(cmd[1])
    elif cmd[0] == 'deleteFirst':
        del(num_list[0])
    else:
        num_list.pop()

print(' '.join(num_list))


### FIXED CODE ###

from collections import deque
dq = deque()
for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b)
print(" ".join(dq))
### BUGGY CODE ###

a,b = map(int,input().split())
for k in range(1,10**9):
  if abs(a-k) == abs(b-k):
    print(k)
    exit()
print("IMPOSSIBLE")

### FIXED CODE ###

a,b = map(int,input().split())
if (a+b)/2 == (a+b)//2:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")
### BUGGY CODE ###

n = int(input())
res = 1

for i in range(1,n+1):
    res *= i

print(res%1000000007)

### FIXED CODE ###

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

n,k = (int(i) for i in input().split())
s = input()

start = s[0]
arr = []
pre = start
cnt = 0
for x in s:
    if x == pre:
        cnt+=1
        continue
    else:
        pre = x
        arr.append(cnt)
        cnt = 1

arr.append(cnt)

if len(arr) == 1:
    print(arr[0])
    exit()
m = 0
if start == "1":
    for i in range((len(arr)//2)-k+1):
        m = max(sum(arr[2*i:2*i+2*k+1]), m)

else:
    m = sum(arr[:2*k])
    for i in range(((len(arr)+1)//2)-k):
        m = max(sum(arr[2*i+1:2*i+2*k+2]), m)
    
print(m)
        

### FIXED CODE ###

n,k = (int(i) for i in input().split())
s = input()

start = s[0]
arr = []
pre = start
cnt = 0
for x in s:
    if x == pre:
        cnt+=1
        continue
    else:
        pre = x
        arr.append(cnt)
        cnt = 1

arr.append(cnt)

if len(arr) == 1:
    print(arr[0])
    exit()

m = 0
if start == "1":
    now = sum(arr[:2*k+1])
    m = now
    for i in range(1, (len(arr)//2)-k+1):
        now = now - arr[2*i-1] - arr[2*i-2] + sum(arr[2*i+2*k-1:2*i+2*k+1]) 
        m = max(now, m)

else:
    m = sum(arr[:2*k])
    now = sum(arr[1:2*k+2])
    m = max(now, m)
    for i in range(1, ((len(arr)+1)//2)-k):
        now = now - arr[2*i] - arr[2*i-1] + sum(arr[2*i+2*k:2*i+2*k+2])
        m = max(now, m)
    
print(m)
### BUGGY CODE ###

from collections import defaultdict
import sys

n = int(input())
orders = [[x - 1 for x in list(map(int, input().split()))] for _ in range(n)]

d = defaultdict(list)
e = defaultdict(list)

for i in range(n):
	for j in range(n - 2):
		a1, a2 = min(i, orders[i][j]), max(i, orders[i][j])
		b1, b2 = min(i, orders[i][j + 1]), max(i, orders[i][j + 1])
		d[(a1, a2)].append((b1, b2))
		e[(b1, b2)].append((a1, a2))
		if j == n - 3:
			d[(b1, b2)].append((-1, -1))
			e[(-1, -1)].append((b1, b2))

visited = [[0 for _ in range(n)] for _ in range(n)]
cnt_dict = defaultdict(int)

ans = []
def visit(cur):
	a, b = cur
	if visited[a][b] == -1:
		print(-1)
		sys.exit()
	elif visited[a][b] == 0:
		visited[a][b] = -1
		if e[cur]:
			cnt = max([visit(x) for x in e[cur]])
		else:
			cnt = 0
		visited[a][b] = 1
		ans.append(cur)
		cnt_dict[cur] = max(cnt_dict[cur], cnt + 1)
		return cnt + 1
	else:
		return cnt_dict[cur]

print(visit((-1, -1)) - 1)

### FIXED CODE ###

from collections import deque

n = int(input())
orders = [deque([x - 1 for x in list(map(int, input().split()))] + [-1]) for _ in range(n)]

nxt = [orders[i].popleft() for i in range(n)]
days = [0 for _ in range(n)]

q = deque([i for i in range(n)])
while q:
	a = q.popleft()
	b = nxt[a]
	if nxt[nxt[a]] == a:
		days[a], days[b] = [max(days[a], days[b]) + 1 for _ in range(2)]
		nxt[a] = orders[a].popleft()
		nxt[b] = orders[b].popleft()
		q.append(a)
		q.append(b)

if sum(nxt) == -n:
	print(max(days))
else:
	print(-1)
### BUGGY CODE ###

import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
counter=[0 for i in range(N+1)]
ans2=[0 for i in range(N+1)]
B=[]
for i in A:
    counter[i]+=1
ans=[0 for i in range(N+1)]
for i,value in enumerate(counter):
    if value>0:
        ans[i]=(value*(value-1)//2)
        ans2[i]=((value-1)*(value-2)//2)
for i in A:
    ans1=copy.deepcopy(ans)
    ans1[i]=ans2[i]
    print(sum(ans1))


### FIXED CODE ###

import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
counter=[0 for i in range(N+1)]
ans2=[0 for i in range(N+1)]
B=[]
for i in A:
    counter[i]+=1
ans=[0 for i in range(N+1)]
for i,value in enumerate(counter):
    if value>0:
        ans[i]=(value*(value-1)//2)
        ans2[i]=((value-1)*(value-2)//2)
total=sum(ans)
for i in A:
    temp=total
    temp-=ans[i]
    temp+=ans2[i]
    print(temp)
### BUGGY CODE ###

#2019/10/16
N, *a = map(int, open(0).read().split())
#print(N, a)
i=0
cnt=1
button=[]
while(True):
    #print("i=",i, "a[i]=",a[i])
    #print("button=", button)
    i=a[i]-1
    if i==1:
        print(cnt)
        break
    elif i in button:
        print("-1")
        break
    else:
        button.append(i)
        cnt+=1

### FIXED CODE ###

#2019/10/16
N, *a = map(int, open(0).read().split())
#print(N, a)
i=0
cnt=0
button=[]
while(True):
    #print("i=",i, "a[i]=",a[i])
    #print("button=", button)
    if i==1:
        print(cnt)
        break
    if cnt >= N:
        print("-1")
        break
    cnt+=1
    i=a[i]-1
### BUGGY CODE ###

mod = int(1e9 + 7)
N = int(input())
A = list(map(int, input().split()))
S = 0
j = 1
while A != [0 for i in range(N)]:
  m = 0
  n = 0
  for i in range(N):
    if A[i] % 2 == 1:
      m += 1
    else:
      n += 1
    A[i] //= 2
  S += (m * n) * j
  j *= 2
S %= mod
print(S)

### FIXED CODE ###

mod = int(1e9 + 7)
N = int(input())
A = [format(i, '060b') for i in map(int, input().split())]
S = 0
for k in range(60):
  s = [b[59-k] for b in A]
  v = s.count('0')*s.count('1')
  S += (v<<k)
S %= mod
print(S)
### BUGGY CODE ###

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

ws = list(map(int, sys.stdin.read().split()))
h = sum(ws)
p = h // k


def isEnough(A, n, k, w):
    ps = [w for x in range(k)]
    j = 0
    for i in range(n):
        a = A[i]
        p = ps[j]
        if p < a:
            j += 1
            if j < k:
                p = ps[j]
            else:
                return False
        dif = p - a
        if dif < 0:
            return False
        else:
            ps[j] = dif
    return True

while not isEnough(ws, n, k, p):
    p += 1

print(p)

### FIXED CODE ###

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

ws = list(map(int, sys.stdin.read().split()))

def check(A, n, k, mid):
    j = 0
    for i in range(k):
        p = mid
        s = 0
        while (s + A[j]) <= p:
            s += A[j]
            j += 1
            if ( j == n ):
                return n
    return j

def solve(A, n, k):
    h = 100000 * 10000
    l = 0
    while 1 < (h - l):
        mid = (h + l) // 2
        v = check(A, n, k, mid)
        if v < n:
            l = mid
        else:
            h = mid
    return h

print(solve(ws, n, k))
### BUGGY CODE ###

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

A_e = list(set(A))

#print(list(set(A)))

for i in A_e:
    x = A.count(i)
    if x >= 2:
        xc2 = x*(x-1)/2
        X = X + xc2
#print("ALL", X)

for k in range(N):
    xk = A.count(A[k])
    print(int(X-xk+1))


### FIXED CODE ###

from collections import Counter
N = int(input(""))
A = list(map(int,input().split()))
X = 0

A_e = list(set(A))

x = Counter(A)

for i in A_e:
    if x[i] >= 2:
        xc2 = x[i]*(x[i]-1)/2
        X = X + xc2

for k in A:
    print(int(X-x[k]+1))
### BUGGY CODE ###

N,K=map(int,input().split())
H=[0]*(K+1)

ans=0
i=K
while i>=1:
    H[i]=(K//i)**N
    j=2
    while j*i<=K:
        H[i]-=H[j*i]
        j+=1
    ans+=H[i]*i
    i-=1

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

### FIXED CODE ###

N,K=map(int,input().split())
H=[0]*(K+1)
m=pow(10,9)+7

ans=0
i=K
while i>=1:
    H[i]=pow(K//i,N,m)
    j=2
    while j*i<=K:
        H[i]-=H[j*i]
        j+=1
    ans+=H[i]*i
    i-=1


print(ans%m)
### BUGGY CODE ###

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

for _ in range(Q):
    q = list(input().split())
    if q[0] == "1":
        S = S[::-1]
    else:
        if q[1] == "1":
            S = q[2] + S
        else:
            S = S + q[2]

print(S)

### FIXED CODE ###

from collections import deque

S = deque(list(input()))
Q = int(input())
q = [list(input().split()) for _ in range(Q)]
r = 0


for i in range(Q):
    if q[i][0] == "1":
        r += 1
    else:
        if (q[i][1] == "1" and r%2==0)or (q[i][1] == "2" and r%2==1 ):
            S.appendleft(q[i][2])
        else:
            S.append(q[i][2])

S = "".join(S)
if r%2==1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

import numpy as np

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

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

            
def judge(x, lst):

    length = len(lst)
    all_pair = (length*(length-1) // 2) + length
    
    lst_r = [-1 if i < x else 1 for i in lst]
    array = np.cumsum(np.array(lst_r))
    lst_accum = array - min(array) + 1
    
    bit = Bit(max(lst_accum))
    ans = 0
    for i, p in enumerate(lst_accum):
        bit.add(p, 1)
        ans += i + 1 - bit.sum(p)
    
    ans = all_pair - ans
    if ans >= (all_pair//2) + 1:
        return True
    else:
        return False

    
lst = sorted(lst)
low = 0
high = len(lst) - 1
t = (low+high) // 2
while low < high:
    i = lst[t]
    if judge(i, lst):
        if low == t:
            break
        low = t
        t = (low+high) // 2
    else:
        if high == t:
            break
        high = t
        t = (low+high) // 2
        
print(lst[high]) if judge(lst[high], lst) else print(lst[t])

### FIXED CODE ###

from itertools import accumulate
from math import ceil
 
N = int(input())
A = list(map(int, input().split()))
 
if N == 1:
    print(A[0])
    exit()
 
 
class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)
 
    def reset(self):
        self.bit = [0] * (self.size + 1)
 
 
BIT = BinaryIndexedTree(N)  # Binaryの先頭の分
lo, hi = -1, 10 ** 9 + 1
while hi - lo > 1:
    # Xは中央値候補
    X = (hi + lo) // 2
 
    # X以上なら1、X未満なら-1に変換
    Binary = [(1 if a >= X else -1) for a in A]
 
    # 累積和をとる
    Binary = list(accumulate(Binary))
 
    # BITを初期化
    BIT.reset()
 
    # 転倒数っぽいものを数える
    inversion = 0
    Binary_sorted = {b: i for i, b in enumerate(sorted(Binary), start=1)}
    for j, b in enumerate(Binary):
        inversion += BIT.sum(Binary_sorted[b]) + (b >= 0)
        BIT.add(Binary_sorted[b], 1)
 
    if inversion >= ceil((N * (N + 1) / 2) / 2):
        lo = X
    else:
        hi = X
 
print(lo)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**5
n = int(input())

graph = [[] for _ in range(n+1)]
d = [[INF]*(n+1) for _ in range(n+1)]

for _ in range(n-1):
    a, b, c = map(int, input().split())
    d[a][b] = d[b][a] = c
    graph[a].append(b)
    graph[b].append(a)

q, k = map(int, input().split())
dist = [INF]*(n+1)


def dfs(v1, parent, add):
    dist[v1] = add
    for v2 in graph[v1]:
        if v2 == parent:
            continue
        dfs(v2, v1, add + d[v1][v2])

dfs(k, -1, 0)

for _ in range(q):
    x, y = map(int, input().split())
    print(dist[x]+dist[y])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**9+1
n = int(input())
graph = [[] for _ in range(n+1)]

for _ in range(n-1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))

q, k = map(int, input().split())
dist = [INF]*(n+1)


def dfs(v1, parent, add):
    dist[v1] = add
    for v2, d in graph[v1]:
        if v2 == parent:
            continue
        dfs(v2, v1, add + d)

dfs(k, -1, 0)

for _ in range(q):
    x, y = map(int, input().split())
    print(dist[x]+dist[y])
### BUGGY CODE ###

import heapq

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]

L=[]
for i in range(M+1):
    L.append([])

for i in range(N):
    if AB[i][0]<=M:
        L[AB[i][0]].append(AB[i][1])

LL=[]
money=0

for i in range(1,M+1):
    LL+=[-k for k in L[i]]
    heapq.heapify(LL)
    if len(LL)==0:
        continue
    money+=heapq.heappop(LL)

print(-money)

### FIXED CODE ###

import heapq

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
L=[[] for i in range(M+1)]

for i in range(N):
    if AB[i][0]<=M:
        L[AB[i][0]].append(-AB[i][1])

LL=[]
money=0

for i in range(1,M+1):
    for j in L[i]:
        heapq.heappush(LL,j)
    if len(LL)==0:
        continue
    money+=heapq.heappop(LL)

print(-money)
### BUGGY CODE ###

def main():
  d=[1]+[0]*12
  for c in input():
    d=tuple(sum(d[(j-k)*9%13]for j in c<'?'and[int(c)]or range(10))%(10**9+7)for k in range(13))
  print(d[5])
main()

### FIXED CODE ###

d=[1]+[0]*12
for i,c in enumerate(input()):
 p=[0]*13
 for j in range(13):
  for k in range(10):p[(j*10+k)%13]+=d[j]*(c>'9'or k==int(c))
 d=[t%(10**9+7)for t in p]
print(d[5])
### BUGGY CODE ###


def distance(P, p1, p2):
    return min(abs(P[p1][1]-P[p2][1]), abs(P[p1][2]-P[p2][2]))

N = int(input())
P = [[j]+[int(i) for i in input().split(' ')] for j in range(N)]
sortX = sorted(P,key=lambda x:x[1])
sortY = sorted(P,key=lambda x:x[2])
EX = [[sortX[i][0], sortX[i+1][0], distance(P,sortX[i][0],sortX[i+1][0])] for i in range(N-1)]
EY = [[sortY[i][0], sortY[i+1][0], distance(P,sortY[i][0],sortY[i+1][0])] for i in range(N-1)]
E = EX + EY
E = sorted(E, key=lambda x:x[2])
CI = [i for i in range(N)]
disSum = 0
for e in E[:]:
    s,l = min(e[0],e[1]),max(e[0],e[1])
    if CI[s] != CI[l]:
        CI = list(map(lambda x:CI[s] if x == CI[l] else x, CI))
        disSum += e[2]
print(disSum)

### FIXED CODE ###


import sys
sys.setrecursionlimit(int(2e9))

def distance(P, p1, p2):
    return min(abs(P[p1][1]-P[p2][1]), abs(P[p1][2]-P[p2][2]))
def root(CI, p):
    if CI[p] == p:
        return p
    else:
        CI[p] = root(CI, CI[p])
        return CI[p] 

N = int(input())
P = [[j]+[int(i) for i in input().split(' ')] for j in range(N)]
sortX = sorted(P,key=lambda x:x[1])
sortY = sorted(P,key=lambda x:x[2])
EX = [[sortX[i][0], sortX[i+1][0], distance(P,sortX[i][0],sortX[i+1][0])] for i in range(N-1)]
EY = [[sortY[i][0], sortY[i+1][0], distance(P,sortY[i][0],sortY[i+1][0])] for i in range(N-1)]
E = EX + EY
E = sorted(E, key=lambda x:x[2])
CI = [i for i in range(N)]
disSum = 0
for e in E:
    s,l = min(e[0],e[1]),max(e[0],e[1])
#     if CI[s] != CI[l]:
#         CI = list(map(lambda x:CI[s] if x == CI[l] else x, CI))
#         disSum += e[2]
    if root(CI, s) != root(CI, l):
        CI[root(CI, l)] = root(CI, s)
        disSum += e[2]
print(disSum)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def calc(N,i,j,k):
  if dp[i][j][k]>=0:
    return dp[i][j][k]
  ans = 1
  if k-1>=0 and j+1<=N:
    ans += calc(N,i,j+1,k-1)*k/N
  if j-1>=0 and i+1<=N:
    ans += calc(N,i+1,j-1,k)*j/N
  if i-1>=0:
    ans += calc(N,i-1,j,k)*i/N
  if i+j+k>0:
    ans *= N/(i+j+k)
  dp[i][j][k] = ans
  return ans

N = int(input())
A = list(map(int, input().split()))
one = A.count(1)
two = A.count(2)
three = A.count(3)
dp = [[[-1]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 0
ans = calc(N,one,two,three)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(float, input().split()))
def solve():
    dp = [[[0]*(N+1-i-j) for j in range(N+1-i)] for i in range(N+1)]
    dp[N][0][0] = 0
    for i in range(N-1,-1,-1):
        for j in range(N-i,-1,-1):
            for k in range(N-i-j,-1,-1):
                dp[i][j][k] = 1/(1-i/N)
                if j != 0:
                    dp[i][j][k] += dp[i+1][j-1][k]*(j/(N-i))
                if k != 0:
                    dp[i][j][k] += dp[i][j+1][k-1]*(k/(N-i))
                if i+j+k != N:
                    dp[i][j][k] += dp[i][j][k+1]*(1-(j+k)/(N-i))
    c = {}
    for i in range(1,3):
        c[i] = A.count(i)
    ans = dp[0][c[1]][c[2]]
    # print(*dp,sep='\n')
    return ans
print(solve())
### BUGGY CODE ###

n = int(input())
c = input()
l = list(c)
ans = 0
while c.count("WR") > 0 :
    for i in range(n) :
        if l[i] == "W" :
            l[i] = "R"
            break
    for i in reversed(range(0,n)) :
        if l[i] == "R" :
            l[i] = "W"
            break
    c = ''.join(l)
    ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
c = list(input())
w = 0
r = c.count("R")
ans = r
for i in range(n) :
    if c[i] == "W" :
        w += 1
    else :
        r -= 1
    if ans > max(w,r) :
        ans = max(w,r)

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

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0

ls_bin = []
for i in range(n):
    b = str(bin(a[i]))[2:]
    c = b.zfill(61)
    ls_bin.append(c)
# print(ls_bin)

ans = 0
for j in reversed(range(61)):
    one = 0
    zero = 0
    for i in range(n):
        s = int(ls_bin[i][j])
        if s==0:
            zero += 1
        else:
            one += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**(60-j))
print(ans%mod)

### FIXED CODE ###

import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def myinput():
    return map(int,readline().split())

n = int(readline())
a = list(myinput())
mod = 10**9 + 7
ans = 0

for j in range(60):
    k = 2**j
    one = 0
    zero = 0
    for i in range(n):
        if (a[i]&k):
            one += 1
        else:
            zero += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**j) 
    ans %= mod   

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

inp = [input() for i in range(2)]
N = int(inp[0])
A = inp[1].split()
A = [int(i) for i in A]

for k in range(N):
    counter = 0
    A_k = A[k]
    other = A[:k] + A[k+1:]
    for i in range(N-1):
        counter += other.count(other[i])
        counter -= 1
    
    print(int(counter/2))


### FIXED CODE ###

import math
inp = [input() for i in range(2)]
N = int(inp[0])
A = list(map(int, inp[1].split()))
# B = 0
d = {}
for k in A:
    # a = A.count(k)
    # B += (a - 1) / 2
    if k in d.keys():
        d[k] += 1
    else:
        d[k] = 1

# for k in range(N):
#     c = A.count(A[k]) - 1
#     counter = B - c
#     print(int(counter))

p = {}
for k in d.keys():
    cnt = d[k]
    p[k] = cnt * (cnt-1) / 2

total = sum(p.values())

for item in A:
    print(int(total - d[item] + 1))
### BUGGY CODE ###

from itertools import accumulate
s = input()
l = len(s)
if 4>l:
    print(0)
    exit()
c = 0
a = [0] + list(accumulate(map(int, list(s))))
for i in range(l-3):
    for j in range(i+4, l):
        if (a[j+1] - a[i]) % 3 == 0:
            if int(s[i:j+1]) % 673 == 0:
                c += 1
print(c)

### FIXED CODE ###

m = 2019
l = [0]*m
a = b = 0;k = 1
for c in input():
  l[b % m] += 1
  b -= int(c)*k
  a += l[b % m]
  k = k*202 % m
print(a)
### BUGGY CODE ###

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

max_A = max(a for a, _ in AB)
inf = float('inf')
dp = [inf] * (H + max_A + 1)
dp[0] = 0
for i in range(1, H + max_A + 1):
    for a, b in AB:
        t1 = i - a
        if t1 < 0:
            continue
        t2 = dp[t1]
        if t2 == inf:
            continue
        if t2 + b < dp[i]:
            dp[i] = t2 + b
print(min(dp[H:]))


### FIXED CODE ###

def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for j in range(N):
            a, b = AB[j]
            if dp[i] + b < dp[i + a]:
                dp[i + a] = dp[i] + b
    print(min(dp[H:]))


main()
### BUGGY CODE ###

# coding: utf-8
# Your code here!

box_num = int(input())
ball_in_box_num_list = tuple([int(i), []] for i in input().split(" "))
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j][0] = 1 - ball_in_box_num_list[j][0]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))

### FIXED CODE ###

# coding: utf-8
# Your code here!

box_num = int(input())
ball_in_box_num_list = tuple([int(i), []] for i in input().split(" "))
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j][0] = 1 - ball_in_box_num_list[j][0]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))