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

#include<cstdio>

#include<vector>

#include<algorithm>

#include<queue>

#include<cmath>

#include<cstring>

using namespace std;

int a[100005];

int n;

int main() {

    scanf("%d",&n);

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

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

    }

    long long maxx=2,minn=2;

    for(int i=n;i>=1&&maxx>=minn;i--){

        if(minn%a[i]!=0){

	       minn=(long long)(minn/a[i])*a[i]+a[i];

	    } 

        maxx=(long long)(maxx/a[i]+1)*a[i]-1;

    }

    if(maxx>=minn){

        printf("%lld %lld\n",minn,maxx);

    }

    else {

	   printf("-1\n");

   }



    return 0;

}


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

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

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



using namespace std;



#define sq(a) ((a) * (a))

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

#define pb push_back

#define mp(a, b) make_pair(a, b)

#define what_is(x) cerr << fixed << setprecision(2) << #x << " = " << x << endl

#define setbitj(n, j) (n |= (1 << (j)))

#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)

#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;



const double EPS = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int MAX = 100005;

const int MOD = 1000000007;



inline bool isEq(double a, double b){return abs(a - b) < EPS;}

inline double toRad(double deg){return deg*PI/180;}

inline double toDeg(double rad){return rad*180/PI;}



inline int geti(int &_int){return scanf("%d", &_int);}

inline int getii(int &_int, int &_int2){return scanf("%d %d", &_int, &_int2);}

inline int getiii(int &_int, int &_int2, int &_int3){return scanf("%d %d %d", &_int, &_int2, &_int3);}



inline int getl(ll &_ll){return scanf("%lld", &_ll);}

inline int getll(ll &_ll, ll &_ll2){return scanf("%lld %lld", &_ll, &_ll2);}

inline int getlll(ll &_ll, ll &_ll2, ll &_ll3){return scanf("%lld %lld %lld", &_ll, &_ll2, &_ll3);}



inline int getd(double &_double){return scanf("%lf", &_double);}

inline int getdd(double &_double, double &_double2){return scanf("%lf %lf", &_double, &_double2);}



inline int getstr(char *str){return scanf("%s", str);}



//#define isValid(a, b) (a >= 0 && a < b)

//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};

//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};



int main(int argc, char* argv[])

{

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

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

    //ios_base::sync_with_stdio(false); cin.tie(NULL);

    int k, ara[MAX];

    geti(k);

    for(int i = 0; i < k; i++)

        geti(ara[i]);

    ll low, high;

    ll l = 0, h = 1e18, mid;

    while(l <= h){

        mid = (l+h)/2;

        ll n = mid;

        for(int i = 0; i < k; i++){n=(n/ara[i])*ara[i];}

        if(n >= 2){

            h = mid-1;

            low = mid;

        }

        else

            l = mid+1;

    }

    l = 0;

    h = 1e18;

    while(l <= h){

        mid = (l+h)/2;

        ll n = mid;

        for(int i = 0; i < k; i++){n=(n/ara[i])*ara[i];}

        if(n <= 2){

            l = mid+1;

            high = mid;

        }

        else

            h = mid-1;

    }

    if(low <= high)

        printf("%lld %lld\n", low, high);

    else

        printf("-1\n");

    return 0;

}


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

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

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

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<vector>

#include<map>

using namespace std;

#define ll long long

#define MAX 100100

inline ll read()

{

	ll x=0;bool t=false;char ch=getchar();

	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

	if(ch=='-')t=true,ch=getchar();

	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();

	return t?-x:x;

}

map<ll,int> M,vis;

int n,tot,ans;

ll a[MAX],b[MAX],p[MAX],pri[MAX];

int main()

{

	n=read();

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

	for(int i=2;i<=2500;++i)

	{

		bool fl=true;

		for(int j=2;j<i;++j)if(i%j==0){fl=false;break;}

		if(fl)pri[++tot]=i;

	}

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

	{

		p[i]=b[i]=1;

		for(int j=1;j<=tot&&a[i]>1;++j)

			if(a[i]%pri[j]==0)

			{

				int cnt=0;

				while(a[i]%pri[j]==0)a[i]/=pri[j],++cnt;

				cnt%=3;if(!cnt)continue;

				if(cnt==1)p[i]*=1ll*pri[j]*pri[j],b[i]*=pri[j];

				else p[i]*=pri[j],b[i]*=1ll*pri[j]*pri[j];

			}

		if(a[i]==1)continue;

		ll s=sqrt(a[i]);b[i]*=a[i];

		if(s*s==a[i])p[i]*=s;

		else p[i]*=a[i]*a[i];

	}

	for(int i=1;i<=n;++i)++M[b[i]];

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

	{

		if(vis[b[i]])continue;

		if(b[i]!=p[i])ans+=max(M[b[i]],M[p[i]]);

		else ans+=1;

		vis[b[i]]=vis[p[i]]=1;

	}

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

	return 0;

}


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

using namespace std;



int n,p[100010],cnt,vis[100010];

long long a[100010],l[100010],r[100010],ans;//l为原数，r为与l乘积为完全立方数的数 

map<long long,int> mp;

int main()

{

	scanf("%d",&n);

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

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

	vis[1]=1;

	for(int i=2;i<=2200;++i)

	{

		if(!vis[i])

		p[++cnt]=i;

		for(int j=1;j<=cnt&&p[j]*i<=2200;++j)

		{

			vis[p[j]*i]=1;

			if(i%p[j]==0)

			break;

		}

	}

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

	{

		long long ji=a[i],qwq=1,ovo=1;

		for(int j=1;j<=cnt;++j)

		{

			int gg=0;

			while(ji%p[j]==0)

			{

				++gg;

				ji/=p[j];

			}

			gg%=3;

			if(gg)

			{

				for(int k=gg;k<3;++k)

				{

					qwq*=p[j];

					if(qwq>1e10)

					qwq=0;

				}

				while(gg)

				{

					ovo*=p[j];

					--gg;

				}

			}

		}

		l[i]=ovo*ji;

		mp[l[i]]++;

		r[i]=qwq;

		long long qaq=(long long)sqrt(ji);

		if(qaq*qaq!=ji)

		{

			if(ji*r[i]<=1e10)

			r[i]*=ji;

			else

			r[i]=0;

			if(ji*r[i]<=1e10)

			r[i]*=ji;

			else

			r[i]=0;

		}

		else

		{

			if(qaq*r[i]<=1e10)

			r[i]*=qaq;

			else

			r[i]=0;

		}

	}

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

	{

		if(l[i]==1)

		continue;

		ans+=max(mp[l[i]],mp[r[i]]);

		mp[l[i]]=0;

		mp[r[i]]=0;

	}

	if(mp[1])

	ans++;

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

	return 0;

}

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



using namespace std;



int n;

long long a[100005];

bool ex = false;

multiset<long long> s, ss;

map<long long, int> f;



int spf[100005];



const int MAXN = 100001;



void sieve() {

    spf[1] = 1;

    for (int i=2; i<=100000; i++)

        spf[i] = i;

 	for (int i=4; i<MAXN; i+=2)

        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)

    {

        if (spf[i] == i)

        {

            for (int j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)

                    spf[j] = i;

        }

    }

}





long long get(long long x) {

	long long ou = 1;

	set<int> vis;

	while (x != 1) {

		if (vis.find(spf[x]) == vis.end()) {

			ou *= spf[x];

			vis.insert(spf[x]);

		}

		x /= spf[x];

	}

	return ou;

}



long long p(long long n) {

	return n*n*n;  

}



signed main() {

	sieve();

	scanf("%d", &n);

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

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

		s.insert(a[i]);

	}

	for (int i = 1; 1ll*i*i*i <= 10000000000; i ++) {

		if (s.find(1ll*i*i*i) != s.end()) {

			ex = true;

			s.erase(1ll*i*i*i);

			ss.insert(1ll*i*i*i);

		}

	}

	//cout << s.size() << endl;

	int res = 0;

	if (ex) res++;

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

		if (ss.find(a[i]) != ss.end()) continue;

		for (int j = 2154; j >= 1; j--) {

			if (a[i] % (1ll*j*j*j) == 0) {

				a[i] /= 1ll*j*j*j;

			}

		}

		f[a[i]]++;

	}

	sort(a+1, a+1+n);

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

		if (ss.find(a[i]) != ss.end()) continue;

		//cout << a[i] << endl;

		if (a[i] > 100000) {res += f[a[i]]; f[a[i]] = 0;}

		else {

			long long op = p(get(a[i]))/a[i];

			res += max(f[a[i]], f[op]);

			f[op] = 0;

			f[a[i]] = 0;

		}

	}	

	cout << res;

}

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

#include<map>

#include<algorithm>

#define N 2200

#define LL long long

#define mod 1000000007

using namespace std;

typedef pair<LL,LL> PLL;

typedef map<LL,int>::iterator miter;

int n,p[N+5],pcnt,ans,cnt0;

bool vis[N+5];

map<LL,int> cnt;

map<LL,LL> iv;

void init()

{

	for(int i=2;i<=N;i++)

	{

		if(!vis[i]) p[++pcnt]=i;

		for(int j=1;i*p[j]<=N;j++)

		{

			vis[i*p[j]]=true;

			if(i%p[j]==0) break;

		}

	}

}

int main()

{

	scanf("%d",&n);

	init();

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

	{

		LL a,tmp,h1=1,inv=1;

		scanf("%lld",&a); tmp=a;

		for(int j=1;j<=pcnt&&1ll*p[j]*p[j]*p[j]<=a;j++)

			if(tmp%p[j]==0)

			{

				int xcnt=0;

				while(tmp%p[j]==0) tmp/=p[j],xcnt++;

				xcnt%=3;

				for(int i=1;i<=xcnt;i++) h1*=1ll*p[j];

				for(int i=1;i<=(3-xcnt)%3;i++) inv*=1ll*p[j];

			}

		if(tmp>1) { h1*=1ll*tmp,inv*=1ll*tmp*tmp; }

		if(h1==1) { cnt0=1; continue; }

		cnt[h1]++;

		iv[h1]=inv,iv[inv]=h1;

	}

	for(miter it=cnt.begin();it!=cnt.end();it++)

		if(cnt.find(iv[it->first])==cnt.end()) ans+=it->second;

		else

		{

			ans+=max(it->second,cnt[iv[it->first]]);

			it->second=cnt[iv[it->first]]=0; 

		}

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

}

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

using namespace std;

#define int long long



template <typename T>

void fin(T a){

  cout<<a<<endl;

  exit(0);

}



signed main(){

  std::vector<bool> is_prime(100001,true);

  std::vector<int> pr;

  is_prime[0]=is_prime[1]=false;

  for(int i=2;i<100001;i++){

    if(!is_prime[i])continue;

    pr.push_back(i);

    for(int j=2*i;j<100001;j+=i)is_prime[j]=false;

  }

  int S=pr.size();

  //cout<<S<<endl;

  //cout<<pr[350]<<endl;

  int N;cin>>N;

  std::vector<int> v(N);

  for(int i=0;i<N;i++)cin>>v[i];

  std::vector<int> w(S);

  for(int i=0;i<S;i++)w[i]=pr[i]*pr[i]*pr[i];

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

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

      if(v[i]<w[j])break;

      if(v[i]%w[j]==0)v[i]/=w[j--];

    }

  }

  map<int,int> m;

  for(int i=0;i<N;i++)m[v[i]]++;

  int ans=0;

  for(auto p:m){

    if(p.second<0)continue;

    if(p.first==1)continue;

    int res=1,n=p.first;

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

      if(n<pr[j]*pr[j])break;

      if(n%pr[j])continue;

      if(n%(pr[j]*pr[j])==0){res*=pr[j];n/=pr[j]*pr[j];}

      else {res*=pr[j]*pr[j];n/=pr[j];}

    }

    res*=n*n;

    //cout<<"P"<<p.first<<" "<<res<<endl;

    if(m.count(res)){

      ans+=max(p.second,m[res]);

      m[res]=-1;

    }

    else ans+=p.second;

  }

  if(m[1])ans++;

  fin(ans);

}


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

using namespace std;



#define int long long

int prime[2234];

vector<int>vp;





signed main(){

  for(int i=2;i<2234;i++)prime[i]=1;

  for(int i=2;i<2234;i++)

    if(prime[i]){

      vp.push_back(i);

      for(int j=i*i;j<2234;j+=i)prime[j]=0;

    }

  int n;cin>>n;

  vector<int> v(n);

  for(int i=0;i<n;i++)cin>>v[i];

  map<int,int> m;

  int ans=0;

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

    for(int p:vp)while(v[i]%(p*p*p)==0)v[i]/=p*p*p;

    if(v[i]==1)ans|=1;

    else m[v[i]]++;

  }

  for(auto p:m){

    int a=p.first;

    int tui=1;

    for(int q:vp){

      if(a%(q*q)==0){

        tui*=q;

        a/=q*q;

      }

      if(a%q==0){

        tui*=q*q;

        a/=q;

      }

    }

    if(a<1e6)tui*=a*a;

    else{

      int tmp=sqrt(a);

      if(a==tmp*tmp)tui*=tmp;

      else if(a==(tmp-1)*(tmp-1))tui*=tmp-1;

      else if(a==(tmp+1)*(tmp+1))tui*=tmp+1;

      else tui*=0;

    }

    if(!(m.count(tui)&&(m[tui]>p.second||(m[tui]==p.second&&tui>p.first))))ans+=p.second;

  }

  cout<<ans<<endl;

}


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

using namespace std;

#define V vector

#define vel V<long long>

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

vel solve(V<vel>& ab, int ex) {

	if (!ex) { return { 1, 0 }; }

	V<V<vel>> qab(2);

	for (vel x : ab) {

		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });

		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }

	}

	V<vel> c(3, vel(2));

	rep(i, 2) {

		for (vel x : qab[i]) {

			int qc = (2 * x[0] + x[1]) % 3;

			if ((qc+1)%2) { c[i][0] ^= 1; }

			if (qc) { c[i][1] ^= 1; }

		}

	}

	rep(i, 2) {

		if (c[1 - i] == c[2]) {

			vel ans = solve(qab[i], ex - 1);

			ans[0] *= 2; ans[1] *= 2; ans[1] += i;

			return ans;

		}

	}

	for(vel &v:ab) { v[0]++; }

	vel ans = solve(ab, ex); ans[0]--;

	return ans;

}

int main() {

	long long inf = 2e17;

	int n; cin >> n;

	V<vel> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	vel ret = solve(ab, 70);

	cout << ret[0] - inf << " " << ret[1] - inf << "\n";

}

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

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

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

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

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

#include<algorithm>

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

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

vel solve(V<vel>& ab, int ex) {

	if (ex == 0) { return { 1, 0 }; }

	V<V<vel>> qab(2);

	for (vel x : ab) {

		int a1 = x[0];

		int b1 = x[1];

		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });

		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }

	}

	V<vel> c(3,vel(2));

	rep(i, 2) {

		for (auto x : qab[i]) {

			int qc = (3 - x[0] + x[1]) % 3; qc = (qc + 3) % 3;

			if (qc == 0) { c[i][0] ^= 1; }

			if (qc == 1) { c[i][1] ^= 1; }

			if (qc == 2) { c[i][0] ^= 1; c[i][1] ^= 1; }

		}

	}

	if (c[0] == c[2]) {

		vel ans = solve(qab[1], ex - 1);

		ans[0] *= 2; ans[1] *= 2;ans[1]++;

		return ans;

	}

	if (c[1] == c[2]) {

		vel ans = solve(qab[0], ex - 1);

		ans[0] *= 2; ans[1] *= 2;

		return ans;

	}

	rep(i, ab.size()) { ab[i][0]++; }

	vel ans = solve(ab, ex); ans[0]--;

	return ans;

}

signed main() {

	int inf = 2e17;

	int n; cin >> n;

	V<vel> ab(n);

	rep(i, n) {

		int a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	vel ret = solve(ab, 70);

	cout << ret[0] - inf << " " << ret[1] - inf << "\n";

}

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

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

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

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

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

using namespace std;

#define int long long

#define V vector

#define vel V<int>

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

vel solve(V<vel>& ab, int ex) {

	if (ex == 0) { return { 1, 0 }; }

	V<V<vel>> qab(2);

	for (vel x : ab) {

		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });

		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }

	}

	V<vel> c(3,vel(2));

	rep(i, 2) {

		for (vel x : qab[i]) {

			int qc = (3 - x[0] + x[1]) % 3; qc = (qc + 3) % 3;

			if (qc==0) { c[i][0] ^= 1; }

			if (qc==1) { c[i][1] ^= 1; }

			if (qc == 2) { c[i][0] ^= 1; c[i][1] ^= 1; }

		}

	}

	rep(i, 2) {

		if (c[1-i] == c[2]) {

			vel ans = solve(qab[i], ex - 1);

			ans[0] *= 2; ans[1] *= 2; ans[1] += i;

			return ans;

		}

	}

	rep(i, ab.size()) { ab[i][0]++; }

	vel ans = solve(ab, ex); ans[0]--;

	return ans;

}

signed main() {

	int inf = 2e17;

	int n; cin >> n;

	V<vel> ab(n);

	rep(i, n) {

		int a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	vel ret = solve(ab, 70);

	cout << ret[0] - inf << " " << ret[1] - inf << "\n";

}

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

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

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

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

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

#include<vector>

#include<bits/stdc++.h>

using namespace std;

#define V vector

#define W V<long long>

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

W S(V<W>&p,int E) {

	if (!E) { return { 1, 0 }; }

	V<V<W>> T(2);

	for (W x : p) {

		T[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });

		if (x[0] & 1) { T[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }

	}

	V<W> c(3,W(2));

	R(i, 2) {

		for (W x : T[i]) {

			int Q = (2 * x[0] + x[1]) % 3;

			if ((Q+ 1) % 2) { c[i][0] ^= 1; }

			if (Q) { c[i][1] ^= 1; }

		}

	}

	R(i, 2) {

		if (c[1 - i] == c[2]) {

			W ans = S(T[i], E-1);

			ans[0] *= 2; ans[1] *= 2; ans[1] += i;

			return ans;

		}

	}

	for (W&v : p) { v[0]++; }

	W A=S(p, E);A[0]--;return A;

}

int main() {

	long long M = 2e17;

	int n; cin >> n;

	V<W> p(n);

	R(i, n) {

		long long a, b; cin >> a >> b;

		p[i] = { a + M,b + M };

	}

	W Q = S(p, 70);

	cout << Q[0] - M << " " << Q[1] - M;

}

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

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

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

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

// Fastest known solution for this problem: