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

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

std::vector<int> solve(std::vector<int> A) {
    vector<int> ans;
    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;
}
