#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> foo = { 2, 1, 6, 1, 4, 6, 2, 1, 1 };
auto last = end(foo);
for(auto first = begin(foo); first < last; ++first) last = remove(next(first), last, *first);
foo.erase(last, end(foo));
for(const auto& i : foo) cout << i << ' ';
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJdmVjdG9yPGludD4gZm9vID0geyAyLCAxLCA2LCAxLCA0LCA2LCAyLCAxLCAxIH07CiAgICBhdXRvIGxhc3QgPSBlbmQoZm9vKTsKCiAgICBmb3IoYXV0byBmaXJzdCA9IGJlZ2luKGZvbyk7IGZpcnN0IDwgbGFzdDsgKytmaXJzdCkgbGFzdCA9IHJlbW92ZShuZXh0KGZpcnN0KSwgbGFzdCwgKmZpcnN0KTsKCiAgICBmb28uZXJhc2UobGFzdCwgZW5kKGZvbykpOwogICAgCiAgICBmb3IoY29uc3QgYXV0byYgaSA6IGZvbykgY291dCA8PCBpIDw8ICcgJzsKfQ==