304 North Cardinal St.
Dorchester Center, MA 02124

# Find A, B, C CodeChef Solution

## Find A, B, C CodeChef Solution in C++17

#include <bits/stdc++.h>

#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("Ofast")//Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

using namespace std;

struct PairHash {inline std::size_t operator()(const std::pair<int, int> &v) const { return v.first * 31 + v.second; }};

// speed
#define Code ios_base::sync_with_stdio(false);
#define By ios::sync_with_stdio(0);
#define Sumfi cout.tie(NULL);

// alias
using ll = long long;
using ld = long double;
using ull = unsigned long long;

// constants
const ld PI = 3.14159265358979323846;  /* pi */
const ll INF = 1e18;
const ld EPS = 1e-9;
const ll MAX_N = 202020;
const ll mod = 1e9 + 7;

// typedef
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef array<ll,3> all3;
typedef array<ll,5> all5;
typedef vector<all3> vall3;
typedef vector<all5> vall5;
typedef vector<ld> vld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef deque<ll> dqll;
typedef deque<pll> dqpll;
typedef pair<string, string> pss;
typedef vector<pss> vpss;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef unordered_set<ll> usll;
typedef unordered_set<pll, PairHash> uspll;
typedef unordered_map<ll, ll> umll;
typedef unordered_map<pll, ll, PairHash> umpll;

// macros
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,m,n) for(ll i=n;i>=m;i--)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define INF(a) memset(a,0x3f3f3f3f3f3f3f3fLL,sizeof(a))
#define ASCEND(a) iota(all(a),0)
#define sz(x) ll((x).size())
#define BIT(a,i) (a & (1ll<<i))
#define BITSHIFT(a,i,n) (((a<<i) & ((1ll<<n) - 1)) | (a>>(n-i)))
#define pyes cout<<"Yes\n";
#define pno cout<<"No\n";
#define endl "\n"
#define pneg1 cout<<"-1\n";
#define ppossible cout<<"Possible\n";
#define pimpossible cout<<"Impossible\n";
#define TC(x) cout<<"Case #"<<x<<": ";
#define X first
#define Y second

// utility functions
template <typename T>
void print(T &&t)  { cout << t << "\n"; }
template<typename T>
void printv(vector<T>v){ll n=v.size();rep(i,0,n){cout<<v[i];if(i+1!=n)cout<<' ';}cout<<endl;}
template<typename T>
void printvln(vector<T>v){ll n=v.size();rep(i,0,n)cout<<v[i]<<endl;}
void fileIO(string in = "input.txt", string out = "output.txt") {freopen(in.c_str(),"r",stdin); freopen(out.c_str(),"w",stdout);}
template<typename T>
template<typename T, typename U>
template<typename T, typename U>

struct Combination {
vll fac, inv;
ll n, MOD;

ll modpow(ll n, ll x, ll MOD = mod) { if(!x) return 1; ll res = modpow(n,x>>1,MOD); res = (res * res) % MOD; if(x&1) res = (res * n) % MOD; return res; }

Combination(ll _n, ll MOD = mod): n(_n + 1), MOD(MOD) {
inv = fac = vll(n,1);
rep(i,1,n) fac[i] = fac[i-1] * i % MOD;
inv[n - 1] = modpow(fac[n - 1], MOD - 2, MOD);
rrep(i,1,n - 2) inv[i] = inv[i + 1] * (i + 1) % MOD;
}

ll fact(ll n) {return fac[n];}
ll nCr(ll n, ll r) {
if(n < r or n < 0 or r < 0) return 0;
return fac[n] * inv[r] % MOD * inv[n-r] % MOD;
}
};

struct Matrix {
ll r,c;
vvll matrix;
Matrix(ll r, ll c, ll v = 0): r(r), c(c), matrix(vvll(r,vll(c,v))) {}

Matrix operator*(const Matrix& B) const {
Matrix res(r, B.c);
rep(i,0,r) rep(j,0,B.c) rep(k,0,B.r) {
res.matrix[i][j] = (res.matrix[i][j] + matrix[i][k] * B.matrix[k][j] % mod) % mod;
}
return res;
}

Matrix copy() {
Matrix copy(r,c);
copy.matrix = matrix;
return copy;
}

Matrix pow(ll n) {
assert(r == c);
Matrix res(r,r);
Matrix now = copy();
rep(i,0,r) res.matrix[i][i] = 1;
while(n) {
if(n & 1) res = res * now;
now = now * now;
n /= 2;
}
return res;
}
};

// geometry data structures
template <typename T>
struct Point {
T y,x;
Point(T y, T x) : y(y), x(x) {}
Point(pair<T,T> p) : y(p.first), x(p.second) {}
Point() {}
void input() {cin>>y>>x;}
friend ostream& operator<<(ostream& os, const Point<T>& p) { os<<p.y<<' '<<p.x<<'\n'; return os;}
Point<T> operator+(Point<T>& p) {return Point<T>(y + p.y, x + p.x);}
Point<T> operator-(Point<T>& p) {return Point<T>(y - p.y, x - p.x);}
Point<T> operator*(ll n) {return Point<T>(y*n,x*n); }
Point<T> operator/(ll n) {return Point<T>(y/n,x/n); }
bool operator<(const Point &other) const {if (x == other.x) return y < other.y;return x < other.x;}
Point<T> rotate(Point<T> center, ld angle) {
ld si = sin(angle * PI / 180.), co = cos(angle * PI / 180.);
ld y = this->y - center.y;
ld x = this->x - center.x;

return Point<T>(y * co - x * si + center.y, y * si + x * co + center.x);
}
ld distance(Point<T> other) {
T dy = abs(this->y - other.y);
T dx = abs(this->x - other.x);
return sqrt(dy * dy + dx * dx);
}

T norm() { return x * x + y * y; }
};

template<typename T>
struct Line {
Point<T> A, B;
Line(Point<T> A, Point<T> B) : A(A), B(B) {}
Line() {}

void input() {
A = Point<T>();
B = Point<T>();
A.input();
B.input();
}

T ccw(Point<T> &a, Point<T> &b, Point<T> &c) {
T res = a.x * b.y + b.x * c.y + c.x * a.y;
res -= (a.x * c.y + b.x * a.y + c.x * b.y);
return res;
}

bool isIntersect(Line<T> o) {
T p1p2 = ccw(A,B,o.A) * ccw(A,B,o.B);
T p3p4 = ccw(o.A,o.B,A) * ccw(o.A,o.B,B);
if (p1p2 == 0 && p3p4 == 0) {
pair<T,T> p1(A.y, A.x), p2(B.y,B.x), p3(o.A.y, o.A.x), p4(o.B.y, o.B.x);
if (p1 > p2) swap(p2, p1);
if (p3 > p4) swap(p3, p4);
return p3 <= p2 && p1 <= p4;
}
return p1p2 <= 0 && p3p4 <= 0;
}

pair<bool,Point<ld>> intersection(Line<T> o) {
if(!this->intersection(o)) return {false, {}};
ld det = 1. * (o.B.y-o.A.y)*(B.x-A.x) - 1.*(o.B.x-o.A.x)*(B.y-A.y);
ld t = ((o.B.x-o.A.x)*(A.y-o.A.y) - (o.B.y-o.A.y)*(A.x-o.A.x)) / det;
return {true, {A.y + 1. * t * (B.y - A.y), B.x + 1. * t * (B.x - A.x)}};
}

//@formula for : y = ax + b
//@return {a,b};
pair<ld, ld> formula() {
T y1 = A.y, y2 = B.y;
T x1 = A.x, x2 = B.x;
if(y1 == y2) return {1e9, 0};
if(x1 == x2) return {0, 1e9};
ld a = 1. * (y2 - y1) / (x2 - x1);
ld b = -x1 * a + y1;
return {a, b};
}
};

template<typename T>
struct Circle {
Point<T> center;
Circle() {}

void input() {
center = Point<T>();
center.input();
}

bool circumference(Point<T> p) {
return (center.x - p.x) * (center.x - p.x) + (center.y - p.y) * (center.y - p.y) == radius * radius;
}

bool intersect(Circle<T> c) {
T d = (center.x - c.center.x) * (center.x - c.center.x) + (center.y - c.center.y) * (center.y - c.center.y);
}

bool include(Circle<T> c) {
T d = (center.x - c.center.x) * (center.x - c.center.x) + (center.y - c.center.y) * (center.y - c.center.y);
}
};

ll __gcd(ll x, ll y) { return !y ? x : __gcd(y, x % y); }
all3 __exgcd(ll x, ll y) { if(!y) return {x,1,0}; auto [g,x1,y1] = __exgcd(y, x % y); return {g, y1, x1 - (x/y) * y1}; }
ll __lcm(ll x, ll y) { return x / __gcd(x,y) * y; }
ll modpow(ll n, ll x, ll MOD = mod) { n%=MOD; if(!x) return 1; ll res = modpow(n,x>>1,MOD); res = (res * res) % MOD; if(x&1) res = (res * n) % MOD; return res; }

vll solve(vll A) {
bitset<32> a(0), b(0), c(0);
ll lg2 = log2(sz(A) - 1);
for(ll i = pow(2,lg2); i; i /= 2) {
ll diff = A[i] - A[0];
if(diff == -3 * i) {
a.set(lg2);
b.set(lg2);
c.set(lg2);
} else if(diff == i){
if(a.to_ulong()<=b.to_ulong() && a.to_ulong()<=c.to_ulong()) a.set(lg2);
else if(b.to_ulong()<=c.to_ulong() && b.to_ulong()<=a.to_ulong()) b.set(lg2);
else c.set(lg2);
}
else if(diff == -i){
if(a.to_ulong() <= c.to_ulong() && b.to_ulong()<=c.to_ulong()){
a.set(lg2);
b.set(lg2);
} else if(b.to_ulong()<=a.to_ulong() && c.to_ulong()<=a.to_ulong()){
b.set(lg2);
c.set(lg2);
} else{
a.set(lg2);
c.set(lg2);
}
}
lg2--;
}
return {(ll)a.to_ullong(), (ll)b.to_ullong(), (ll)c.to_ullong()};
}

int main() {
Code By Sumfi
cout.precision(12);
ll tc = 1;
cin>>tc;
rep(i,1,tc+1) {
ll n;
cin>>n;
vll A(n + 1);
printv(solve(A));
}
return 0;
}

## Find A, B, C CodeChef Solution in C++14

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(), _obj.end()
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
ll INF = 1e18;
const int N = 1e5 + 11, mod = 1e9 + 7;
ll max(ll a, ll b) { return ((a > b) ? a : b); }
ll min(ll a, ll b) { return ((a > b) ? b : a); }
void sol(void)
{
int n;
vector<int> a(3, 0);
cin >> n;
int f[n + 1];
for (int i = 0; i <= n; i++)
cin >> f[i];
for (int i = 18; i >= 0; i--)
{
if ((1 << i) > n)
continue;
sort(all(a));
int diff = (f[1 << i] - f[0]) / (1 << i);
if (diff == -3)
{
a[0] ^= (1 << i);
a[1] ^= (1 << i);
a[2] ^= (1 << i);
}
else if (diff == 1)
{
a[0] ^= (1 << i);
}
else if (diff == -1)
{
a[0] ^= (1 << i);
a[1] ^= (1 << i);
}
}

cout << a[0] << ' ' << a[1] << ' ' << a[2] << '\n';
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
int test = 1;
cin >> test;
while (test--)
sol();
}

## Find A, B, C CodeChef Solution in PYTH 3

for _ in range(int(input())):
num=int(input())
lis=list(map(int,input().split()))
bigl=[0,0,0]
for i in range(20,-1,-1):
if((2**i)>num):
continue
bigl=list(sorted(bigl))
mount=(3-(lis[2**i]-lis[0])//(2**i))//2
for j in range(mount):
bigl[j] += 2**i
print(bigl[0],bigl[1],bigl[2])

## Find A, B, C CodeChef Solution in C

#include <stdlib.h>
#include <stdio.h>
#include<math.h>
#include<time.h>
#include<string.h>
#include<float.h>
#include<limits.h>
#include<assert.h>
#include<complex.h>
long long int vishall(const void *klpd, const void *porus)
{
long long int yujj=12;
return (*(long long int*)klpd-*(long long int*)porus);
long long int yuyfvbvcxjj=12;
}
long long int hemalooo(long long int N)
{
long long int kjdbjc=3;
long long int umst= log2(N);
long long int gettingdegree = (long long int)umst;
double king=pow(2,gettingdegree);
return (long long int)king;
}
long long int kopaaaa(const void *perk,const void *absurd)
{
long long int itperr=40;
return (*( long long int*)perk-*( long long int*)absurd);
long long int yukjhgfdsasdfgjj=12;
}

int main()
{
long long int T,v,N;
long long int maxT,r,A, B,P,Q,maxN, sumN;
long long int ylko=0;
long long int potoo=ylko;
scanf("%lld",&T);
long long int klpd=T-1;
for(v=potoo;v<=klpd;)
{
long long int pikasoo = B%2;
long long int hiser=A/2;
long long int yila=0;
long long int jigar=hiser;
long long int pikasitar = Q%2;
scanf("%lld",&N);
long long int countingnumbers=yila;
long long int countingnum=yila;
long long int yukraja=N-4;
long long int ioooyu=countingnum;
long long int cgv=N-15;
long long int zsdxfcvb=N-23;
long long int chnbbn=N-30;
long long int gitee=A-P;
long long int iyu;
long long int cht=jigar;
long long int utry=10;
long long int A[N+1];
for(iyu=ioooyu;iyu<=yukraja+4;)
{
scanf("%lld",&A[iyu]);
iyu=iyu+1;
}
long long int usam=jigar*utry;
long long int ghapty[utry-7];
long long int yamaso=N-1;
long long int nobita=A[0]+A[1];
long long int yamaspp=A[1];
long long int waffer=nobita-yamaspp;
long long int opmnb;
long long int ghaptooy[utry-5];
long long int ko=yamaso;

for(opmnb=countingnum;opmnb<=yamaso-N+3;)
{
ghapty[opmnb]=0;
opmnb=opmnb+1;
}

//long long int ghapty[3]={0,0,0};
long long int giteepp=gitee;
long long int pikasitarpp = Q/2;
long long int hampter;
for(hampter=hemalooo(N);hampter>=1;hampter=hampter/2)
{
long long int minist=A[hampter];
long long int maxist=waffer;
long long int pjihbvgc=minist;
long long int xdgcfv= maxist;
long long int ftgvhbm=pjihbvgc+7;
long long int bhjjftgvhbm=xdgcfv+7;
long long int temporaryyy=ftgvhbm-bhjjftgvhbm;
long long int xcfghvhbjnkjv=temporaryyy;
long long int qwerty=giteepp%2;
long long int giteefgh=B-Q;
long long int ravan=1;

long long int opit=ko;
long long int ravantt=ravan;
long long int teepp=giteefgh;
long long int opitoo=P/2;
long long int utsdop=9223372036854775807;
long long int iotuibh=utsdop;
long long int opop=teepp%2;
long long int opitoopp=P%2;

for(long long int t=yila;t<=ko;t=t+1)
{
long long int gestooa=A[t]%2;
long long int gesta=A[t]/2;
if(gestooa==0)
{
countingnum=countingnum*2;
}
else if(gestooa>0)
{
countingnumbers=countingnumbers+1;
}
else if(gestooa<0)
{
countingnum=countingnum/2;
}
else
{

}
if(A[t]<iotuibh)
{
long long int ayu=10;
countingnum=countingnum-1;
iotuibh=A[t];
long long int yu=10;
}
else if(A[t]==iotuibh)
{
long long int hayu=10;
countingnum=countingnum+1;
iotuibh=A[t];
long long int yuyu=10;
}
else
{

}
}
if (opop==0)
{
long long int yup=0;
if(qwerty!=0)
{
//printf("NO\n");
}
else if(qwerty==0)
{
//printf("YES\n");
}
else
{

}
//printf("%lld\n",ko&(jigar*utry)&(jigar*utry));
for(long long int vishal=0;vishal<=maxT-1;)
{
yup=yup+jigar;
vishal=vishal+1;
}
}
else if (opop!=0)
{
long long int yuper=10;
if(qwerty==0)
{
//printf("NO\n");
}
else if(qwerty!=0)
{
//printf("YES\n");
}
else
{

}
//printf("%lld\n",(jigar*utry)&(opit)&(jigar*utry));
for(long long int vish=0;vish<=maxT-1;)
{
yuper=yuper+hiser;
vish=vish+1;
}

}

else if(yamaso<pikasoo)
{
long long int vikas=sumN/maxN;
long long int tak=sumN%maxN;
long long int uzuki=vikas*hiser/maxN;
long long int ioter=yamaso-uzuki;
long long int yuter=ioter*ioter;
long long int rtyp=vikas*hiser;
long long int kopta=rtyp;
long long int parsooo=yuter+kopta;
if (tak==0)
{

// printf("%lld\n",parsooo);
long long int yiter=0;
for(long long int harry=0;harry<=vikas-1;)
{
yiter=yiter+cht;
vikas=vikas+1;
}

}
else if(tak>0)
{

long long int vikas=sumN/maxN;
long long int tak=sumN%maxN;
long long int uzukiii=vikas*hiser/maxN;
long long int ioterii=yamaso-uzukiii;
long long int yuterii=ioterii*ioterii;
long long int rtypii=vikas*hiser;
long long int koptaii=rtypii;
long long int parsoooii=yuterii+koptaii;
//printf("%lld\n",parsoooii);
long long int yimser=0;
for(long long int hacker=0;hacker<=vikas-1;)
{
yimser=yimser+jigar;
vikas=vikas+1;
}
long long int bioter=sumN-(sumN/maxN)*maxN;
long long int bismat=bioter*bioter;
long long int ufo=bismat;

}
else
{

}
}
else
{

}

long long int juhbygvcfdxes=hampter^ghapty[0];
long long int jgvcfdxes=hampter^ghapty[1];
long long int juhbxes=hampter^ghapty[2];
long long int xdcvgtbhyfvrb= jgvcfdxes;
long long int xdchbgvfcdfvrb= juhbygvcfdxes;
long long int xbgvfcdcfvrb= juhbxes;
long long intkjhgfd = xdcvgtbhyfvrb;
long long int sdygbvfcd= xdchbgvfcdfvrb;
long long int lkojgtfrcn= xbgvfcdcfvrb;

if(bhjjftgvhbm>ftgvhbm)
{
long long int ftgjbhvcghjb=78000000;
xcfghvhbjnkjv=abs(xcfghvhbjnkjv);
long long int ftgbnhgfjbhvcghjb=98778000000;

//A[hampter]-waffer=waffer- A[hampter];
long long int arayyyy[12]={1,2,3,4,5,6,7,8,9,0,1,2};
long long int storing;
storing=xcfghvhbjnkjv/hampter;
long long int mknj=N-17;
long long int vtfcdx=mknj;
long long int xdcfvrb= vtfcdx;
//long long int zaheer=0;

long long int cvgbh=storing;

long long int yyy[10]={1,2,3,4,5,6,7,8,9,0};
long long int xnhbcfgv=xdcfvrb+15;
long long int xnhbgvfchbcfgv=xdcfvrb-7;
long long int vgcfd = xnhbgvfchbcfgv;
long long int jinb=N+19;
long long int klpmaax=cvgbh;
// long long int cvbtrf=klpmaax;
//long long int jnhgvcvw=cvbtrf;
long long int yutbhn=storing;
long long int visballk=3;
long long int hahbvh=visballk;

if( klpmaax==jinb-N-18)
{

klpmaax=jinb-N-17;
if(xdcfvrb+17==xdchbgvfcdfvrb)
{
klpmaax= klpmaax-1;
ghapty[0]=sdygbvfcd;

}
else if(xdcfvrb+17>xdchbgvfcdfvrb)
{
klpmaax= klpmaax-1;
ghapty[0]=sdygbvfcd;

}
if((xnhbcfgv+2==xdcvgtbhyfvrb)&&klpmaax)
{
klpmaax= klpmaax-1;
ghapty[1]=intkjhgfd;
//zaheer=zaheer*2;

}

else if((xnhbcfgv+2>xdcvgtbhyfvrb)&&klpmaax)
{
klpmaax= klpmaax-1;
ghapty[1]=intkjhgfd;

}

if((xnhbgvfchbcfgv+24==xbgvfcdcfvrb)&&klpmaax>0)
{
//if(klpmaax>0)
ghapty[2]=xbgvfcdcfvrb;

}
else if((xnhbgvfchbcfgv+24>xbgvfcdcfvrb)&&klpmaax>0)
{
//if(klpmaax>0)
ghapty[2]=xbgvfcdcfvrb;

}

}
else if(cvgbh==hahbvh)
{
// long long int drftgh=ghapty[2];
ghapty[2]=xbgvfcdcfvrb;
//long long int drftgnmkh=ghapty[1];
ghapty[1]=intkjhgfd;
//long long int drjvcsabftgh=ghapty[0];
ghapty[0]=sdygbvfcd;

}

}
else if(bhjjftgvhbm==ftgvhbm)
{

long long int storing=xcfghvhbjnkjv/hampter;
//long long int vhb=xcfghvhbjnkjv/hampter;
/*long long int dhobii=ghapty[0]^hampter;
long long int dhobiiii=ghapty[1]^hampter;
long long int dhobiiiiii=ghapty[2]^hampter;*/
//long long gjvtcmfrxd=storing;
//long long int storing=xcfghvhbjnkjv/hampter;

if(xcfghvhbjnkjv!=hampter)
//if(storing!=1)
{
}
else
{

if((chnbbn+30)>=lkojgtfrcn) ghapty[2]=lkojgtfrcn;
else  if((zsdxfcvb+23)>=intkjhgfd) ghapty[1]=intkjhgfd;
else if((cgv+15)>=sdygbvfcd) ghapty[0]=sdygbvfcd;
else
{

}
}
}
else if(bhjjftgvhbm<ftgvhbm)
{

long long int storing=xcfghvhbjnkjv/hampter;
//long long int vhb=xcfghvhbjnkjv/hampter;
/*long long int dhobii=ghapty[0]^hampter;
long long int dhobiiii=ghapty[1]^hampter;
long long int dhobiiiiii=ghapty[2]^hampter;*/
//long long gjvtcmfrxd=storing;
//long long int storing=xcfghvhbjnkjv/hampter;

if(xcfghvhbjnkjv!=hampter)
//if(storing!=1)
{
}
else
{

if((cgv+15)>=sdygbvfcd) ghapty[0]=sdygbvfcd;
else  if((zsdxfcvb+23)>=intkjhgfd) ghapty[1]=intkjhgfd;
else  if((chnbbn+30)>=lkojgtfrcn) ghapty[2]=lkojgtfrcn;
else
{

}
}
}

else
{

}

qsort(ghapty, 3, sizeof(long long int),  kopaaaa);
}
long long int xdfcgbhjjn=2;
long long int xdfgiop=-1;
for(long long int logical=xdfgiop+1;logical<=xdfcgbhjjn;)
{
printf("%lld\t",ghapty[logical]);
logical=logical+1;
}
printf("\n");

v=v+1;
}
return 0;
}

## Find A, B, C CodeChef Solution in JAVA

import java.util.*;
import java.lang.*;
class FINDABC
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
int i,j;
while(t-->0)
{
int n=sc.nextInt();
int a[]=new int[n+1];
for(i=0;i<=n;i++)
a[i]=sc.nextInt();
int pi=0,count;
int ip[]={0,0,0};
for(i=n;i>0;i--)
{
if((i&(i-1))==0)
{
pi=i;
break;
}
}
for(i=pi;i>0;i=i/2)
{
int d=a[i]-a[0];
if(d<0)
{
d*=-1;count=(int)d/i;
if(count==1)
{
if((ip[0]^i)<=n)
{ip[0]^=i;count--;}
if((ip[1]^i)<=n)
{ip[1]^=i;count--;}
if(count>-1 && (ip[2]^i)<=n)
ip[2]^=i;
}
else if(count==3)
{
ip[0]^=i;
ip[1]^=i;
ip[2]^=i;
}
}
else
{
count=(int)d/i;
if(count==1)
{
if((ip[0]^i)<=n)
ip[0]^=i;
else if((ip[1]^i)<=n)
ip[1]^=i;
else
ip[2]^=i;
}
}
Arrays.sort(ip);
}
System.out.println(ip[0]+" "+ip[1]+" "+ip[2]);
}
}
}

## Find A, B, C CodeChef Solution in PYPY 3

from sys import stdin, stdout
from collections import defaultdict, Counter, deque
import math, heapq, bisect

def isPowerOfTwo(x):
return (x and (not(x & (x - 1))))

def lcm(a, b):
return ((a*b)//math.gcd(a, b))

def gcd(a, b):
return math.gcd(a, b)

def gcd_list_of_elements(li):
n = len(li); res = li[0]

for i in range(1, n):
res = math.gcd(res, li[i])

return res

def isPalindrome(x):
x = str(x)
return x==x[::-1]

######################################## SegmentTree ###########################################

class SegmentTree:

"""
This SegmentTree is 0-indexed
data -> array for which we have to use SegmentTree
default -> default value in SegmentTree arr
func -> function in SegmentTree
"""

def __init__(self, data, default=0, func=lambda a, b: a+b):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()

self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(range(_size)):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])

def __delitem__(self, idx):
self[idx] = self._default

def __getitem__(self, idx):
return self.data[idx + self._size]

def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1

def __len__(self):
return self._len

def query(self, start, stop):
if start == stop:
return self.__getitem__(start)
stop += 1
start += self._size
stop += self._size

res = self._default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res

def __repr__(self):
return "SegmentTree({0})".format(self.data)

######################################## SegmentTree ###########################################

######################################## FenwickTreeSum ########################################

class FenwickTreeSum:
# Fenwick tree for range-sum queries over a mutable array
def __init__(self, arr):
self.n = len(arr)
self.f = [0] * self.n
for i, x in enumerate(arr):
self.increment(i, x)

def increment(self, j, v):
# Increment the jth value in the array by v

while j < self.n:
self.f[j] += v
# Iteratively replace the right most zero digits with ones
j = j | (j + 1)

def range_sum(self, l, r):
# Return the sum of the elements from l (inclusive) to r (exclusive)
return self.prefix_sum(r - 1) - self.prefix_sum(l - 1)

def prefix_sum(self, x):
# return sum upto and including element x
z = x
res = 0
while z >= 0:
res += self.f[z]
# Strip trailing zeros from z, and then take away one
z = (z & (z + 1)) - 1
return res

######################################## FenwickTreeSum ########################################

if __name__ == "__main__":

t = int(input().strip())

for _ in range(t):
n = int(input().strip())
a = list(map(int, input().strip().split()))

ans = [0, 0, 0]
for i in range(int(math.log2(n)),-1,-1):
pw = (1<<i)
set_bits = (3+((a[0]-a[pw])//pw))//2

ans.sort()
#print(ans)

for i in range(set_bits):
ans[i]+=pw

print(*ans)

## Find A, B, C CodeChef Solution in C#

using System;

namespace CodeChef22
{
// Prepared as a solution to FindABC
// David Sturge (David_S)  9 July 2022

class FindABC
{
static void Main()
{
int space_i;
int t = StringToInt(str_in, 0, out space_i);
while (t-- > 0) {
int n = StringToInt(str_in, 0, out space_i);
int[] ar = StringToIntArray(n + 1, Console.ReadLine());

int sum = ar[0];
int[] nb = new int[20];  // number of times each bit is occupied
int j = 0;
int p = 1;
do {
// When r of abc have 0, 1, 2, 3 bits p set, expect v = -3, -1, 1, 3
int v = (sum - ar[p]) / p;
int r = (v + 3) / 2;
nb[j++] = r;
p <<= 1;
} while (p <= n);

int[] abc = new int[3];

// distribute the bits so that no number is more than N
while (--j >= 0) {
p >>= 1;

switch (nb[j]) {
case 3:
abc[0] |= p;
abc[1] |= p;
abc[2] |= p;
break;
case 0:
break;
default:  // 1 or 2
Array.Sort(abc);
abc[0] |= p;
if (nb[j] == 2)
abc[1] |= p;
break;
}
}

Console.WriteLine("{0} {1} {2}", abc[0], abc[1], abc[2]);
}
}

static int[] StringToIntArray(int num, string s)
// Convert string to integer array.
{
int[] output = new int[num];
int start_i = 0;
int len = s.Length;
while (num_read < num && start_i < len) {
int next_i;
output[num_read++] = StringToInt(s, start_i, out next_i);
start_i = next_i + 1;
}
return output;
}

static int StringToInt(string s, int index, out int space_i)
// Convert string from index up to next space or end to integer.
// Return space_i = index of next space encountered, or off end of string.
{
const int c_zero = '0';
int n = s[index] - c_zero;
int len = s.Length;
while (++index < len) {
if (s[index] < c_zero)
break;
n = n * 10 + (s[index] - c_zero);
}
space_i = index;
return n;
}
}
}

## Find A, B, C CodeChef Solution in NODEJS

input: process.stdin,
output: process.stdout
})
const lines = []
rl.on('line', (input) => {
lines.push(input);
})
rl.on('close', () => {
// (function() {
// const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
let l = 0;
let t = +lines[l++]
const output = []
for (let i = 0; i < t; i++) {
const n = +lines[l++]
const arr = lines[l++].trim().split(' ').map(Number)
output[i] = solve(n, arr)
}
console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
const s = arr[0] // a + b + c
let a = 0
let b = 0
let c = 0
let p
for (p = 1; p <= n; p *= 2) {
const d = arr[p] - s
if (d === 3 * p) {
// 000
} else if (d === -3 * p) {
// 111
a += p
b += p
c += p
} else if (d === p) {
// 100
a += p
} else if (d === -p) {
// 110
a += p
b += p
}
}
const sp = p
for (p = sp; p >= 1; p /= 2) {
if (a <= n) break
if ((a & p) && !(c & p)) {
a -= p
c += p
}
}
// for (p = 1; p <= n; p *= 2) {
for (p = sp; p >= 1; p /= 2) {
if (b <= n) break
if ((b & p) && !(c & p)) {
b -= p
c += p
}
}
// if (a > n || b > n || c > n) throw arr.join(' ')
// const x = []
// for (let i = 0; i <= n; i++) {
//     x[i] = (a ^ i) + (b ^ i) + (c ^ i)
//     if (x[i] !== arr[i]) throw arr.join(' ')
// }
// console.log(x)
return [a, b, c].join(' ')
}

## Find A, B, C CodeChef Solution in GO

package main

import (
"bufio"
"bytes"
"fmt"
"os"
"sort"
)

func main() {
var buf bytes.Buffer
for tc > 0 {
tc--
res := solve(n, F)
buf.WriteString(fmt.Sprintf("%d %d %d\n", res[0], res[1], res[2]))
}

fmt.Print(buf.String())
}

func readUint64(bytes []byte, from int, val *uint64) int {
i := from

var tmp uint64
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + uint64(bytes[i]-'0')
i++
}
*val = tmp

return i
}

func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}

for i := 0; i < len(s); i++ {
if s[i] == '\n' {
return s[:i]
}
}
return s
}

return
}

a, b = res[0], res[1]
return
}

a, b, c = res[0], res[1], res[2]
return
}

res := make([]int, n)
x := 0
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
}
return res
}

func solve(n int, F []int) []int {
R := make([]int, 3)

for i := 18; i >= 0; i-- {
if 1<<uint(i) > n {
continue
}
sort.Ints(R)

diff := (F[1<<uint(i)] - F[0]) / (1 << uint(i))
if diff == -3 {
R[0] ^= 1 << uint(i)
R[1] ^= 1 << uint(i)
R[2] ^= 1 << uint(i)
} else if diff == 1 {
R[0] ^= 1 << uint(i)
} else if diff == -1 {
R[0] ^= 1 << uint(i)
R[1] ^= 1 << uint(i)
}
}

return R
}
##### Find A, B, C CodeChef Solution Review:

In our experience, we suggest you solve this Find A, B, C CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Find A, B, C CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Find A, B, C CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!