#include "partition.h"
#include <bits/stdc++.h>
std::vector<int> solve(std::vector<int> A) {
    vector<int>br(A.size()+1,0);
    for (int i=0;i<A.size();i++){
        int c=A[i];
        br[c]++;
    }
    vector<int>brnu(A.size()+1,0);
    vector<int>rezi;
    vector<int>rezic;
    vector<int>rezz;
    for (int i=0;i<A.size();i++){
        int b=A[i];
        brnu[b]++;
        if (brnu[b]<=(br[b]/2)){
            rezi.push_back(i);
        }
        else{
            rezic.push_back(i);
        }
    }
    for (int i=0;i<A.size();i++){
        if (i<rezi.size()){
            rezz.push_back(rezi[i]);
        }
        else{
            rezz.push_back(rezic[i-rezi.size()]);
        }
    }

    return {rezz};
}





