#include "partition.h"
using namespace std;
const int MAX=3*(1e7)+5;
vector<int> v[MAX];
vector<int> a;
std::vector<int> solve(std::vector<int> A)
{
    a=A;
    for(int i=0;i<a.size();i++)
    {
        v[a[i]].push_back(i);
    }
    vector<int> ans1;
    vector<int> ans2;
    for(int i=0;i<MAX;i++)
    {
        for(int j=0;j<v[i].size()/2;j++)
        {
            ans1.push_back(v[i][j]);
        }

        for(int j=v[i].size()/2;j<v[i].size();j++)
        {
            ans2.push_back(v[i][j]);
        }
    }
    for(int x:ans2)ans1.push_back(x);
    return ans1;
}
