Language: C++

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		for(int p=0;p<29;p++){
			long[] a = new long[N];
			long[] b = new long[N];
			for(int i=0;i<N;i++){
				long mask = (1L << (p + 1)) - 1;
				a[i] = A[i] & mask;
				b[i] = B[i] & mask;
			}
			Array.Sort(b);
			
			long cnt = 0;
			long l0 = 1L << p;
			long r0 = l0 + (1L << p);
			long l1 = r0 + (1L << p);
			long r1 = l1 + (1L << p);
//Console.WriteLine("{0} {1} {2} {3}",l0,r0,l1,r1);
//Console.WriteLine("a:{0}",String.Join(" ",a));
//Console.WriteLine("b:{0}",String.Join(" ",b));
			
			foreach(var na in a){
				int l = 0, r = N;
				int li0 = 0, ri0 = 0, li1 = 0, ri1 = 0;
				
				if(na + b[0] >= l0){
					li0 = -1;
				} else {
					l = 0; r = N;
					while(r - l > 1){
						int c = (l + r) / 2;
						if(na + b[c] < l0){
							l = c;
						} else {
							r = c;
						}
					}
					li0 = l;
				}
				
				if(na + b[0] >= r0){
					ri0 = -1;
				} else {
					l = 0; r = N;
					while(r - l > 1){
						int c = (l + r) / 2;
						if(na + b[c] < r0){
							l = c;
						} else {
							r = c;
						}
					}
					ri0 = l;
				}
				
				if(ri0 != -1 && ri0 > li0) cnt += ri0 - li0;
				
				if(na + b[0] >= l1){
					li1 = -1;
				} else {
					l = 0; r = N;
					while(r - l > 1){
						int c = (l + r) / 2;
						if(na + b[c] < l1){
							l = c;
						} else {
							r = c;
						}
					}
					li1 = l;
				}
				
				if(na + b[0] >= r1){
					ri1 = -1;
				} else {
					l = 0; r = N;
					while(r - l > 1){
						int c = (l + r) / 2;
						if(na + b[c] < r1){
							l = c;
						} else {
							r = c;
						}
					}
					ri1 = l;
				}
				
				if(ri1 != -1 && ri1 > li1) cnt += ri1 - li1;
				
//Console.WriteLine("na:{0}, li0:{1}, ri0:{2}, li1:{3}, ri1:{4}",na, li0, ri0, li1, ri1);
				
			}
			
			ans |= ((long)(cnt % 2) << p);
//Console.WriteLine("{0} {1}",cnt, ans);
			
		}
		Console.WriteLine(ans);
/*		
		List<long> dbg = new List<long>();
		foreach(var x in A) foreach(var y in B) dbg.Add(x + y);
		long v = 0;
		foreach(var xy in dbg) v ^= xy;
		Console.WriteLine(v);
*/		
		
	}
	int N;
	long[] A,B;
	public Sol(){
		using( var r = new FastIn()){
			N = r.ReadInt();
			A = new long[N];
			for(int i=0;i<N;i++) A[i] = r.ReadLong();
			B = new long[N];
			for(int i=0;i<N;i++) B[i] = r.ReadLong();
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}



class FastIn:IDisposable {
	int Size;
	byte[] Mem;
	int ptr;
	int rsize;
	bool unfinished;
	Stream stdin;
	void Init(int n) {
		Size = n;
		Mem = new byte[Size];
		rsize=(stdin=Console.OpenStandardInput()).Read(Mem, 0, Size);
		ptr = 0;
		unfinished=(rsize == Size);
	}
	void Next() {
		if (unfinished == false) return;
		rsize=stdin.Read(Mem, 0, Size);
		ptr = 0;
		unfinished = (rsize == Size);
	}
	
	~FastIn(){
		stdin.Dispose();
	}
	void IDisposable.Dispose(){
		stdin.Dispose();
	}
	public void Dispose(){
		stdin.Dispose();
	}
	
	public FastIn() {
		Init(100000);
	}
	public FastIn(int n) {
		Init(n);
	}
	public int ReadInt() {
		int ret = 0;
		int sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++; continue;
			}
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public uint ReadUint() {
		uint ret = 0;
		uint sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public long ReadLong() {
		long ret = 0;
		long sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++; continue;
			}
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')  ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	
	public double ReadDouble() {
		double ret = 0;
		double sig = 1;
		bool dot = false;
		double keta = 0.1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++;
				if (ptr == Size) Next();
				continue;
			}
			if(Mem[ptr] == '.'){
				dot = true;
				ptr++;
				if (ptr == Size) Next();
				continue;
			}
			if(!dot){
				ret = ret * 10 + Mem[ptr++] - '0';
				if (ptr == Size) Next();
			}else{
				ret = ret + (Mem[ptr++] - '0')*keta;
				keta /= 10.0;
				if (ptr == Size) Next();
			}
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}

	public String ReadStr() {
		//2byte文字はNG
		StringBuilder sb = new StringBuilder();
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
			sb.Append((char)Mem[ptr++]);
			if (ptr == Size && unfinished) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size && unfinished) Next();
		}
		return sb.ToString();
	}
	public String ReadLine() {
		//極力使わない(split/parseするくらいなら上をつかう）
		StringBuilder sb = new StringBuilder();
		while (ptr < rsize && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
			sb.Append((char)Mem[ptr++]);
			if (ptr == Size && unfinished) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
			ptr++;
			if (ptr == Size && unfinished) Next();
		}
		return sb.ToString();
	}
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Linq;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Text;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'System'
    6 | using System.IO;
      |       ^~~~~~
a.cc:13:2: error: expected ';' after class definition
   13 | }
      |  ^
      |  ;
a.cc: In static member function 'static void TEST::Main()':
a.cc:10:17: error: 'Sol' was not declared in this scope
   10 |                 Sol mySol =new Sol();
      |                 ^~~
a.cc:11:17: error: 'mySol' was not declared in this scope
   11 |                 mySol.Solve();
      |                 ^~~~~
a.cc: At global scope:
a.cc:16:15: error: expected ':' before 'void'
   16 |         public void Solve(){
      |               ^~~~~
      |               :
a.cc:125:13: error: expected unqualified-id before '[' token
  125 |         long[] A,B;
      |             ^
a.cc:126:15: error: expected ':' before 'Sol'
  126 |         public Sol(){
      |               ^~~~
      |               :
a.cc:136:16: error: 'String' does not name a type
  136 |         static String rs(){return Console.ReadLine();}
      |                ^~~~~~
a.cc:140:16: error: 'String' does not name a type
  140 |         static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
      |                ^~~~~~
a.cc:141:19: error: expected unqualified-id before '[' token
  141 |         static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
      |                   ^
a.cc:142:20: error: expected unqualified-id before '[' token
  142 |         static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
      |                    ^
a.cc:143:22: error: expected unqualified-id before '[' token
  143 |         static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
      |                      ^
a.cc:144:2: error: expected ';' after class definition
  144 | }
      |  ^
      |  ;
a.cc: In member function 'void Sol::Solve()':
a.cc:20:29: error: structured binding declaration cannot have type 'long int'
   20 |                         long[] a = new long[N];
      |                             ^~
a.cc:20:29: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:20:29: error: empty structured binding declaration
a.cc:20:32: error: expected initializer before 'a'
   20 |                         long[] a = new long[N];
      |                                ^
a.cc:21:29: error: structured binding declaration cannot have type 'long int'
   21 |                         long[] b = new long[N];
      |                             ^~
a.cc:21:29: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:21:29: error: empty structured binding declaration
a.cc:21:32: error: expected initializer before 'b'
   21 |                         long[] b = new long[N];
      |                                ^
a.cc:24:33: error: 'a' was not declared in this scope
   24 |                                 a[i] = A[i] & mask;
      |                                 ^
a.cc:24:40: error: 'A' was not declared in this scope
   24 |                                 a[i] = A[i] & mask;
      |                                        ^
a.cc:25:33: error: 'b' was not declared in this scope
   25 |                                 b[i] = B[i] & mask;
      |                                 ^
a.cc:25:40: error: 'B' was not declared in this scope
   25 |                                 b[i] = B[i] & mask;
      |                                        ^
a.cc:27:25: error: 'Array' was not declared in this scope
   27 |                         Array.Sort(b);
      |                         ^~~~~
a.cc:27:36: error: 'b' was not declared in this scope
   27 |                         Array.Sort(b);
      |                                    ^
a.cc:38:33: error: 'var' was not declared in this scope
   38 |                         foreach(var na in a){
      |                                 ^~~
a.cc:38:25: error: 'foreach' was not declared in this scope
   38 |                         foreach(var na in a){
      |                         ^~~~~~~
a.cc:114:17: error: 'Console' was not declared in this scope
  114 |                 Console.WriteLine(ans);
      |                 ^~~~~~~
a.cc: In constructor 'Sol::Sol()':
a.cc:127:22: error: expected nested-name-specifier before '(' token
  127 |                 using( var r = new FastIn()){
      |                      ^
a.cc: In static member function 'static int Sol::ri()':
a.cc:137:32: error: expected primary-expression before 'int'
  137 |         static int ri(){return int.Parse(Console.ReadLine());}
      |                                ^~~
a.cc:137:32: error: expected ';' before 'int'
a.cc:137:35: error: expected unqualified-id before '.' token
  137 |         static int ri(){return int.Parse(Console.ReadLine());}
      |                                   ^
a.cc: In static member function 'static long int Sol::rl()':
a.cc:138:33: error: expected primary-expression before 'long'
  138 |         static long rl(){return long.Parse(Console.ReadLine());}
      |                                 ^~~~
a.cc:138:33: error: expected ';' before 'long'
a.cc:138:37: error: expected unqualified-id before '.' token
  138 |         static long rl(){return long.Parse(Console.ReadLine());}
      |                                     ^
a.cc: In static member function 'static double Sol::rd()':
a.cc:139:35: error: expected primary-expression before 'double'
  139 |         static double rd(){return double.Parse(Console.ReadLine());}
      |                                   ^~~~~~
a.cc:139:35: error: expected ';' before 'double'
a.cc:139:41: error: expected unqualified-id before '.' token
  139 |         static double rd(){return double.Parse(Console.ReadLine());}
      |                                         ^
a.cc: At global scope:
a.cc:148:26: error: expected class-name before '{' token
  148 | class FastIn:IDisposable {
      |                          ^
a.cc:150:9: error: 'byte' does not name a type
  150 |         byte[] Mem;
      |         ^~~~
a.cc:154:9: error: 'Stream' does not name a type
  154 |         Stream stdin;
      |         ^~~~~~
a.cc:172:14: error: variable or field 'IDisposable' declared void
  172 |         void IDisposable.Dispose(){
      |              ^~~~~~~~~~~
a.cc:172:14: error: expected ';' at end of member declaration
  172 |         void IDisposable.Dispose(){
      |              ^~~~~~~~~~~
      |                         ;
a.cc:172:25: error: expected unqualified-id before '.' token
  172 |         void IDisposable.Dispose(){
      |                         ^
a.cc:175:15: error: expected ':' before 'void'
  175 |         public void Dispose(){
      |               ^~~~~
      |               :
a.cc:179:15: error: expected ':' before 'FastIn'
  179 |         public FastIn() {
      |               ^~~~~~~
      |               :
a.cc:182:15: error: expected ':' before 'FastIn'
  182 |         public FastIn(int n) {
      |               ^~~~~~~
      |               :
a.cc:185:15: error: expected ':' before 'int'
  185 |         public int ReadInt() {
      |               ^~~~
      |               :
a.cc:201:15: error: expected ':' before 'uint'
  201 |         public uint ReadUint() {
      |               ^~~~~
      |               :
a.cc:201:16: error: 'uint' does not name a type; did you mean 'int'?
  201 |         public uint ReadUint() {
      |                ^~~~
      |                int
a.cc:214:15: error: expected ':' before 'long'
  214 |         public long ReadLong() {
      |               ^~~~~
      |               :
a.cc:231:15: error: expected ':' before 'double'
  231 |         public double ReadDouble() {
      |               ^~~~~~~
      |               :
a.cc:264:15: error: expected ':' before 'String'
  264 |         public String ReadStr() {
      |               ^~~~~~~
      |               :
a.cc:264:16: error: 'String' does not name a type
  264 |         public String ReadStr() {
      |                ^~~~~~
a.cc:277:15: error: expected ':' before 'String'
  277 |         public String ReadLine() {
      |               ^~~~~~~
      |               :
a.cc:277:16: error: 'String' does not name a type
  277 |         public String ReadLine() {
      |                ^~~~~~
a.cc:290:2: error: expected ';' after class definition
  290 | }
      |  ^
      |  ;
a.cc: In member function 'void FastIn::Init(int)':
a.cc:157:17: error: 'Mem' was not declared in this scope
  157 |                 Mem = new byte[Size];
      |                 ^~~
a.cc:157:27: error: 'byte' does not name a type
  157 |                 Mem = new byte[Size];
      |                           ^~~~
a.cc:158:24: error: 'stdin' was not declared in this scope
  158 |                 rsize=(stdin=Console.OpenStandardInput()).Read(Mem, 0, Size);
      |                        ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using System;
a.cc:158:30: error: 'Console' was not declared in this scope
  158 |                 rsize=(stdin=Console.OpenStandardInput()).Read(Mem, 0, Size);
      |                              ^~~~~~~
a.cc: In member function 'void FastIn::Next()':
a.cc:164:23: error: 'stdin' was not declared in this scope
  164 |                 rsize=stdin.Read(Mem, 0, Size);
      |                       ^~~~~
a.cc:164:23: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:164:34: error: 'Mem' was not dec