#include <bits/stdc++.h>
#define INF 1000000000
#define fi first
#define se second
#include "partition.h"
//#pragma GCC optimize ("Ofast", "unroll-loops")
//#pragma GCC target ("avx2")
using namespace std;

vector<int> solve(vector<int> a) {
    int tot=0, n=a.size(), minim=INF, i, j;
    vector<int>ans;
    map<int, int> h;
    h.clear();
    vector<int>v, t;
    v.resize(26);
    int poww=(1<<26), ok=0;
    t.resize(n);
    for (i=0; i<n; i++) t[i]=0;
    for (i=25; i>=0; i--) {
        poww/=2;
        for (auto x:a) {
            if (x==poww) v[i]++;
        }
        int nr=0;
        if (v[i]==0) continue;
        if (v[i]%2==0) {
            for (j=0; j<n; j++) {
                if (a[j]==poww) {
                    nr++;
                    if (nr<=v[i]/2) {
                        ans.push_back(j);
                        t[j]=1;
                    }
                }

            }
        }
        else {
            if (ok==0) {
                for (j=0; j<n; j++) {
                    if (a[j]==poww) {
                        nr++;
                        if (nr<=v[i]/2+1) {
                            ans.push_back(j);
                            t[j]=1;
                        }
                    }

                }
                ok=1;
            }
            else {
                for (j=0; j<n; j++) {
                    if (a[j]==poww) {
                        nr++;
                        if (nr<=v[i]/2) {
                            ans.push_back(j);
                            t[j]=1;
                        }
                    }

                }
            }
        }
    }
    for (i=0; i<n; i++) {
        if (t[i]==0) ans.push_back(i);
    }
    return ans;
}

