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

#from scipy.special import comb
#from math import factorial
import collections

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#a = cmb(n,r)
c = collections.Counter(A)
l1 = []
l2 = []
l3 = []
for i in c.keys():
  l1.append(i)
  if c[i] == 1:
    l2.append(0)
    l3.append(0)
  if c[i] == 2:
    l2.append(1)
    l3.append(0)
  if c[i] >= 3:
    l2.append(cmb(c[i], 2))
    l3.append(cmb(c[i]-1, 2))    

#print(l1)
#print(l2)
#print(l3)

for i in range(N):
  sum = 0
  for j in c.keys():
    var_index = l1.index(j)
    if A[i] != j:
      sum += l2[var_index]
    else:
      sum += l3[var_index]
  print(sum)

### FIXED CODE ###

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

from collections import Counter
C=Counter(A)
ANS=0
for i in C.values():
    ANS+=i*(i-1)//2

for a in A:
    k=C[a]

    print(ANS-(k*(k-1)//2)+((k-1)*(k-2)//2))
### BUGGY CODE ###

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

L = []
R = []
for i in range(M):
  L.append(LR[i][0])
  R.append(LR[i][1])
  
count = 0
flag = 0
for i in range(1, N+1):
  flag = 0
  for j in range(M-1, -1, -1):
    if not (L[j] <= i <= R[j]):
      break
    else:
      flag += 1
    if flag == M:
      count += 1

print(count)

### FIXED CODE ###

N, M = map(int, input().split())

LR = [list(map(int, input().split())) for _ in range(M)]

L = []
R = []
for i in LR:
  L.append(i[0])
  R.append(i[1])
  
if min(R) - max(L) < 0:
  print(0)
else:
  print(min(R) - max(L) + 1)
### BUGGY CODE ###

N, Q = map(int, input().split())

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

queue = [0]
parent = [0 for _ in range(N)]
while len(queue) > 0:
  q = queue.pop(0)
  for br in to[q]:
    to[br].remove(q)
    parent[br] = q
    queue.append(br)

cnt = [0 for _ in range(N)]
for _ in range(Q):
  p, x = map(int, input().split())
  p -= 1
  cnt[p] += x

queue = [0]
while len(queue) > 0:
  q = queue.pop(0)
  if q != 0:
    cnt[q] += cnt[parent[q]]
  for br in to[q]:
    queue.append(br)

for i in range(N):
  print(cnt[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

### FIXED CODE ###

from collections import deque
n, Q = map(int, input().split())
edges = [[] for _ in range(n+1)]
count = [0]*(n+1)
q = deque()
q.append((1, 0))

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    count[p] += x

while(q):
    k = q.popleft()
    count[k[0]] += count[k[1]]
    for i in edges[k[0]]:
        if not i == k[1]:
            q.append((i, k[0]))

print(*count[1:])
### BUGGY CODE ###

import sys
from operator import itemgetter


scan = sys.stdin.readline


def main():
  n, m = map(int, scan().rstrip().split())
  a = list(map(int, scan().rstrip().split()))
  operations = [tuple(map(int, scan().rstrip().split())) for _ in range(m)]
  operations.sort(key=itemgetter(1))
  
  for b, c in operations:
    a.sort()
    count = 0
    while count < b and a[count] < c:
      a[count] = c
      count += 1
  
  print(sum(a))
  

if __name__ == "__main__":
  main()


### FIXED CODE ###

import sys
from operator import itemgetter
from collections import deque


scan = sys.stdin.readline


def main():
  n, m = map(int, scan().rstrip().split())
  a = list(map(int, scan().rstrip().split()))
  operations = [tuple(map(int, scan().rstrip().split())) for _ in range(m)]
  
  a.sort()
  operations.sort(key=itemgetter(1), reverse=True)
  
  a = deque(a)
  
  for b, c in operations:
    count = 0
    while count < b:
      if a[0] < c:
        a.append(c)
        count += 1
        a.popleft()
      else:
        print(sum(a))
        exit(0)

  print(sum(a))
  

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

N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  sum = int(p[i])*(int(p[i])+1)/2
  expected_list.append(float(sum/(int(p[i]))))
  
for i in range(N):
  anan = 0
  for j in range(K):
    try:
      anan += expected_list[i+j]
    except:
      pass
  max_list.append(anan)
  
print(max(max_list))
  

### FIXED CODE ###

N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  expected_list.append((int(p[i])+1)/2)
anan = 0
for j in range(K):
  anan += expected_list[j]
max_list.append(anan)
for i in range(N):
  if i == 0:
    continue
  anan = 0
  try:
    anan = max_list[i-1]-expected_list[i-1]+expected_list[i+K-1]
  except:
    pass
  max_list.append(anan)
  
print(max(max_list))
### BUGGY CODE ###


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

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

#print (hn)

tab = [0]*n

tab[0] = 0


if n-1<=k:
    #一回で橋まで飛べるならそれが最適
    print( abs(hn[-1] - hn[0]) )

else:
    # k番目まで1回で飛ぶコスト
    for i in range(1,k+1):
        tab[i] = abs( hn[i]-hn[0])
#       print(tab[i])

#    print("Initialized")


    for i in range(k+1,n):
        t = 1000000000 # > 10^4

        # ここ(i [k+1,n) にki( [1,k+1) ) から1回で来るコスト)
        for ki in range(1,k+1):
            tt = abs(hn[i] - hn[i-ki]) + tab[i-ki]
            t = min(t, tt)
#            print((i,ki,tt))

        tab[i] = t
    
    print(tab[-1])


    


### FIXED CODE ###




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

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

#print (hn)

tab = [0]*n

tab[0] = 0


if n-1<=k:
    #一回で橋まで飛べるならそれが最適
    print( abs(hn[-1] - hn[0]) )

else:
    # k番目まで1回で飛ぶコスト
    for i in range(1,k+1):
        tab[i] = abs( hn[i]-hn[0])
#       print(tab[i])

#    print("Initialized")


    for i in range(k+1,n):
        t = 1000000000 # > 10^4

        # ここ(i [k+1,n) にki( [1,k+1) ) から1回で来るコスト)
        for ki in range(1,k+1):
            tt = abs(hn[i] - hn[i-ki]) + tab[i-ki]
            t = min(t, tt)
#            print((i,ki,tt))

        tab[i] = t
    
    print(tab[-1])
### BUGGY CODE ###

from collections import deque

H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(input())

ret = 0
for i in range(H):
    for j in range(W):
        s = S[i][j]
        queue = deque([(i,j,0)])
        footprint = [(i,j)]
        if s == '#':
            continue
        while True:
            x, y, d = queue.popleft()
            for p in [(x-1, y), (x, y-1), (x, y+1), (x+1, y)]:
                if p[0] >= 0 and p[0] < H and p[1] >=0 and p[1] < W and p not in footprint and S[p[0]][p[1]] != '#':
                        queue.append((p[0], p[1], d+1))
                        footprint.append(p)

            if len(queue) == 0:
                break
        if d > ret:
            ret = d

print(ret)

### FIXED CODE ###

from collections import deque

H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(input())

ret = 0
for i in range(H):
    for j in range(W):
        s = S[i][j]
        queue = deque([(i,j,0)])
        footprint = [(i,j)]
        if s == '#':
            continue
        while True:
            x, y, d = queue.popleft()
            for p in [(x-1, y), (x, y-1), (x, y+1), (x+1, y)]:
                if p[0] >= 0 and p[0] < H and p[1] >=0 and p[1] < W and p not in footprint and S[p[0]][p[1]] != '#':
                        queue.append((p[0], p[1], d+1))
                        footprint.append(p)

            if len(queue) == 0:
                break
        if d > ret:
            ret = d

print(ret)
### BUGGY CODE ###

from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j

for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2


if max(div)<=1:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')

### FIXED CODE ###

from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
f=0
for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2
    if f==1:
        break
        


if max(div)<=1 and f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')
### BUGGY CODE ###

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

count = 0

for i in range(M):
  B, C = map(int, input().split())
  count = count + B
  for j in range(B):
    A.append(C)

A.sort()
ans = A[count : len(A)+1]

print(sum(ans))

### FIXED CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]
BC = [list(map(int, input().split())) for _ in range(M)]
count = 0

BC = sorted(BC, key=lambda x: x[1],reverse=True)
min_A = min(A)

for B,C in BC:
  if min_A >= C and count > N:
    break
  else:
    l = min(B, N-count)
    for i in range(l):
      count+=1
      A.append(C)

A.sort()

ans = sum(A[count:len(A)])

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

import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(n, cnt):
  aoki_visited[n] = True
  aoki[n] = cnt
  for x in edge[n]:
    if aoki_visited[x] == False:
      tami(x, cnt+1)

def tami2(n, cnt):
  choku_visited[n] = True
  if cnt <= aoki[n]:
    choku[n] = cnt
    for x in edge[n]:
      if choku_visited[x] == False:
        tami2(x, cnt+1)

N, u, v = IL()
ab = [IL() for _ in range(N-1)]

aoki = [0]*(N+1)
aoki_visited = [False]*(N+1)
choku = [0]*(N+1)
choku_visited = [False]*(N+1)

edge = [[] for _ in range(N+1)]
for a,b in ab:
  edge[a].append(b)
  edge[b].append(a)

ans = 0
aoki[v] = MAX_INT
tami(v, 0)
tami2(u, 0)
#print(aoki)
#print(choku)

for i in range(N+1):
  if choku[i] == 0 and i != u:
    continue
  if aoki[i] > choku[i]:
    ans = max(ans, aoki[i] - 1)

print(ans)

### FIXED CODE ###

import sys
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N, u, v = IL()
ab = [IL() for _ in range(N-1)]

aoki = [0]*(N+1)
aoki_visited = [False]*(N+1)
choku = [0]*(N+1)
choku_visited = [False]*(N+1)

edge = [[] for _ in range(N+1)]
for a,b in ab:
  edge[a].append(b)
  edge[b].append(a)

d = deque([[v,0]])
while d:
  n,cnt = d.popleft()
  aoki_visited[n] = True
  aoki[n] = cnt
  for x in edge[n]:
    if aoki_visited[x] == False:
      d.append([x, cnt+1])

dd = deque([[u,0]])
while dd:
  n,cnt = dd.popleft()
  choku_visited[n] = True
  if cnt <= aoki[n]:
    choku[n] = cnt
  for x in edge[n]:
    if choku_visited[x] == False:
      dd.append([x, cnt+1])

#print(aoki)
#print(choku)

ans = 0
for i in range(N+1):
  if choku[i] == 0 and i != u:
    continue
  if aoki[i] > choku[i]:
    ans = max(ans, aoki[i] - 1)

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

N=int(input())
x=0
for i in range(1,N):
    x+=i

print(x)

### FIXED CODE ###

N=int(input())
x=int(N*(N-1)//2)
print(x)
### BUGGY CODE ###

K, S = map(int, input().split())

Xs = [i for i in range(K+1)]
Ys = Xs[:]
Zs = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        for z in Zs:
            if x+y+z == S:
                count += 1
print(count)

### FIXED CODE ###

K, S = map(int, input().split())

Xs = [i for i in range(K+1)]
Ys = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        if 0<= S - x - y <= K:
            count += 1
print(count)
### BUGGY CODE ###

from math import sqrt
n=int(input())
rn=int(sqrt(n))
s=[0]*(rn+1)
s[0]=-1
s[1]=-1
t=[0]*(rn+1)
for i in range(2,rn+1):
    if s[i] != 0:
        continue
    s[i] = i
    j = i
    while j < rn + 1:
        t[j] = 1
        j *= i
        for j in range(i * i, rn + 1):
            if s[j] == 0:
                s[j] == i

result = 0
last = -1
for i in range(2,rn+1):
    if t[i] == 0:
        continue
    if n % i == 0:
        result += 1
        n //= i
        last =i
if n != 1 and n > rn:
    result += 1
print(result)

### FIXED CODE ###

from math import sqrt

N = int(input())

rn = int(sqrt(N))
sieve = [0] * (rn + 1)
sieve[0] = -1
sieve[1] = -1
t = [0] * (rn + 1)
for i in range(2, rn + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    j = i
    while j < rn + 1:
        t[j] = 1
        j *= i
    for j in range(i * i, rn + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

result = 0
last = -1
for i in range(2, rn + 1):
    if t[i] == 0:
        continue
    if N % i == 0:
        result += 1
        N //= i
        last = i
if N != 1 and N > rn:
    result += 1
print(result)
### BUGGY CODE ###

N,K = map(int, input().split())
X = []; Y = []
oriX  = []; oriY = []


for i in range(N):
    x,y = map(int,input().split())
    oriX.append(x)
    oriY.append(y)
    X.append(x)
    Y.append(y)

X = sorted(list(set(X)))
Y = sorted(list(set(Y)))

for i in range(len( oriX)) :
    oriX[i] = X.index(oriX[i] )
    oriY[i] = Y.index( oriY[i] )  

MAP = [ [0] * len(oriX) for _ in (oriY)]
for i in range(len(oriX)):
    MAP[ oriY[i] ][ oriX[i] ] = 1


ans = float("inf")

for i in range(len(oriX)):
    for j in range(len(oriX)):
        if i == j : continue

        for p in range(len(oriY)):
            for q in range(len(oriY)):
                if p == q: continue


                npoints = 0
                for c in range(N):
                    if  oriX[i] <= oriX[c] <= oriX[j]:
                        if oriY[p] <= oriY[c] <= oriY[q]:
                            npoints += 1
                        
                # for h in range(oriY[p], oriY[q]+1):
                #     for w in range(oriX[i], oriX[j]+1):
                #         if MAP[h][w] == 1: 
                #             npoints += 1

                if npoints >= K:
                    tmp = (X[oriX[j]] - X[oriX[i]]) * (Y[oriY[q]] - Y[oriY[p]])
                    ans = min(tmp, ans)

print(ans)


### FIXED CODE ###

N,K = map(int, input().split())
XY = [ [int(j) for j in input().split()] for _ in range(N)]

xlst = []
ylst = []

for x,y in XY:
    x += 10**9 + 1
    y += 10**9 + 1
    xlst.append(x)
    ylst.append(y)

xset = sorted(list(set(xlst)))
yset = sorted(list(set(ylst)))

# print(xset, yset)

S = [ [0]*(N+1) for _ in range(N+1)]

for x,y in zip(xlst,ylst):
    x=xset.index(x)+1
    y=yset.index(y)+1
    S[y][x] = 1

for y in range(N+1):
    for x in range(1, N+1):
        S[y][x] += S[y][x-1]
for x in range(N+1):
    for y in range(1,N+1):
        S[y][x] += S[y-1][x]


ans = float("inf")
for i in range(N):
    for j in range(N):
        for k in range(N):
            for ll in range(N):

                left     = xlst[i]
                right    = xlst[j]
                top      = ylst[k]
                bottom   = ylst[ll]

                if right <= left: continue
                if bottom <= top: continue

                left = xset.index(left)+1
                right = xset.index(right)+1
                top = yset.index(top)+1
                bottom=yset.index(bottom)+1


                cnt = 0
                cnt += S[bottom][right]
                # print(cnt)
                cnt += S[top-1][left-1]
                # print(cnt)
                cnt -= S[top-1][right]
                # print(cnt)
                cnt -= S[bottom][left-1]
                # print(cnt)
                if cnt >= K:
                    left = xset[left    -1 ]
                    right = xset[right  -1 ]
                    top = yset[top      -1 ]
                    bottom = yset[bottom-1 ]
                    rect_area = (right-left)*(bottom-top)
                    ans = min(ans, rect_area)
                
print(ans)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

for j in range(N):
    sub = A[j]
    del A[j]
    print(max(A))
    A.insert(j,sub)


### FIXED CODE ###

n = int(input())
a = []
#print('n a',n,a)
for i in range(n):
        a.append(int(input()))
#print('As',a)
max1 = max(a)
location1 = a.index(max1)
#print('1st MAX',max1,'INDEX',location1)
a.remove(a[location1])
max2 = max(a)
#print('2nd MAX',max2)
if max1 == max2:
        #print('1=2')
        for i in range(n):
                print(max1)
else:
        #print('1!=2')
        for i in range(n):
                if i == location1:
                        #print('max2')
                        print(max2)
                else:
                        #print('max1')
                        print(max1)
### BUGGY CODE ###

H,W = map(int, input().split())
B = [list(input()) for i in range(H)]

l = []

for i in range(H):
    for j in range(W):
        if B[i][j] == '#':
            l.append((i,j))

def a(l):
    n = []
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for y, x in l:
        for dy, dx in d:
            ny = y + dy
            nx = x + dx
            if 0 <= ny < H and 0 <= nx < W and B[ny][nx] == '.':
                B[ny][nx] = '#'
                n.append((ny, nx))
    return set(n)

ans = 0
while len(l) != 0:
    l = a(l)
    ans += 1
print(ans-1)

### FIXED CODE ###

H,W = map(int, input().split())
B = [list(input()) for i in range(H)]

l = []

for i in range(H):
    for j in range(W):
        if B[i][j] == '#':
            l.append((i,j))

def a(l):
    n = []
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for y, x in l:
        for dy, dx in d:
            ny = y + dy
            nx = x + dx
            if 0 <= ny < H and 0 <= nx < W and B[ny][nx] == '.':
                B[ny][nx] = '#'
                n.append((ny, nx))
    return set(n)

ans = 0
while len(l) != 0:
    l = a(l)
    ans += 1
print(ans-1)
### BUGGY CODE ###

def comp(v,w):
    if v[0]<w[0] or (v[0]==w[0] and v[1]<w[1]):
        return True
    else:
        return False


def mergesort(list0):
    n=len(list0)
    if n<=1:
        return list0
    else:
        a=mergesort(list0[0:n//2])
        b=mergesort(list0[n//2:n])
        return merge(a,b)


def merge(list1,list2):
    a=0
    b=0
    s=[]
    for c in range(len(list1)+len(list2)):
        if b>=len(list2) or (a<len(list1) and comp(list1[a],list2[b])):
            s.append(list1[a])
            a=a+1
        else:
            s.append(list2[b])
            b=b+1
    return s


h,w,m=map(int,input().split())
g=[]
e1=[[0,t] for t in range(h)]
e2=[[0,t] for t in range(w)]
for c in range(m):
    a,b=map(int,input().split())
    g.append([a-1,b-1])
    e1[a-1][0]+=1
    e2[b-1][0]+=1
f1=mergesort(e1)
f2=mergesort(e2)
p=f1[-1][0]
q=f2[-1][0]
x=[]
y=[]
for c in range(h-1,-1,-1):
    if p>f1[c][0]:
        break
    x.append(f1[c][1])
for c in range(w-1,-1,-1):
    if q>f2[c][0]:
        break
    y.append(f2[c][1])
r=1
for i in x:
    for j in y:
        if not ([i,j] in g):
            r=0
            break
    else:
        continue
    break
print(p+q-r)

### FIXED CODE ###

h,w,m=map(int,input().split())
g=[]
e1=[0]*h
e2=[0]*w
for c in range(m):
    a,b=map(int,input().split())
    g.append([a-1,b-1])
    e1[a-1]+=1
    e2[b-1]+=1
p1=max(e1)
p2=max(e2)
x=[1 if e1[c]==p1 else 0 for c in range(h)]
y=[1 if e2[c]==p2 else 0 for c in range(w)]
r=sum(x)*sum(y)
for i in g:
    if x[i[0]]==1 and y[i[1]]==1:
        r-=1
if r==0:
    print(p1+p2-1)
else:
    print(p1+p2)
### BUGGY CODE ###

N = int(input())
S = input()
cnt = 0
for i in range(0,1000):
  if i >= 100:
    i = str(i)
  elif i >= 10:
    i = "0" + str(i)
  else:
    i = "00" + str(i)
  checker = 0
  for j in range(N):
    if S[j] == i[checker]:
      checker += 1
      if checker == 3:
        cnt += 1
        break
print(cnt)
      

### FIXED CODE ###

N = int(input())
S = input()
count = 0
for i in range(0,1000):
  if i >= 100:
    t = str(i)
  elif i >= 10:
    t = "0"+str(i)
  else:
    t = "00"+str(i)
  ti = 0
  for j in range(N):
    if S[j] == t[ti]:
      ti += 1
      if ti == 3:
        count += 1
        break
print(count)
### BUGGY CODE ###

N, Y = map(int,input().split())
flag = False
for x in range(N+1):
  for y in range(N+1):
    for z in range(N+1):
      if Y == x*10000 + y*5000 + z*1000 and N == (x+y+z):
        print(x, y, z)
        flag = True
        break
      if flag == True:
        break
  if flag == True:
    break
  
if flag == False:
  print(-1,-1,-1)

### FIXED CODE ###

N, Y = map(int,input().split())
flag = False
for x in range(N+1):
  for y in range(N+1-x):
    if Y == x*10000 + y*5000 + (N-x-y)*1000:
      print(x, y, N-x-y)
      flag = True
      exit()
if flag == False:
  print(-1,-1,-1)
### BUGGY CODE ###

n = int(input())
a = [int(_) for _ in input().split()]
const = 10**9 + 7

ans = 0

zero = [0] * 60
one = [0] * 60

for i in range(n):
    for j in range(60):
        if a[i] >> j & 1:
            one[j] += 1
        else:
            zero[j] += 1

ans = 0

for i in range(n):
    j = 0
    while a[i] != 0:
        if a[i] % 2 == 0:
            ans += one[j] * (2**j)
            zero[j] -= 1
        else:
            ans += zero[j] * (2**j)
            one[j] -= 1
        a[i] //= 2
        j += 1
    ans %= const

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = tuple(map(int,input().split()))
const = 10**9 + 7

ans = 0

zero = [0] * 60
one = [0] * 60

for i in range(60):
    for j in range(n):
        if a[j] >> i & 1:
            one[i] += 1
        else:
            zero[i] += 1

ans = 0

for i in range(60):
    ans += one[i] * zero[i] * 2**i
    ans %= const

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

K = int(input())
D = int(input())
n = len(str(K))

mod = 10**9+7

s = str(K)

dp = [[[0, 0] for _ in range(D)] for _ in range(n+1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(D):
        for k in range(2):
            nd = int(s[i])
            for d in range(10):
                ni = i+1
                nj = (j+d)%D
                nk = k
                if k == 0:
                    if d > nd:
                        continue
                    elif d < nd:
                        nk = 1
                    else:
                        pass
                dp[ni][nj][nk] += dp[i][j][k]%mod
print((dp[n][0][0]+dp[n][0][1]-1)%mod)

### FIXED CODE ###

K = int(input())
D = int(input())
n = len(str(K))

mod = 10**9+7

s = str(K)

dp = [[[0, 0] for _ in range(D)] for _ in range(n+1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(D):
        for k in range(2):
            nd = int(s[i])
            for d in range(10):
                ni = i+1
                nj = (j+d)%D
                nk = k
                if k == 0:
                    if d > nd:
                        continue
                    elif d < nd:
                        nk = 1
                    else:
                        pass
                dp[ni][nj][nk] += dp[i][j][k]%mod
print((dp[n][0][0]+dp[n][0][1]-1)%mod)