#include <iostream>
#include <algorithm>
#include <iterator>
#include <list>
using namespace std;
int main()
{
list<int> coll{ 1, 2, 3, 4, 5 };
copy(coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));
cout << endl;
copy(coll.begin(), coll.end(), back_inserter(coll));
copy(coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));
cout << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiAKI2luY2x1ZGUgPGxpc3Q+CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAppbnQgbWFpbigpCnsKICAgIGxpc3Q8aW50PiBjb2xseyAxLCAyLCAzLCA0LCA1IH07CiAKICAgIGNvcHkoY29sbC5iZWdpbigpLCBjb2xsLmVuZCgpLCBvc3RyZWFtX2l0ZXJhdG9yPGludD4oY291dCwgIiAiKSk7CiAgICBjb3V0IDw8IGVuZGw7CiAKICAgIGNvcHkoY29sbC5iZWdpbigpLCBjb2xsLmVuZCgpLCBiYWNrX2luc2VydGVyKGNvbGwpKTsKIAogICAgY29weShjb2xsLmJlZ2luKCksIGNvbGwuZW5kKCksIG9zdHJlYW1faXRlcmF0b3I8aW50Pihjb3V0LCAiICIpKTsKICAgIGNvdXQgPDwgZW5kbDsKfQ==