output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> int f[10000]; int ans[10000]; int F(int x) { if (x <= 0) return 0; return f[x]; } int main() { int s, k; scanf("%d%d", &s, &k); f[1] = 1; f[2] = 1; int ii; for (ii = 3; f[ii - 1] < s; ii++) f[ii] = f[ii - 1] * 2 - F(ii - k - 1); int len = ii; for (int i = len; i >= 1; i--) ...
### Prompt Please formulate a CPP solution to the following problem: Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≀ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer ...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using vc = vector<T>; ll s, k, A[(ll)1e5 + 10], t, tp; int main() { scanf("%lld %lld", &s, &k); tp = k - 1; while (t < s) { t = (tp == k - 1 || tp == k) ? 1 : (t + A[tp - k] - (tp - 2 * k >= 0 ? A...
### Prompt Develop a solution in cpp to the problem described below: Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≀ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, t = 1, it, s, i, ac, a[60] = {0}, b[60] = {0}; cin >> s >> k; a[1] = 1; a[2] = 1; ac = 2; it = k; while (a[ac] < s) { ac++; for (i = 1; i <= it; i++) { a[ac] += a[ac - i]; if (ac - i == 1) i = it + 1; } } ...
### Prompt Please provide a cpp coded solution to the problem described below: Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≀ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), fo...
#include <bits/stdc++.h> using namespace std; const long long OO = 1e9; const long double EPS = (1e-12); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } unsigned long long gcd(unsigned long long a, unsigned long long b) { for (;;) { if (a == 0) return b; b %= a; if (b == 0...
### Prompt Your task is to create a CPP solution to the following problem: Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≀ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for in...
#include <bits/stdc++.h> using namespace std; long long tmp[10]; struct Bigint { const static int maxn = 10; const static int Base = (int)1e5; int a[maxn]; int n; Bigint(long long x = 0) { n = 0; for (; x; x /= Base) a[n++] = x % Base; } void operator+=(const Bigint &b) { for (; n < b.n; a[n++...
### Prompt Create a solution in CPP for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long mod1 = 2e10; const long long mod2 = 1e10 + 9; const long long mod3 = 1e10; const long long val = 1e16; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } ...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> const int N = 100; const int M = 100000; long long ans[N]; long long now[N]; long long jie[N]; void clear(long long x[]) { int i; for (i = 1; i <= x[0]; i++) x[i] = 0; x[0] = 0; } void add(long long x[], int y) { x[1] += y; int i = 1; while (x[i] >= M) { x[i + 1] += x[i] / M; ...
### Prompt Please provide a cpp coded solution to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const __int128 P = 10000000000ll; __int128 g(__int128 x) { return x * (x + 1) * (2 * x + 1) / 6; } __int128 f(__int128 x, __int128 y) { __int128 u, v; if (x < y) { u = g(y - 1) - g(x - 1) + y - x; v = u + (x - 1) * (y - x); return (1 + x * x) * x * x / 2 + (...
### Prompt Please formulate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; long long P = (long long)12e10, MOD = (long long)1e10; long long mul(long long a, long long b, long long p) { a %= p, b %= p; return (a * b - (long long)(a / (long double)p * b + 1e-10) * p + p) % p; } long long S(long long t) { return (mul(t, t + 1, P) / 2) % MOD; } lo...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e+11; const long long rev3 = 66666666667LL; inline long long T(long long a, long long b) { return ((a * b - (long long)((long double)a * b / mod) * mod + mod) % mod); } inline long long C(long long x, long long y) { if (x >= y) { re...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const int maxbits = 5; const int maxn = 1000000000; struct data { long long bit[maxbits + 1]; }; void mul(data a, data b, data &c) { data t; memset(t.bit, 0, sizeof(t.bit)); for (int i = 1; i <= maxbits / 2 + 1; ++i) for (int j = 1; j <= maxbits / 2 + 1; ++j) { ...
### Prompt Your task is to create a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; long long MOD = 10000000000LL; long long prod(long long a, long long b) { a = a % MOD; b = b % MOD; return (((a / 100) * b) % MOD * 100 + (a % 100) * b) % MOD; ; } long long sumn2(int n) { if (n < 1) return 0; long long ans = 1LL * n * (n + 1) / 2; if (ans % 3...
### Prompt In Cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; long long mod, mmod = 2e10, val = 1e16; long long ksc(long long x, long long y) { long long res = 0; while (y) { if (y & 1) res += x; x <<= 1; if (x >= val) x %= mod; y >>= 1; } return res % mod; } long long qwq(long long x, long long y) { if (x ==...
### Prompt Develop a solution in Cpp to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e+11; const long long rev3 = 66666666667LL; long long T(long long a, long long b) { return ((a * b - (long long)((long double)a * b / mod) * mod + mod) % mod); } long long C(long long x, long long y) { if (x >= y) return T(T(T(4, x)...
### Prompt Please provide a Cpp coded solution to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(0.0) * 2.0; const double eps = 1e-12; template <class T> inline T abs1(T a) { return a < 0 ? -a : a; } template <class T> inline T max1(T a, T b) { return a > b ? a : b; } template <class T> inline T min1(T a, T b) { return a < b ? a : b; } temp...
### Prompt Generate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> const double eps = 1e-9; const double pi = acos(-1); const int oo = 1000000000; const int T = 1000000000; const long long mod = 1000000000000000000LL; const long long mod2 = 10000000000LL; const double E = 2.7182818284590452353602874713527; using namespace std; struct case1 { double a1; lon...
### Prompt Construct a cpp code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; inline long long read() { register long long x = 0, f = 1; register char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * f; } v...
### Prompt Please formulate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } typedef int bignum_t[10 + 1]; int read(bignum_t a, istream& is...
### Prompt Please create a solution in cpp to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; struct num { int a[15]; num(long long x = 0) { memset(a, 0, sizeof(a)); if (!x) a[0] = 1; else for (; x; x /= 100000000) a[++a[0]] = x % 100000000; } num operator*(long long b) { num c; c[0] = a[0]; long long x = 0, y; for (in...
### Prompt Please create a solution in CPP to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; inline int Get() { int res = 0, q = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') q = -1, ch = getchar(); while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar(); return res * q; } const doubl...
### Prompt In cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const int inf = 0x20202020; const int mod = 1000000007; template <class T> inline void read(T& first) { bool fu = 0; char c; for (c = getchar(); c <= 32; c = getchar()) ; if (c == '-') fu = 1, c = getchar(); for (first = 0; c > 32; c = getchar()) first = first...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long M = 10000000000ll; inline int getint() { static char c; while ((c = getchar()) < '0' || c > '9') ; int res = c - '0'; while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0'; return res; } inline long long modmul(long long a, long l...
### Prompt Create a solution in cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; inline long long multi(long long x, long long y, long long m) { x %= 10000000000LL, y %= 10000000000LL; return (x * y - (long long)(x / (long double)m * y + 1e-5) * m + m) % m; } inline long long mul(long long a, long long b) { if (a & 1) b >>= 1; else a >>=...
### Prompt Generate a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> #pragma GCC optimize("O2,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") using namespace std; using ll = long long; const int maxn = 1 << 17; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 1e10; __int128 s1(__int128 n) { return n * (n + 1) / 2; } __in...
### Prompt Develop a solution in CPP to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const long long mo = (long long)6e10; struct Huge { long long A; long double B; Huge(long long A = 0, long double B = 0) : A(A), B(B) {} inline long long mul(const long long &x, const long long &y) { return (x / 100000ll * y % mo * 100000ll + x % 100000ll * y % ...
### Prompt In Cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; struct Gao { long long int ww[7]; Gao() { memset(ww, 0, sizeof(ww)); } friend Gao operator+(const Gao &, const Gao &); friend Gao operator+(const Gao &, const long long int &); friend Gao operator+(const long long int &, const Gao &); friend Gao operator-(const ...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long md = 10000000000ll; inline long long _mul(long long a, long long b) { return (a * b - (a / 20 * b) / md * 20 * md) % md; } struct itype { long long l; long double d; itype() {} itype(long long x) : l(x % md), d(x) {} itype(long long x, long doubl...
### Prompt Create a solution in cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long modd = 10000000000ll; int a, b, c, d; long long ans; long long sqr(long long x) { return x * x; } long long cross(long long a, long long b) { return (a * (b / 100000) % modd * 100000 % modd + a * (b % 100000) % modd) % modd; } long long done(long ...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e+11; const long long rev3 = 66666666667LL; long long T(long long a, long long b) { return ((a * b - (long long)((long double)a * b / mod) * mod + mod) % mod); } long long C(long long x, long long y) { if (x >= y) return T(T(T(4, x)...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; inline long long read() { register long long x = 0, f = 1; register char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * f; } v...
### Prompt Please formulate a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> struct ty { double v1; long long v2[2]; } ans, zero, tmp[5]; ty operator*(ty c1, ty c2) { c1.v1 *= c2.v1; c1.v2[1] = c1.v2[1] * c2.v2[0] + c1.v2[0] * c2.v2[1]; c1.v2[0] *= c2.v2[0]; c1.v2[1] += c1.v2[0] / 1000000000; c1.v2[0] %= 1000000000; c1.v2[1] %= 1000000000; return c1; }...
### Prompt Your task is to create a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; long long mul(long long x, long long y) { x = (x % 10000000000 + 10000000000) % 10000000000, y = (y % 10000000000 + 10000000000) % 10000000000; long long tmp = (long long)((long double)x * y / 10000000000); long long s = x * y - 10000000000 * tmp; return s < 0 ? s...
### Prompt Your challenge is to write a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { T f = 0, x = 0; char c = getchar(); while (!isdigit(c)) f = c == '-', c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); return f ? -x : x; } namespace run { const long long mod1 = 1e10, mod2 = mod1 + 9; l...
### Prompt Please create a solution in cpp to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const long long Mod = 10000000000ll; inline long long modplus(const long long &a, const long long &b) { return a + b < Mod ? a + b : a + b - Mod; } inline long long &modplusto(long long &a, const long long &b) { a += b; if (a >= Mod) a -= Mod; return a; } inline lon...
### Prompt In Cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; long long mod = 1e10; const long long rad = 1e6; long long mul(long long p, long long k) { p %= mod; k %= mod; long long p0 = p % rad; p /= rad; long long k0 = k % rad; k /= rad; return (p0 * k0 + p0 * k % mod * rad + p * k0 % mod * rad + p * k % mod...
### Prompt Develop a solution in CPP to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e+11; const long long rev3 = 66666666667LL; long long T(long long a, long long b) { return ((a * b - (long long)((long double)a * b / mod) * mod + mod) % mod); } long long C(long long x, long long y) { if (x >= y) return T(T(T(4, x)...
### Prompt Create a solution in cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; struct BigNumber { long long X[8]; void Set(int T) { memset(X, 0, sizeof(X)); X[0] = T; int P = 0; while (X[P] >= 100000) { X[P + 1] = X[P] / 100000; X[P] %= 100000; P++; } } void Output() { bool Flag = false; for (int i...
### Prompt Generate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> long long MOD = 1e10; inline long long mul(long long x, long long y) { x %= MOD; y %= MOD; if (y < 0) y += MOD; if (x < 0) x += MOD; if (fabs(x * 1.0 * y) <= 9223372036854775800.0) return x * y % MOD; long long res = 0; for (; y; y /= 2) { if (y & 1) { res += x; if...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const unsigned long long mod = 10000000000; const unsigned long long pow32 = 4294967296; const unsigned long long ullong_max = 18446744073709551615; const unsigned long long rem1 = ((ullong_max % mod) / 100000) * 100000; const unsigned long long rem2 = ullong_max % 100000 +...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; namespace Solver { long long P; long long mul(long long a, long long b) { a %= P, b %= P; return (a * b - (long long)(((long double)a * b + 0.5) / P) * P + P) % P; } long long sum(long long a) { if (a <= 0) return 0; long long b = a + 1, c = 2 * a + 1; if (a % 2) ...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 10000000000ULL; int a, b, c, d; unsigned long long s1(unsigned long long x0) { unsigned long long ret; if (x0 & 1) ret = (x0 + 1) / 2 * ((2 * x0 + 1)) % MOD * x0 % MOD; else ret = (x0) / 2 * (2 * x0 + 1) % MOD * (x0 + 1) % MOD; ...
### Prompt Your task is to create a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; struct big { int len; long long x[8]; big(long long a) { memset(x, 0, sizeof(x)); len = 0; while (a) { x[len] = a % 100000; len++; a /= 100000; } } big operator+(big a) { big b(0); int i; b.len = max(len, a.len); f...
### Prompt Your task is to create a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; const long long P = 10000000000; struct rec { long double x; long long v; }; int T, lx, ly, rx, ry; long long mul(long long x, long long y) { return (x * (y % 100000) + x * (y / 100000) % P * 100000 % P) % P; } rec operator-(rec a, rec b) { rec c; c.x = a.x - b.x;...
### Prompt Please create a solution in Cpp to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:66777216") using namespace std; int a, b, c, d, i, j, n, m, k; int mas[101][101]; inline void fill() { int c = 1; for (int _n((100) - 1), h(0); h <= _n; h++) { for (int _n((h + 1) - 1), i(0); i <= _n; i++) { mas[i][h] = c++; } for (int i = (...
### Prompt Generate a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> using namespace std; long long mo; long long mul(long long x, long long y) { x %= mo; y %= mo; if (x < 0) x += mo; if (y < 0) y += mo; return ((x * y - (long long)((long double)x * y / mo) * mo) % mo + mo) % mo; } long long mul2(long long x, long long y) { x %= mo; y %= mo; if (...
### Prompt Generate a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, c = getchar(), f = 0; for (; c > '9' || c < '0'; f = c == '-', c = getchar()) ; for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar()) ; return f ? -x : x; } inline void write(long long x) { if (x < 0)...
### Prompt Your challenge is to write a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const long long mod1 = 2e10; const long long mod2 = 1e10 + 9; const long long mod3 = 1e10; const long long val = 1e16; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } ...
### Prompt Create a solution in cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e+11; const long long rev3 = 66666666667LL; long long T(long long a, long long b) { return ((a * b - (long long)((long double)a * b / mod) * mod + mod) % mod); } long long C(long long x, long long y) { if (x >= y) return T(T(T(4, x)...
### Prompt Develop a solution in CPP to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; long long mo; long long quick(long long x, long long y) { return (x * y - (long long)(x / (long double)mo * y + 1e-3) * mo + mo) % mo; } long long get(int k) { unsigned long long k1 = 1ll * k * (k + 1) / 2, k2 = k * 2 + 1; if (k1 % 3 == 0) k1 /= 3; else k2 /...
### Prompt Your task is to create a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; const long long MODULE = 10000000000ULL; const long long hMODULE = 100000; long long mul(long long x, long long y) { x %= MODULE; y %= MODULE; long long xa = x / hMODULE; long long xb = x % hMODULE; return (xa * y % MODULE * hMODULE + xb * y) % MODULE; } long long...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; void read(int &digit) { digit = 0; char c; for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar()) ; bool type = false; if (c == '-') type = true, c = getchar(); for (; c >= '0' && c <= '9'; digit = digit * 10 + c - '0', c = getchar()) ; i...
### Prompt Construct a CPP code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > '9' || c ...
### Prompt Generate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> const long long Mo = (long long)1e10; const long long Mo2 = Mo * 2ll; const long long Mo6 = Mo * 6ll; using namespace std; long long i, j, m, n, p, k, ans, T; int l, r, l1, r1; int t; long double X; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long dou...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; template <typename X> inline bool minimize(X& p, X q) { if (p <= q) return 0; p = q; return 1; } template <typename X> inline bool maximize(X& p, X q) { if (p >= q) return 0; p = q; return 1; } const long long mod = 10000000000ll; inl...
### Prompt Your task is to create a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; const long long mo = 10000000000ll; long long mul(long long x, long long y) { x %= mo; y %= mo; long long xa = x / 100000; long long xb = x % 100000; return (xa * y % mo * 100000 + xb * y) % mo; } long long x2(long long n) { return (n & 1) ? (mul(n, (n + 1) / 2)...
### Prompt Construct a Cpp code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
#include <bits/stdc++.h> using namespace std; long long mul(long long x, long long y) { x = (x % 10000000000 + 10000000000) % 10000000000, y = (y % 10000000000 + 10000000000) % 10000000000; return ((((x >> 20) * y % 10000000000) << 20) + (x & ((1 << 20) - 1)) * y) % 10000000000; } long long two(long long...
### Prompt Generate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getchar(); bool positive...
### Prompt Create a solution in CPP for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; long long mo; long long mul(long long x, long long y) { x %= mo; y %= mo; if (x < 0) x += mo; if (y < 0) y += mo; return ((x * y - (long long)((long double)x * y / mo) * mo) % mo + mo) % mo; } long long mul2(long long x, long long y) { x %= mo; y %= mo; if (...
### Prompt Your task is to create a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; const int MAXD = 13; const int MOD = 10000; struct bignum { int d[MAXD]; }; bignum carry(bignum tval) { for (int i = 0; i < MAXD - 1; i++) { while (tval.d[i] < 0) { tval.d[i] += MOD; tval.d[i + 1]--; } tval.d[i + 1] += tval.d[i] / MOD; tval.d...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; long long fpm(long long b, long long e, long long m) { long long t = 1; for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0; return t; } template <class T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; } template <class T> inline bool c...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> const long long mo1 = 10000000000ll; const long long mo2 = 10000000009ll; using namespace std; long long mul(long long x, long long y, long long mo) { long long ans = (long long)(1.0 * x / mo * y); ans = (x * y - ans * mo); return (ans % mo + mo) % mo; } long long S1(long long x, long lon...
### Prompt Your challenge is to write a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const long long P = (long long)1e11, Q = 66666666667ll * 5; long long m(long long a, long long b) { return ((a * b - (long long)((long double)a * b / P) * P + P) % P); } long long f(long long x, long long y) { if (x < y) return m(m(m(x, m(x, x)) - x + m(4, y) + m(3,...
### Prompt Create a solution in Cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; long long mod, mmod = 2e10, val = 1e16; long long ksc(long long a, long long b) { long long r = a * b - (long long)((long double)a * b / mod + 0.5) * mod; return r < 0 ? r + mod : r; } long long qwq(long long x, long long y) { if (x == 0 || y == 0) return 0; long lo...
### Prompt Construct a CPP code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
#include <bits/stdc++.h> using namespace std; long long Mod; const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; long long powmod(long long a, long long b) { long long tmp = 1; a %= Mod; for (; b; b >>= 1) { if (b & 1) tmp = tmp * a % Mod; a = a * a % Mod; } return tmp; } long long gcd(long long a, ...
### Prompt Your task is to create a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; using DO = long double; const long long z = 1e10; const long long MX = 1e18; long long ans; DO res; inline long long multi(long long first, long long second) { return (first * second - (long long)(first / (long double)MX * second + 1e-5) * MX + MX) % z;...
### Prompt Please create a solution in CPP to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> const long long mo = 1000000000000000000LL; const long long tt = 10000000000LL; const long long B = 1000000000LL; struct pnt { long long x, y; pnt(long long x = 0, long long y = 0) : x(x), y(y) {} pnt operator+(pnt a) { long long ty = a.y + y; long long tx = a.x + x; if (ty >=...
### Prompt Please provide a CPP coded solution to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e8; struct vint { long long t[10]; int l; vint(long long b) { memset(t, 0, sizeof(t)); l = 0; while (b) t[l++] = b % mod, b /= mod; if (!l) l++; } vint() { memset(t, 0, sizeof(t)); l = 1; } vint operator+(const vi...
### Prompt In cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; long long int modulo = 1000000000; void set0(long long int r[4]) { for (int i = 0; i < 4; i++) r[i] = 0; } void corrige(long long int b[4]) { for (int i = 0; i < 4; i++) { if (b[i] < 0) { b[i] += modulo; b[i + 1] -= 1; } else if (b[i] >= modulo) { ...
### Prompt Your task is to create a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; long long mo; long long quick(long long x, long long y) { return (((x >> 17) * y % mo << 17) % mo + (x & ((1 << 17) - 1)) * y % mo) % mo; } long long get(int k) { unsigned long long k1 = 1ll * k * (k + 1) / 2, k2 = k * 2 + 1; if (k1 % 3 == 0) k1 /= 3; e...
### Prompt Create a solution in cpp for the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petr...
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)1e10; long long Element(int x, int y) { if (x > y) return (x - 1LL) * (x - 1LL) + y; return (long long)y * y - x + 1; } void adjust(long long &x) { if (x < 0 || x >= MOD) { x %= MOD; if (x < 0) x += MOD; } } long long mul(lon...
### Prompt Please formulate a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; int Read() { char c; while (c = getchar(), (c != '-') && (c < '0' || c > '9')) ; bool neg = (c == '-'); int ret = (neg ? 0 : c - 48); while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + c - 48; return neg ? -ret : ret; } const unsigned long long MOD...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; int t, lx, ly, rx, ry; const long long bas = 1000000000000000000ll, bas2 = 1000000000ll; pair<long long, long long> operator+(const pair<long long, long long> &a, const pair<long long, long long> &b) { return make_pair(a.first + b.firs...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; unsigned long long mod0 = 10000000000LL, mod1 = 10000000001LL, mod; unsigned long long sum1(unsigned long long a, unsigned long long b) { unsigned long long v = b, w = b + 1, x = a, y = (a == 0) ? 0 : (a - 1); if (v % 2 == 0) v /= 2; else w /= 2; if (x % 2 =...
### Prompt Develop a solution in CPP to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> char ch; inline void read(int &x) { x = 0; ch = getchar(); while (ch <= 32) ch = getchar(); while (ch > 32) { x = x * 10 + ch - 48; ch = getchar(); }; }; inline long long mul(long long x, long long y) { x = (x % 10000000000LL + 10000000000LL) % 10000000000LL; y = (y % 1000...
### Prompt Your challenge is to write a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:66777216") using namespace std; int a, b, c, d, i, j, n, m, k; inline long long mul(long long a, long long b, long long mod) { a %= mod; b %= mod; if ((double)a * b < 5e18) return a * b % mod; if (a < b) swap(a, b); long long ans = 0; while (b) { ...
### Prompt Please provide a Cpp coded solution to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; long long p; int t; long long mulit(long long a, long long b) { if (b < 10000000000 / 100) return (a * b) % p; return ((mulit(a, b >> 1) << 1) + (b & 1 ? a : 0)) % p; } long long sum2(long long x) { long long a, b, c; a = x; b = (x + 1); c = (2 * x + 1); if (a...
### Prompt Your task is to create a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; long long mul(long long x, long long y) { x = (x % 100000000000000000 + 100000000000000000) % 100000000000000000, y = (y % 100000000000000000 + 100000000000000000) % 100000000000000000; long long tmp = (long long)((long double)x * y / 100000000000000000); long long ...
### Prompt Generate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e+11; const long long rev3 = 66666666667LL; long long T(long long a, long long b) { return ((a * b - (long long)((long double)a * b / mod) * mod + mod) % mod); } long long C(long long x, long long y) { if (x >= y) return T(T(T(4, x)...
### Prompt Please formulate a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const int MAXD = 11; const int MOD = 10000; struct bignum { int d[MAXD]; }; bignum carry(bignum tval) { for (int i = 0; i < MAXD - 1; i++) { while (tval.d[i] < 0) { tval.d[i] += MOD; tval.d[i + 1]--; } tval.d[i + 1] += tval.d[i] / MOD; tval.d...
### Prompt In CPP, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> const unsigned long long MOD = 10000000000ULL; struct num { long double r; unsigned long long a; inline num() {} inline num(int x) : r(x), a(x) {} inline num(long double rr, unsigned long long aa) : r(rr), a(aa) {} inline void output() { if (r < MOD) printf("%I64u\n", a); ...
### Prompt Construct a cpp code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
#include <bits/stdc++.h> unsigned long long MOD = 10000000000ull; using namespace std; void verify(unsigned long long &a, unsigned long long &b, unsigned long long &c, int d) { if (a % d == 0) a /= d; else if (b % d == 0) b /= d; else c /= d; } unsigned long long sum_pow2(unsigned long lon...
### Prompt Your challenge is to write a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; long long mod = (long long)1e10; long long multiply(long long a, long long b) { long long c = a % mod; long long d = b % mod; long long e = d / 1000; long long f = d % 1000; long long prod = c * e; prod %= mod; prod *= 1000; prod %= mod; prod += c * f; p...
### Prompt Generate a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> using namespace std; long long P = 10000000000LL; long long ans; long double ansd; long long mul(long long x, long long y) { x %= P, y %= P; long long t = (long long)(double(x) * y / 1e10) - 2; return (x * y - P * t) % P; } long long cal2(long long a1, long long a2) { if (a1 % 2 == 0) ...
### Prompt In Cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = 3.1415926535897932384626433832795; template <class T> T sqr(T x) { return x * x; } template <class T> T abs(T x) { return x < 0 ? -x : x...
### Prompt Please formulate a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; long long mod, mmod = 2e10, val = 1e16; long long ksc(long long a, long long b) { long long r = a * b - (long long)((long double)a * b / mod + 0.5) * mod; return r < 0 ? r + mod : r; } long long qwq(long long x, long long y) { if (x == 0 || y == 0) return 0; long lo...
### Prompt Please create a solution in cpp to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; long long mod = 10000000000; long long fix(long long x) { x %= mod; x += mod; return x % mod; } struct modInteger { long long val; modInteger() { val = 0; } modInteger(long long v) { val = fix(v); } modInteger operator+(const modInteger &u) { return modInteger...
### Prompt In Cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; const double eps(1e-8); const double pi(3.14159265358979); const long long mod = 10000000000ll, re3 = (mod + mod + 1) / 3; inline int getint() { char ch; while (!isdigit(ch = getchar())) ; int x = ch - '0'; while (isdigit(ch = getchar())) x = x * 10 + ch - '0'; ...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const int kSize = 10; const long long kBase = 100000; struct Int { long long v[kSize]; int ln; Int() { ln = 1; fill(&v[0], &v[kSize], 0); } Int(long long q) { ln = 0; fill(&v[0], &v[kSize], 0); do { v[ln++] = q % kBase, q /= kBase; } ...
### Prompt Your task is to create a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine acad...
#include <bits/stdc++.h> using namespace std; const long long md = (long long)100000 * 100000; long long mul(long long x, long long y) { x %= md; y %= md; long long z = (long double)x * y / md; return ((x * y - z * md) % md + md) % md; } pair<long long, long double> operator+(const pair<long long, long double> ...
### Prompt Please create a solution in Cpp to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> using namespace std; const long long P = (long long)1e11, Q = 66666666667ll * 5; long long m(long long a, long long b) { long long r = a * b - (long long)((long double)a * b / P + 0.5) * P; return r < 0 ? r + P : r; } long long f(long long x, long long y) { if (x < y) return m(m(m(x, ...
### Prompt In Cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; int a, b, c, d; unsigned long long p = 10000000000ULL; unsigned long long S(unsigned long long x) { unsigned long long u; if (x & 1) u = (x + 1) / 2 * (2 * x + 1) % p * x % p; else u = x / 2 * (2 * x + 1) % p * (x + 1) % p; while (u % 3) u += p; u /= 3; ...
### Prompt In cpp, your task is to solve the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Pet...
#include <bits/stdc++.h> using namespace std; long long p, ans1, ans2; long long mul(long long a, long long b) { a %= p; b %= p; if (b < 0) b += p; long long ans = 0; for (; b; b >>= 16, a = (a << 16) % p) ans = (ans + a * (b & 65535)) % p; return ans; } long long sum1(long long n1) { long long n2 = n1 + ...
### Prompt Your challenge is to write a CPP solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const long long mod1 = 1e10; const long long mod2 = 1e10 + 9; long long mod; long long mul(long long a, long long b, long long p = mod) { if (a >= p) a %= p; if (b >= p) b %= p; return (a * b - (long long)((long double)a / p * b + 1e-3) * p + p) % p; } void inc(long l...
### Prompt Generate a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician Petrov...
#include <bits/stdc++.h> using namespace std; struct huge { long long p[11]; int l; huge() { memset(p, 0, sizeof(p)); l = 0; } inline void init() { memset(p, 0, sizeof(p)); l = 0; } friend inline huge operator+(const huge &a, const huge &b) { huge c; c.l = a.l; if (b.l > c.l) c...
### Prompt Develop a solution in Cpp to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...
#include <bits/stdc++.h> const unsigned long long MOD = 10000000000ULL; struct num { long double r; unsigned long long a; inline num() {} inline num(int x) : r(x), a(x) {} inline num(long double rr, unsigned long long aa) : r(rr), a(aa) {} inline void output() { if (r < MOD) printf("%I64u\n", a); ...
### Prompt Construct a CPP code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
#include <bits/stdc++.h> using namespace std; unsigned long long Mod3; unsigned long long mult(unsigned long long a, unsigned long long b) { a %= Mod3; b %= Mod3; unsigned long long c = a / 10, d = b / 10, e = a % 10, f = b % 10; return (c * d % Mod3 * 100 % Mod3 + e * d * 10 + f * c * 10 + e * f) % Mod3; } uns...
### Prompt Please provide a CPP coded solution to the problem described below: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; struct big { long long a; long double b; inline void print() { if (a < 0) a += 60000000000ll; a %= (long long)1e10; if (b > 1e10) printf("...%010I64d\n", a); else printf("%I64d\n", a); } inline long long mul(long long a, long long b) { ...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; long long mo; long long mul(long long x, long long y, long long z) { x %= z; y %= z; return (x * y - (long long)(x / (long double)z * y + 1e-3) * z + z) % z; } long long sqrsum(long long n) { if (n & 1) return mul(mul((n - 1) >> 1, n + 1, mo) + 1, mul(n, n, mo),...
### Prompt Your challenge is to write a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> unsigned long long MOD = 10000000000ull; using namespace std; void verify(unsigned long long &a, unsigned long long &b, unsigned long long &c, int d) { if (a % d == 0) a /= d; else if (b % d == 0) b /= d; else c /= d; } unsigned long long sum_pow2(unsigned long lon...
### Prompt Your challenge is to write a cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine ...
#include <bits/stdc++.h> using namespace std; const long long P = 1000000000000LL; long long co[10][10]; long long mul(long long a, long long b) { a %= P, b %= P; if (a <= (long long)(1e8) && b <= (long long)(1e8)) return a * b % P; return (a * b - (long long)(a / (long double)P * b + 1e-3) * P + P) % P; } long l...
### Prompt Please formulate a Cpp solution to the following problem: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academicia...