#include <iostream>
#include <set>
#include <iterator>
#include <algorithm>
using namespace std;
int main() {
set<int> oldset;
for (int i = 0; i < 10; ++i) oldset.insert(i);
copy(oldset.begin(), oldset.end(), ostream_iterator<int>(cout));
cout << endl;
// cut [b, e)
set<int>::iterator b = oldset.find(3);
set<int>::iterator e = oldset.find(7);
set<int> newset(b, e);
oldset.erase(b, e);
copy(oldset.begin(), oldset.end(), ostream_iterator<int>(cout));
cout << endl;
copy(newset.begin(), newset.end(), ostream_iterator<int>(cout));
cout << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkgewogIHNldDxpbnQ+IG9sZHNldDsKICBmb3IgKGludCBpID0gMDsgaSA8IDEwOyArK2kpIG9sZHNldC5pbnNlcnQoaSk7CgogIGNvcHkob2xkc2V0LmJlZ2luKCksIG9sZHNldC5lbmQoKSwgb3N0cmVhbV9pdGVyYXRvcjxpbnQ+KGNvdXQpKTsKICBjb3V0IDw8IGVuZGw7CgogIC8vIGN1dCBbYiwgZSkgCiAgc2V0PGludD46Oml0ZXJhdG9yIGIgPSBvbGRzZXQuZmluZCgzKTsKICBzZXQ8aW50Pjo6aXRlcmF0b3IgZSA9IG9sZHNldC5maW5kKDcpOwogIHNldDxpbnQ+IG5ld3NldChiLCBlKTsKICBvbGRzZXQuZXJhc2UoYiwgZSk7CgogIGNvcHkob2xkc2V0LmJlZ2luKCksIG9sZHNldC5lbmQoKSwgb3N0cmVhbV9pdGVyYXRvcjxpbnQ+KGNvdXQpKTsKICBjb3V0IDw8IGVuZGw7CiAgY29weShuZXdzZXQuYmVnaW4oKSwgbmV3c2V0LmVuZCgpLCBvc3RyZWFtX2l0ZXJhdG9yPGludD4oY291dCkpOwogIGNvdXQgPDwgZW5kbDsKfQo=