#include<bits/stdc++.h>
#include "partition.h"
using namespace std;
vector<int> solve(std::vector<int> A) {
    unordered_map<int, int> m, m1;
    int n = A.size();
    for (int i = 0; i < n; i++){
        m[A[i]]++;
    }
    vector<int> sol;
    for (int i = 0; i < n; i++){
        m1[A[i]]++;
        if (m1[A[i]] <= m[A[i]] / 2)sol.push_back(i);
        else{
            m1[A[i]]--;
        }
    }
    for (int i = n - 1; i >= 0; i--){
        m1[A[i]]++;
        if (m1[A[i]] <= m[A[i]])sol.push_back(i);
    }
    return {sol};
}
