#include <iostream>
#include <memory>
using namespace std;
struct mirror_ptr
{
int*& ptr;
mirror_ptr(int*& p) : ptr(p){}
};
int main() {
int* raw_ptr = new int;
shared_ptr<mirror_ptr> shared = make_shared<mirror_ptr>(raw_ptr);
delete raw_ptr;
raw_ptr = nullptr;
//...
if (shared->ptr) { std::cout << "ok\n"; }
std::cout << "end\n";
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBtaXJyb3JfcHRyCnsKICAgaW50KiYgcHRyOwogICBtaXJyb3JfcHRyKGludComIHApIDogcHRyKHApe30KfTsKCgppbnQgbWFpbigpIHsKaW50KiByYXdfcHRyID0gbmV3IGludDsKc2hhcmVkX3B0cjxtaXJyb3JfcHRyPiBzaGFyZWQgPSBtYWtlX3NoYXJlZDxtaXJyb3JfcHRyPihyYXdfcHRyKTsKCQpkZWxldGUgcmF3X3B0cjsKcmF3X3B0ciA9IG51bGxwdHI7CgovLy4uLgoKaWYgKHNoYXJlZC0+cHRyKSB7IHN0ZDo6Y291dCA8PCAib2tcbiI7IH0JCnN0ZDo6Y291dCA8PCAiZW5kXG4iOwoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJcmV0dXJuIDA7Cn0=