#include "partition.h"
#include <bits/stdc++.h>

std::vector<int> solve(std::vector<int> A) {
    std::unordered_set<int> seti;
    std::vector<int> veci(A.size());

    for (int i = 0; i<A.size(); i++) {
        if (seti.contains(A[i])) {
            seti.erase(A[i]);
        }
        else {
            seti.insert(A[i]);
            veci.push_back(A[i]);
        }
    }
    for (int i = 0; i<veci.size(); i++) {
        veci.push_back(veci[i]);
    }

    return veci;
}