#include "partition.h"
using namespace std;
#include <map>

std::vector<int> solve(std::vector<int> A) {
	vector<int> res;
	map<int, vector<int>> mp;
	for (int i = 0; i < A.size(); i++) {
		mp[A[i]].push_back(i);
	}
	for (auto i : mp) {
		for (int j = 0; j < i.second.size() / 2; j++) {
			res.push_back(i.second[j]);
		}
	}
	for (auto i : mp) {
		for (int j = i.second.size() / 2; j < i.second.size(); j++) {
			res.push_back(i.second[j]);
		}
	}
	return res;
}
