#include <cstdlib>
#include <thread>
#include <chrono>
#include <iostream>
using namespace std;
using namespace std::literals;
struct A
{
int n_ = 0;
A(int n) : n_(n) { cout << "A:" << n_ << endl; }
~A() { cout << "~A:" << n_ << endl; }
};
A a1(1);
int main()
{
std::thread t([]()
{
static A a2(2);
thread_local A a3(3);
std::this_thread::sleep_for(4s);
});
static A a4(4);
thread_local A a5(5);
std::this_thread::sleep_for(2s);
t();
std::exit(0);
}
I2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDx0aHJlYWQ+CiNpbmNsdWRlIDxjaHJvbm8+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIG5hbWVzcGFjZSBzdGQ6OmxpdGVyYWxzOwoKc3RydWN0IEEKewogICAgaW50IG5fID0gMDsKICAgIEEoaW50IG4pIDogbl8obikgeyBjb3V0IDw8ICJBOiIgPDwgbl8gPDwgZW5kbDsgfQogICAgfkEoKSB7IGNvdXQgPDwgIn5BOiIgPDwgbl8gPDwgZW5kbDsgfQp9OwoKQSBhMSgxKTsKCmludCBtYWluKCkKewogICAgc3RkOjp0aHJlYWQgdChbXSgpCiAgICB7CiAgICAgICAgc3RhdGljIEEgYTIoMik7CiAgICAgICAgdGhyZWFkX2xvY2FsIEEgYTMoMyk7CiAgICAgICAgc3RkOjp0aGlzX3RocmVhZDo6c2xlZXBfZm9yKDRzKTsKICAgIH0pOwoKICAgIHN0YXRpYyBBIGE0KDQpOwogICAgdGhyZWFkX2xvY2FsIEEgYTUoNSk7CgogICAgc3RkOjp0aGlzX3RocmVhZDo6c2xlZXBfZm9yKDJzKTsKICAgIHQoKTsKICAgIHN0ZDo6ZXhpdCgwKTsKfQ==