結果
問題 | No.523 LED |
ユーザー | maspy |
提出日時 | 2023-11-07 18:40:07 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 27,878 bytes |
コンパイル時間 | 4,295 ms |
コンパイル使用メモリ | 291,640 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 23:25:39 |
合計ジャッジ時間 | 5,086 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 3 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 6 ms
5,376 KB |
testcase_20 | AC | 7 ms
5,376 KB |
testcase_21 | AC | 3 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 7 ms
5,376 KB |
testcase_24 | AC | 4 ms
5,376 KB |
ソースコード
#line 1 "/home/maspy/compro/library/my_template.hpp" #if defined(LOCAL) #include <my_template_compiled.hpp> #else #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using u32 = unsigned int; using u64 = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; using f128 = __float128; template <class T> constexpr T infty = 0; template <> constexpr int infty<int> = 1'000'000'000; template <> constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2; template <> constexpr u32 infty<u32> = infty<int>; template <> constexpr u64 infty<u64> = infty<ll>; template <> constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>; template <> constexpr double infty<double> = infty<ll>; template <> constexpr long double infty<long double> = infty<ll>; using pi = pair<ll, ll>; using vi = vector<ll>; template <class T> using vc = vector<T>; template <class T> using vvc = vector<vc<T>>; template <class T> using vvvc = vector<vvc<T>>; template <class T> using vvvvc = vector<vvvc<T>>; template <class T> using vvvvvc = vector<vvvvc<T>>; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; #define vv(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define vvv(type, name, h, w, ...) \ vector<vector<vector<type>>> name( \ h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) #define vvvv(type, name, a, b, c, ...) \ vector<vector<vector<vector<type>>>> name( \ a, vector<vector<vector<type>>>( \ b, vector<vector<type>>(c, vector<type>(__VA_ARGS__)))) // https://trap.jp/post/1224/ #define FOR1(a) for (ll _ = 0; _ < ll(a); ++_) #define FOR2(i, a) for (ll i = 0; i < ll(a); ++i) #define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i) #define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c)) #define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i) #define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i) #define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i) #define overload4(a, b, c, d, e, ...) e #define overload3(a, b, c, d, ...) d #define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__) #define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__) #define FOR_subset(t, s) \ for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s))) #define all(x) x.begin(), x.end() #define len(x) ll(x.size()) #define elif else if #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second #define stoi stoll int popcnt(int x) { return __builtin_popcount(x); } int popcnt(u32 x) { return __builtin_popcount(x); } int popcnt(ll x) { return __builtin_popcountll(x); } int popcnt(u64 x) { return __builtin_popcountll(x); } int popcnt_mod_2(int x) { return __builtin_parity(x); } int popcnt_mod_2(u32 x) { return __builtin_parity(x); } int popcnt_mod_2(ll x) { return __builtin_parityll(x); } int popcnt_mod_2(u64 x) { return __builtin_parityll(x); } // (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2) int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); } int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); } int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); } int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); } // (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2) int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); } int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); } int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); } int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); } template <typename T> T floor(T a, T b) { return a / b - (a % b && (a ^ b) < 0); } template <typename T> T ceil(T x, T y) { return floor(x + y - 1, y); } template <typename T> T bmod(T x, T y) { return x - y * floor(x, y); } template <typename T> pair<T, T> divmod(T x, T y) { T q = floor(x, y); return {q, x - q * y}; } template <typename T, typename U> T SUM(const vector<U> &A) { T sm = 0; for (auto &&a: A) sm += a; return sm; } #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define UNIQUE(x) \ sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit() template <typename T> T POP(deque<T> &que) { T a = que.front(); que.pop_front(); return a; } template <typename T> T POP(pq<T> &que) { T a = que.top(); que.pop(); return a; } template <typename T> T POP(pqg<T> &que) { T a = que.top(); que.pop(); return a; } template <typename T> T POP(vc<T> &que) { T a = que.back(); que.pop_back(); return a; } template <typename F> ll binary_search(F check, ll ok, ll ng, bool check_ok = true) { if (check_ok) assert(check(ok)); while (abs(ok - ng) > 1) { auto x = (ng + ok) / 2; (check(x) ? ok : ng) = x; } return ok; } template <typename F> double binary_search_real(F check, double ok, double ng, int iter = 100) { FOR(iter) { double x = (ok + ng) / 2; (check(x) ? ok : ng) = x; } return (ok + ng) / 2; } template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } // ? は -1 vc<int> s_to_vi(const string &S, char first_char) { vc<int> A(S.size()); FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); } return A; } template <typename T, typename U> vector<T> cumsum(vector<U> &A, int off = 1) { int N = A.size(); vector<T> B(N + 1); FOR(i, N) { B[i + 1] = B[i] + A[i]; } if (off == 0) B.erase(B.begin()); return B; } // stable sort template <typename T> vector<int> argsort(const vector<T> &A) { vector<int> ids(len(A)); iota(all(ids), 0); sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); }); return ids; } // A[I[0]], A[I[1]], ... template <typename T> vc<T> rearrange(const vc<T> &A, const vc<int> &I) { vc<T> B(len(I)); FOR(i, len(I)) B[i] = A[I[i]]; return B; } #endif #line 1 "/home/maspy/compro/library/other/io.hpp" #define FASTIO #include <unistd.h> // https://judge.yosupo.jp/submission/21623 namespace fastio { static constexpr uint32_t SZ = 1 << 17; char ibuf[SZ]; char obuf[SZ]; char out[100]; // pointer of ibuf, obuf uint32_t pil = 0, pir = 0, por = 0; struct Pre { char num[10000][4]; constexpr Pre() : num() { for (int i = 0; i < 10000; i++) { int n = i; for (int j = 3; j >= 0; j--) { num[i][j] = n % 10 | '0'; n /= 10; } } } } constexpr pre; inline void load() { memcpy(ibuf, ibuf + pil, pir - pil); pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin); pil = 0; } inline void flush() { fwrite(obuf, 1, por, stdout); por = 0; } void rd(char &c) { do { if (pil + 1 > pir) load(); c = ibuf[pil++]; } while (isspace(c)); } void rd(string &x) { x.clear(); char c; do { if (pil + 1 > pir) load(); c = ibuf[pil++]; } while (isspace(c)); do { x += c; if (pil == pir) load(); if (pil == pir) break; c = ibuf[pil++]; } while (!isspace(c)); } template <typename T> void rd_real(T &x) { string s; rd(s); x = stod(s); } template <typename T> void rd_integer(T &x) { if (pil + 100 > pir) load(); char c; do c = ibuf[pil++]; while (c < '-'); bool minus = 0; if constexpr (is_signed<T>::value || is_same_v<T, i128>) { if (c == '-') { minus = 1, c = ibuf[pil++]; } } x = 0; while (c >= '0') { x = x * 10 + (c & 15), c = ibuf[pil++]; } if constexpr (is_signed<T>::value || is_same_v<T, i128>) { if (minus) x = -x; } } void rd(int &x) { rd_integer(x); } void rd(ll &x) { rd_integer(x); } void rd(i128 &x) { rd_integer(x); } void rd(u32 &x) { rd_integer(x); } void rd(u64 &x) { rd_integer(x); } void rd(u128 &x) { rd_integer(x); } void rd(double &x) { rd_real(x); } void rd(long double &x) { rd_real(x); } void rd(f128 &x) { rd_real(x); } template <class T, class U> void rd(pair<T, U> &p) { return rd(p.first), rd(p.second); } template <size_t N = 0, typename T> void rd_tuple(T &t) { if constexpr (N < std::tuple_size<T>::value) { auto &x = std::get<N>(t); rd(x); rd_tuple<N + 1>(t); } } template <class... T> void rd(tuple<T...> &tpl) { rd_tuple(tpl); } template <size_t N = 0, typename T> void rd(array<T, N> &x) { for (auto &d: x) rd(d); } template <class T> void rd(vc<T> &x) { for (auto &d: x) rd(d); } void read() {} template <class H, class... T> void read(H &h, T &... t) { rd(h), read(t...); } void wt(const char c) { if (por == SZ) flush(); obuf[por++] = c; } void wt(const string s) { for (char c: s) wt(c); } void wt(const char *s) { size_t len = strlen(s); for (size_t i = 0; i < len; i++) wt(s[i]); } template <typename T> void wt_integer(T x) { if (por > SZ - 100) flush(); if (x < 0) { obuf[por++] = '-', x = -x; } int outi; for (outi = 96; x >= 10000; outi -= 4) { memcpy(out + outi, pre.num[x % 10000], 4); x /= 10000; } if (x >= 1000) { memcpy(obuf + por, pre.num[x], 4); por += 4; } else if (x >= 100) { memcpy(obuf + por, pre.num[x] + 1, 3); por += 3; } else if (x >= 10) { int q = (x * 103) >> 10; obuf[por] = q | '0'; obuf[por + 1] = (x - q * 10) | '0'; por += 2; } else obuf[por++] = x | '0'; memcpy(obuf + por, out + outi + 4, 96 - outi); por += 96 - outi; } template <typename T> void wt_real(T x) { ostringstream oss; oss << fixed << setprecision(15) << double(x); string s = oss.str(); wt(s); } void wt(int x) { wt_integer(x); } void wt(ll x) { wt_integer(x); } void wt(i128 x) { wt_integer(x); } void wt(u32 x) { wt_integer(x); } void wt(u64 x) { wt_integer(x); } void wt(u128 x) { wt_integer(x); } void wt(double x) { wt_real(x); } void wt(long double x) { wt_real(x); } void wt(f128 x) { wt_real(x); } template <class T, class U> void wt(const pair<T, U> val) { wt(val.first); wt(' '); wt(val.second); } template <size_t N = 0, typename T> void wt_tuple(const T t) { if constexpr (N < std::tuple_size<T>::value) { if constexpr (N > 0) { wt(' '); } const auto x = std::get<N>(t); wt(x); wt_tuple<N + 1>(t); } } template <class... T> void wt(tuple<T...> tpl) { wt_tuple(tpl); } template <class T, size_t S> void wt(const array<T, S> val) { auto n = val.size(); for (size_t i = 0; i < n; i++) { if (i) wt(' '); wt(val[i]); } } template <class T> void wt(const vector<T> val) { auto n = val.size(); for (size_t i = 0; i < n; i++) { if (i) wt(' '); wt(val[i]); } } void print() { wt('\n'); } template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) { wt(head); if (sizeof...(Tail)) wt(' '); print(forward<Tail>(tail)...); } // gcc expansion. called automaticall after main. void __attribute__((destructor)) _d() { flush(); } } // namespace fastio using fastio::read; using fastio::print; using fastio::flush; #define INT(...) \ int __VA_ARGS__; \ read(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ read(__VA_ARGS__) #define U32(...) \ u32 __VA_ARGS__; \ read(__VA_ARGS__) #define U64(...) \ u64 __VA_ARGS__; \ read(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ read(__VA_ARGS__) #define CHAR(...) \ char __VA_ARGS__; \ read(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ read(__VA_ARGS__) #define VEC(type, name, size) \ vector<type> name(size); \ read(name) #define VV(type, name, h, w) \ vector<vector<type>> name(h, vector<type>(w)); \ read(name) void YES(bool t = 1) { print(t ? "YES" : "NO"); } void NO(bool t = 1) { YES(!t); } void Yes(bool t = 1) { print(t ? "Yes" : "No"); } void No(bool t = 1) { Yes(!t); } void yes(bool t = 1) { print(t ? "yes" : "no"); } void no(bool t = 1) { yes(!t); } #line 3 "main.cpp" #line 2 "/home/maspy/compro/library/mod/modint_common.hpp" struct has_mod_impl { template <class T> static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{}); template <class T> static auto check(...) -> std::false_type; }; template <class T> class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {}; template <typename mint> mint inv(int n) { static const int mod = mint::get_mod(); static vector<mint> dat = {0, 1}; assert(0 <= n); if (n >= mod) n %= mod; while (len(dat) <= n) { int k = len(dat); int q = (mod + k - 1) / k; dat.eb(dat[k * q - mod] * mint::raw(q)); } return dat[n]; } template <typename mint> mint fact(int n) { static const int mod = mint::get_mod(); assert(0 <= n && n < mod); static vector<mint> dat = {1, 1}; while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint::raw(len(dat))); return dat[n]; } template <typename mint> mint fact_inv(int n) { static vector<mint> dat = {1, 1}; if (n < 0) return mint(0); while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat))); return dat[n]; } template <class mint, class... Ts> mint fact_invs(Ts... xs) { return (mint(1) * ... * fact_inv<mint>(xs)); } template <typename mint, class Head, class... Tail> mint multinomial(Head &&head, Tail &&... tail) { return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...); } template <typename mint> mint C_dense(int n, int k) { static vvc<mint> C; static int H = 0, W = 0; auto calc = [&](int i, int j) -> mint { if (i == 0) return (j == 0 ? mint(1) : mint(0)); return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0); }; if (W <= k) { FOR(i, H) { C[i].resize(k + 1); FOR(j, W, k + 1) { C[i][j] = calc(i, j); } } W = k + 1; } if (H <= n) { C.resize(n + 1); FOR(i, H, n + 1) { C[i].resize(W); FOR(j, W) { C[i][j] = calc(i, j); } } H = n + 1; } return C[n][k]; } template <typename mint, bool large = false, bool dense = false> mint C(ll n, ll k) { assert(n >= 0); if (k < 0 || n < k) return 0; if constexpr (dense) return C_dense<mint>(n, k); if constexpr (!large) return multinomial<mint>(n, k, n - k); k = min(k, n - k); mint x(1); FOR(i, k) x *= mint(n - i); return x * fact_inv<mint>(k); } template <typename mint, bool large = false> mint C_inv(ll n, ll k) { assert(n >= 0); assert(0 <= k && k <= n); if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k); return mint(1) / C<mint, 1>(n, k); } // [x^d](1-x)^{-n} template <typename mint, bool large = false, bool dense = false> mint C_negative(ll n, ll d) { assert(n >= 0); if (d < 0) return mint(0); if (n == 0) { return (d == 0 ? mint(1) : mint(0)); } return C<mint, large, dense>(n + d - 1, d); } #line 3 "/home/maspy/compro/library/mod/modint.hpp" template <int mod> struct modint { static constexpr u32 umod = u32(mod); static_assert(umod < u32(1) << 31); u32 val; static modint raw(u32 v) { modint x; x.val = v; return x; } constexpr modint() : val(0) {} constexpr modint(u32 x) : val(x % umod) {} constexpr modint(u64 x) : val(x % umod) {} constexpr modint(u128 x) : val(x % umod) {} constexpr modint(int x) : val((x %= mod) < 0 ? x + mod : x){}; constexpr modint(ll x) : val((x %= mod) < 0 ? x + mod : x){}; constexpr modint(i128 x) : val((x %= mod) < 0 ? x + mod : x){}; bool operator<(const modint &other) const { return val < other.val; } modint &operator+=(const modint &p) { if ((val += p.val) >= umod) val -= umod; return *this; } modint &operator-=(const modint &p) { if ((val += umod - p.val) >= umod) val -= umod; return *this; } modint &operator*=(const modint &p) { val = u64(val) * p.val % umod; return *this; } modint &operator/=(const modint &p) { *this *= p.inverse(); return *this; } modint operator-() const { return modint::raw(val ? mod - val : u32(0)); } modint operator+(const modint &p) const { return modint(*this) += p; } modint operator-(const modint &p) const { return modint(*this) -= p; } modint operator*(const modint &p) const { return modint(*this) *= p; } modint operator/(const modint &p) const { return modint(*this) /= p; } bool operator==(const modint &p) const { return val == p.val; } bool operator!=(const modint &p) const { return val != p.val; } modint inverse() const { int a = val, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b), swap(u -= t * v, v); } return modint(u); } modint pow(ll n) const { assert(n >= 0); modint ret(1), mul(val); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } static constexpr int get_mod() { return mod; } // (n, r), r は 1 の 2^n 乗根 static constexpr pair<int, int> ntt_info() { if (mod == 167772161) return {25, 17}; if (mod == 469762049) return {26, 30}; if (mod == 754974721) return {24, 362}; if (mod == 880803841) return {23, 211}; if (mod == 943718401) return {22, 663003469}; if (mod == 998244353) return {23, 31}; if (mod == 1045430273) return {20, 363}; if (mod == 1051721729) return {20, 330}; if (mod == 1053818881) return {20, 2789}; return {-1, -1}; } static constexpr bool can_ntt() { return ntt_info().fi != -1; } }; #ifdef FASTIO template <int mod> void rd(modint<mod> &x) { fastio::rd(x.val); assert(0 <= x.val && x.val < mod); } template <int mod> void wt(modint<mod> x) { fastio::wt(x.val); } #endif using modint107 = modint<1000000007>; using modint998 = modint<998244353>; #line 1 "/home/maspy/compro/library/mod/factorial107.hpp" // 1<<20 int factorial107table[1024] = {1,55098162,799018112,644524227,804570289,699421653,999080403,347644092,298264049,547915206,68604898,242165296,99769214,860919687,695517422,304751648,800304985,404296372,345504787,346396697,661521818,811907079,150066936,379369971,383295467,935785718,884263687,185573413,564595064,703180737,200891912,45268585,361946029,862561983,555223579,717470752,742784681,818749011,825255985,753131797,774984247,244818236,509057662,323909107,486700580,791867040,303567866,976227856,944323045,513842788,567328309,686789145,441779759,195814622,2372115,135277835,294954750,723496015,119271996,986547466,717213282,842873786,234208469,864111391,117175975,118474328,890000195,504224423,508111147,725796711,802878396,246336953,468479803,310148765,702396285,576460826,175957429,883569154,610938868,287010876,212131504,438039362,359800384,432795594,633410554,155137408,314936343,179257123,943713322,673162662,422288605,545194215,158939936,115503469,689488055,401702717,532814826,592763273,773200138,474494844,496413916,528795782,353056535,193856493,974131920,921613963,393169150,830738748,837700032,174096350,803328680,434966400,698398808,589644499,669724987,860591235,921625212,16363628,511768062,515388641,946983274,375285964,288822198,841563728,550332445,512378200,723231171,688050346,638916270,303773384,338440254,794857710,983752474,388318097,628785057,576616801,25029917,915971206,534292228,562759338,78040824,844961917,391581518,37735563,166114276,533068572,866703952,971782310,839681504,713554826,626185157,514984174,485251798,656102354,587843669,710027943,85325823,3718675,780721779,888259006,709912685,458901728,526677538,873562554,28552679,273046452,694930680,19258350,633408320,497294065,699279305,863781574,941853248,754504516,567820050,153017173,309672260,864251395,999648212,504204977,139941702,735693996,475650352,751284240,61380201,358232497,650878822,427480644,552589593,7500105,216677699,848980694,565479858,273508588,466692797,613411243,300912167,686394608,943827276,838125279,585515687,370926564,947737740,905550006,780384258,985335993,380437817,436417804,952004841,168955240,310513812,254079069,734838326,209059985,189848103,178192696,239063132,724829800,471021218,22656326,940110791,670514782,160800189,60164301,534784668,623973502,444037086,781751482,292944263,109226380,542920902,293050078,501265668,293547492,678045668,870103700,199000138,973807329,712358272,567141781,667220314,930560330,520238050,188798676,915219645,875218552,107463226,924068096,373354885,161687663,742633209,899649882,172223561,490032230,532248036,733461058,864357307,39004186,666796032,19300991,866949601,152723250,632980031,28154382,812475803,342290061,378814433,311792214,811932026,628385664,925729472,483891986,104909388,838245993,226415225,80497756,905742254,760776367,59951296,502463774,432422968,529614143,987845867,941009243,680208181,129640287,135701022,93697263,580002085,736790935,647149348,963929930,456358064,393498474,345303775,836988638,663009951,688270876,821556726,61653598,10436780,40516807,602622268,365808294,624854174,764883550,133418712,979879958,883675628,802594907,960259381,657818185,789571797,869941376,925271608,584915231,373203547,780879573,162303580,219381059,988122582,809692587,524697206,890686281,255441194,208655553,818176738,234316848,355059206,328134956,168206574,937157388,816978580,176422569,755437061,653448585,104372309,277493780,817870252,509736736,467977765,33347068,537441964,30292019,828581950,303478168,255296787,226318316,205744264,27632923,92186650,148892391,626052914,122285044,885244951,369494295,227491286,978201674,280638485,366898179,400916139,936093782,457514504,799178457,77262843,887662440,311502312,433979195,62200437,841399346,399849157,55933275,269778121,314076684,346937429,587781485,403077288,120051495,341462465,804288108,354008902,773347166,273225862,977284051,711403642,332515431,72546287,70463395,383292501,583203296,58684392,59801553,934861184,123659858,172225366,16490486,640104831,651484064,414057597,912563140,516388569,982284977,354948305,845441532,249139343,112170128,852836789,363141564,95948290,593351477,538225430,684921161,437291872,753187673,197482933,175217286,930569788,733325632,206283594,860092876,264612104,375479413,433058282,824726232,663285168,610355794,410260572,141034667,801620565,280447634,539012567,582334448,117111267,192909957,901437820,242191138,473245986,119617826,582524622,27271548,763258578,517785257,740102975,807353604,677357433,502074113,763360936,37227708,928062158,453067630,416392863,403468924,390966467,90780688,97580941,397618185,444801884,718494493,905625902,439144581,809645601,571259258,311262977,379698006,619843354,42160512,709478648,139908674,884941258,7778675,277356393,574397869,64807900,568439116,884254362,793527033,634827367,242270229,166836929,699666005,782871805,430576594,69423864,551852289,854389404,33130302,690600649,389114637,594444305,378027483,501626534,769371462,565727105,185366687,760889594,622679145,531967768,895838088,631099033,636979633,966288648,722632929,487185734,674289231,978197320,42219437,631006005,62801370,477869560,150370443,708309474,569052485,373979365,110651678,526192057,1187964,604094093,92402540,199407377,263950464,85094825,143055746,488295779,242448163,271952450,88191394,640214992,291887361,38760888,143069496,957354294,970267065,791944735,188497194,644438434,778147734,540003575,909162269,307294631,117326469,318009725,133188612,150701170,968756181,75908005,226593925,597645956,881933480,899459287,455981899,229221768,807672432,414097149,643328910,465859747,254429407,523184583,71216457,323329780,538880177,339599190,794248796,185173563,244936068,257855397,449978612,725702638,935779255,177430235,442849413,379319626,300751979,635487273,183449414,5934499,378785317,861919911,678817974,268409923,203403445,572871951,443809175,295389783,505988742,840133940,846932417,746139508,669216033,75861584,858480227,466369788,200782437,410124462,398817445,968382032,980738344,56008451,983178362,179562483,823724361,469703761,906401712,312400795,531915860,313966891,499155799,188116091,542673699,973727253,756116696,555496689,953139148,664729273,301347505,874894370,769419863,39619555,844221994,437468538,567165362,826223750,237919972,889742229,340395341,391452566,470281592,861327653,391319516,846903225,165819062,626164401,316709929,521538790,990712756,973874818,890738343,563978092,109958482,828180512,763297389,963971145,754096813,773609544,459522164,8038398,631562195,353217532,305814226,567542439,895416683,84833664,222068809,137353990,316612885,847273944,686340505,587953096,891163150,312873714,170456823,499030076,552288670,984000707,296655021,907848089,795824037,868241961,731318793,613986016,504817890,831254264,714194680,892153437,432990870,213690618,820549872,68492073,905288570,828076972,100771571,701929895,429147966,855717720,702005759,834355402,271364955,808645569,975796499,767810085,630847407,570582799,453848037,305413582,658578009,72025782,432456806,679768447,209753914,642309814,367985447,648596045,662634665,934081491,20395923,976333508,947778280,290901114,683388002,527020810,977326275,488693383,189698098,419374780,110616851,127872982,575257710,581134348,809887616,616715986,785224788,330000241,549806410,300312979,453241111,120873512,806993146,171910094,251834489,979979771,418698259,752813751,394025833,29105970,80840916,796020902,589114561,204474745,376387134,234987470,80775688,766942711,782094550,251204403,958598099,73582601,425563446,280068465,830973501,760007127,289646156,209940903,843351800,279527279,738627148,205145989,347868746,12854961,648847391,11192482,203518335,83599363,614624895,760355983,241204239,725553388,423530890,233709513,129164025,183143523,474024463,587482677,262947835,830758485,490545965,42715938,774365958,917430364,848838405,184884783,363325662,815621393,13287526,130498889,568838029,994918408,689158356,514272481,755554988,448513470,717322665,827827457,350229871,213613603,814952584,154931117,596054309,996378663,464177580,523761543,498980428,224645330,774166263,755880313,389249660,81743329,776397644,662396499,223245698,916069463,500419874,906869272,990436276,83413835,861165195,955992714,931625913,809913797,990584878,385913422,976567861,988873023,385236984,677028085,265052939,959365279,418677004,258798519,676383755,636025853,270238386,206316099,239739022,885152995,473139022,930824994,355594287,876223850,584874216,450993348,250278273,66731334,677818083,932165316,513087030,595832582,266493735,941688056,358758739,118809938,109331276,935297327,907221850,844856226,966689708,153251680,426805713,872205902,228749156,852770211,253065643,265234802,21716397,785998921,576621647,514060757,602374495,488838351,959753273,105481283,471659303,687019929,675067970,650147251,384820796,572532868,616933893,598368862,955007801,991174700,162133698,58160791,148888347,464964795,922938492,89012579,110574373,388391339,378503165,317247776,8038731,656691478,44251737,780947050,9218625,591467905,660897916,894672548,927151139,575483441,12732642,292282890,535590986,602061256,105810330,549519899,900104648,428472182,404847041,747230327,464453245,284822208,7040213,767161925,268629370,892069143,822121223,971455916,221846561,64553306,769796929,675275231,652246661,449517151,975374186,994429602,299117212,782066823,100306236,683957845,778001329,951091055,742690935,735367617,614080637,290990048,34499833,990980489,559407811,525864614,317820378,806036323,701425752,761690151,688462290,373529632,32050577,719463331,118313951,999322637,97750199,523426443,819087263,545301062,488598090,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int factorial107(ll n) { constexpr int mod = 1000000007; if (n >= mod) return 0; auto [q, r] = divmod<int>(n, 1 << 20); ll x = factorial107table[q]; int s = q << 20; FOR(i, r) x = x * (s + i + 1) % mod; return x; } #line 6 "main.cpp" using mint = modint107; void solve() { INT(N); mint ANS = 1; ANS *= factorial107(2 * N); ANS *= inv<mint>(2).pow(N); print(ANS); } signed main() { int T = 1; // INT(T); FOR(T) solve(); return 0; }