#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=3*1e7+1;
ll n;
bool visited[MAXA];
pair<vector<int>,int>cr[MAXA];
std::vector<int> solve(std::vector<int> a) {
    n=a.size();
    ll s=0;
    std::vector<int>ans;
    std::vector<int>d;
    for(ll i=0;i<n;i++)
    {
        s+=a[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;
}
