#include <functional>
#include <memory>
using namespace std;
struct A
{
int x;
};
function<int()> GetFunc()
{
auto c = make_shared<A>(A{0});
return [=]{ return c->x++; };
}
int main()
{
auto x = GetFunc();
return x()+x()+x()-3;
}
I2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxtZW1vcnk+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgQQp7CiAgICBpbnQgeDsKfTsKCmZ1bmN0aW9uPGludCgpPiBHZXRGdW5jKCkKewogICAgYXV0byBjID0gbWFrZV9zaGFyZWQ8QT4oQXswfSk7CiAgICByZXR1cm4gWz1deyByZXR1cm4gYy0+eCsrOyB9Owp9CgppbnQgbWFpbigpCnsKICAgIGF1dG8geCA9IEdldEZ1bmMoKTsKICAgIHJldHVybiB4KCkreCgpK3goKS0zOwp9