#include <algorithm>
#include <iterator>
#include <iostream>
#include <memory>

using namespace std;

int main() {
	std::vector<std::unique_ptr<int>> source, target;
	source.emplace_back(new int(1));
	source.emplace_back(new int(2));
	source.emplace_back(new int(3));
	source.emplace_back(new int(4));
	source.emplace_back(new int(5));
	// your code goes here
	
	for(auto const& i : source) {
		std::cout << *i << ",";
	}
	std::cout << endl;
	
	auto it = std::stable_partition(begin(source),end(source),[](std::unique_ptr<int> const& val) {
		return *val < 3; // only copy values >= 3
	});
	std::move(it,end(source),std::back_inserter(target));
	source.erase(it,end(source));

	
	std::cout << "after" << endl;
	
	for(auto const& i : target) {
		std::cout << *i << ",";
	}
	
	return 0;
}