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

using namespace std;

std::vector<int> solve(std::vector<int> A) {
    int n = A.size();
    map<int,int>cnt;
    for(int i=0;i<n;i++)
        cnt[A[i]]++;
    map<int,int>loc;
    vector<int>ans,bck;
    for(int i=0;i<n;i++){
        loc[A[i]]++;
        if(loc[A[i]]<=cnt[A[i]]/2){
            ans.push_back(i);
        } else bck.push_back(i);
    }
    for(int i : bck)ans.push_back(i);
    return ans;
}