#include "partition.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> solve(std::vector<int> A) {
  int n = (int)A.size();
  map<int, vector<int>> idx;
  for (int i = 0; i < n; ++i) {
    idx[A[i]].push_back(i);
  }
  vector<int> ans;
  for (auto &[x, v] : idx) {
    for (int i = 0; i < v.size() / 2; ++i) {
      ans.push_back(v[i]);
    }
  }
  for (auto &[x, v] : idx) {
    for (int i = v.size() / 2; i < v.size(); ++i) {
      ans.push_back(v[i]);
    }
  }
  return ans;
}
