#include "partition.h"
#include <vector>
const int VMAX=30000005;
const int NMAX=1000005;

using namespace std;

int frecv[VMAX],frecv2[VMAX],frecvI[NMAX];

vector<int> solve(std::vector<int> v)
{
    vector<int> ans;
    for(auto i:v)
    {
        frecv[i]++;
        frecv2[i]=frecv[i]/2;
    }
    for(int i=0;i<v.size();i++)
    {
        if(frecvI[i]==0 && frecv[v[i]]>frecv2[v[i]])
        {
            ans.push_back(i);
            frecvI[i]++;
            frecv[v[i]]--;
        }
    }
    for(int i=0;i<v.size();i++)
    {
        if(frecvI[i]==0) ans.push_back(i);
    }
    return ans;
}
