#include "partition.h"
#include <bits/stdc++.h>

using namespace std;
const int N = 3e7+2;
int cnt[N];

std::vector<int> solve(std::vector<int> A) {
    int n = (int)A.size();
    vector<int> pos(26, -1);
    for (int i = 0; i < n; ++i) {
		int x = 31-__builtin_clz(A[i]);
		pos[x] = i;
	}
	
	vector<int> res, res2;
	for (int i = 25; i >= 0; --i)
		if (~pos[i])res.push_back(pos[i]);
	int m = ((int)res.size()-1)/2;
	while (m--) {
		res2.push_back(res.back());
		res.pop_back();
	}
	for (auto i: res)res2.push_back(i);
	return res2;
}
