#if 0 // Kuin Programming Language v.2021.4.17 func main() var n: int :: cui@inputInt() var a: int :: cui@inputInt() var ab: int :: cui@inputInt() + a var abc: int :: cui@inputInt() + ab var xx: []int :: #[n + 1]int var len: int :: 0 var map: dict :: #dict for i(1, n) do len :+ ^cui@inputStr() do xx[i] :: len do map.add(len, true) end for var ans: int :: 0 for i(0, n - 3) var x: int :: xx[i] if(map.get(x + a, &) & map.get(x + ab, &) & map.get(x + abc, &)) do ans :+ 1 end if end for do cui@print("\{ans}\n") end func #endif //{{{ C++ code below is transpiled from Kuin code above by Kuin Programming Language v.2021.4.17 #if defined(_WIN32) #define _CRT_SECURE_NO_WARNINGS #else #define _FILE_OFFSET_BITS 64 #endif #include #include static int64_t classTable_[21]; #include #define new_(...) std::make_shared<__VA_ARGS__> #define type_(...) std::shared_ptr<__VA_ARGS__> #define newPrim_(...) new __VA_ARGS__ #define delPrim_(x) delete x #define newPrimArray_(x, ...) new __VA_ARGS__[x] #define delPrimArray_(x) delete[] x #define dcast_(...) std::dynamic_pointer_cast<__VA_ARGS__> #define addr_(...) (__VA_ARGS__==nullptr?0:reinterpret_cast(__VA_ARGS__.get())) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { template std::size_t bufLen_() { return 0; } template<> std::size_t bufLen_() { return 1; } } static int64_t exitCode_ = 0; struct Class_ { Class_() : Y(0LL) {} virtual ~Class_() {} int64_t Y; }; template struct Array_ { Array_() : L(), B() {} template explicit Array_(A... a) { L = sizeof...(a); B = newPrimArray_(static_cast(sizeof...(a) + bufLen_()), T); BufferCopy(B, std::forward(a)...); if (bufLen_() > 0) B[sizeof...(a)] = 0; } ~Array_() { delPrimArray_(B); } void BufferCopy(T* b) {} template void BufferCopy(T* b, A h, B... t) { *b = h; BufferCopy(b + 1, std::forward(t)...); } type_(Array_) Cat(const type_(Array_) t) { type_(Array_) r = new_(Array_)(); r->B = newPrimArray_(static_cast(L + t->L + bufLen_()), T); for (int64_t i = 0; i < L; i++) r->B[i] = B[i]; for (int64_t i = 0; i < static_cast(t->L + bufLen_()); i++) r->B[L + i] = t->B[i]; r->L = L + t->L; return r; } int64_t Len() { return L; } T& At(int64_t n) { if (n < 0 || n >= L) throw 0xe9170002; return B[n]; } int64_t L; T* B; }; template struct List_ { List_() : B(), I(B.end()) {} int64_t Len() { return static_cast(B.size()); } std::list B; typename std::list::iterator I; }; template struct Stack_ { Stack_() : B() {} int64_t Len() { return static_cast(B.size()); } std::stack B; }; template struct Queue_ { Queue_() : B() {} int64_t Len() { return static_cast(B.size()); } std::queue B; }; template struct dictImpl_; template dictImpl_* dictAddRec_(dictImpl_* n, T1 k, T2 v, bool* a); template dictImpl_* dictDelRec_(dictImpl_* n, T1 k, bool* d); template dictImpl_* dictCopyRec_(dictImpl_* n); template void dictToBinRec_(type_(Array_) a, dictImpl_* d); template void dictFreeRec_(dictImpl_* n); template struct Dict_ { Dict_() : L(0LL), B(nullptr) {} ~Dict_() { dictFreeRec_(B); } int64_t Len() { return L; } void Add(T1 k, T2 v) { bool a = false; B = dictAddRec_(B, k, v, &a); B->R = false; if (a) L++; } void Del(T1 k) { bool d = false; B = dictDelRec_(B, k, &d); if (B != nullptr) B->R = false; if (d) L--; } int64_t L; dictImpl_* B; }; template struct dictImpl_ { dictImpl_(T1 k, T2 v) : K(k), V(v), CL(nullptr), CR(nullptr), R(true) {} T1 K; T2 V; dictImpl_* CL; dictImpl_* CR; bool R; }; #if _MSC_VER >= 1900 && _MSC_VER < 1922 static std::string utf16ToUtf8_(const std::u16string& s) { const int16_t* p = reinterpret_cast(s.data()); return std::wstring_convert, int16_t>{}.to_bytes(p, p + s.size()); } static std::u16string utf8ToUtf16_(const std::string& s) { const auto t = std::wstring_convert, int16_t>{}.from_bytes(s); return std::u16string(reinterpret_cast(t.data()), t.size()); } #else static std::string utf16ToUtf8_(const std::u16string& s) { return std::wstring_convert, char16_t>{}.to_bytes(s); } static std::u16string utf8ToUtf16_(const std::string& s) { return std::wstring_convert, char16_t>{}.from_bytes(s); } #endif #if defined(_WIN32) #pragma comment(lib, "shlwapi.lib") #define STRICT #define _WIN32_DCOM #include #include #include const char newLine_[] = { '\r', '\n' }; static void normPath_(char16_t* p, bool d) { if (*p == 0) return; do { if (*p == '\\') *p = '/'; p++; } while (*p != 0); if (d && p[-1] != '/') { p[0] = '/'; p[1] = 0; } } static bool fileExists_(const char16_t* p) { return PathFileExistsW(reinterpret_cast(p)) != 0; } static int64_t getCurDir_(char16_t* p) { if (!::GetCurrentDirectoryW(511, reinterpret_cast(p))) return 0; normPath_(p, true); return ::wcslen(reinterpret_cast(p)); } static void setCurDir_(const char16_t* p) { ::SetCurrentDirectoryW(reinterpret_cast(p)); } static bool makeDir_(const char16_t* p) { return ::CreateDirectoryW(reinterpret_cast(p), 0) != 0; } static bool delFile_(const char16_t* p) { if (!PathFileExistsW(reinterpret_cast(p))) return true; return ::DeleteFileW(reinterpret_cast(p)) != 0; } static bool copyFile_(const char16_t* d, const char16_t* s) { return ::CopyFileW(reinterpret_cast(s), reinterpret_cast(d), false) != 0; } static bool moveFile_(const char16_t* d, const char16_t* s) { return ::MoveFileExW(reinterpret_cast(s), reinterpret_cast(d), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING) != 0; } static int64_t fullPath_(char16_t* p, const char16_t* q) { wchar_t* f; if (!::GetFullPathNameW(reinterpret_cast(q), 511, reinterpret_cast(p), &f)) return 0; normPath_(p, q[::wcslen(reinterpret_cast(q)) - 1] == '/'); return ::wcslen(reinterpret_cast(p)); } static void sleep_(int64_t t) { for (int64_t i = 0; i < t / 10000; i++) Sleep(10000); Sleep(static_cast(t % 10000)); } #else #include #include #include #define _A_SUBDIR 0x10 const char newLine_[] = { '\n' }; static void normPath_(char* p, bool d) { if (*p == 0) return; std::size_t l = ::strlen(p); if (d && p[l - 1] != '/') { p[l] = '/'; p[l + 1] = 0; } } static bool fileExists_(const char16_t* p) { struct stat b; std::u16string s = p; const std::string& t = utf16ToUtf8_(s); return ::stat(t.c_str(), &b) == 0; } static int64_t getCurDir_(char16_t* p) { char b[512]; if (getcwd(b, 511) == nullptr) return 0; normPath_(b, true); std::string s = b; const std::u16string& t = utf8ToUtf16_(s); if (t.size() >= 512) return 0; memcpy(p, t.c_str(), sizeof(char16_t) * (t.size() + 1)); return static_cast(t.size()); } static void setCurDir_(const char16_t* p) { std::u16string s = p; const std::string& t = utf16ToUtf8_(s); ::chdir(t.c_str()); } static bool makeDir_(const char16_t* p) { std::u16string s = p; const std::string& t = utf16ToUtf8_(s); return ::mkdir(t.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0; } static bool delFile_(const char16_t* p) { struct stat b; std::u16string s = p; const std::string& t = utf16ToUtf8_(s); if (::stat(t.c_str(), &b) != 0) return true; return ::unlink(t.c_str()) == 0; } static bool copyFile_(const char16_t* d, const char16_t* s) { std::u16string s1 = d; const std::string& t1 = utf16ToUtf8_(s1); std::u16string s2 = s; const std::string& t2 = utf16ToUtf8_(s2); int i = ::open(t2.c_str(), O_RDONLY); if (i < 0) return false; struct stat f; if (::stat(t2.c_str(), &f) != 0) { ::close(i); return false; } int o = ::open(t1.c_str(), O_CREAT | O_WRONLY | O_TRUNC, f.st_mode); if (o < 0) { ::close(i); return false; } ssize_t r = 1; char* buf = newPrimArray_(65536, char); while (r > 0 && (r = ::read(i, buf, 65536)) > 0) { ssize_t z, w = 0; do { if ((z = ::write(o, buf + w, r - w)) < 0) { r = z; break; } w += z; } while (w < r); } if (::close(i) < 0) r = -1; if (::close(o) < 0) r = -1; delPrimArray_(buf); return r >= 0; } static bool moveFile_(const char16_t* d, const char16_t* s) { std::u16string s1 = d; const std::string& t1 = utf16ToUtf8_(s1); std::u16string s2 = s; const std::string& t2 = utf16ToUtf8_(s2); struct stat b; if (::stat(t1.c_str(), &b) == 0) { if (::unlink(t1.c_str()) != 0) return false; } return ::rename(t2.c_str(), t1.c_str()) == 0; } static int64_t fullPath_(char16_t* p, const char16_t* q) { std::u16string s1 = q; const std::string& t1 = utf16ToUtf8_(s1); char a[512 + 1]; if (::realpath(t1.c_str(), a) == nullptr) return 0; normPath_(a, t1[t1.size() - 1] == '/'); std::string s2 = a; const std::u16string& t2 = utf8ToUtf16_(s2); if (t2.size() >= 512) return 0; memcpy(p, t2.c_str(), sizeof(char16_t) * (t2.size() + 1)); return static_cast(t2.size()); } static void sleep_(int64_t t) { timespec r = { t / 1000, t % 1000 * 1000000 }; nanosleep(&r, nullptr); } #endif static bool fileForEach_(const std::u16string& p, bool r, bool(*f)(type_(Array_), bool, type_(Class_)), type_(Class_) d) { if (p.size() > 512) return false; #if defined(_WIN32) WIN32_FIND_DATAW t; HANDLE h; #else dirent* t; DIR* h; #endif bool a = true; { #if defined(_WIN32) wchar_t p3[514]; memcpy(p3, p.c_str(), sizeof(wchar_t) * static_cast(p.size())); p3[p.size()] = '*'; p3[p.size() + 1] = 0; h = FindFirstFileW(p3, &t); if (h == INVALID_HANDLE_VALUE) return false; #else const std::string& p2 = utf16ToUtf8_(p); h = ::opendir(p2.c_str()); if (h == nullptr) return false; #endif } { type_(Array_) x = new_(Array_)(); x->L = static_cast(p.size()); x->B = newPrimArray_(static_cast(p.size() + 1), char16_t); memcpy(x->B, p.c_str(), sizeof(char16_t) * static_cast(p.size() + 1)); if (!f(x, true, d)) a = false; } if (a) { #if defined(_WIN32) do { wchar_t* b = t.cFileName; if ((t.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { std::size_t l = ::wcslen(b); #else while ((t = readdir(h)) != nullptr) { if ((t->d_type & _A_SUBDIR) == 0) { std::string s = t->d_name; const std::u16string& p2 = utf8ToUtf16_(s); std::size_t l = p2.size(); const char16_t* b = p2.c_str(); #endif type_(Array_) p3 = new_(Array_)(); p3->L = p.size() + static_cast(l); p3->B = newPrimArray_(static_cast(p.size() + l + 1), char16_t); memcpy(p3->B, p.c_str(), sizeof(char16_t) * static_cast(p.size())); memcpy(p3->B + p.size(), b, sizeof(char16_t) * (l + 1)); if (!f(p3, false, d)) { a = false; break; } } else if (r) { std::u16string p3 = p; #if defined(_WIN32) if (wcscmp(b, L".") == 0 || wcscmp(b, L"..") == 0) continue; p3 += reinterpret_cast(b); #else const char* n = t->d_name; if (strcmp(n, ".") == 0 || strcmp(n, "..") == 0) continue; std::string s = n; const std::u16string& p2 = utf8ToUtf16_(s); p3 += p2; #endif p3 += u'/'; if (!fileForEach_(p3, r, f, d)) { a = false; break; } } } #if defined(_WIN32) while (FindNextFileW(h, &t)); #endif } #if defined(_WIN32) FindClose(h); #else closedir(h); #endif return a; } static bool delDir_(const std::u16string& p) { if (p.size() > 512) return false; if (!fileExists_(p.c_str())) return true; #if defined(_WIN32) WIN32_FIND_DATAW t; HANDLE h; #else dirent* t; DIR* h; #endif bool a = true; { #if defined(_WIN32) wchar_t p3[514]; memcpy(p3, p.c_str(), sizeof(wchar_t) * static_cast(p.size())); p3[p.size()] = '*'; p3[p.size() + 1] = 0; h = FindFirstFileW(p3, &t); if (h == INVALID_HANDLE_VALUE) return false; #else const std::string& p2 = utf16ToUtf8_(p); h = ::opendir(p2.c_str()); if (h == nullptr) return false; #endif } #if defined(_WIN32) do { if ((t.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { std::u16string b = p; b += reinterpret_cast(t.cFileName); #else while ((t = readdir(h)) != nullptr) { if ((t->d_type & _A_SUBDIR) == 0) { std::string n = t->d_name; const std::u16string& n2 = utf8ToUtf16_(n); std::u16string b = p; b += n2; #endif if (!delFile_(b.c_str())) { a = false; break; } } else { std::u16string p2 = p; #if defined(_WIN32) const wchar_t* n = t.cFileName; if (wcscmp(n, L".") == 0 || wcscmp(n, L"..") == 0) continue; p2 += reinterpret_cast(n); #else const char* n = t->d_name; if (strcmp(n, ".") == 0 || strcmp(n, "..") == 0) continue; std::string s = n; const std::u16string& n2 = utf8ToUtf16_(s); p2 += n2; #endif p2 += u"/"; if (!delDir_(p2)) { a = false; break; } } } #if defined(_WIN32) while (FindNextFileW(h, &t)); FindClose(h); #else closedir(h); #endif if (a) { #if defined(_WIN32) a = ::RemoveDirectoryW(reinterpret_cast(p.c_str())) != 0; #else const std::string& p2 = utf16ToUtf8_(p); a = ::rmdir(p2.c_str()) == 0; #endif } return a; } static bool copyDir_(const std::u16string& d, const std::u16string& s) { if (s.size() > 512) return false; #if defined(_WIN32) WIN32_FIND_DATAW t; HANDLE h; #else dirent* t; DIR* h; #endif bool a = true; { #if defined(_WIN32) wchar_t p3[514]; memcpy(p3, s.c_str(), sizeof(wchar_t) * static_cast(s.size())); p3[s.size()] = '*'; p3[s.size() + 1] = 0; h = FindFirstFileW(p3, &t); if (h == INVALID_HANDLE_VALUE) return false; #else const std::string& p2 = utf16ToUtf8_(s); h = ::opendir(p2.c_str()); if (h == nullptr) return false; #endif } if (!fileExists_(d.c_str())) { if (!makeDir_(d.c_str())) a = false; } if (a) { #if defined(_WIN32) do { if ((t.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { std::u16string s2 = s; s2 += reinterpret_cast(t.cFileName); std::u16string d2 = d; d2 += reinterpret_cast(t.cFileName); #else while ((t = readdir(h)) != nullptr) { if ((t->d_type & _A_SUBDIR) == 0) { std::string n = t->d_name; const std::u16string& n2 = utf8ToUtf16_(n); std::u16string s2 = s; s2 += n2; std::u16string d2 = d; d2 += n2; #endif if (!copyFile_(d2.c_str(), s2.c_str())) { a = false; break; } } else { std::u16string s2 = s; std::u16string d2 = d; #if defined(_WIN32) const wchar_t* n = t.cFileName; if (wcscmp(n, L".") == 0 || wcscmp(n, L"..") == 0) continue; s2 += reinterpret_cast(n); d2 += reinterpret_cast(n); #else const char* n = t->d_name; if (strcmp(n, ".") == 0 || strcmp(n, "..") == 0) continue; std::string t = n; const std::u16string& n2 = utf8ToUtf16_(t); s2 += n2; d2 += n2; #endif s2 += u"/"; d2 += u"/"; if (!copyDir_(d2, s2)) { a = false; break; } } } #if defined(_WIN32) while (FindNextFileW(h, &t)); #endif } #if defined(_WIN32) FindClose(h); #else closedir(h); #endif return a; } static bool moveDir_(const char16_t* d, const char16_t* s) { #if defined(_WIN32) if (::MoveFileExW(reinterpret_cast(s), reinterpret_cast(d), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING)) return true; #endif std::u16string d2 = d; std::u16string s2 = s; if (!copyDir_(d2, s2)) return false; if (!delDir_(s2)) return false; return true; } static bool makeDir2_(const char16_t* p) { char16_t b[512]; int64_t l = fullPath_(b, p); if (l == 0) return false; const char16_t* q = b; while (*q != 0){ while (*q != '/') q++; char16_t a[512]; memcpy(a, b, sizeof(char16_t) * static_cast(q - b + 1)); a[q - b + 1] = 0; if (!fileExists_(a)) { if (!makeDir_(a)) return false; } q++; } return true; } template struct newArraysRec_ { T operator()() { throw 0; } template T operator()(A h, B... t) { throw 0; } }; template struct newArraysRec_)> { type_(Array_) operator()() { throw 0; } template type_(Array_) operator()(A h, C... t) { if (h < 0) throw 0xe917000b; type_(Array_) r = new_(Array_)(); r->L = h; r->B = newPrimArray_(static_cast(h + bufLen_()), T); if (sizeof...(t) == 0) memset(r->B, 0, sizeof(T) * static_cast(h + bufLen_())); else { for (int64_t i = 0; i < h; i++) r->B[i] = newArraysRec_()(std::forward(t)...); } return r; } }; template T newArrays_(A... a) { if (sizeof...(a) > 64) return nullptr; return newArraysRec_()(std::forward(a)...); } template type_(Array_) newArrayBin_(int64_t l, const void* d) { type_(Array_) r = new_(Array_)(); r->L = l; r->B = newPrimArray_(static_cast(l) + bufLen_(), T); memcpy(r->B, d, sizeof(T) * static_cast(l)); if (bufLen_() > 0) r->B[l] = 0; return r; } template type_(Array_) toArray_(type_(List_) l) { type_(Array_) a = new_(Array_)(); a->L = l->Len(); a->B = newPrimArray_(static_cast(a->L) + bufLen_(), T); int64_t i = 0; for (auto& e : l->B) { a->B[i] = e; i++; } if (bufLen_() > 0) a->B[a->L] = 0; return a; } template struct copy_ {}; template struct copy_)> { type_(Array_) operator()(type_(Array_) t) { if (t == nullptr) return nullptr; type_(Array_) r = new_(Array_)(); r->L = t->L; r->B = newPrimArray_(static_cast(t->L) + bufLen_(), T); for (int64_t i = 0; i < t->L; i++) r->B[i] = copy_()(t->B[i]); if (bufLen_() > 0) r->B[r->L] = 0; return r; } }; template struct copy_)> { type_(List_) operator()(type_(List_) t) { if (t == nullptr) return nullptr; type_(List_) r = new_(List_)(); for (auto i = t->B.begin(); i != t->B.end(); ++i) { r->B.push_back(copy_()(*i)); if (i == t->I) { auto e = r->B.end(); --e; r->I = e; } } return r; } }; template struct copy_)> { type_(Stack_) operator()(type_(Stack_) t) { if (t == nullptr) return nullptr; type_(Stack_) r = new_(Stack_)(); std::stack b; while (!t->B.empty()) { b.push(t->B.top()); t->B.pop(); } while (!b.empty()) { r->B.push(copy_()(b.top())); t->B.push(b.top()); b.pop(); } return r; } }; template struct copy_)> { type_(Queue_) operator()(type_(Queue_) t) { if (t == nullptr) return nullptr; type_(Queue_) r = new_(Queue_)(); std::queue b; while (!t->B.empty()) { b.push(t->B.front()); t->B.pop(); } while (!b.empty()) { r->B.push(copy_()(b.front())); t->B.push(b.front()); b.pop(); } return r; } }; template struct copy_)> { type_(Dict_) operator()(type_(Dict_) t) { if (t == nullptr) return nullptr; type_(Dict_) r = new_(Dict_)(); r->L = t->L; r->B = dictCopyRec_(t->B); return r; } }; template struct copy_ { type_(T) operator()(type_(T) t) { if (std::is_class::value) { if (t == nullptr) return nullptr; return dcast_(T)(reinterpret_cast(classTable_[t->Y + 4])(t)); } else return t; } }; template<> struct copy_ { int64_t operator()(int64_t t) { return t; } }; template<> struct copy_ { char16_t operator()(char16_t t) { return t; } }; template<> struct copy_ { bool operator()(bool t) { return t; } }; template<> struct copy_ { double operator()(double t) { return t; } }; template<> struct copy_ { uint8_t operator()(uint8_t t) { return t; } }; template<> struct copy_ { uint16_t operator()(uint16_t t) { return t; } }; template<> struct copy_ { uint32_t operator()(uint32_t t) { return t; } }; template<> struct copy_ { uint64_t operator()(uint64_t t) { return t; } }; static type_(Array_) toStr_(int64_t v) { std::stringstream s; s << v; const std::string& t = s.str(); type_(Array_) r = new_(Array_)(); r->L = static_cast(t.size()); r->B = newPrimArray_(t.size() + 1, char16_t); int64_t p = 0; for (char c : t) r->B[p++] = c; r->B[t.size()] = 0; return r; } static type_(Array_) toStr_(char16_t v) { type_(Array_) r = new_(Array_)(); r->L = static_cast(1); r->B = newPrimArray_(2, char16_t); r->B[0] = v; r->B[1] = 0; return r; } static type_(Array_) toStr_(bool v) { type_(Array_) r = new_(Array_)(); if (v) { r->L = static_cast(4); r->B = newPrimArray_(5, char16_t); r->B[0] = 't'; r->B[1] = 'r'; r->B[2] = 'u'; r->B[3] = 'e'; r->B[4] = 0; } else { r->L = static_cast(5); r->B = newPrimArray_(6, char16_t); r->B[0] = 'f'; r->B[1] = 'a'; r->B[2] = 'l'; r->B[3] = 's'; r->B[4] = 'e'; r->B[5] = 0; } return r; } static type_(Array_) toStr_(double v) { std::stringstream s; s << std::setprecision(16) << v; const std::string& t = s.str(); type_(Array_) r = new_(Array_)(); r->L = static_cast(t.size()); r->B = newPrimArray_(t.size() + 1, char16_t); int64_t p = 0; for (char c : t) r->B[p++] = c; r->B[t.size()] = 0; return r; } static type_(Array_) toStr_(uint8_t v) { std::stringstream s; s << "0x" << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << static_cast(v); const std::string& t = s.str(); type_(Array_) r = new_(Array_)(); r->L = static_cast(t.size()); r->B = newPrimArray_(t.size() + 1, char16_t); int64_t p = 0; for (char c : t) r->B[p++] = c; r->B[t.size()] = 0; return r; } static type_(Array_) toStr_(uint16_t v) { std::stringstream s; s << "0x" << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << v; const std::string& t = s.str(); type_(Array_) r = new_(Array_)(); r->L = static_cast(t.size()); r->B = newPrimArray_(t.size() + 1, char16_t); int64_t p = 0; for (char c : t) r->B[p++] = c; r->B[t.size()] = 0; return r; } static type_(Array_) toStr_(uint32_t v) { std::stringstream s; s << "0x" << std::uppercase << std::setfill('0') << std::setw(8) << std::hex << v; const std::string& t = s.str(); type_(Array_) r = new_(Array_)(); r->L = static_cast(t.size()); r->B = newPrimArray_(t.size() + 1, char16_t); int64_t p = 0; for (char c : t) r->B[p++] = c; r->B[t.size()] = 0; return r; } static type_(Array_) toStr_(uint64_t v) { std::stringstream s; s << "0x" << std::uppercase << std::setfill('0') << std::setw(16) << std::hex << v; const std::string& t = s.str(); type_(Array_) r = new_(Array_)(); r->L = static_cast(t.size()); r->B = newPrimArray_(t.size() + 1, char16_t); int64_t p = 0; for (char c : t) r->B[p++] = c; r->B[t.size()] = 0; return r; } static type_(Array_) toStr_(type_(Array_) v) { return v; } static int64_t cmp_(type_(Array_) a, type_(Array_) b) { int64_t p = 0; while (p < a->L && p < b->L) { if (a->B[p] != b->B[p]) return a->B[p] > b->B[p] ? 1 : (a->B[p] < b->B[p] ? -1 : 0); p++; } return a->L > b->L ? 1 : (a->L < b->L ? -1 : 0); } static int64_t cmp_(type_(Class_) a, type_(Class_) b) { return reinterpret_cast(classTable_[a->Y + 3])(a, b); } static int64_t cmp_(int64_t a, int64_t b) { return a - b; } static int64_t cmp_(char16_t a, char16_t b) { return static_cast(a) - static_cast(b); } static int64_t cmp_(double a, double b) { return a > b ? 1LL : (a < b ? -1LL : 0LL); } static int64_t cmp_(uint8_t a, uint8_t b) { return static_cast(a) - static_cast(b); } static int64_t cmp_(uint16_t a, uint16_t b) { return static_cast(a) - static_cast(b); } static int64_t cmp_(uint32_t a, uint32_t b) { return static_cast(a) - static_cast(b); } static int64_t cmp_(uint64_t a, uint64_t b) { return a > b ? 1LL : (a < b ? -1LL : 0LL); } static type_(Array_) makeBin_(const void* v, std::size_t s) { type_(Array_) r = new_(Array_)(); r->L = s; r->B = newPrimArray_(s, uint8_t); memcpy(r->B, v, s); return r; } static void mergeBin_(type_(Array_) a, const type_(Array_) b) { int64_t l = a->L + b->L; uint8_t* d = newPrimArray_(static_cast(l), uint8_t); memcpy(d, a->B, static_cast(a->L)); memcpy(d + a->L, b->B, static_cast(b->L)); a->L = l; a->B = d; } template struct toBin_ {}; template struct toBin_)> { type_(Array_) operator()(type_(Array_) v) { if (v == nullptr) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } type_(Array_) r = makeBin_(&v->L, sizeof(int64_t)); for (int64_t i = 0; i < v->L; i++) mergeBin_(r, toBin_()(v->B[i])); return r; } }; template struct toBin_)> { type_(Array_) operator()(type_(List_) v) { if (v == nullptr) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } int64_t s = static_cast(v->B.size()); type_(Array_) r = makeBin_(&s, sizeof(int64_t)); int64_t c = 0, d = -1; for (auto i = v->B.begin(); i != v->B.end(); ++i, ++c) if (i == v->I) { d = c; break; } mergeBin_(r, makeBin_(&d, sizeof(int64_t))); for (auto& n : v->B) mergeBin_(r, toBin_()(n)); return r; } }; template struct toBin_)> { type_(Array_) operator()(type_(Stack_) v) { if (v == nullptr) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } int64_t s = static_cast(v->B.size()); std::stack b; type_(Array_) r = makeBin_(&s, sizeof(int64_t)); while (!v->B.empty()) { b.push(v->B.top()); v->B.pop(); } while (!b.empty()) { T n = b.top(); mergeBin_(r, toBin_()(n)); v->B.push(n); b.pop(); } return r; } }; template struct toBin_)> { type_(Array_) operator()(type_(Queue_) v) { if (v == nullptr) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } int64_t s = static_cast(v->B.size()); std::queue b; type_(Array_) r = makeBin_(&s, sizeof(int64_t)); while (!v->B.empty()) { T n = v->B.front(); b.push(n); mergeBin_(r, toBin_()(n)); v->B.pop(); } while (!b.empty()) { v->B.push(b.front()); b.pop(); } return r; } }; template struct toBin_)> { type_(Array_) operator()(type_(Dict_) v) { if (v == nullptr) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } type_(Array_) r = makeBin_(&v->L, sizeof(int64_t)); dictToBinRec_(r, v->B); return r; } }; template struct toBin_ { type_(Array_) operator()(type_(T) v) { if (v == nullptr) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } auto w = dcast_(Class_)(v); type_(Array_) r = makeBin_(&w->Y, sizeof(int64_t)); mergeBin_(r, reinterpret_cast)(*)(type_(Class_))>(classTable_[w->Y + 5])(w)); return r; } }; template<> struct toBin_ { type_(Array_) operator()(int64_t v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(double v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(char16_t v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(bool v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(uint8_t v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(uint16_t v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(uint32_t v) { return makeBin_(&v, sizeof(v)); } }; template<> struct toBin_ { type_(Array_) operator()(uint64_t v) { return makeBin_(&v, sizeof(v)); } }; template type_(Array_) toBinFunc_(T v) { int64_t p = -1; return makeBin_(&p, sizeof(p)); } template struct fromBin_ {}; template struct fromBin_)> { type_(Array_) operator()(type_(Array_) b, int64_t& o) { int64_t l = *reinterpret_cast(b->B + o); o += sizeof(int64_t); if (l == -1) return nullptr; type_(Array_) r = new_(Array_)(); r->L = l; r->B = newPrimArray_(static_cast(l) + bufLen_(), T); for (int64_t i = 0; i < l; i++) r->B[i] = fromBin_()(b, o); if (bufLen_() > 0) r->B[l] = 0; return r; } }; template struct fromBin_)> { type_(List_) operator()(type_(Array_) b, int64_t& o) { int64_t l = *reinterpret_cast(b->B + o); o += sizeof(int64_t); if (l == -1) return nullptr; type_(List_) r = new_(List_)(); int64_t d = *reinterpret_cast(b->B + o); o += sizeof(int64_t); for (int64_t i = 0; i < l; i++) { r->B.push_back(fromBin_()(b, o)); if (i == d) { auto e = r->B.end(); --e; r->I = e; } } return r; } }; template struct fromBin_)> { type_(Stack_) operator()(type_(Array_) b, int64_t& o) { int64_t l = *reinterpret_cast(b->B + o); o += sizeof(int64_t); if (l == -1) return nullptr; type_(Stack_) r = new_(Stack_)(); for (int64_t i = 0; i < l; i++) r->B.push(fromBin_()(b, o)); return r; } }; template struct fromBin_)> { type_(Queue_) operator()(type_(Array_) b, int64_t& o) { int64_t l = *reinterpret_cast(b->B + o); o += sizeof(int64_t); if (l == -1) return nullptr; type_(Queue_) r = new_(Queue_)(); for (int64_t i = 0; i < l; i++) r->B.push(fromBin_()(b, o)); return r; } }; template struct fromBin_)> { type_(Dict_) operator()(type_(Array_) b, int64_t& o) { int64_t l = *reinterpret_cast(b->B + o); o += sizeof(int64_t); if (l == -1) return nullptr; type_(Dict_) r = new_(Dict_)(); r->L = l; for (int64_t i = 0; i < l; i++) { T1 k = fromBin_()(b, o); T2 v = fromBin_()(b, o); r->Add(k, v); } return r; } }; template struct fromBin_ { type_(T) operator()(type_(Array_) b, int64_t& o) { int64_t y = *reinterpret_cast(b->B + o); o += sizeof(int64_t); if (y == -1) return nullptr; return dcast_(T)(reinterpret_cast), int64_t*)>(classTable_[y + 6])(nullptr, b, &o)); } }; template<> struct fromBin_ { int64_t operator()(type_(Array_) b, int64_t& o) { int64_t r = *reinterpret_cast(b->B + o); o += sizeof(int64_t); return r; } }; template<> struct fromBin_ { double operator()(type_(Array_) b, int64_t& o) { double r = *reinterpret_cast(b->B + o); o += sizeof(double); return r; } }; template<> struct fromBin_ { char16_t operator()(type_(Array_) b, int64_t& o) { char16_t r = *reinterpret_cast(b->B + o); o += sizeof(char16_t); return r; } }; template<> struct fromBin_ { bool operator()(type_(Array_) b, int64_t& o) { bool r = *reinterpret_cast(b->B + o); o += sizeof(bool); return r; } }; template<> struct fromBin_ { uint8_t operator()(type_(Array_) b, int64_t& o) { uint8_t r = *reinterpret_cast(b->B + o); o += sizeof(uint8_t); return r; } }; template<> struct fromBin_ { uint16_t operator()(type_(Array_) b, int64_t& o) { uint16_t r = *reinterpret_cast(b->B + o); o += sizeof(uint16_t); return r; } }; template<> struct fromBin_ { uint32_t operator()(type_(Array_) b, int64_t& o) { uint32_t r = *reinterpret_cast(b->B + o); o += sizeof(uint32_t); return r; } }; template<> struct fromBin_ { uint64_t operator()(type_(Array_) b, int64_t& o) { uint64_t r = *reinterpret_cast(b->B + o); o += sizeof(uint64_t); return r; } }; template T fromBinFunc_(type_(Array_) b, int64_t& o) { o += sizeof(void*); return nullptr; } template type_(Array_) sub_(type_(Array_) a, int64_t start, int64_t len) { if (len == -1) len = a->L - start; if (start < 0 || len < 0 || start + len > a->L) throw 0xe9170006; type_(Array_) r = new_(Array_)(); r->L = len; r->B = newPrimArray_(static_cast(len + bufLen_()), T); for (int64_t i = 0; i < len; i++) r->B[i] = a->B[start + i]; if (bufLen_() > 0) r->B[len] = 0; return r; } template type_(T) as_(const int64_t * y, type_(Class_) c, int64_t o) { if (c == nullptr) return nullptr; int64_t m = c->Y; for (; ; ) { if (m == o) return dcast_(T)(c); if (m == 0) return nullptr; m = y[m]; } } static bool is_(const int64_t * y, type_(Class_) c, int64_t o) { int64_t m = c->Y; for (; ; ) { if (m == o) return true; if (m == 0) return false; m = y[m]; } } template T min_(type_(Array_) a) { if (a->L == 0) return (T)0; T r = a->B[0]; for (int64_t i = 0; i < a->L; i++) { if (cmp_(r, a->B[i]) > 0) r = a->B[i]; } return r; } template T max_(type_(Array_) a) { if (a->L == 0) return (T)0; T r = a->B[0]; for (int64_t i = 0; i < a->L; i++) { if (cmp_(r, a->B[i]) < 0) r = a->B[i]; } return r; } template type_(Array_) repeat_(type_(Array_) a, int64_t n) { type_(Array_) r = new_(Array_)(); r->L = a->L * n; r->B = newPrimArray_(static_cast(r->L) + bufLen_(), T); for (int64_t i = 0; i < n; i++) { for (int64_t j = 0; j < a->L; j++) r->B[i * a->L + j] = a->B[j]; } if (bufLen_() > 0) r->B[r->L] = 0; return r; } template dictImpl_* dictRotateLeft_(dictImpl_ * n) { dictImpl_* r = n->CR; n->CR = r->CL; r->CL = n; r->R = n->R; n->R = true; return r; } template dictImpl_* dictRotateRight_(dictImpl_ * n) { dictImpl_* l = n->CL; n->CL = l->CR; l->CR = n; l->R = n->R; n->R = true; return l; } template void dictFlip_(dictImpl_ * n) { n->R = !n->R; n->CL->R = !n->CL->R; n->CR->R = !n->CR->R; } template dictImpl_* dictFixUp_(dictImpl_ * n) { if (n->CR != nullptr && n->CR->R) n = dictRotateLeft_(n); if (n->CL != nullptr && n->CL->R && n->CL->CL != nullptr && n->CL->CL->R) n = dictRotateRight_(n); if (n->CL != nullptr && n->CL->R && n->CR != nullptr && n->CR->R) dictFlip_(n); return n; } template dictImpl_* dictAddRec_(dictImpl_ * n, T1 k, T2 v, bool* a) { if (n == nullptr) { *a = true; return newPrim_(dictImpl_)(k, v); } int64_t c = cmp_(k, n->K); if (c == 0) { n->V = v; return n; } if (c < 0) n->CL = dictAddRec_(n->CL, k, v, a); else n->CR = dictAddRec_(n->CR, k, v, a); return dictFixUp_(n); } template dictImpl_* dictMoveRedLeft_(dictImpl_ * n) { dictFlip_(n); if (n->CR->CL != nullptr && n->CR->CL->R) { n->CR = dictRotateRight_(n->CR); n = dictRotateLeft_(n); dictFlip_(n); } return n; } template dictImpl_* dictMoveRedRight_(dictImpl_ * n) { dictFlip_(n); if (n->CL->CL != nullptr && n->CL->CL->R) { n = dictRotateRight_(n); dictFlip_(n); } return n; } template dictImpl_* dictDelMinRec_(dictImpl_ * n) { if (n->CL == nullptr) return nullptr; if (!n->CL->R && !(n->CL->CL != nullptr && n->CL->CL->R)) n = dictMoveRedLeft_(n); n->CL = dictDelMinRec_(n->CL); return dictFixUp_(n); } template dictImpl_* dictDelRec_(dictImpl_ * n, T1 k, bool* d) { if (n == nullptr) return nullptr; if (cmp_(k, n->K) < 0) { if (n->CL != nullptr && !n->CL->R && !(n->CL->CL != nullptr && n->CL->CL->R)) n = dictMoveRedLeft_(n); n->CL = dictDelRec_(n->CL, k, d); } else { if (n->CL != nullptr && n->CL->R) n = dictRotateRight_(n); if (n->CR != nullptr && !n->CR->R && !(n->CR->CL != nullptr && n->CR->CL->R)) n = dictMoveRedRight_(n); if (cmp_(k, n->K) == 0) { *d = true; if (n->CR == nullptr) return nullptr; dictImpl_* p = n->CR; while (p->CL != nullptr) p = p->CL; n->K = p->K; n->V = p->V; n->CR = dictDelMinRec_(n->CR); } else n->CR = dictDelRec_(n->CR, k, d); } return dictFixUp_(n); } template dictImpl_* dictCopyRec_(dictImpl_ * n) { if (n == nullptr) return nullptr; dictImpl_* r = newPrim_(dictImpl_)(copy_()(n->K), copy_()(n->V)); r->R = n->R; r->CL = dictCopyRec_(n->CL); r->CR = dictCopyRec_(n->CR); return r; } template void dictToBinRec_(type_(Array_) a, dictImpl_ * d) { if (d->CL != nullptr) dictToBinRec_(a, d->CL); mergeBin_(a, toBin_()(d->K)); mergeBin_(a, toBin_()(d->V)); if (d->CR != nullptr) dictToBinRec_(a, d->CR); } template T2 dictSearch_(dictImpl_ * r, T1 k, bool* f) { dictImpl_* n = r; while (n != nullptr) { int64_t c = cmp_(k, n->K); if (c == 0) { *f = true; return n->V; } if (c < 0) n = n->CL; else n = n->CR; } *f = false; return (T2)0; } template bool dictForEach_(dictImpl_ * r, bool(*f)(T1, T2, type_(Class_)), type_(Class_) p) { if (r == nullptr) return true; if (!dictForEach_(r->CL, f, p)) return false; if (!f(r->K, r->V, p)) return false; if (!dictForEach_(r->CR, f, p)) return false; return true; } template bool dictExist_(dictImpl_ * r, T1 k) { dictImpl_* n = r; while (n != nullptr) { int64_t c = cmp_(k, n->K); if (c == 0) return true; if (c < 0) n = n->CL; else n = n->CR; } return false; } template void dictFreeRec_(dictImpl_ * n) { if (n == nullptr) return; dictFreeRec_(n->CL); dictFreeRec_(n->CR); delPrim_(n); } static int64_t powI_(int64_t a, int64_t b) { switch (b) { case 0LL: return 1LL; case 1LL: return a; case 2LL: return a * a; } if (a == 1LL) return 1LL; if (a == -1LL) return (b & 1LL) == 0LL ? 1LL : -1LL; if (b < 0LL) return 0LL; int64_t r = 1LL; for (; ; ) { if ((b & 1LL) == 1LL) r *= a; b >>= 1LL; if (b == 0LL) break; a *= a; } return r; } template void reverse_(type_(Array_) me) { std::reverse(me->B, me->B + me->L); } template bool sortCmp_(const T & a, const T & b) { return cmp_(a, b) < 0; } template void sort_(type_(Array_) me) { std::sort(me->B, me->B + me->L, sortCmp_); } static uint8_t sar_(uint8_t me_, int64_t n) { return static_cast(static_cast(me_) >> n); } static uint16_t sar_(uint16_t me_, int64_t n) { return static_cast(static_cast(me_) >> n); } static uint32_t sar_(uint32_t me_, int64_t n) { return static_cast(static_cast(me_) >> n); } static uint64_t sar_(uint64_t me_, int64_t n) { return static_cast(static_cast(me_) >> n); } static uint8_t endian_(uint8_t me_) { return me_; } static uint16_t endian_(uint16_t me_) { return ((me_ & 0x00ff) << 8) | ((me_ & 0xff00) >> 8); } static uint32_t endian_(uint32_t me_) { me_ = ((me_ & 0x00ff00ff) << 8) | ((me_ & 0xff00ff00) >> 8); return ((me_ & 0x0000ffff) << 16) | ((me_ & 0xffff0000) >> 16); } static uint64_t endian_(uint64_t me_) { me_ = ((me_ & 0x00ff00ff00ff00ff) << 8) | ((me_ & 0xff00ff00ff00ff00) >> 8); me_ = ((me_ & 0x0000ffff0000ffff) << 16) | ((me_ & 0xffff0000ffff0000) >> 16); return ((me_ & 0x00000000ffffffff) << 32) | ((me_ & 0xffffffff00000000) >> 32); } struct reader_ { reader_() : F(nullptr) {} std::FILE* F; }; struct writer_ { writer_() : F(nullptr) {} std::FILE* F; }; template struct listPtr_ { listPtr_() {} typename T::iterator I; }; static void init_() { setlocale(LC_ALL, ""); } class k_o; class k_n; void k_main_(); static void k_d(); static void k_e(); static void k_f(); static void k_g(); static void k_i(); static void k_j(); static void k_l(int64_t k_bs /*excpt*/); static void k_p(type_(k_o) k_bv /*me*/); static void k_q(k_o* k_bw); static int64_t k_r(type_(k_o) k_bx /*me*/, type_(k_o) k_by /*t*/); static type_(k_o) k_s(type_(k_o) k_bz /*me*/); static type_(Array_) k_t(type_(k_o) k_cc /*me*/); static type_(k_o) k_u(type_(k_o) k_ce /*me*/, type_(Array_) k_cf /*bin*/, int64_t* k_cg /*idx*/); static type_(Array_) k_v(type_(k_o) k_cj /*me*/); static void k_w(type_(k_n) k_ck /*me*/); using k_cm=void(*)(type_(k_o)); static int64_t k_x(type_(k_n) k_cn /*me*/, int64_t k_co /*min*/, int64_t k_cp /*max*/); using k_cx=uint64_t(*)(type_(k_n)); static uint64_t k_y(type_(k_n) k_da /*me*/); using k_dc=uint32_t(*)(type_(k_n)); static double k_z(type_(k_n) k_df /*me*/, double k_dg /*min*/, double k_dh /*max*/); static void k_aa(type_(k_n) k_dk /*me*/, uint32_t k_dl /*seed*/); static uint32_t k_ab(type_(k_n) k_dr /*me*/); static void k_ac(k_n* k_dt); static type_(k_n) k_ad(type_(k_n) k_du); static type_(Array_) k_ae(type_(k_n) k_dx); static type_(k_n) k_af(type_(k_n) k_ed, type_(Array_) k_ee, int64_t* k_ef); static type_(k_n) k_ag(type_(k_n) k_ei /*me2*/, uint32_t k_ej /*seed*/); using k_ek=void(*)(type_(k_n), uint32_t); templatestatic T_ k_ai(T_ k_el /*me_*/, type_(Array_) k_em /*type*/, T_ k_en /*n*/); static int64_t k_aj(); static int64_t k_ak(); static int64_t k_an(); static type_(Array_) k_ba(); templatestatic void k_bb(T_ k_fo /*me_*/, type_(Array_) k_fp /*type*/, K_ k_fq /*key*/, V_ k_fr /*item*/); templatestatic R_ k_bk(T_ k_fs /*me_*/, type_(Array_) k_ft /*type*/, C_ k_fu /*key*/, bool* k_fv /*existed*/); static void k_bq(type_(Array_) k_fw /*str*/); templatestatic type_(Array_) k_br(T_ k_fx /*me_*/, type_(Array_) k_fy /*type*/); templatestatic T_ k_dd(T_ k_fz /*me_*/, type_(Array_) k_ga /*type*/, T_ k_gb /*n*/); templatestatic T_ k_de(T_ k_gc /*me_*/, type_(Array_) k_gd /*type*/, int64_t k_ge /*n*/); templatestatic T_ k_dq(T_ k_gh /*me_*/, type_(Array_) k_gi /*type*/, int64_t k_gj /*n*/); static int64_t k_er(type_(Array_) k_gm /*me_*/, bool* k_gn /*success*/); static char16_t k_fa(); templatestatic T_ k_fn(T_ k_hc /*me_*/, type_(Array_) k_hd /*type*/, int64_t k_he /*start*/, int64_t k_hf /*len*/); static char16_t k_gs(); static int64_t argc_; static char** argv_; // Class class k_o : public Class_{ public: k_o(); virtual ~k_o(); }; // Rnd class k_n : public k_o{ public: k_n(); virtual ~k_n(); uint32_t k_dm; // x uint32_t k_dn; // y uint32_t k_do; // z uint32_t k_dp; // w }; static type_(k_n) k_m; static type_(Array_) k_al; k_o::k_o(): Class_(){ Y = 0; } k_o::~k_o(){ k_q(this); } k_n::k_n(): k_o(), k_dm(), k_dn(), k_do(), k_dp(){ Y = 8; } k_n::~k_n(){ k_ac(this); } // k_main_ void k_main_(){ int64_t k_b; // $ try{ try{ (k_d)(); (k_e)(); (k_f)(); (k_g)(); (k_i)(); (k_j)(); }catch(int64_t k_b){ if(((0LL) <= k_b && k_b <= (4294967295LL))){ (k_l)((k_b)); } else{ throw; } } } catch(...){ (k_i)(); (k_j)(); throw; } } // _init static void k_d(){ } // _init static void k_e(){ type_(k_n) k_ah; (k_m) = ((k_ag)((k_ah = new_(k_n)(), k_w(k_ah), k_ah), (k_ai((static_cast((k_aj)())), (nullptr), (static_cast((k_ak)())))))); } // _initVars static void k_f(){ (k_al) = (newArrayBin_(3,"\x20\x00\x2C\x00\x0A\x00")); } // main static void k_g(){ int64_t k_am; // n int64_t k_ao; // a int64_t k_ap; // ab int64_t k_aq; // abc type_(Array_) k_ar; // xx int64_t k_as; // len type_(Dict_) k_at; // map int64_t k_ax; int64_t k_bc; // ans int64_t k_bg; int64_t k_bi; // x int64_t k_ay; int64_t k_bh; bool k_bl; bool k_bm; bool k_bn; (k_am) = ((k_an)()); (k_ao) = ((k_an)()); (k_ap) = (((k_an)()) + (k_ao)); (k_aq) = (((k_an)()) + (k_ap)); (k_ar) = (newArrays_)>(((k_am) + (1LL)))); (k_as) = (0LL); (k_at) = (new_(Dict_)()); for(k_ax = (1LL), k_ay = (k_am); k_ax <= k_ay; k_ax += (1LL)){ (k_as) = ((k_as) + (((k_ba)())->Len())); ((k_ar)->At(k_ax)) = (k_as); k_bb), int64_t, bool>((k_at), (nullptr), (k_as), (true)); } (k_bc) = (0LL); for(k_bg = (0LL), k_bh = ((k_am) - (3LL)); k_bg <= k_bh; k_bg += (1LL)){ (k_bi) = ((k_ar)->At(k_bg)); if(((k_bk), int64_t, bool>((k_at), (nullptr), ((k_bi) + (k_ao)), (std::memset(&k_bl, 0, sizeof(bool)), &k_bl))) && (k_bk), int64_t, bool>((k_at), (nullptr), ((k_bi) + (k_ap)), (std::memset(&k_bm, 0, sizeof(bool)), &k_bm)))) && (k_bk), int64_t, bool>((k_at), (nullptr), ((k_bi) + (k_aq)), (std::memset(&k_bn, 0, sizeof(bool)), &k_bn)))){ (k_bc) = ((k_bc) + (1LL)); } } (k_bq)((((newArrayBin_(0,""))->Cat(k_br((k_bc), (nullptr))))->Cat(newArrayBin_(1,"\x0A\x00")))); } // _finVars static void k_i(){ (k_al) = (nullptr); (k_m) = (nullptr); } // _fin static void k_j(){ } // _err static void k_l(int64_t k_bs /*excpt*/){ } // ctor static void k_p(type_(k_o) k_bv /*me*/){ } // _dtor static void k_q(k_o* k_bw){ } // cmp static int64_t k_r(type_(k_o) k_bx /*me*/, type_(k_o) k_by /*t*/){ throw 3910598660LL; } // _copy static type_(k_o) k_s(type_(k_o) k_bz /*me*/){ type_(k_o) k_ca; type_(k_o) k_cb; (k_ca) = (k_cb = new_(k_o)(), k_p(k_cb), k_cb); return as_(classTable_, (k_ca), 0); } // _toBin static type_(Array_) k_t(type_(k_o) k_cc /*me*/){ type_(Array_) k_cd; (k_cd) = (newArrays_)>((0LL))); return k_cd; } // _fromBin static type_(k_o) k_u(type_(k_o) k_ce /*me*/, type_(Array_) k_cf /*bin*/, int64_t* k_cg /*idx*/){ type_(k_o) k_ch; type_(k_o) k_ci; (k_ch) = (k_ci = new_(k_o)(), k_p(k_ci), k_ci); return k_ch; } // toStr static type_(Array_) k_v(type_(k_o) k_cj /*me*/){ return newArrayBin_(0,""); } // ctor static void k_w(type_(k_n) k_ck /*me*/){ k_cm k_cl; // super (k_cl) = (k_p); } // rnd static int64_t k_x(type_(k_n) k_cn /*me*/, int64_t k_co /*min*/, int64_t k_cp /*max*/){ uint64_t k_cs; // n uint64_t k_ct; // m uint64_t k_cu; // r (k_cs) = (static_cast(((k_cp) - (k_co)) + (1LL))); (k_ct) = ((0x0000000000000000ULL) - (((0x0000000000000000ULL) - (k_cs)) % (k_cs))); (k_cu) = (0x0000000000000000ULL); if((k_ct) == (0x0000000000000000ULL)){ (k_cu) = ((reinterpret_cast(classTable_[(k_cn)->Y + 9]))((k_cn))); } else{ do{ (k_cu) = ((reinterpret_cast(classTable_[(k_cn)->Y + 9]))((k_cn))); }while((k_ct) <= (k_cu)); } return (static_cast((k_cu) % (k_cs))) + (k_co); } // rndBit64 static uint64_t k_y(type_(k_n) k_da /*me*/){ uint32_t k_db; // t (k_db) = ((reinterpret_cast(classTable_[(k_da)->Y + 12]))((k_da))); return k_dd((k_de((static_cast(k_db)), (nullptr), (32LL))), (nullptr), (static_cast((reinterpret_cast(classTable_[(k_da)->Y + 12]))((k_da))))); } // rndFloat static double k_z(type_(k_n) k_df /*me*/, double k_dg /*min*/, double k_dh /*max*/){ return (((static_cast((reinterpret_cast(classTable_[(k_df)->Y + 9]))((k_df)))) / (1.844674407370955e+19)) * ((k_dh) - (k_dg))) + (k_dg); } // setSeed static void k_aa(type_(k_n) k_dk /*me*/, uint32_t k_dl /*seed*/){ ((k_dk)->k_dm) = (0x075BCD15U); ((k_dk)->k_dn) = (0x159A55E5U); ((k_dk)->k_do) = ((0x1F123BB5U) * (k_dl)); ((k_dk)->k_dp) = ((0x05491333U) * (k_dq(((k_dk)->k_do), (nullptr), (1LL)))); } // xs128 static uint32_t k_ab(type_(k_n) k_dr /*me*/){ uint32_t k_ds; // t (k_ds) = (k_ai(((k_dr)->k_dm), (nullptr), (k_de(((k_dr)->k_dm), (nullptr), (11LL))))); ((k_dr)->k_dm) = ((k_dr)->k_dn); ((k_dr)->k_dn) = ((k_dr)->k_do); ((k_dr)->k_do) = ((k_dr)->k_dp); ((k_dr)->k_dp) = (k_ai((k_ai(((k_dr)->k_dp), (nullptr), (k_dq(((k_dr)->k_dp), (nullptr), (19LL))))), (nullptr), (k_ai((k_ds), (nullptr), (k_dq((k_ds), (nullptr), (8LL))))))); return (k_dr)->k_dp; } // _dtor static void k_ac(k_n* k_dt){ } // _copy static type_(k_n) k_ad(type_(k_n) k_du){ type_(k_n) k_dv; type_(k_n) k_dw; (k_dv) = (k_dw = new_(k_n)(), k_w(k_dw), k_dw); ((k_dv)->k_dm) = ((k_du)->k_dm); ((k_dv)->k_dn) = ((k_du)->k_dn); ((k_dv)->k_do) = ((k_du)->k_do); ((k_dv)->k_dp) = ((k_du)->k_dp); return as_(classTable_, (k_dv), 8); } // _toBin static type_(Array_) k_ae(type_(k_n) k_dx){ type_(Array_) k_dy; (k_dy) = (newArrays_)>((0LL))); (k_dy) = ((k_dy)->Cat(toBin_()(((k_dx)->k_dm)))); (k_dy) = ((k_dy)->Cat(toBin_()(((k_dx)->k_dn)))); (k_dy) = ((k_dy)->Cat(toBin_()(((k_dx)->k_do)))); (k_dy) = ((k_dy)->Cat(toBin_()(((k_dx)->k_dp)))); return k_dy; } // _fromBin static type_(k_n) k_af(type_(k_n) k_ed, type_(Array_) k_ee, int64_t* k_ef){ type_(k_n) k_eg; type_(k_n) k_eh; (k_eg) = (k_eh = new_(k_n)(), k_w(k_eh), k_eh); ((k_eg)->k_dm) = (fromBin_()((k_ee), (*k_ef))); ((k_eg)->k_dn) = (fromBin_()((k_ee), (*k_ef))); ((k_eg)->k_do) = (fromBin_()((k_ee), (*k_ef))); ((k_eg)->k_dp) = (fromBin_()((k_ee), (*k_ef))); return k_eg; } // makeRnd static type_(k_n) k_ag(type_(k_n) k_ei /*me2*/, uint32_t k_ej /*seed*/){ (reinterpret_cast(classTable_[(k_ei)->Y + 11]))((k_ei), (k_ej)); return k_ei; } // _xor templatestatic T_ k_ai(T_ k_el /*me_*/, type_(Array_) k_em /*type*/, T_ k_en /*n*/){ return k_el^k_en; } // sysTime static int64_t k_aj(){ return static_cast(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); } // now static int64_t k_ak(){ return std::time(nullptr); } // inputInt static int64_t k_an(){ type_(Array_) k_eo; // s bool k_ep; // b int64_t k_eq; // r (k_eo) = ((k_ba)()); (k_ep) = (false); (k_eq) = ((k_er)((k_eo), (&k_ep))); if(!(k_ep)){ throw 3910598664LL; } return k_eq; } // inputStr static type_(Array_) k_ba(){ type_(Array_) k_eu; // buf int64_t k_ev; // ptr char16_t k_ez; // c (k_eu) = (newArrays_)>((1024LL))); (k_ev) = (0LL); while(true){ (k_ez) = ((k_fa)()); if((k_ez) == (u'\uFFFF')){ if((k_ev) == (0LL)){ throw 3910598664LL; } break; } if((k_ez) == (u'\u0000')){ if((k_ev) == (0LL)){ continue; } break; } if((k_ev) == ((k_eu)->Len())){ (k_eu) = ((k_eu)->Cat(newArrays_)>(((k_eu)->Len())))); } ((k_eu)->At(k_ev)) = (k_ez); (k_ev) = ((k_ev) + (1LL)); } return k_fn)>((k_eu), (nullptr), (0LL), (k_ev)); } // _addDict templatestatic void k_bb(T_ k_fo /*me_*/, type_(Array_) k_fp /*type*/, K_ k_fq /*key*/, V_ k_fr /*item*/){ k_fo->Add(k_fq,k_fr); } // _getDict templatestatic R_ k_bk(T_ k_fs /*me_*/, type_(Array_) k_ft /*type*/, C_ k_fu /*key*/, bool* k_fv /*existed*/){ return dictSearch_(k_fs->B,k_fu,k_fv); } // print static void k_bq(type_(Array_) k_fw /*str*/){ if(k_fw==nullptr){ fputs("(null)",stdout); return; } #if defined(_WIN32) fputws(reinterpret_cast(k_fw->B),stdout); #else std::u16string s_=k_fw->B; const std::string&t_=utf16ToUtf8_(s_); fputs(t_.c_str(),stdout); #endif } // _toStr templatestatic type_(Array_) k_br(T_ k_fx /*me_*/, type_(Array_) k_fy /*type*/){ return toStr_(k_fx); } // _or templatestatic T_ k_dd(T_ k_fz /*me_*/, type_(Array_) k_ga /*type*/, T_ k_gb /*n*/){ return k_fz|k_gb; } // _shl templatestatic T_ k_de(T_ k_gc /*me_*/, type_(Array_) k_gd /*type*/, int64_t k_ge /*n*/){ return k_gc<static T_ k_dq(T_ k_gh /*me_*/, type_(Array_) k_gi /*type*/, int64_t k_gj /*n*/){ return k_gh>>k_gj; } // _toInt static int64_t k_er(type_(Array_) k_gm /*me_*/, bool* k_gn /*success*/){ std::u16string u_=k_gm->B; const std::string&t_=utf16ToUtf8_(u_); try{ std::size_t s_; int64_t v_=t_.size()>2&&t_[0]=='0'&&t_[1]=='x'?std::stoll(t_,&s_,16):std::stoull(t_,&s_); if(s_==t_.size()){ *k_gn=true; return v_; }else{ *k_gn=false; return 0; } }catch(...){ *k_gn=false; return 0; } } // inputCharWithDelimiter static char16_t k_fa(){ char16_t k_gr; // c int64_t k_gw; int64_t k_gx; while(true){ (k_gr) = ((k_gs)()); for(k_gw = (0LL), k_gx = (((k_al)->Len()) - (1LL)); k_gw <= k_gx; k_gw += (1LL)){ if(((k_gr) == ((k_al)->At(k_gw))) || (((k_gr) == (u'\u000D')) && (((k_al)->At(k_gw)) == (u'\u000A')))){ return u'\u0000'; } } if((k_gr) == (u'\u000D')){ continue; } return k_gr; } } // _sub templatestatic T_ k_fn(T_ k_hc /*me_*/, type_(Array_) k_hd /*type*/, int64_t k_he /*start*/, int64_t k_hf /*len*/){ return sub_(k_hc,k_he,k_hf); } // inputLetter static char16_t k_gs(){ #if defined(_WIN32) wchar_t c_=fgetwc(stdin); return static_cast(c_==WEOF?0xffff:c_); #else int l_; char c_; do{c_=fgetc(stdin);}while((c_&0xc0)==0x80); if((c_&0x80)==0x00)l_=0; else if((c_&0xe0)==0xc0){l_=1;c_&=0x1f;} else if((c_&0xf0)==0xe0){l_=2;c_&=0x0f;} else if((c_&0xf8)==0xf0){l_=3;c_&=0x07;} else if((c_&0xfc)==0xf8){l_=4;c_&=0x03;} else if((c_&0xfe)==0xfc){l_=5;c_&=0x01;} else return 0xffff; uint32_t u_=static_cast(c_); for(int i_=0;i_(fgetc(stdin))&0x3f); return static_cast(u_); #endif } int main(int c, char** v){ argc_ = static_cast(c) - 1; argv_ = v + 1; classTable_[0] = 0; classTable_[1] = reinterpret_cast(k_p); classTable_[2] = reinterpret_cast(k_q); classTable_[3] = reinterpret_cast(k_r); classTable_[4] = reinterpret_cast(k_s); classTable_[5] = reinterpret_cast(k_t); classTable_[6] = reinterpret_cast(k_u); classTable_[7] = reinterpret_cast(k_v); classTable_[8] = 0; classTable_[9] = reinterpret_cast(k_w); classTable_[10] = reinterpret_cast(k_ac); classTable_[11] = reinterpret_cast(k_r); classTable_[12] = reinterpret_cast(k_ad); classTable_[13] = reinterpret_cast(k_ae); classTable_[14] = reinterpret_cast(k_af); classTable_[15] = reinterpret_cast(k_v); classTable_[16] = reinterpret_cast(k_x); classTable_[17] = reinterpret_cast(k_y); classTable_[18] = reinterpret_cast(k_z); classTable_[19] = reinterpret_cast(k_aa); classTable_[20] = reinterpret_cast(k_ab); init_(); k_main_(); return static_cast(exitCode_); } //}}}