#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

std::vector<int> solve(std::vector<int> a) {
    int n = a.size();
    vector<int> ans;

    map<int, vector<int> > mp;
    for (int i=0; i<n; i++)
            mp[a[i]].push_back(i);

    for (int it=0; it<2; it++) {
        for (auto [v, vec] : mp) {
            int sz = vec.size() / 2;
            for (int i=0; i<=sz-1; i++)
                ans.push_back(vec[sz*it+i]);
        }
    }

    return ans;
}
