#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;

using std::set;
using std::vector;
using std::remove_copy_if;

int main(){
	vector<int> a = {1, 2, 3, 4, 6, 5, 2, 3, 4, 1, 2, 5, 1, 3, 6, 5};
	vector<int> b(a.size());
	set<int> s;
	
	remove_copy_if(a.begin(), a.end(), b.begin(), [&](int v){
		if(s.find(v) != s.end()){
			return true;
		}else{
			s.insert(v);
			return false;
		}
	});
	b.resize(s.size());
	
	for_each(b.begin(), b.end(), [](int v){
		cout << v << ' ';
	});

	cout << endl;

	return 0;
}