stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{ll v; ll c; ll t;};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.front(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;



			for(Info next : to[now.v]){

				q.push(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			q.push(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

		}

	}



	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{

	ll v; ll c; ll t;

	bool operator<(const DP& o) const{

		return t > o.t;

	}

};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	priority_queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.top(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;

q.emplace(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

			for(Info next : to[now.v]){

				q.emplace(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			

		}

	}

	

	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int t[10][10],u[10][10],ans[10][10],n,flg;

int compute();

void dfs(int);

void change(int,int);

int main(){

  cin>>n;

  while(n--){

    flg=0;

    for(int i=0;i<10;i++){

      for(int j=0;j<10;j++){

	cin>>t[i][j];

	ans[i][j]=0;

      }

    }

    dfs(0);

  }

  return 0;

}

void dfs(int x){

  if(x==10){

    /*

    for(int i=0;i<10;i++)cout<<ans[0][i];

    cout<<endl;

    */

    

    if(compute()){

      for(int i=0;i<10;i++){

	for(int j=0;j<10;j++){

	  if(j)cout<<' ';

	  cout<<ans[i][j];

	}

	cout<<endl;

      }

    }

    

    return;

  }

  ans[0][x]=0;

  dfs(x+1);

  ans[0][x]=1;

  dfs(x+1);

}



int compute(){

  for(int i=0;i<10;i++){

    for(int j=0;j<10;j++){

      u[i][j]=t[i][j];

      if(i)ans[i][j]=0;

    }

  }



  for(int i=0;i<10;i++){

    if(ans[0][i])change(0,i);

  }



  for(int i=1;i<10;i++){

    for(int j=0;j<10;j++){

      if(u[i-1][j]){

	ans[i][j]=1;

	change(i,j);

      }

    }

  }

  for(int i=0;i<10;i++){

    if(u[9][i])return 0;

  }

  return 1;

}



void change(int y,int x){

  u[y][x]=!u[y][x];

  if(y>0)u[y-1][x]=!u[y-1][x];

  if(x>0)u[y][x-1]=!u[y][x-1];

  if(y<9)u[y+1][x]=!u[y+1][x];

  if(x<9)u[y][x+1]=!u[y][x+1];

}

// Optimized solution to the same problem (faster):
#include<iostream>

using namespace std;

int I,flg;

int t[10][10],u[10][10];

int ans[10][10];

void check();

void dfs(int);

void compute(int,int);

int main(){

  cin>>I;

  while(I--){

    flg=0;

    for(int i=0;i<10;i++){

      for(int j=0;j<10;j++){

	cin>>t[i][j];

	u[i][j]=t[i][j];

	ans[i][j]=0;

      }

    }

    dfs(0);

  }

  return 0;

}





void dfs(int x){

  if(flg)return;

  if(x==10){

    check();

  }else{

    ans[0][x]=0;

    dfs(x+1);

    if(flg)return;

    ans[0][x]=1;

    dfs(x+1);

  }

}





void check(){

  if(flg)return;

  for(int i=0;i<10;i++)for(int j=0;j<10;j++)t[i][j]=u[i][j];



  for(int i=0;i<10;i++)if(ans[0][i]==1)compute(0,i);

  

  for(int i=1;i<10;i++){

    for(int j=0;j<10;j++){

      ans[i][j]=0;

      if(t[i-1][j]==1){

	ans[i][j]=1;

	compute(i,j);

      }

    }

  }

  /*

  for(int i=0;i<10;i++){

    for(int j=0;j<10;j++){

      if(j)cout<<' ';

      cout<<t[i][j];

    }

    cout<<endl;

  }

  */

  int cnt=0;

  for(int i=0;i<10;i++)cnt+=t[9][i];

  if(cnt==0){

    flg=1;

    for(int i=0;i<10;i++){

      for(int j=0;j<10;j++){

	if(j)cout<<' ';

	cout<<ans[i][j];

      }

      cout<<endl;

    }

  }

}



void compute(int y,int x){

  t[y][x]=(t[y][x]*-1)+1;

  if(y>0)t[y-1][x]=(t[y-1][x]*-1)+1;

  if(x>0)t[y][x-1]=(t[y][x-1]*-1)+1;

  if(y<9)t[y+1][x]=(t[y+1][x]*-1)+1;

  if(x<9)t[y][x+1]=(t[y][x+1]*-1)+1;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		cin >> a[i];

		goukei ^= a[i];

	}



	int M = 60;

	bool A[100000][60] = {};

	rep(i, N) {

		rep(j, M) {

			A[i][j] = a[i] >> j & 1;

		}

	}



	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (A[j][i]) {

					rep(k, M) swap(A[r][k], A[j][k]);



					for (int j = r + 1; j < N; j++) {

						if (A[j][i]) {

							rep(k, M) A[j][k] ^= A[r][k];

						}

					}

					if (!A[0][i]) {

						rep(k, M) A[0][k] ^= A[r][k];

					}

					r++;

					break;

				}

			}

		}

	}



	ll kotae = 0;

	rep(i, M) {

		if (!(goukei >> i & 1)) {

			if (A[0][i]) {

				kotae += 1ll << (i + 1);

			}

		}

		else {

			kotae += 1ll << i;

		}

	}

	co(kotae);







	Would you please return 0;

}

// Optimized solution to the same problem (faster):
//#include<bits/stdc++.h>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline ll getint() {

	ll A = 0;

	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		a[i] = getint();;

		goukei ^= a[i];

	}



	int M = 60;

	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (a[j] >> i & 1) {

					swap(a[r], a[j]);

					for (int k = max(j, r + 1); k < N; k++) {

						if (a[k] >> i & 1) {

							a[k] ^= a[r];

						}

					}

					if (!(a[0] >> i & 1)) {

						a[0] ^= a[r];

					}

					r++;

					break;

				}

			}

		}

	}



	printf("%lld", a[0] + (a[0] ^ goukei));



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		cin >> a[i];

		goukei ^= a[i];

	}



	int M = 60;

	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (a[j] >> i & 1) {

					swap(a[r], a[j]);



					for (int j = r + 1; j < N; j++) {

						if (a[j] >> i & 1) {

							a[j] ^= a[r];

						}

					}

					if (!(a[0] >> i & 1)) {

						a[0] ^= a[r];

					}

					r++;

					break;

				}

			}

		}

	}



	co(a[0] + (a[0] ^ goukei));



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
//#include<bits/stdc++.h>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline ll getint() {

	ll A = 0;

	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		a[i] = getint();;

		goukei ^= a[i];

	}



	int M = 60;

	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (a[j] >> i & 1) {

					swap(a[r], a[j]);

					for (int k = max(j, r + 1); k < N; k++) {

						if (a[k] >> i & 1) {

							a[k] ^= a[r];

						}

					}

					if (!(a[0] >> i & 1)) {

						a[0] ^= a[r];

					}

					r++;

					break;

				}

			}

		}

	}



	printf("%lld", a[0] + (a[0] ^ goukei));



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		cin >> a[i];

		goukei ^= a[i];

	}



	int M = 60;

	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (a[j] >> i & 1) {

					swap(a[r], a[j]);

					for (int k = max(j, r + 1); k < N; k++) {

						if (a[k] >> i & 1) {

							a[k] ^= a[r];

						}

					}

					if (!(a[0] >> i & 1)) {

						a[0] ^= a[r];

					}

					r++;

					break;

				}

			}

		}

	}



	co(a[0] + (a[0] ^ goukei));



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
//#include<bits/stdc++.h>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline ll getint() {

	ll A = 0;

	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		a[i] = getint();;

		goukei ^= a[i];

	}



	int M = 60;

	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (a[j] >> i & 1) {

					swap(a[r], a[j]);

					for (int k = max(j, r + 1); k < N; k++) {

						if (a[k] >> i & 1) {

							a[k] ^= a[r];

						}

					}

					if (!(a[0] >> i & 1)) {

						a[0] ^= a[r];

					}

					r++;

					break;

				}

			}

		}

	}



	printf("%lld", a[0] + (a[0] ^ goukei));



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#define loop(i, n) for(int i = 0;i < int(n);i++)

#define rloop(i, n) for(int i = int(n);i >= 0;i--)

#define range(i, a, b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int, int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





const int N = 1e5 + 10, LOG_A = 60;

ll basis[LOG_A];



void insertVector(ll mask) {

    for (int i = LOG_A - 1; i >= 0; i--) {

        if ((mask & 1LL << i) == 0) continue;



        if (!basis[i]) {

            basis[i] = mask;

            return;

        }



        mask ^= basis[i];

    }

}



int main() {



#ifndef ONLINE_JUDGE

//    freopen("in.in", "r", stdin);

    //freopen("out.in", "w", stdout);

#endif

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int n;

    ll all = 0, ans = 0;

    cin >> n;

    vector<ll> v(n);

    for (auto &x : v)cin >> x, all ^= x;

    for (auto &x : v)x &= (~all);

    for (auto &x : v)insertVector(x);

    rloop(i, LOG_A - 1) {

        if (!basis[i])continue;

        if ((ans >> i) & 1)continue;

        ans ^= basis[i];

    }



    cout << ans + ans + all << endl;



    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <stdint.h>

#include <stdbool.h>

#include <stdlib.h>

#include <string.h>



typedef uint64_t ull;

typedef  int64_t sll;



static const ull MOD = 1000000007LL;



int n;

int k;

int q;



ull a[200019];



ull umin (ull a, ull b) {

	return (a < b) ? a : b;

}

ull umax (ull a, ull b) {

	return (a > b) ? a : b;

}



ull solve () {

	sll i, j, ki;

	ull res = 0;



	ull allxor = 0;

	for (i = 0; i < n; i++) {

		allxor ^= a[i];

	}

	for (i = 0; i < n; i++) {

		a[i] &= ~allxor;

	}



	ull rank = 0;

	for (i = 59; i >= 0; i--) {

		for (j = rank; j < n; j++) {

			if (a[j] & (1LL << i)) break;

		}

		if (j == n) {

			continue;

		}



		if (j > rank) a[rank] ^= a[j];

		for (j = rank + 1; j < n; j++) {

			a[j] = umin(a[j], a[j] ^ a[rank]);

		}



		rank++;

	}

	ull x = 0;

	for (i = 0; i < n; i++) {

		x = umax(x, x ^ a[i]);

	}



	res = (x * 2) + allxor;



	return res;

}



int main(void){



	scanf("%d", &n, &k);

	for (int i = 0; i < n; i++) {

		scanf("%lld", &a[i]);

	}



	printf("%lld\n", solve());



	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>



int n;

long long int A[100000];



// max_{R} xor_R  + (A xor xor_R)

// max_{R} xor_R and ~A



int main(){

  int i;

  long long int a=0, b, c, z=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%lld", A+i);

    a ^= A[i];

  }



  for(b=1LL<<59;b;b>>=1){

    if(b&a) continue;

    for(i=0;i<n;i++){

      if(A[i]&b) break;

    }

    if(i==n) continue;

    if(!(z&b)) z ^= A[i];

    c = A[i];

    for(;i<n;i++){

      if(A[i]&b) A[i] ^= c;

    }

  }



  printf("%lld\n", 2*(z&~a) + a);



  return 0;

}


// Optimized solution to the same problem (faster):


#include <unistd.h>



int n;

long long int A[100000];



char ibuf[4000000];

char *ibufe = ibuf-1;



void readall(){

  int k, t = 0;

  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;

}



long long int read_uintll(){

  long long int x=0;

  while(*(++ibufe) <'0');

  do {

    x *= 10;

    x += *ibufe-'0';

  } while(*(++ibufe) >='0');



  return x;

}



char buf[2100000];

char *bufe = buf;



void write_uintll(long long int x){

  int i;

  static char tmp[14];

  if(x==0){

    *bufe++ = '0';

    *bufe++ = '\n';

    return;

  }



  for(i=0; x; i++){

    tmp[i] = '0' + x % 10;

    x /= 10;

  }

  for(i--; i >= 0; i--){

    *bufe++ = tmp[i];

  }

  *bufe++ = '\n';

}



void writeall(){

  int k, t = 0;

  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;

}







int main(){

  int i;

  long long int a=0, b, c, z=0;

  readall();

  n = read_uintll();

  for(i=0;i<n;i++){

    A[i] = read_uintll();

    a ^= A[i];

  }



  for(b=1LL<<59;b;b>>=1){

    if(b&a) continue;

    for(i=0;i<n;i++){

      if(A[i]&b) break;

    }

    if(i==n) continue;

    if(!(z&b)) z ^= A[i];

    c = A[i];

    for(;i<n;i++){

      if(A[i]&b) A[i] ^= c;

    }

  }



  write_uintll(2*(z&~a) + a);

  writeall();



  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define me(a,x) memset(a,x,sizeof(a))

#define IN freopen("in.txt","r",stdin);

#define OUT freopen("out.txt","w",stdout);

#define sc scanf

#define itn int

#define STR clock_t startTime = clock();

#define END clock_t endTime = clock();cout << double(endTime - startTime) / CLOCKS_PER_SEC *1000<< "ms" << endl;

using namespace std;

const int N=1e6+5;

const long long mod=1e9+7;

const long long mod2=998244353;

const int oo=0x7fffffff;

const int sup=0x80000000;

typedef long long ll;

typedef unsigned long long ull;

template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}

template <typename it>

string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}

template <typename it>int o(it a){cout<<a<<endl;return 0;}

inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}

inline ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}

inline void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=x*(a/b);}

int n;

ll a[N];

ll dp[65];

bool vis[65]={0};

void insert(ll x){

  for(int i=60;i>=0;i--){

    if(!vis[i])continue; 

    if(x>>i&1){

      if(!dp[i]){

        dp[i]=x;

        break;

      }

      x^=dp[i];

    }

  }

}

ll Q(){

  ll ans=0;

  for(int i=60;i>=0;i--)if(vis[i]&&(ans>>i&1)==0)ans^=dp[i];

  return ans;

}

int main(){

  cin>>n;

  ll sum=0;

  for(int i=1;i<=n;i++){

    sc("%lld",&a[i]);

    sum^=a[i];

  }

  for(int i=0;i<=60;i++){

    if(sum>>i&1)continue;

    vis[i]=1;

  }

  for(int i=1;i<=n;i++)insert(a[i]);

  ll g=Q();

  o((sum^g)+g);

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long ll;

const int maxd = 1e5+10;

ll p[maxd],a[maxd],sum,ans;

int t[maxd],tot,n;

void insert(ll x)

{

    for(int i=1;i<=tot;i++)

        if((x>>t[i])&1)

        {

            if(p[i]) x^= p[i];

            else

            {

                p[i]=x;

                break;

            }

        }

}

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

    for(int i=1;i<=n;i++) sum ^= a[i];

    for(int i=60;i>=0;i--) if(( (sum>>i)&1) == 0) t[++tot]=i;

    for(int i=1;i<=n;i++) insert(a[i]);

    for(int i=1;i<=tot;i++) 

        if(((ans >>t[i])&1) == 0) ans ^=p[i];

    printf("%lld\n",ans+(sum^ans));





    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define all(a) (a).begin(),(a).end()

#define EQ(a,b) (abs((a)-(b))<EPS)

#define fs first

#define sc second



using namespace std;

typedef double D;

typedef pair<int,int> P;

typedef pair<P,P> L;

typedef pair<D,int> pdi;



const D EPS = 1e-8;



inline D func(int x, P a, P b){

  D difx = b.fs - a.fs;

  D dify = b.sc - a.sc;

  return (D)dify/difx * (x-a.fs) + a.sc;

}



int main(){

  int m;

  while(cin >> m,m){

    vector<P> p(m);

    rep(i,m)cin >> p[i].fs >> p[i].sc, p[i].first*=2;

    vector<L> s(m);

    rep(i,m){

      s[i] = L(p[i],p[(i+1)%m]);

      if(s[i].fs > s[i].sc)swap(s[i].fs,s[i].sc);

    }



    int ans = 0;

    for(D x = -3999;x<4000;x+=2){

      vector<pdi> inv;

      rep(i,m){

	if(s[i].fs.fs < x+EPS && x< s[i].sc.fs+EPS){

	  inv.push_back(pdi(func(x,s[i].fs,s[i].sc), i));

	}

      }



      sort(all(inv));

      int prv = -10000;

      for(int i=0;i<(int)inv.size();i+=2){

	int u = inv[i+1].sc, b = inv[i].sc;

	int up = ceil(max(func(x-1,s[u].fs,s[u].sc),

			  func(x+1,s[u].fs,s[u].sc))-EPS);

	int bot = floor(min(func(x-1,s[b].fs,s[b].sc),

			    func(x+1,s[b].fs,s[b].sc))+EPS);

	if(bot<prv)bot = prv;

	ans += up - bot;

	prv = up;

      }

    }

    cout << ans << endl;

  }

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define all(a) (a).begin(),(a).end()

#define EQ(a,b) (abs((a)-(b))<EPS)

#define fs first

#define sc second



using namespace std;

typedef double D;

typedef pair<int,int> P;

typedef pair<P,P> L;

typedef pair<D,int> pdi;



const D EPS = 1e-8;



inline D func(int x, P a, P b){

  D difx = b.fs - a.fs;

  D dify = b.sc - a.sc;

  return (D)dify/difx * (x-a.fs) + a.sc;

}



int main(){

  int m,l,r;

  P p[110];

  L s[110];

  while(scanf("%d",&m),m){

    l = 10000, r = -10000;

    rep(i,m){

      scanf("%d%d",&p[i].fs,&p[i].sc);

      p[i].fs*=2;

      l = min(l,p[i].fs);

      r = max(r,p[i].fs);

    }

    rep(i,m){

      s[i] = L(p[i],p[(i+1)%m]);

      if(s[i].fs > s[i].sc)swap(s[i].fs,s[i].sc);

    }



    int ans = 0;

    for(D x=l+1;x<r;x+=2){

      vector<pdi> inv; inv.reserve(110);

      rep(i,m){

	if(s[i].fs.fs < x+EPS && x< s[i].sc.fs+EPS){

	  inv.push_back(pdi(func(x,s[i].fs,s[i].sc), i));

	}

      }



      sort(all(inv));

      int prv = -10000;

      for(int i=0;i<(int)inv.size();i+=2){

	int u = inv[i+1].sc, b = inv[i].sc;

	int up = ceil(max(func(x-1,s[u].fs,s[u].sc),

			  func(x+1,s[u].fs,s[u].sc))-EPS);

	int bot = floor(min(func(x-1,s[b].fs,s[b].sc),

			    func(x+1,s[b].fs,s[b].sc))+EPS);

	if(bot<prv)bot = prv;

	ans += up - bot;

	prv = up;

      }

    }

    printf("%d\n",ans);

  }

}

// Fastest known solution for this problem: