/*#include "partition.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using prvi=pair<vector<int>,int>;
const ll MAXN=1e5+1;//1e6*2+1
const ll MAXA=3*1e7+1;
int n;
bool visited[MAXA];
prvi cr[MAXA];
std::vector<int> solve(std::vector<int> a) {
    n=a.size();
    vi ans;
    vi d;
    unordered_map<int, prvi>sp; //key, value
    for(int i=0;i<n;i++)
    {
        sp[a[i]].second++;
        sp[a[i]].first.push_back(i);
    }
    for(int i=0;i<n;i++)
    {
        if(visited[a[i]])continue;
        else visited[a[i]]=1;
           for(int j=0; j<cr[a[i]].second/2;j++)
           {
               ans.push_back(sp[a[i]].first[j]);
               sp[a[i]].first.erase(sp[a[i]].first[j]);
           }
    }
    for(int i=0;i<sp.size();i++)
    {
        for(int j=0;j<sp[i].first.size();j++)
        ans.push_back(sp[i].first[j]);
        //if(sp.find()==sp.end())ans.push_back(i);
    }
    return ans;
}
*/
#include "partition.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAXN=1e5+1;//1e6*2+1
const ll MAXA=1e7;
ll n;
bool visited[MAXA];
pair<vector<int>,int>cr[MAXA];
std::vector<int> solve(std::vector<int> a) {
    n=a.size();
    std::vector<int>ans;
    std::vector<int>d;
    for(ll i=0;i<n;i++)
    {
        cr[a[i]].second++;
        cr[a[i]].first.push_back(i);
    }
    for(ll i=0;i<n;i++)
    {
        if(visited[a[i]])continue;
        else visited[a[i]]=1;
           for(int j=0; j<cr[a[i]].second/2;j++)
           {
               ans.push_back(cr[a[i]].first[j]);
           }

           for(int j=cr[a[i]].second/2;j<cr[a[i]].second;j++)
           {
               d.push_back(cr[a[i]].first[j]);

           }

    }
    for(int i=0;i<d.size();i++)ans.push_back(d[i]);
    return ans;
}

