#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> solve(std::vector<int> A) {
    map<int, int> m;
    vector<int> res;
    vector<int> res2;
    for(int i = 0; i < A.size(); i++) {
        int e = A[i];
        if(m.count(e) == 0) {
            m.insert({e, 1});
            res.push_back(i);
        }
        else if(m[e] % 2 == 0) {
            m[e]++;
            res.push_back(i);
        }
        else {
            m[e]++;
            res2.push_back(i);
        }
    }
    for(auto x : res2) {
        res.push_back(x);
    }
    return res;
}
