#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> solve(std::vector<int> A) {
    int N = A.size();
    map<int, int> inefficientfuck;
    set<int> whatamievendoingatp;
    map<int, vector<int>> K;
    vector<int> ans;
    vector<int> fnaf;
    
    for (int i = 0; i < N; i++) {
        K[A[i]].push_back(i);
        inefficientfuck[A[i]]++;
        whatamievendoingatp.insert(A[i]);
    }

    for (auto u : whatamievendoingatp) {
        for(int i = 0; i < inefficientfuck[u]/2; i++) {
            ans.push_back(u);
        }
    }

    for (int i = 0; i < N / 2; i++) {
        ans.push_back(ans[i]);
    }



    for (int i = 0; i < A.size(); i++) {
        fnaf.push_back(K[ans[i]][0]);
        K[ans[i]].erase(K[ans[i]].begin());
    }

    return fnaf;
}
// 1
// 12
// 7 4 2 7 9 4 4 9 2 7 7 4