prompt
string
response
string
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; long long P[12], phi, nrp; long long N, MOD, l, r; void setMod(long long MOD) { phi = MOD; nrp = 0; for (long long i...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5; template <typename T> inline void read(T &x) { x = 0; char c = getchar(), f = 0; for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = 1; for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long n, p, l, r, tot, pri[50], fac[100005], inv[100005], t[100005][50]; long long pown(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % p; a = a * a % p, b >>= 1; } return res; } long long phi(long long n) { long l...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:108777216") using namespace std; int const MAX_N = 105 * 1024; void ad(long long& x, long long val, long long p) { x = (x + val) % p; } using namespace std; const int inf = 1010000000; const double eps = 1e-9; long long p[111]; int pp = 0; long long P; struct num...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int fac[100010], inv[100010], num[100010], mod, A[100010]; long long a[50], m[50]; int n, l, r, tot, p, P, mul; int qpow(int a, int b) { int ret = 1; while (b) { if (b & 1) ret = 1ll * ret * a % mod; a = 1ll * a * a % mod; b >>= 1; } return ret; } long l...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(int64_t &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> jie[15][100010]; long long pres[100010], pred[100010]; int n, typ, mod, a, b; int primes[15], realmod[15], primes_num[15], cnt = 0, primes_prod[15][35]; void predeal() { for (int t = 1; t <= cnt; t++) { jie[t][0] = make_pair(0, 1); pres[...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> int n, mod, l, r, p[20], pcnt, sum[100005][20], fac[100005], inv[100005], ans; long long Pow(long long x, long long k) { long long t = 1; for (; k; k >>= 1, x = x * x % mod) if (k & 1) t = t * x % mod; return t; } int C(int a, int b) { if (b < 0) return 0; int res = 1ll * fac[a] *...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using LL = long long; struct Elem { int val = 0; std::vector<LL> cnt; Elem() {} explicit Elem(int v, const std::vector<int>& preserves) : cnt(preserves.size()) { for (int i = 0; i < preserves.size(); ++i) { int w = preserves[i]; while (v % w == 0) ++cnt[i], v /= w;...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 7; int p, tot; long long fac[maxn], inv[maxn], a[maxn], c[maxn][30]; long long qpow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % p; x = x * x % p; n >>= 1; } return res; } void init() { fa...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Div1_449D { static int n; static long mod; static long[] pF; static int nP; sta...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { int m0 = m, t, q; int x0 = 0, x1 = 1; if (m == 1) return 0; while (a > 1) { q = a / m; t = m; m = a % m, a = t; t = x0; x0 = x1 - q * x0; x1 = t; } if (x1 < 0) x1 += m0; return...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { int m0 = m, t, q; int x0 = 0, x1 = 1; if (m == 1) return 0; while (a > 1) { q = a / m; t = m; m = a % m, a = t; t = x0; x0 = x1 - q * x0; x1 = t; } if (x1 < 0) x1 += m0; return...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { if (a <= 1) return a; int ans = (1 - (long long int)inverse(m % a, a) * m) / a; return ans + m; } int fact[N], ifact[N], pot[N][P]; int sz, p[P]; void primes(int n) { for (int d = 2; d * d <= n; d++) if...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; struct NTT { int p, g, m; static int quick_power(int n, int i, int p) { long long r = 1; for (; i; i >>= 1, n = 1LL * n * n % p) (i & 1) && (r = r * n % p); return r; } NTT() {} NTT(int p, int g) { this->p = p, this->g = g, m = 0; } void FFT(int *arr...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool cmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool cmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } int inp() { int x = 0, f = 1; char ch; for (ch = getchar(); !isdigit(ch); ch = getch...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long expo(long long base, long long exponent, long long mod) { long long ans = 1; while (exponent != 0) { if (exponent & 1) ans = (1LL * ans * base) % mod; base = (1LL * base * base) % mod; exponent >>= 1; } return ans % mod; } long long euclid(long...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int Maxn = 100005; int n, p, l, r, ct, cnt, phi, sum[15][Maxn], res[15]; long long ans, fac[Maxn], inv[Maxn]; long long fast_pow(long long x, long long y) { long long ans = 1, now = x; while (y) { if (y & 1) ans = ans * now % p; now = now * now % p; y ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> const int N = 100005; int n, factor[N], ifactor[N]; int cnt[10][N], pr[10], pt, mod, phi; int pow(int x, int y, int ans = 1) { for (; y; y >>= 1, x = (long long)x * x % mod) if (y & 1) ans = (long long)ans * x % mod; return ans; } void factor_integer(int mod) { int tmp = mod; phi = ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long jc[100005], fac[12], vp[12], P[12], s, v[100005][12], r[100005][12]; long long n, L, R, p; long long fpower(long long x, long long k) { long long ans = 1; while (k) { if (k & 1) ans = ans * x % p; x = x * x % p; k >>= 1; } if (!ans) return p; ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } const int inf = INT_MAX / 2; const long long infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } re...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using std::cin; using std::cout; const int N = 100054; int mod; int n, l, r; int o = 0, pr[10], al[10], pral[10][32]; int maj[N], fact[N], finv[N], c[N][10]; inline int min(const int x, const int y) { return x < y ? x : y; } int exgcd(int a, int b, int &x, int &y) { if (b) { int d = exgcd...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int c = 200002, k = 30; long long n, mod, mod2, l, r; long long cnt, pr[k], t[k], fakt[c][k], sum = 0; int phi(int n) { int result = n; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { pr[++cnt] = i; while (n % i == 0) n /= i; result -= r...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, p, L, R; int fact[N], ifact[N], expo[N], prime, power; int expomod(long long int a, long long int e) { int ans = 1; while (e) { if (e & 1) ans = ans * a % power; e /= 2; a = a * a % power; } return ans; } void chinese(int &...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { int m0 = m, t, q; int x0 = 0, x1 = 1; if (m == 1) return 0; while (a > 1) { q = a / m; t = m; m = a % m, a = t; t = x0; x0 = x1 - q * x0; x1 = t; } if (x1 < 0) x1 += m0; return...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma GCC optimize( \ "Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; template <typename T> inline bool cmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; using ll = long long; static const ll N = 1e5 + 10; static const ll P = 11; ll n, p, l, r; ll t = 0; vector<ll> prime(P); vector<ll> fac(N); vector<ll> inv(N); vector<ll> val(N); vector<vector<ll>> vp(P, vecto...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int N = 1E5 + 5; int n, MOD, l, r, prim[N], tot, sum[N]; long long tr[N * 4], C[N]; vector<int> G[N]; bool o[N]; int find(int x, int n) { if (!n) return 1; long long ans = find(x, n / 2); ans = ans * ans % MOD; if (n & 1) ans = ans * x % MOD; return ans; } v...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? "YES" : "NO"); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { assert(y >= 0); x += y; if (x >...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int readint() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } long long n, p, l, r, cnt, ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int n, MOD, PHI, residue[100001], fact[100001], inv_fact[100001]; vector<int> primeDivisors; vector<vector<int> > C, P; int ModExp(int a, int n) { long long x = a % MOD, y = 1 % MOD; while (n) { if (n % 2) y = (x * y) % MOD; x = (x * x) % MOD; n /= 2; } ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } long long gcd(long long a, long long b) { if (b == 0) return a; return...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int P = 10, N = 1e5 + 10; int inverse(int a, int m) { if (a <= 1) return a; int ans = (1 - (long long int)inverse(m % a, a) * m) / a; if (ans < 0) ans += m; return ans; } int fact[N], ifact[N], pot[N][P]; int sz, p[P]; void primes(int n) { for (int d = 2; d ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> const int N = 1e5 + 5; int a[10], s[N], v[N], k[N], c[N][10], d[N][10], t, p; long long P(long long x, int y) { long long z = 1; for (; y; y >>= 1, x = x * x % p) if (y & 1) z = z * x % p; return z; } long long C(int x, int y) { if (x < y) return 0; int a = (long long)s[x] * v[y] ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T& x, T y) { return x > y ? x = y, true : false; } template <class T> inline bool chkmax(T& x, T y) { return x < y ? x = y, true : false; } inline long long read(void) { long long x, f = 1; char ch = getchar(); for (; !isdigit...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inli...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; const int INF = 1000000007; const double PI = acos(-1.0); long long f[MAXN], g[MAXN]; long long extended_euclidean(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long expo(long long a, long long n, long long mod) { long long ans = 1; while (n) { if (n & 1LL) ans = (ans * a) % mod; n >>= 1; a = (a * a) % mod; } return ans; } const int N = 100004; long long fact[N], revFact[N]; vector<int> cnts[N]; vector<int>...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(int64_t &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int n, l, r, mod, P[100...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
import java.util.*; /** * Created by mcl on 2017/12/2. */ public class Main { public static void main(String[] args) { new Main().cal(); } int n; int p; int left; int right; long[][] fact = null; List<Integer[]> list = new ArrayList<>(); void cal() { Scanner in = new Scanner(System.in);...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int N = 100010, M = 12; long long ans; int n, mod; long long cm[M], cx[M], cy[M]; struct comb { int mod, phi, p, c, maxn; int cj[N], f[N], num[N], fi[N]; int pow[40]; int power(int x, int y) { int ret = 1; for (; y; y >>= 1, x = 1ll * x * x % mod) { ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long expo(long long base, long long exponent, long long mod) { long long ans = 1; while (exponent != 0) { if (exponent & 1) ans = (1LL * ans * base) % mod; base = (1LL * base * base) % mod; exponent >>= 1; } return ans % mod; } long long euclid(long...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long maxn = 1e5 + 5; long long add(long long x, long long y, long long m) { x += y; if (x >= m) x -= m; return x; } long long mul(long long x, long long y, long long m) { long long z = 1LL * x * y; return z - z / m * m; } ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma GCC optimize("trapv") using namespace std; using ll = long long; const int maxn = 1 << 18; int n, l, r; ll m; int bp(int a, int p) { int r = 1; while (p) { if (p & 1) r = r * 1ll * a % m; a = a * 1ll * a % m, p >>= 1; } return r; } int phi, nop = 0; int p[maxn]; struct n...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; namespace Comb { struct P { long long x, y; } f[22][N + 5]; long long mod, pn, p[22], p_a[22]; long long power(long long a, long long k, long long mod) { long long res = 1; for (a %= mod; k; k >>= 1, a = a * a % mod) { if (k & 1) res = res * a %...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long N, P, L, R; bool V[50005]; long long Prime[50005]; long long Desc[50005], Exp[50005], cnt; pair<long long, long long> Fact[25][100005]; long long Number[100005]; void sieve() { for (long long i = 2; i <= 50000; i++) { if (V[i] == 0) { Prime[++Prime[0]]...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> const int N = 100050; using namespace std; inline int gi() { char ch = getchar(); int x = 0, q = 0; while (ch < '0' || ch > '9') ch == '-' ? q = 1 : 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return q ? (-x) : x; } int fap(int a, int b, in...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int MN = 100010; vector<int> pr, pchk; void Sieve() { pchk = vector<int>(MN, 0); for (int i = 2; i < MN; i++) { if (!pchk[i]) { pr.push_back(i); } for (int j = 0; j < pr.size() && i * pr[j] < MN; j++) { pchk[i * pr[j]] = 1; if (i % pr...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } const int inf = INT_MAX / 2; const long long infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } re...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int B = 100010; int f[B], rev[B], P, N, p[20], cnt, num[B][20]; int qpow(int a, int x) { int res = 1; while (x) { if (x & 1) res = (long long)res * a % P; a = (long long)a * a % P; x >>= 1; } return res; } void solve() { int phi = P, tp = P; f[...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int n, p, l, r, t, m, a[50], c[100000 + 10][50], jic[100000 + 10], inv[100000 + 10], sum; inline int quick_power(int a, int b) { int s = 1; for (; b; b >>= 1, a = 1ll * a * a % p) if (b & 1) s = 1ll * s * a % p; return s; } inline void init() { int i, j, w =...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, p; int a[33], c[100010][33]; int fac[100010], inv[100010]; int l, r, L, R, len, Ans; inline int Pow(int x, int y) { int Ans = 1; for (; y; y >>= 1, x = 1ll * x * x % p) if (y & 1) Ans = 1ll * Ans * x % p; return Ans; } inline void Init() { int...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; template <class S, class T> ostream& operator<<(ostream& o, const pair<S, T>& p) { return o << "(" << p.first << "," << p.second << ")"; } template <class T> ostream& operator<<(ostream& o, const vector<T>& vc) { o << "sz = " << vc.size() << endl << "["; for (const T&...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; namespace thecold { inline int read() { int res = 0; bool flag = false; char c = getchar(); while (!isdigit(c)) flag = (c == '-'), c = getchar(); while (isdigit(c)) res = res * 10 + (c ^ 48), c = getchar(); return !flag ? res : -res; } const int Max_n = 15; int ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
import java.io.*; import java.util.*; public class D { int mod; int[] primes = new int[10]; int[] pows = new int[10]; int[][] prPows; int ps; int phi = 1; void prepare() { int mod = this.mod; ps = 0; for (int i = 2; i * i <= mod; i++) { if (mod % i == 0) { primes[ps] = i; phi *= i - 1; p...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int Mod, Res[101000], n, L, R, CC[101000]; vector<int> P[101000], U[101000]; int IT[131072 + 131072], C[101000]; void Put(int a, int b) { a += 131072; IT[a] = b; while (a != 1) { a >>= 1; IT[a] = 1ll * IT[a + a] * IT[a + a + 1] % Mod; } } void Ins(int a, int...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; long long jc[100005], fac[12], vp[12], P[12], s, v[100005][12], r[100005][12]; long long n, L, R, p; long long fpower(long long x, long long k) { long long ans = 1; while (k) { if (k & 1) ans = ans * x % p; x = x * x % p; k >>= 1; } if (!ans) return p; ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int N = 100005; long long p, n, l, r; long long pr[N], inv[N], f[N], c[N][40], phi; int cnt = 0; long long powe(long long a, long long b) { long long base = 1; while (b) { if (b & 1) base = (base * a) % p; a = (a * a) % p; b >>= 1; } return base; }...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; int N, MOD, l, r, tot, pri[MAXN], pre_cnt[MAXN][15]; long long fac[MAXN], ifac[MAXN]; inline long long fast_power(long long x, long long k) { long long res = 1; while (k) { if (k & 1) (res *= x) %= MOD; (x *= x) %= MOD; k >>= 1; } ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; void factorize(long long v, std::map<long long, int> &result) { long long p = 2; while (v > 1 && p * p <= v) { int cnt = 0; while (v % p == 0) { cnt++; v /= p; } if (cnt > 0) { if (result.count(p) == 0) { result[p] = 0; } ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template <typename T1, typename T2> void chkmax(T1 &x, T2 y) { if (x < y) x = y; } inline void debug(int x) { fprintf(stderr, "ycx has aked ioi %d times\n", x); } namespace fastio { char ...
Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) T...
#include <bits/stdc++.h> using namespace std; int mod; int a[100010]; vector<int> ps; vector<pair<int, int> > f[100010]; const int N = 1 << 16; int e[N]; long long b[N + N]; int pow(int p, int k) { if (k == 0) return 1; if (k == 1) return p; long long res = pow(p, k / 2); res = res * res % mod; if (k & 1) { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int n, m, Q, E, cnt, cntpoi, tree[200001], ret[200001]; int to[200001], nex[200001], fir[200001], w[200001], pa[200001]; int st[200001], ed[200001], size[200001], co[200001], dep[200001]; int acori[200001], acrev[200001]; vector<int> vec[200001]; bool vis[200001]; int posor...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; queue<int> que_init; vector<int> vec[200010]; bool vis[200010]; int size_tree_read[200010], __G, color[200010], Deep[200010], cnt_this, Size_all, Minsize, n, m, T, Len, Every_letter_end_for_AC[200010], Every_letter_end_rev_AC[200010], tmp_pos...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, M = 2e5 + 5, mo1 = 993244853, mo2 = 1e9 + 9; struct P { int x, y; } mi[N]; inline P operator*(const P& a, const P& b) { return (P){int(1ll * a.x * b.x % mo1), int(1ll * a.y * b.y % mo2)}; } inline P operator+(const P& a, const P& b) { return (P)...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, lm = 2e5 + 5; int rd() { int x = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + (ch ^ 48); ch = getchar(); } return x * w; } s...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 100000; const int MAXALPH = 26; const int MAXWORD = 100000; const int MAXSUMWORDLEN = 100000; const int MAXAHONODES = MAXSUMWORDLEN + 1; const int MAXQ = 100000; const int MAXSTN...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct node { int x, v, id; }; vector<node> vQ[N]; vector<int> S[N]; int n, m, Q, ans[N]; int type[N], L[2][N]; char s[N]; struct Hash { int v1, v2, p1, p2; Hash() { v1 = v2 = 0; p1 = p2 = 1; } Hash(int _c) { if (_c == -1) { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int gi() { int x = 0, o = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') o = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * o; } int...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline T1 max(T1 a, T2 b) { return a < b ? b : a; } template <typename T1, typename T2> inline T1 min(T1 a, T2 b) { return a < b ? a : b; } const char lf = '\n'; const int _ = 200007, alp = 26; struct gsam { int fa[_], len[_], tran[...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int RLEN = 1 << 18 | 1; inline char nc() { return getchar(); } inline int rd() { char ch = nc(); int i = 0, f = 1; while (!isdigit(ch)) { if (ch == '-') f = -1; ch = nc(); } while (isdigit(ch)) { i = (i << 1) + (i << 3) + ch - '0'; ch = nc();...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int n, m, lq; struct Edge { int to, next; char v; } edge[200011 << 1]; int first[200011], le = 2; void in(int x, int y, char v) { Edge &e = edge[le]; e.to = y; e.v = v; e.next = first[x]; first[x] = le++; } void insert(int x, int y, char v) { in(x, y, v); ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int tree[300005 * 20], lefto[300005 * 20], righto[300005 * 20], nw; struct ext { int len, link; map<char, int> next; }; ext st[300005]; int sz, last; void sa_init() { sz = last = 0; st[0].len = 0; st[0].link = -1; ++sz; } int update(int node, int st, int en, int...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int n, m, Q, E, cnt, cntpoi, tree[200001], ret[200001]; int to[200001], nex[200001], fir[200001], w[200001], pa[200001]; int st[200001], ed[200001], size[200001], co[200001], dep[200001]; int acori[200001], acrev[200001]; vector<int> vec[200001]; bool vis[200001]; int posor...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int tree[300005 * 20], lefto[300005 * 20], righto[300005 * 20], nw; struct ext { int len, link; map<char, int> next; }; ext st[300005]; int sz, last; void sa_init() { sz = last = 0; st[0].len = 0; st[0].link = -1; ++sz; } int update(int node, int st, int en, int...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int RLEN = (1 << 20) | 3; inline char gc() { static char ibuf[RLEN], *ib, *ob; (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin)); return (ib == ob) ? EOF : *ib++; } inline int read() { char ch = gc(); int res = 0; bool f = 1; while (!isdigit...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, lm = 2e5 + 5; int rd() { int x = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + (ch ^ 48); ch = getchar(); } return x * w; } s...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int L = 500; const int N = 220000; const int M1 = 1e9 + 7; const int M2 = 1e9 + 9; int chd[N][26], go[N][26]; int len[N], q[N], p[N]; int s[N], dp[N], f[17][N], t[N]; char str[N], _str[N]; int st[N], en[N], wh[N], fr[N], to[N], cur[N], state[N], id[N], ans[N], cnt[N],...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> const std::pair<long long, long long> MOD = {1001001011, 1000000007}, BAS = {37, 10007}, iBAS = {784568360, 820925358}; inline std::pair<long long, long long> operator+( const std::pair<long long, long long> &a, ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> #pragma GCC target("pclmul") using ul = std::uint32_t; using ull = std::uint64_t; using li = std::int32_t; using ll = std::int64_t; using llf = long double; using uss = std::uint8_t; const ul maxn = 1e5; const ul maxm = 1e5; const ul maxlen = 1e5; const ul maxq = 1e5; ul n, m, q; std::vector<st...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int read() { char c = getchar(); int d = 0, f = 1; for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1; for (; c >= '0' && c <= '9'; d = d * 10 + c - 48, c = getchar()) ; return d * f; } char Read() { char c = getchar(); while (c < 'a' || c ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, maxm = 2e5 + 10; int n, m_n, q_n, u[maxn], v[maxn], i[maxn], ans[maxn], bel[maxn], mu[maxn], mv[maxn], par[maxn], fuck_id; char par_c[maxn]; string m[maxm]; vector<pair<int, char> > g[maxn]; vector<int> has[maxn], border[maxm]; bool vis[maxn];...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int a14; inline int rd(int l, int r) { return rand() % (r - l + 1) + l; } const int mxn = 2e5 + 3; int n, m, qn, to[mxn], nxt[mxn], fir[mxn], gn = 1, co[mxn]; inline void gadd(int x, int y, char c) { to[++gn] = y, nxt[gn] = fir[x], fir[x] = gn, co[gn] = c; } int lp[mxn], ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int n, m, lq; struct Edge { int to, next; char v; } edge[200011 << 1]; int first[200011], le = 2; void in(int x, int y, char v) { Edge &e = edge[le]; e.to = y; e.v = v; e.next = first[x]; first[x] = le++; } void insert(int x, int y, char v) { in(x, y, v); ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int n, m, lq; struct Edge { int to, next; char v; } edge[200011 << 1]; int first[200011], le = 2; void in(int x, int y, char v) { Edge &e = edge[le]; e.to = y; e.v = v; e.next = first[x]; first[x] = le++; } void insert(int x, int y, char v) { in(x, y, v); ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 100000; const int MAXALPH = 26; const int MAXWORD = 100000; const int MAXSUMWORDLEN = 100000; const int MAXAHONODES = MAXSUMWORDLEN + 1; const int MAXQ = 100000; const int MAXSTN...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, maxm = 2e5 + 10; int n, m_n, q_n, u[maxn], v[maxn], i[maxn], ans[maxn], bel[maxn], mu[maxn], mv[maxn], par[maxn], fuck_id; char par_c[maxn]; string m[maxm]; vector<pair<int, char> > g[maxn]; vector<int> has[maxn], border[maxm]; bool vis[maxn];...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int tree[300005 * 20], lefto[300005 * 20], righto[300005 * 20], nw; struct ext { int len, link; map<char, int> next; }; ext st[300005]; int sz, last; void sa_init() { sz = last = 0; st[0].len = 0; st[0].link = -1; ++sz; } int update(int node, int st, int en, int...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int a14; inline int rd(int l, int r) { return rand() % (r - l + 1) + l; } const int mxn = 2e5 + 3; int n, m, qn, to[mxn], nxt[mxn], fir[mxn], gn = 1, co[mxn]; inline void gadd(int x, int y, char c) { to[++gn] = y, nxt[gn] = fir[x], fir[x] = gn, co[gn] = c; } int lp[mxn], ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7, M = 30, pa = 998244353, pb = 1e9 + 7; char p[N]; vector<int> vc[N]; bool fk[N]; int n, m, q, l, x, y, sn, l1[N], l2[N], w1[N], w2[N], st[N], qt[N], val[N], vaw[N], les[N], tot, ret, res, ght, pot, vac, leng, of[N], f[N], p1[N], p2[N], ft[N], o...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, lm = 2e5 + 5; int rd() { int x = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + (ch ^ 48); ch = getchar(); } return x * w; } s...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> namespace _ { const int inf = 1e9 + 7; namespace _in { template <class T> inline T read() { char ch; bool flag = 0; T x = 0; while (ch = getchar(), !isdigit(ch)) if (ch == '-') flag = 1; while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); return flag ? -x : x; } struct { ...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int tree[300005 * 20], lefto[300005 * 20], righto[300005 * 20], nw; struct ext { int len, link; map<char, int> next; }; ext st[300005]; int sz, last; void sa_init() { sz = last = 0; st[0].len = 0; st[0].link = -1; ++sz; } int update(int node, int st, int en, int...
Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tre...
#include <bits/stdc++.h> using namespace std; int tree[300005 * 20], lefto[300005 * 20], righto[300005 * 20], nw; struct ext { int len, link; map<char, int> next; }; ext st[300005]; int sz, last; void sa_init() { sz = last = 0; st[0].len = 0; st[0].link = -1; ++sz; } int update(int node, int st, int en, int...