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

def main():
    num, yen_sum = map(int, input().split())
    res = [-1, -1, -1]
    for bill_10000 in range(num+1):
        for bill_5000 in range(num-bill_10000+1):
            for bill_1000 in range(num-bill_10000-bill_5000+1):

                if bill_10000*10000 + bill_5000*5000 + bill_1000*1000 == yen_sum\
                    and bill_10000 + bill_5000 + bill_1000 == num:
                    res = [bill_10000, bill_5000, bill_1000]
                    break
    print(*res)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    num, yen_sum = map(int, input().split())
    yen_sum /=1000
    res = [-1, -1, -1]
    for bill_10000 in range(num+1):
        if bill_10000*10 + (num-bill_10000+1)*5 <= yen_sum:
            continue
        for bill_5000 in range(num-bill_10000+1):
            bill_1000 = num - bill_10000 - bill_5000
            if bill_10000*10 + bill_5000*5 + bill_1000*1 == yen_sum:
                res = [bill_10000, bill_5000, bill_1000]
                break
    print(*res)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from heapq import heappop,heappush
import math

xs,ys,xt,yt = map(int,input().split())
n = int(input())

v = [[xs,ys,0]]
for _ in range(n):
    v.append(list(map(int,input().split())))
v.append([xt,yt,0])

def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[] for i in range(n+2)]
for i in range(n+2):
    for j in range(n+2):
        if i != j:
            d_ij = dd(v[i],v[j])
            edges[i].append((d_ij,j))
            edges[j].append((d_ij,i))

def dijkstra(s,n,edges):
    #edges[source] = [(cost_1,target_1),(cost_2,target_2),...]
    #import 'heap'
    d = [float('inf')] * n
    d[s] = 0
    q = [(d[s],s)]
    while q:
        dist_u, u = heappop(q)
        for c, v in edges[u]:
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q,(d[v],v))
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
from heapq import heappop,heappush
import math
 
xs,ys,xt,yt = map(int,input().split())
n = int(input())
 
v = [[xs,ys,0]]
for _ in range(n):
    x,y,r = map(int,input().split())
    v.append([x,y,r])
v.append([xt,yt,0])
 
def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[0]*(n+2) for _ in range(n+2)]
for i in range(n+2):
    for j in range(i+1,n+2):
        edges[i][j] = dd(v[i],v[j])
        edges[j][i] = dd(v[i],v[j])

def dijkstra(s,n,edges):
    #edges[i][j] : the cost of i→j
    #import 'heap'
    d = [float('inf') for _ in range(n)]
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])
### BUGGY CODE ###

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

    cnt = 0
    for i in range(N-2):
        for j in range(i + A[i] + 1, N):
            if A[i] + A[j] == j - i:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections
def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = [a+i for i, a in enumerate(A)]
    C = [a-i for i, a in enumerate(A)]

    
    c = collections.Counter(C)

    ans = 0
    for b in B:
        ans += c.get(-b, 0)
    print(ans)


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

N = int(raw_input())
A = []
for n in xrange(N):
  A.append(map(int, raw_input().split(' ')))

memo = {}
def route(f, t, now, arrived):
  if now == t:
    return 0
  if (t, now, tuple(arrived)) in memo:
    return memo[(t, now, tuple(arrived))]
  min_dist = float('inf')
  for k in xrange(N):
    if k in arrived or (k == t and len(arrived) == 1):
      continue
    min_dist = min(route(f, t, k, arrived|set([k]))+A[now][k], min_dist)
  memo[(t, now, tuple(arrived))] = min_dist
  return min_dist

answer = 0
for i in xrange(N):
  for j in xrange(i):
    L = route(i, j, i, set([i]))
    if A[i][j] == L:
      pass
    elif A[i][j] > L:
      print -1
      exit()
    else:
      answer += A[i][j]

print answer

### FIXED CODE ###

N = int(raw_input())
A = []
for n in xrange(N):
  A.append(map(int, raw_input().split(' ')))
  A[n][n] = 1000000001

answer = 0
for i in range(N):
  Ai = A[i]
  for j in range(i):
    Aij = Ai[j]
    L = min(map(sum, zip(Ai, A[j])))
    if Aij < L:
      answer += Aij
    else:
      if Aij > L:
        print -1
        exit()
print answer
### BUGGY CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    
    score=1
    for i in range(n):
        score*=arr[i]
        if (i+1) > k:
            score = score//arr[i-k]
            if score > bef:
                print("Yes")
            else:
                print("No")
        bef=score

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


### FIXED CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    
    score=1
    for i in range(n):
        #score*=arr[i]
        if (i+1) > k:
            #score = score//arr[i-k]
            if arr[i] > arr[i-k]:
                print("Yes")
            else:
                print("No")
        #bef=score

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
### BUGGY CODE ###

import sys

sys.setrecursionlimit(1000000)




def main():
    n = int(input())
    a_dic = {}
    i = 0
    count = 0
    for a in map(int, input().split()):
        a_dic[i] = a
        for j in range(i-1):
            if i - j == a + a_dic[j]:
                count += 1
        i += 1

    # for i in range(n):
    #     ai = a_dic[i]
    #     for j in range(i+1, n):
    #         # combi = (i,j)
    #         if j - i == ai + a_dic[j]:
    #             count += 1
    print(count)



main()



### FIXED CODE ###

def is_ok(mid: int, target: int, ls: []):
    return target <= ls[mid]


def bi_search(target: int, ls: []):
    ng = -1
    ok = len(ls)

    cnt = 0
    while ok - ng > 1:
        mid = ng + int((ok - ng) / 2)
        cnt += 1
        if is_ok(mid, target, ls):
            ok = mid
        else:
            ng = mid
    return ok


def main():
    n = int(input())
    l_dic = {}
    r_dic = {}
    i = 0
    for a in map(int, input().split()):
        ld = l_dic.setdefault(i + a, [])
        ld.append(i)
        rd = r_dic.setdefault(i - a, [])
        rd.append(i)
        i += 1

    count = 0
    for rk, rv_list in r_dic.items():
        if rk not in l_dic:
            continue
        lv_list = l_dic[rk]
        for rv in rv_list:
            ind = bi_search(rv, lv_list)
            if ind == len(lv_list):
                count += ind
            else:
                count += ind + 1
            # for lv in lv_list:
            #     if lv < rv:
            #         count += 1
            #     else:
            #         break

    print(count)


main()
### BUGGY CODE ###

import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))
L = int(sys.stdin.readline())
Q = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

N += 2
X = [X[0]] + X + [X[-1]]
X = np.array(X, dtype=int)
# dp[d][i]: i番のホテルから(2^d)日で何個右までいけるか
dp = np.zeros((N.bit_length() + 1, N), dtype=int)
dp[0] = np.searchsorted(X, X + L, side='right') - np.arange(N) - 1
for d in range(1, N.bit_length() + 1):
    dp[d] = dp[d - 1] + dp[d - 1][np.arange(N) + dp[d - 1]]


def solve(l, r):
    ret = 0
    d = IINF
    while l < r:
        d = np.searchsorted(dp[:d + 1, l], r - l)
        if dp[d, l] == r - l:
            ret += pow(2, d)
            break
        if d > 0:
            d -= 1
        ret += pow(2, d)
        l += dp[d, l]
    return ret


for a, b in AB:
    r = solve(min(a, b), max(a, b))
    print(r)


### FIXED CODE ###

import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))
L = int(sys.stdin.readline())
Q = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

N += 2
X = [X[0]] + X + [X[-1]]
X = np.array(X, dtype=int)
# dp[d][i]: i番のホテルから(2^d)日で何個右までいけるか
dp = np.zeros((N.bit_length() + 1, N), dtype=int)
dp[0] = np.searchsorted(X, X + L, side="right") - 1
for d in range(1, N.bit_length() + 1):
    dp[d] = dp[d - 1][dp[d - 1]]
dp = dp.tolist()


def solve(l, r):
    ret = 0
    d = len(dp) - 1
    while l + 1 < r:
        while d > 0 and dp[d][l] >= r:
            d -= 1
        ret += 1 << d
        l = dp[d][l]
    if l < r:
        ret += 1
    return ret


ans = []
for a, b in AB:
    ans.append(solve(min(a, b), max(a, b)))
print(*ans, sep='\n')
### BUGGY CODE ###

X, Y, A, B, C = map(int, input().split())
p, q, r = [list(map(int, input().split())) for _ in range(3)]

p = list(map(lambda x: [x, 'p'], p))
q = list(map(lambda x: [x, 'q'], q))
r = list(map(lambda x: [x, 'r'], r))

l = p+q+r

l.sort(reverse=True)

x = 0
y = 0

sum = 0

while not (x == X and y == Y):
    apple = l.pop(0)
    if apple[1] == 'p' and x < X:
        x += 1
        sum += apple[0]
    if apple[1] == 'q' and y < Y:
        y += 1
        sum += apple[0]
    if apple[1] == 'r':
        if X-x < Y-y and y < Y:
            y += 1
            sum += apple[0]
        if Y-y <= X-x and x < X:
            x += 1
            sum += apple[0]

print(sum)
        

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p, q, r = [list(map(int, input().split())) for _ in range(3)]

p = sorted(p, reverse=True)[:X]
q = sorted(q, reverse=True)[:Y]

l = p+q+r

l.sort(reverse=True)

print(sum(l[:X+Y]))
### BUGGY CODE ###

from numba import njit

@njit
def factorize1(n):
    ans=dict()
    i = 2
    while i*i<=n:
        while n%i==0:
            n=n//i
            if i in ans:
                ans[i]+=1
            else:
                ans[i]=1
        i+=1
    if n!=1:
        ans[n]=1
        
    div=1
    for j in ans.items():
        div *= j[1]+1
    return div
   
N=int(input())
ans=1
for k in range(2,N):
    ans += factorize1(k)
print(ans)

### FIXED CODE ###

N=int(input())
ans = 0
for i in range(1,N):
    ans += (N-1)//i
print(ans)
### BUGGY CODE ###

s = list(input())
q = int(input())

f = 1
tail1 = []
head1 = []
for _ in range(q):
    i = list(map(str, input().split()))
    if i[0] == "1":
        f *= -1
    else:
        j,x,s1 = i
        if x == "1":
            if f == 1:
                head1 = [s1] + head1
            else:
                tail1 = tail1 + [s1]
        else:
            if f == -1:
                head1 = [s1] + head1
            else:
                tail1 = tail1 + [s1]

s2 = (head1 + s + tail1)[::f]

print("".join(s2))

### FIXED CODE ###

from collections import deque
 
S = input()
L = deque([])
for c in S:
    L.append(c)
Q = int(input())
flag = 1
for _ in range(Q):
    q = list(input().split())
    if q[0] == "1":
        flag *= -1
    else:
        F = q[1]
        if F == "1":
            if flag == 1:
                L.appendleft(q[2])
            else:
                L.append(q[2])
        else:
            if flag == 1:
                L.append(q[2])
            else:
                L.appendleft(q[2])
if flag == 1:
    print("".join(map(str, L)))
else:
    L.reverse()
    print("".join(map(str, L)))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
sum = 0
for i in range(N):
  for j in range(i+1, N):
    if (A[i] + A[j]) == (j - i):
      sum += 1
print(sum)

### FIXED CODE ###

from collections import defaultdict
 
N = int(input())	# 使わない
 
# j - i = A[i] + A[j] から、
# i + A[i] = j - A[j] となり、iとjが独立するため、同時並行で処理
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)
for i, val in enumerate(map(int, input().split())):
  L[i - val] += 1	# i - val <= j - A[j]
  R[i + val] += 1	# i + val <= i + A[i]
  
cnt = 0
for key, val in L.items():
  if key > 0:
    cnt += L[key] * R[key]
    
print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# # スペース区切りの整数の入力
# b, c = map(int, input().split())
# スペース区切りの整数の入力
strs = input().split()
zyousi = []
for s in strs:
    zyousi.append(int(s))

for i in range(a-1):
    buka_num = zyousi.count(i+1)
    # for j in range(i, a-1):
    #     # print(j)
    #     if i+1 == zyousi[j]:
    #         buka_num += 1
    print(buka_num)
print(0)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# # スペース区切りの整数の入力
# b, c = map(int, input().split())
# スペース区切りの整数の入力
strs = input().split()

buka_nums = []
for i in range(a):
    buka_nums.append(0)

zyousi = []
for s in strs:
    zyousi_n = int(s)
    buka_nums[zyousi_n - 1] += 1

for i in buka_nums:
    print(i)
### BUGGY CODE ###

from functools import *
from collections import *
import sys
sys.setrecursionlimit(10**6)

M = 10**9+7

@lru_cache(maxsize=None)
def mod_inv(a):
  b, x, y = M, 1, 0
  while a != 1:
    (d, a), b = divmod(b, a), a
    x, y = y-d*x, x
  return x%M

cache = defaultdict(dict)
def calc_cache(root, parent):
  c = cache[root]
  if not c or parent in c:
    return
  
  if c and None not in c:
    for p, (r2, t2, s2) in c.items():
      r3, t3, s3 = calc_subtree(p, root)
      r = r2 * t3
      s = s2 + s3
      c[None] = r, None, s
      break
  
  if parent is None:
    return
  
  if None in c:
    r0, t0, s0 = c[None]
    r1, t1, s1 = calc_subtree(parent, root)
    r = r0 * mod_inv(t1) % M
    s = s0 - s1
    c[parent] = r, r * mod_inv(s) % M, s

  
def calc_subtree(root, parent):
  calc_cache(root, parent)
  
  if parent in cache[root]:
    return cache[root][parent]
  
  ret = 1
  size = 1
  for child in (Edge[root] - {parent}):
    r, t, s = calc_subtree(child, root)
    ret = ret * t % M
    size += s
  cache[root][parent] = ret, ret * mod_inv(size) % M if parent else None, size
  return cache[root][parent]

N = int(input())
Edge = defaultdict(set)
fact = 1
for i in range(1, N):
  fact = fact * i % M
  a, b = map(int, input().split())
  Edge[a].add(b)
  Edge[b].add(a)

for i in range(1, N+1):
  print(calc_subtree(i, None)[0] * fact % M)


### FIXED CODE ###

from functools import *
from collections import *
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
 
M = 10**9+7

@lru_cache(maxsize=None)
def mod_inv(a):
  b, x, y = M, 1, 0
  while a != 1:
    (d, a), b = divmod(b, a), a
    x, y = y-d*x, x
  return x%M

@lru_cache(maxsize=None)
def calc_subtree(v):
  ret = 1
  size = 1
  for child in Edge[v]:
    Edge[child].remove(v)
    r, s = calc_subtree(child)
    ret = ret * r % M
    size += s
      
  ret = ret * size % M
  return ret, size

ans = {}
def set_ans(v, a):
  ans[v] = a
  for child in Edge[v]:
    n = calc_subtree(child)[1]
    set_ans(child, ans[v] * n * mod_inv(N-n) % M)

N = int(input())
Edge = defaultdict(set)
fact = N
for i in range(1, N):
  fact = fact * i % M
  a, b = map(int, input().split())
  Edge[a].add(b)
  Edge[b].add(a)

set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)
for i in range(1, N+1):
  print(ans[i])
### BUGGY CODE ###

n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
p=[0]*2**n
p[0]=1
for I in range(2**n-1):
 for j,s in enumerate(bin(A[bin(I).count('1')]&~I)[:1:-1]):
  if s=='1':p[I|1<<j]+=p[I];p[I|1<<j]%=10**9+7
print(p[-1])

### FIXED CODE ###

n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])
### BUGGY CODE ###

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

for i in range(m):
  a.sort()
  a[n-1]=a[n-1]//2
  
print(sum(a))

### FIXED CODE ###

import heapq

n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)

for i in range(m):
  top=heapq.heappop(a)
  heapq.heappush(a,(-1)*(-top//2))
  
print(-sum(a))
### BUGGY CODE ###

from collections import deque
def main():
    A, B, K = map(int, input().split())
    number = deque()
    for i in range(A, B+1):
        number.append(i)
    for i in range(K):
        if len(number) > 0:
            print(number.popleft())
    l = deque()
    for i in range(K):
        if len(number) > 0:
            l.append(number.pop())
    for i in range(len(l)):
        if len(l) > 0:
            print(l.pop())
main()

### FIXED CODE ###

def main():
    A, B, K = map(int, input().split())
    if 2*K > B - A:
        for j in range(A, B + 1):
            print(j)
    else:
        for i in range(A, A + K):
            print(i)
        for j in range(B-(K-1), B + 1):
            print(j)
main()
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

H, W, K = map(int,input().split())
sth,stw,glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
Dist = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
init_q =[]

from collections import deque

def bfs(init):
    next_q = deque([])
    for i in init:
        next_q.append(i)
        Dist[i[0]][i[1]] = 0

    while len(next_q)!=0:
        #キュー取り出し(先頭)
        h,w = next_q.popleft()
        for d in direc:
            for sk in range(1,K+1):
                hs, ws = h + d[0]*sk, w + d[1]*sk
                if not (0<=hs<H and 0<=ws<W):
                    break
                if Gmap[hs][ws]=='@':
                    break
                if Gmap[hs][ws]=='.' and Dist[hs][ws]==INF:
                    next_q.append([hs,ws])
                    Dist[hs][ws] = Dist[h][w] + 1
    return Dist

def main():
    #固定
    init_q.append([sth, stw])

    ret = bfs(init_q)
    print(ret[glh][glw])


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

H, W, K = map(int,input().split())
sth, stw, glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
Seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}

from collections import deque

def bfs(sth, stw, glh, glw):
    next_q = deque([])
    next_q.append((sth,stw,0))
    Seen[sth][stw] = 0

    while len(next_q)!=0:
        #キュー取り出し(先頭)
        h, w, c = next_q.popleft()
        for dh, dw in direc:
            for sk in range(1,K+1):
                hs, ws = h + dh*sk, w + dw*sk
                if not (0<=hs<H and 0<=ws<W):
                    break
                if Gmap[hs][ws]=='@':
                    break
                if Seen[hs][ws]==INF:
                    next_q.append((hs,ws,c+1))
                    Seen[hs][ws] = c + 1
                elif Seen[hs][ws]<=c:
                    break
                if hs==glh and ws==glw:
                    return c + 1
    return -1

def main():
    ret = bfs(sth, stw, glh, glw)
    print(ret)

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

n = int(input())
i = 1
ret = ""
while True:
    x = i
    if  x % 3 == 0:
        ret = " " + str(i)
        i+=1
        if i > n:
            print(ret)
            break


### FIXED CODE ###

#
# 5d
#

def main():
    n = int(input())
    s = ""
    for i in range(1, n+1):
        x = i
        if x % 3 == 0 or x % 10 == 3:
            s += " " + str(i)
        else:
            x //= 10
            while x:
                if x % 10 == 3:
                    s += " " + str(i)
                    break
                x //= 10
    print(s)


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

import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort(reverse=True)
        b.sort()
        p_mdr_av = 0
        p_mdl_av = 0
        p_mdr = 0
        p_mdl_mdr_av = 0
        d = collections.defaultdict(int)
        for av in a:
            if mdl - av >= 0:
                if mdr - av not in d:
                    p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                    d[mdr - av] = p_mdr_av
                else:
                    p_mdr_av = d[mdr - av]
                if mdl - av not in d:
                    p_mdl_av = bisect.bisect_left(b, mdl - av, p_mdl_av)
                    d[mdl - av] = p_mdl_av
                else:
                    p_mdl_av = d[mdl - av]
                dp[i] += p_mdr_av - p_mdl_av
            else:
                if mdr - av not in d:
                    p_mdr_av = bisect.bisect_left(b, mdr - av, p_mdr_av)
                    d[mdr - av] = p_mdr_av
                else:
                    p_mdr_av = d[mdr - av]
                dp[i] += p_mdr_av
                if mdr not in d:
                    p_mdr = bisect.bisect_left(b, mdr, p_mdr)
                    d[mdr] = p_mdr
                else:
                    p_mdr = d[mdr]
                if mdl + mdr - av not in d:
                    p_mdl_mdr_av = bisect.bisect_left(b, mdl + mdr - av, p_mdl_mdr_av)
                    d[mdl + mdr - av] = p_mdl_mdr_av
                else:
                    p_mdl_mdr_av = d[mdl + mdr - av]
                dp[i] += p_mdr - p_mdl_mdr_av
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


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

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

aMax = max(a)

answer = 0
countOld = 0

for i,v in enumerate(a):
    if i != 0:
        count = 0
        while v + count < a[i-1] + countOld:
            count += 1
        answer += count
        countOld = count

print(answer)


### FIXED CODE ###

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

aMax = max(a)

answer = 0
countOld = 0

for i,v in enumerate(a):
    if i != 0:
        count = 0
        count = a[i-1] + countOld - v
        if count < 0:
            count = 0
        answer += count
        countOld = count

print(answer)