#include <algorithm>
#include <iostream>
#include <iterator>
#include <set>
using namespace std;
int main() {
set<int> foo = { 1, 2, 3 };
for(auto it = begin(foo), finish = end(foo); it != finish; ++it) {
foo.insert(*it * 2);
}
copy(cbegin(foo), cend(foo), ostream_iterator<int>(cout, " "));
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxzZXQ+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglzZXQ8aW50PiBmb28gPSB7IDEsIDIsIDMgfTsKCglmb3IoYXV0byBpdCA9IGJlZ2luKGZvbyksIGZpbmlzaCA9IGVuZChmb28pOyBpdCAhPSBmaW5pc2g7ICsraXQpIHsKCQlmb28uaW5zZXJ0KCppdCAqIDIpOwoJfQoJCgljb3B5KGNiZWdpbihmb28pLCBjZW5kKGZvbyksIG9zdHJlYW1faXRlcmF0b3I8aW50Pihjb3V0LCAiICIpKTsKfQ==