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

const int MAX_N = 2e6, MAX_A = 3e7;
vector<int> poses[MAX_A];

std::vector<int> solve(std::vector<int> A) {
    vector<int> ans;
    unordered_set<int> nums;
    int n = A.size();
    for(int i = 0; i < n; ++i) {
        poses[A[i]].push_back(i);
        nums.insert(A[i]);
    }
    for(auto x : nums) {
        for(int i = 0; i < poses[x].size() / 2; ++i) {
            ans.push_back(poses[x][i]);
        }
    }
    for(auto x : nums) {
        for(int i = poses[x].size() / 2; i < poses[x].size(); ++i) {
            ans.push_back(poses[x][i]);
        }
    }
    return ans;
}
