#include "partition.h"
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;

std::vector<int> solve(std::vector<int> A) {

    map<ll, ll> mp;

    for (ll x : A) {
        mp[x]++;
    }

    set<int> st;
    vector<int> ans;
    map<ll, ll> mp2;

    bool used[A.size()] = {false};

    for (ll i = 0; i < A.size(); ++i) {
        if (mp2[A[i]] < (mp[A[i]] / 2)) {
            ans.push_back(i);
            mp2[A[i]]++;
            used[i] = true;
        }
    }

    for (ll i = 0; i < A.size(); ++i) {
        if (!used[i]) {
            ans.push_back(i);
        }
    }

    return ans;
}
