#if 0 // Kuin Programming Language v.2021.4.17 func main() var s: []char :: cui@input() var n3: int :: 0 var n5: int :: 0 for i(0, ^s - 1) var d: int :: s[i] $ int - '0' $ int do n3 :+ d do n5 :+ ((i % 2 = 0) ?(1, -1)) * d end for if(n3 % 3 = 0 & n5 % 5 = 0) do cui@print("FizzBuzz\n") elif(n5 % 5 = 0) do cui@print("Buzz\n") elif(n3 % 3 = 0) do cui@print("Fizz\n") else do cui@print("\{s}\n") end if 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_bf /*excpt*/); static void k_p(type_(k_o) k_bi /*me*/); static void k_q(k_o* k_bj); static int64_t k_r(type_(k_o) k_bk /*me*/, type_(k_o) k_bl /*t*/); static type_(k_o) k_s(type_(k_o) k_bm /*me*/); static type_(Array_) k_t(type_(k_o) k_bp /*me*/); static type_(k_o) k_u(type_(k_o) k_br /*me*/, type_(Array_) k_bs /*bin*/, int64_t* k_bt /*idx*/); static type_(Array_) k_v(type_(k_o) k_bw /*me*/); static void k_w(type_(k_n) k_bx /*me*/); using k_bz=void(*)(type_(k_o)); static int64_t k_x(type_(k_n) k_ca /*me*/, int64_t k_cb /*min*/, int64_t k_cc /*max*/); using k_ck=uint64_t(*)(type_(k_n)); static uint64_t k_y(type_(k_n) k_cn /*me*/); using k_cp=uint32_t(*)(type_(k_n)); static double k_z(type_(k_n) k_cs /*me*/, double k_ct /*min*/, double k_cu /*max*/); static void k_aa(type_(k_n) k_cx /*me*/, uint32_t k_cy /*seed*/); static uint32_t k_ab(type_(k_n) k_de /*me*/); static void k_ac(k_n* k_dg); static type_(k_n) k_ad(type_(k_n) k_dh); static type_(Array_) k_ae(type_(k_n) k_dk); static type_(k_n) k_af(type_(k_n) k_dq, type_(Array_) k_dr, int64_t* k_ds); static type_(k_n) k_ag(type_(k_n) k_dv /*me2*/, uint32_t k_dw /*seed*/); using k_dx=void(*)(type_(k_n), uint32_t); templatestatic T_ k_ai(T_ k_dy /*me_*/, type_(Array_) k_dz /*type*/, T_ k_ea /*n*/); static int64_t k_aj(); static int64_t k_ak(); static type_(Array_) k_an(); static void k_ba(type_(Array_) k_ev /*str*/); templatestatic type_(Array_) k_be(T_ k_ew /*me_*/, type_(Array_) k_ex /*type*/); templatestatic T_ k_cq(T_ k_ey /*me_*/, type_(Array_) k_ez /*type*/, T_ k_fa /*n*/); templatestatic T_ k_cr(T_ k_fb /*me_*/, type_(Array_) k_fc /*type*/, int64_t k_fd /*n*/); templatestatic T_ k_dd(T_ k_fg /*me_*/, type_(Array_) k_fh /*type*/, int64_t k_fi /*n*/); static char16_t k_eh(); templatestatic T_ k_eu(T_ k_fl /*me_*/, type_(Array_) k_fm /*type*/, int64_t k_fn /*start*/, int64_t k_fo /*len*/); 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_cz; // x uint32_t k_da; // y uint32_t k_db; // z uint32_t k_dc; // 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_cz(), k_da(), k_db(), k_dc(){ 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(){ type_(Array_) k_am; // s int64_t k_ao; // n3 int64_t k_ap; // n5 int64_t k_at; int64_t k_av; // d int64_t k_au; (k_am) = ((k_an)()); (k_ao) = (0LL); (k_ap) = (0LL); for(k_at = (0LL), k_au = (((k_am)->Len()) - (1LL)); k_at <= k_au; k_at += (1LL)){ (k_av) = ((static_cast((k_am)->At(k_at))) - (48LL)); (k_ao) = ((k_ao) + (k_av)); (k_ap) = ((k_ap) + (((((k_at) % (2LL)) == (0LL)) ? (1LL) : (-1LL)) * (k_av))); } if((((k_ao) % (3LL)) == (0LL)) && (((k_ap) % (5LL)) == (0LL))){ (k_ba)((newArrayBin_(9,"\x46\x00\x69\x00\x7A\x00\x7A\x00\x42\x00\x75\x00\x7A\x00\x7A\x00\x0A\x00"))); } else if(((k_ap) % (5LL)) == (0LL)){ (k_ba)((newArrayBin_(5,"\x42\x00\x75\x00\x7A\x00\x7A\x00\x0A\x00"))); } else if(((k_ao) % (3LL)) == (0LL)){ (k_ba)((newArrayBin_(5,"\x46\x00\x69\x00\x7A\x00\x7A\x00\x0A\x00"))); } else{ (k_ba)((((newArrayBin_(0,""))->Cat(k_be)>((k_am), (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_bf /*excpt*/){ } // ctor static void k_p(type_(k_o) k_bi /*me*/){ } // _dtor static void k_q(k_o* k_bj){ } // cmp static int64_t k_r(type_(k_o) k_bk /*me*/, type_(k_o) k_bl /*t*/){ throw 3910598660LL; } // _copy static type_(k_o) k_s(type_(k_o) k_bm /*me*/){ type_(k_o) k_bn; type_(k_o) k_bo; (k_bn) = (k_bo = new_(k_o)(), k_p(k_bo), k_bo); return as_(classTable_, (k_bn), 0); } // _toBin static type_(Array_) k_t(type_(k_o) k_bp /*me*/){ type_(Array_) k_bq; (k_bq) = (newArrays_)>((0LL))); return k_bq; } // _fromBin static type_(k_o) k_u(type_(k_o) k_br /*me*/, type_(Array_) k_bs /*bin*/, int64_t* k_bt /*idx*/){ type_(k_o) k_bu; type_(k_o) k_bv; (k_bu) = (k_bv = new_(k_o)(), k_p(k_bv), k_bv); return k_bu; } // toStr static type_(Array_) k_v(type_(k_o) k_bw /*me*/){ return newArrayBin_(0,""); } // ctor static void k_w(type_(k_n) k_bx /*me*/){ k_bz k_by; // super (k_by) = (k_p); } // rnd static int64_t k_x(type_(k_n) k_ca /*me*/, int64_t k_cb /*min*/, int64_t k_cc /*max*/){ uint64_t k_cf; // n uint64_t k_cg; // m uint64_t k_ch; // r (k_cf) = (static_cast(((k_cc) - (k_cb)) + (1LL))); (k_cg) = ((0x0000000000000000ULL) - (((0x0000000000000000ULL) - (k_cf)) % (k_cf))); (k_ch) = (0x0000000000000000ULL); if((k_cg) == (0x0000000000000000ULL)){ (k_ch) = ((reinterpret_cast(classTable_[(k_ca)->Y + 9]))((k_ca))); } else{ do{ (k_ch) = ((reinterpret_cast(classTable_[(k_ca)->Y + 9]))((k_ca))); }while((k_cg) <= (k_ch)); } return (static_cast((k_ch) % (k_cf))) + (k_cb); } // rndBit64 static uint64_t k_y(type_(k_n) k_cn /*me*/){ uint32_t k_co; // t (k_co) = ((reinterpret_cast(classTable_[(k_cn)->Y + 12]))((k_cn))); return k_cq((k_cr((static_cast(k_co)), (nullptr), (32LL))), (nullptr), (static_cast((reinterpret_cast(classTable_[(k_cn)->Y + 12]))((k_cn))))); } // rndFloat static double k_z(type_(k_n) k_cs /*me*/, double k_ct /*min*/, double k_cu /*max*/){ return (((static_cast((reinterpret_cast(classTable_[(k_cs)->Y + 9]))((k_cs)))) / (1.844674407370955e+19)) * ((k_cu) - (k_ct))) + (k_ct); } // setSeed static void k_aa(type_(k_n) k_cx /*me*/, uint32_t k_cy /*seed*/){ ((k_cx)->k_cz) = (0x075BCD15U); ((k_cx)->k_da) = (0x159A55E5U); ((k_cx)->k_db) = ((0x1F123BB5U) * (k_cy)); ((k_cx)->k_dc) = ((0x05491333U) * (k_dd(((k_cx)->k_db), (nullptr), (1LL)))); } // xs128 static uint32_t k_ab(type_(k_n) k_de /*me*/){ uint32_t k_df; // t (k_df) = (k_ai(((k_de)->k_cz), (nullptr), (k_cr(((k_de)->k_cz), (nullptr), (11LL))))); ((k_de)->k_cz) = ((k_de)->k_da); ((k_de)->k_da) = ((k_de)->k_db); ((k_de)->k_db) = ((k_de)->k_dc); ((k_de)->k_dc) = (k_ai((k_ai(((k_de)->k_dc), (nullptr), (k_dd(((k_de)->k_dc), (nullptr), (19LL))))), (nullptr), (k_ai((k_df), (nullptr), (k_dd((k_df), (nullptr), (8LL))))))); return (k_de)->k_dc; } // _dtor static void k_ac(k_n* k_dg){ } // _copy static type_(k_n) k_ad(type_(k_n) k_dh){ type_(k_n) k_di; type_(k_n) k_dj; (k_di) = (k_dj = new_(k_n)(), k_w(k_dj), k_dj); ((k_di)->k_cz) = ((k_dh)->k_cz); ((k_di)->k_da) = ((k_dh)->k_da); ((k_di)->k_db) = ((k_dh)->k_db); ((k_di)->k_dc) = ((k_dh)->k_dc); return as_(classTable_, (k_di), 8); } // _toBin static type_(Array_) k_ae(type_(k_n) k_dk){ type_(Array_) k_dl; (k_dl) = (newArrays_)>((0LL))); (k_dl) = ((k_dl)->Cat(toBin_()(((k_dk)->k_cz)))); (k_dl) = ((k_dl)->Cat(toBin_()(((k_dk)->k_da)))); (k_dl) = ((k_dl)->Cat(toBin_()(((k_dk)->k_db)))); (k_dl) = ((k_dl)->Cat(toBin_()(((k_dk)->k_dc)))); return k_dl; } // _fromBin static type_(k_n) k_af(type_(k_n) k_dq, type_(Array_) k_dr, int64_t* k_ds){ type_(k_n) k_dt; type_(k_n) k_du; (k_dt) = (k_du = new_(k_n)(), k_w(k_du), k_du); ((k_dt)->k_cz) = (fromBin_()((k_dr), (*k_ds))); ((k_dt)->k_da) = (fromBin_()((k_dr), (*k_ds))); ((k_dt)->k_db) = (fromBin_()((k_dr), (*k_ds))); ((k_dt)->k_dc) = (fromBin_()((k_dr), (*k_ds))); return k_dt; } // makeRnd static type_(k_n) k_ag(type_(k_n) k_dv /*me2*/, uint32_t k_dw /*seed*/){ (reinterpret_cast(classTable_[(k_dv)->Y + 11]))((k_dv), (k_dw)); return k_dv; } // _xor templatestatic T_ k_ai(T_ k_dy /*me_*/, type_(Array_) k_dz /*type*/, T_ k_ea /*n*/){ return k_dy^k_ea; } // 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); } // input static type_(Array_) k_an(){ type_(Array_) k_eb; // buf int64_t k_ec; // ptr char16_t k_eg; // c (k_eb) = (newArrays_)>((1024LL))); (k_ec) = (0LL); while(true){ (k_eg) = ((k_eh)()); if((k_eg) == (u'\u000D')){ continue; } if((k_eg) == (u'\uFFFF')){ if((k_ec) == (0LL)){ return nullptr; } break; } if((k_eg) == (u'\u000A')){ break; } if((k_ec) == ((k_eb)->Len())){ (k_eb) = ((k_eb)->Cat(newArrays_)>(((k_eb)->Len())))); } ((k_eb)->At(k_ec)) = (k_eg); (k_ec) = ((k_ec) + (1LL)); } return k_eu)>((k_eb), (nullptr), (0LL), (k_ec)); } // print static void k_ba(type_(Array_) k_ev /*str*/){ if(k_ev==nullptr){ fputs("(null)",stdout); return; } #if defined(_WIN32) fputws(reinterpret_cast(k_ev->B),stdout); #else std::u16string s_=k_ev->B; const std::string&t_=utf16ToUtf8_(s_); fputs(t_.c_str(),stdout); #endif } // _toStr templatestatic type_(Array_) k_be(T_ k_ew /*me_*/, type_(Array_) k_ex /*type*/){ return toStr_(k_ew); } // _or templatestatic T_ k_cq(T_ k_ey /*me_*/, type_(Array_) k_ez /*type*/, T_ k_fa /*n*/){ return k_ey|k_fa; } // _shl templatestatic T_ k_cr(T_ k_fb /*me_*/, type_(Array_) k_fc /*type*/, int64_t k_fd /*n*/){ return k_fb<static T_ k_dd(T_ k_fg /*me_*/, type_(Array_) k_fh /*type*/, int64_t k_fi /*n*/){ return k_fg>>k_fi; } // inputLetter static char16_t k_eh(){ #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 } // _sub templatestatic T_ k_eu(T_ k_fl /*me_*/, type_(Array_) k_fm /*type*/, int64_t k_fn /*start*/, int64_t k_fo /*len*/){ return sub_(k_fl,k_fn,k_fo); } 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_); } //}}}