#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 12, INF = 1e18 + 7;
vector<int> solve(vector<int> A) {
	map<int, int>mp, mp2;
	vector<int>res, used((int)A.size(), 0);
	for(auto x : A){
		mp[x] += 1;
	}
	for(int i = 0; i < (int)A.size(); ++i){
		if(mp2[A[i]] + 1 <= mp[A[i]] / 2){
			mp2[A[i]] += 1;
			used[i] = 1;
			res.push_back(i);
		}
	}
	for(int i = 0; i < (int)A.size(); ++i){
		if(used[i] != 1){
			res.push_back(i);
		}
	}
	return res;
}
