#include <iostream>
using namespace std;
int main() {
auto exec = [i = 0]() mutable { cout << ++i << ' '; };
exec(); // 1
exec(); // 2
auto exec2 = exec;
exec2(); // 3
exec(); // 3
cout << endl;
auto exec3 = []() { static int i = 0; cout << ++i << ' '; };
exec3(); // 1
exec3(); // 2
auto exec4 = exec3;
exec4(); // 3
exec3(); // 4
cout << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglhdXRvIGV4ZWMgPSBbaSA9IDBdKCkgbXV0YWJsZSB7IGNvdXQgPDwgKytpIDw8ICcgJzsgfTsKCWV4ZWMoKTsgIC8vIDEKCWV4ZWMoKTsgIC8vIDIKCWF1dG8gZXhlYzIgPSBleGVjOwoJZXhlYzIoKTsgLy8gMwoJZXhlYygpOyAgLy8gMwoJCgljb3V0IDw8IGVuZGw7CgkKCWF1dG8gZXhlYzMgPSBbXSgpIHsgc3RhdGljIGludCBpID0gMDsgY291dCA8PCArK2kgPDwgJyAnOyB9OwoJZXhlYzMoKTsgLy8gMQoJZXhlYzMoKTsgLy8gMgoJCglhdXRvIGV4ZWM0ID0gZXhlYzM7CglleGVjNCgpOyAvLyAzCglleGVjMygpOyAvLyA0CgkKCWNvdXQgPDwgZW5kbDsKCQoJcmV0dXJuIDA7Cn0=