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

const int MAX_N = 2e6, MAX_A = 3e7;
int times[MAX_A];
int curtimes[MAX_A];

std::vector<int> solve(std::vector<int> A) {
    vector<int> ans;
    vector<int> a = A;
    int n = a.size();
    for(int i = 0; i < n; ++i) {
        times[a[i]]++;
    }
    for(int i = 0; i < n; ++i) {
        curtimes[a[i]]++;
        if(curtimes[a[i]] <= times[a[i]] / 2) {
            ans.push_back(i);
        }
    }
    for(int i = 0; i < n; ++i) {
        curtimes[a[i]] = 0;
    }
    for(int i = 0; i < n; ++i) {
        curtimes[a[i]]++;
        if(curtimes[a[i]] > times[a[i]] / 2) {
            ans.push_back(i);
        }
    }
    return ans;
}
