#include <bits/stdc++.h>   using namespace std;   const long long lar = 1e16;   const long long nlar = -1e16;   const long long INF = LLONG_MAX;   const long long NINF = LLONG_MIN;   const long long mod = 998244353;   const long long N = 1e6 + 100;   struct hash_pair {     template <class T1, class T2>     size_t operator()(const pair<T1, T2>& p) const {       auto hash1 = hash<T1>{}(p.first);       auto hash2 = hash<T2>{}(p.second);       return hash1 ^ hash2;     }   };   void google(long long t) { cout <<  Case #  << t <<  :  ; }   long double sqrtBinarySearch(long long num, long long p) {     long long left = 0, right = num;     long long mid;     long double res;     while (left <= right) {       mid = (left + right) / 2;       if (mid * mid == num) {         res = mid;         break;       }       if (mid * mid < num) {         left = mid + 1;         res = mid;       } else {         right = mid - 1;       }     }     long double incr = 0.1;     for (long long i = 0; i < p; i++) {       while (res * res <= num) {         res += incr;       }       res -= incr;       incr /= 10;     }     return res;   }   long long modInverse(long long a, long long m) {     long long m0 = m;     long long y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long q = a / m;       long long t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   long long add(long long x, long long y) {     x += y;     while (x >= mod) x -= mod;     while (x < 0) x += mod;     return x;   }   long long mul(long long x, long long y) { return (x * 1ll * y) % mod; }   long long binpow(long long x, long long y) {     long long ans = 1;     while (y > 0) {       if (y % 2 == 1) ans = mul(ans, x);       x = mul(x, x);       y /= 2;     }     return ans;   }   long long divmod(long long i, long long pp) {     return ((i * (modInverse(pp, mod))) % mod);   }   long long divide(long long x, long long y) {     return mul(x, binpow(y, mod - 2));   }   string to_binary(long long num) {     string res =   ;     while (num) {       res += ((num & (1LL)) +  0 );       num /= 2;     }     reverse(res.begin(), res.end());     return res;   }   long long to_decimal(string bi) {     long long dec = 0;     long long si = bi.size();     long long upd = 1;     for (long long i = si - 1; i >= 0; i--) {       dec += (upd * ((long long)(bi[i] -  0 )));       upd *= 2;     }     return dec;   }   vector<bool> SieveOfEratosthenes(long long n) {     vector<bool> prime(n + 1, true);     for (long long p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (long long i = p * p; i <= n; i += p) prime[i] = false;       }     }     return prime;   }   long long digitsum(long long x) {     long long ans = 0;     while (x) {       ans += x % 10;       x /= 10;     }     return ans;   }   long long nCr(long long n, long long r) {     if (n == r)       return 1;     else if (r == 0)       return 1;     else       return ((nCr(n - 1, r - 1) + nCr(n - 1, r)) % mod);   }   long long sqroot(long long number) {     long long x = sqrt(number);     while (x * x < number) x++;     while (x * x > number) x--;     return x;   }   long long cbroot(long long number) {     long long x = cbrt(number);     while (x * x * x < number) x++;     while (x * x * x > number) x--;     return x;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     if (b == 0) return a;     return gcd(b % a, a);   }   long long power(long long a, long long b) {     if (b == 0) return 1;     if (b & 1) return (a * power(a, b - 1));     long long temp = power(a, b / 2);     return (temp * temp);   }   long long powermod(long long a, long long b) {     if (b == 0) return 1;     if (b & 1) return (a * powermod(a, b - 1)) % mod;     long long temp = powermod(a, b / 2) % mod;     return (temp * temp) % mod;   }   vector<long long> factor(long long x) {     vector<long long> fact;     for (long long i = 1; i * i <= x; i++) {       if (x % i == 0) {         fact.push_back(i);         if (i * i != x) {           fact.push_back(x / i);         }       }     }     return fact;   }   long long fact[N];   void Initial_Factorial() {     fact[0] = 1;     for (long long i = 1; i < N; i++) {       fact[i] = (fact[i - 1] * i);       fact[i] %= mod;     }   }   long long binpow(long long val, long long deg, long long mod) {     if (!deg) return 1 % mod;     if (deg & 1) return binpow(val, deg - 1, mod) * val % mod;     long long res = binpow(val, deg >> 1, mod);     return (res * res) % mod;   }   long long nCr_Binomial(long long n, long long i) {     long long res = fact[n];     long long div = fact[n - i] * fact[i];     div %= mod;     div = binpow(div, mod - 2, mod);     return (res * div) % mod;   }   vector<long long> adj[10];   long long number_of_nodes = 10;   vector<long long> visited(number_of_nodes, 0);   void dfs(long long node) {     visited[node] = 1;     for (long long i = 0; i < adj[node].size(); ++i) {       if (visited[adj[node][i]] == 0) dfs(adj[node][i]);     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     Initial_Factorial();     long long n;     cin >> n;     if (n == 1) {       cout << 1 <<   n ;       return 0;     }     long long ans = n;     ans *= fact[n];     ans %= mod;     long long curr = 1;     long long sum = 1;     long long st = n - 1;     while (st > 1) {       curr *= st;       curr %= mod;       sum += curr;       sum %= mod;       st--;     }     sum *= n;     sum %= mod;     cout << (ans + mod - sum) % mod <<   n ;     cerr <<   ntime taken :   << (long double)clock() / CLOCKS_PER_SEC <<  secs           <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int nmax = 5e5 + 42;   struct info {     int u, v, cost;   };   info inp[nmax];   pair<int, int> my[nmax];   int n, k, m;   int parent[nmax];   int root(int node) {     if (parent[node] == node) return node;     parent[node] = root(parent[node]);     return parent[node];   }   long long outp;   set<int> seen[nmax];   vector<int> adj[nmax];   set<pair<int, int> > my_edge;   void solve(int node, int par) {     int biggest = -1;     for (auto k : adj[node])       if (k != par) {         solve(k, node);         if (biggest == -1)           biggest = k;         else if (seen[biggest].size() < seen[k].size())           biggest = k;       }     if (biggest != -1) {       swap(seen[biggest], seen[node]);       for (auto w : seen[biggest])         if (seen[node].count(w))           seen[node].erase(w);         else           seen[node].insert(w);     }     for (auto k : adj[node])       if (k != par && k != biggest) {         for (auto w : seen[k])           if (seen[node].count(w))             seen[node].erase(w);           else             seen[node].insert(w);       }     if (my_edge.count({node, par}) || my_edge.count({par, node})) {       if (seen[node].size() == 0) {         printf( -1 n );         exit(0);       }       outp += inp[*seen[node].begin()].cost;     }   }   int main() {     scanf( %i%i%i , &n, &k, &m);     for (int i = 1; i <= n; i++) parent[i] = i;     for (int i = 1; i <= k; i++) {       scanf( %i%i , &my[i].first, &my[i].second);       adj[my[i].first].push_back(my[i].second);       adj[my[i].second].push_back(my[i].first);       parent[root(my[i].first)] = root(my[i].second);       my_edge.insert({my[i].first, my[i].second});     }     for (int i = 1; i <= m; i++) {       scanf( %i%i%i , &inp[i].u, &inp[i].v, &inp[i].cost);       if (root(inp[i].u) != root(inp[i].v)) {         parent[root(inp[i].u)] = root(inp[i].v);         adj[inp[i].u].push_back(inp[i].v);         adj[inp[i].v].push_back(inp[i].u);       } else {         seen[inp[i].u].insert(i);         seen[inp[i].v].insert(i);       }     }     solve(1, 0);     printf( %lld n , outp);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ld = long double;   using ll = long long;   using ull = unsigned long long;   const ll mod = 1004535809, mod_g = 3;   const int N = int(1e5 + 10);   template <typename T>   inline T read() {     T 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;   }   template <typename T>   inline T print(T x) {     if (x < 0) {       putchar( - );       x = -x;     }     if (x > 9) print(x / 10);     putchar(x % 10 +  0 );   }   const ld pi = acos(-1.0);   struct Complex {     ld r, i;     Complex(ld _r = 0, ld _i = 0) : r(_r), i(_i) {}     Complex operator+(const Complex &b) const {       return Complex(r + b.r, i + b.i);     }     Complex operator-(const Complex &b) const {       return Complex(r - b.r, i - b.i);     }     Complex operator*(const Complex &b) const {       return Complex(r * b.r - i * b.i, r * b.i + i * b.r);     }     Complex operator/(const Complex &b) const {       return Complex((r * b.r + i * b.i) / (b.r * b.r + b.i * b.i),                      (i * b.r - r * b.i) / (b.r * b.r + b.i * b.i));     }   };   int R[int(1e6 + 10000)];   Complex x[int(1e6 + 10000)], y[int(1e6 + 10000)];   void get_R(int lim) {     for (int i = 0; i < lim; i++) {       R[i] = (i & 1) * (lim >> 1) + (R[i >> 1] >> 1);     }   }   void FFT(Complex *f, int lim, int rev) {     for (int i = 0; i < lim; i++) {       if (i < R[i]) swap(f[i], f[R[i]]);     }     for (int mid = 1; mid < lim; mid <<= 1) {       Complex wn = Complex(cos(pi / mid), rev * sin(pi / mid));       for (int len = mid << 1, cur = 0; cur < lim; cur += len) {         Complex w = Complex(1, 0);         for (int k = 0; k < mid; k++, w = w * wn) {           Complex x = f[cur + k], y = w * f[cur + mid + k];           f[cur + k] = x + y, f[cur + mid + k] = x - y;         }       }     }     if (rev == -1) {       for (int i = 0; i < lim; i++) {         f[i].r /= lim;       }     }   }   ll quick_pow(ll ans, ll p, ll res = 1) {     for (; p; p >>= 1, ans = ans * ans % mod)       if (p & 1) res = res * ans % mod;     return res % mod;   }   ll ans[200010];   inline void solve() {     int n, X;     cin >> n >> X;     for (int i = 1; i <= n; ++i) {       int xx;       cin >> xx;       ans[i] = ans[i - 1] + (xx < X);       x[ans[i]].r++;       y[200000 - ans[i]].r++;       x[i].i = y[i].i = 0;     }     x[0].r++, y[200000].r++;     int lim = 1;     while (lim <= 400000) lim <<= 1;     get_R(lim);     FFT(x, lim, 1);     FFT(y, lim, 1);     for (int i = 0; i <= lim - 1; ++i) x[i] = x[i] * y[i];     FFT(x, lim, -1);     cout << (ll(x[200000].r + 0.5) - n - 1) / 2;     for (int i = 1; i <= n; ++i) cout <<     << ll(x[200000 + i].r + 0.5);     cout <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long int MOD = (long long int)1e9 + 7;   long long int powmod(long long int a, long long int b) {     long long int res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % MOD;       a = (a * a) % MOD;       b = b >> 1;     }     return res % MOD;   }   void solve(long long int testnum) {     long long int n, k;     cin >> n >> k;     string s;     cin >> s;     string t;     cin >> t;     long long int ans = 0;     long long int tmpmn = 0;     long long int tmpmx = 0;     long long int check = 0;     for (long long int i = 0; i < n; i++) {       if (s[i] ==  b ) {         tmpmn++;       }       if (t[i] ==  b ) {         tmpmx++;       }       long long int ort = tmpmx - tmpmn + 1;       if (ort >= k) {         check = 1;       }       if (check == 0) {         ans += min(k, ort);       } else {         ans += k;       }       if (tmpmn == tmpmx) {         tmpmn = 0;         tmpmx = 0;       }       if (check == 0) {         tmpmn *= 2;         tmpmx *= 2;       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t = 1;     for (long long int i = 1; i <= t; i++) {       solve(i);     }   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10000;   const int MAXK = 20;   int V[MAXK + 3][MAXN + 3], Ans[MAXK + 3][MAXN + 3];   int main() {     V[0][1] = 0;     for (int j = 2; j <= MAXN; j++) {       V[0][j] = 1;     }     for (int i = 1; i <= MAXK; i++) {       int k = 1;       for (int j = 1; j <= MAXN; j++) {         if (k < MAXN && V[i - 1][k] < V[i - 1][k + 1] &&             V[i - 1][j] + V[i - 1][k] < j - 1)           k++;         V[i][j] = V[i - 1][j] + V[i - 1][k];         Ans[i][j] = k;       }     }     int N, K;     while (~scanf( %d%d , &N, &K)) {       for (int i = 1; i <= K; i++) {         for (int j = N; j > 1; j--) printf( %d  , N - Ans[i][j] + 1);         printf( %d n , N - Ans[i][1] + 1);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   void solve() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     for (auto i : a) {       cout << i <<    ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     { solve(); }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long int maxN = 1e5 + 10;   long long int n, i, a[maxN], mx, cnt, nxt;   stack<pair<long long int, long long int> > st;   int main() {     cin >> n;     for (long long int i = 0; i < n; i++) cin >> a[i];     for (long long int i = n - 1; i >= 0; i--) {       while (!st.empty()) {         if (a[i] < st.top().first) break;         cnt++;         cnt = max(cnt, st.top().second);         st.pop();       }       mx = max(mx, cnt);       st.push(make_pair(a[i], cnt));       cnt = 0;     }     cout << mx << endl;   }


#include <bits/stdc++.h>   using namespace std;   int n, m, a, b, c, d, x, y, p, q, t, ans[400009], res, mi, T, lca[22][400009],       sub[400009];   vector<int> v[400009];   int ma[2];   void dfs(int id, int par) {     lca[1][id] = par;     lca[0][id] = id;     for (int i = 0; i < v[id].size(); i++) {       int u = v[id][i];       if (u == par) continue;       dfs(u, id);       sub[id] += sub[u];     }     sub[id]++;   }   int centroid(int id, int par) {     int f = 0, s = 0;     for (int i = 0; i < v[id].size(); i++) {       int u = v[id][i];       if (u == par) continue;       if (sub[u] > T)         return centroid(u, id);       else         s += sub[u];     }     if (f == 0 && n - 1 - s <= T) return id;   }   int lim;   void init_lca() {     lim = log(n) / log(2) + 1;     for (int i = 2; i <= lim; i++) {       for (int j = 1; j <= n; j++) {         lca[i][j] = lca[1][lca[i - 1][lca[i - 1][j]]];       }     }   }   void calc(int id, int par, int branch = 0) {     for (int i = 0; i < v[id].size(); i++) {       int u = v[id][i];       if (u == par) continue;       int branch2 = (branch == 0 ? u : branch);       if (branch2 != ma[0]) {         if (n - sub[ma[0]] - sub[u] <= T) ans[u] = 1;       } else {         if (n - sub[ma[1]] - sub[u] <= T) ans[u] = 1;       }       if (n - sub[branch2] <= T) ans[u] = 1;       calc(u, id, branch2);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 1; i < n; i++) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     if (n <= 4) {       for (int i = 1; i <= n; i++) cout << 1 <<    ;       return 0;     }     dfs(1, 0);     T = n / 2;     c = centroid(1, 0);     memset(sub, 0, sizeof(sub));     dfs(c, 0);     ans[c] = 1;     for (int i = 0; i < v[c].size(); i++) {       int u = v[c][i];       if (sub[u] >= sub[ma[0]]) {         ma[1] = ma[0];         ma[0] = u;       } else if (sub[u] > sub[ma[1]])         ma[1] = u;     }     calc(c, 0);     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     return 0;   }


#include <bits/stdc++.h>   template <class T1, class T2>   inline bool cmin(T1 &a, const T2 &b) {     return b < a ? (a = b, true) : false;   }   template <class T1, class T2>   inline bool cmax(T1 &a, const T2 &b) {     return a < b ? (a = b, true) : false;   }   template <class Type>   Type read() {     Type a;     bool b;     unsigned char c;     while (c = getchar() - 48, (c > 9) & (c != 253))       ;     for (a = (b = c == 253) ? 0 : c; (c = getchar() - 48) <= 9; a = a * 10 + c)       ;     return b ? -a : a;   }   int (*rd)() = read<int>;   const int N = 2e5;   std::vector<int> b[N], g[N];   int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }   std::pair<int, int> exgcd(int x, int y) {     if (y == 0) return {1, 0};     int a, b;     std::tie(b, a) = exgcd(y, x % y);     return {a, b - x / y * a};   }   void gg() {     puts( -1 );     exit(0);   }   long long solve(int n, int m, const std::vector<int> &b,                   const std::vector<int> &g) {     long long ans = -1;     std::vector<std::pair<int, int>> pos;     int inv = exgcd(n, m).second % n;     if (inv < 0) inv += n;     for (int i : b) pos.emplace_back((long long)i * inv % n, 0);     for (int i : g) pos.emplace_back((long long)i * inv % n, 1);     std::sort(pos.begin(), pos.end());     pos.resize(std::unique(pos.begin(), pos.end(),                            [](std::pair<int, int> p, std::pair<int, int> q) {                              return p.first == q.first;                            }) -                pos.begin());     int i = pos.back().first;     for (auto p : pos) {       if ((p.first - 1 + n) % n != i)         cmax(ans,              (long long)(p.first - i - 1 + n) % n * m + (long long)i * m % n);       if (p.second) cmax(ans, (long long)i * m % n);       i = p.first;     }     return ans;   }   int main() {     int n, m, d;     long long ans = 0;     std::vector<int> glob, glog;     n = rd(), m = rd(), d = gcd(n, m);     glob.resize(rd());     for (int &i : glob) i = rd();     glog.resize(rd());     for (int &i : glog) i = rd();     if (glob.size() + glog.size() < d) gg();     for (int i : glob) b[i % d].push_back(i / d);     for (int i : glog) g[i % d].push_back(i / d);     n /= d, m /= d;     for (int i = 0; i < d; ++i) {       if (b[i].empty() && g[i].empty()) gg();       cmax(ans,            std::max(solve(n, m, b[i], g[i]), solve(m, n, g[i], b[i])) * d + i);     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int N;   pair<pair<int, int>, int> arr[2050];   int vis[2050];   char s[2050];   double angle(pair<int, int> x, pair<int, int> y, pair<int, int> z) {     pair<int, int> xy = {y.first - x.first, y.second - x.second};     pair<int, int> xz = {y.first - z.first, y.second - z.second};     double angyx = 1.0 * xy.first * xz.first + 1.0 * xy.second * xz.second;     double angyz = 1.0 * xy.first * xz.second - 1.0 * xy.second * xz.first;     return atan2(angyz, angyx);   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       int x, y;       scanf( %d%d , &x, &y);       arr[i] = {{x, y}, i + 1};     }     scanf( %s , s);     sort(arr, arr + N,          [](const pair<pair<int, int>, int> &a,             const pair<pair<int, int>, int> &b) {            if (a.first.second == b.first.second)              return a.first.first < b.first.first;            return a.first.second < b.first.second;          });     pair<int, int> tmp1 = {arr[0].first.first - 1, arr[0].first.second};     pair<int, int> tmp2 = arr[0].first;     vis[0] = 1;     pair<int, int> a = {-1, -1};     pair<int, int> b = {1, -1};     pair<int, int> c = {2, -1};     printf( %d  , arr[0].second);     for (int i = 0; i < N - 2; i++) {       double max = -1234567.0, min = 1234567.0;       int maxi, mini;       for (int j = 0; j < N; j++) {         if (vis[j] == 1) continue;         double ang = angle(tmp1, tmp2, arr[j].first);         if (i == 0) {         }         if (i == 0 && arr[j].first.second == arr[0].first.second &&             arr[j].first.first > arr[0].first.first) {           min = -1234, mini = j;           continue;         }         if (i == 0 && arr[j].first.second == arr[0].first.second &&             arr[j].first.first < arr[0].first.first) {           max = 1234, maxi = j;           continue;         }         if (ang > max) max = ang, maxi = j;         if (ang < min) min = ang, mini = j;       }       if (s[i] ==  R ) {         tmp1 = tmp2;         tmp2 = arr[maxi].first;         vis[maxi] = 1;         printf( %d  , arr[maxi].second);       } else {         tmp1 = tmp2;         tmp2 = arr[mini].first;         vis[mini] = 1;         printf( %d  , arr[mini].second);       }     }     for (int i = 0; i < N; i++) {       if (vis[i] == 0) {         printf( %d n , arr[i].second);       }     }   }


#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   ostream &operator<<(ostream &os, const pair<T1, T2> &p) {     os <<  {  << p.first <<  ,  << p.second <<  } ;     return os;   }   const int N = 3e5 + 5;   const int oo = 1e9 + 7;   vector<pair<int, pair<int, int> > > g[N];   int f[N];   int ans[N];   int x[N];   int y[N];   bool vis[N];   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int w;       cin >> x[i] >> y[i] >> w;       g[x[i]].push_back({i, {y[i], w}});       g[y[i]].push_back({i, {x[i], w}});     }     for (int i = 2; i <= n - 1; i++) {       for (auto p : g[i]) {         f[i] += p.second.second;       }       assert(f[i] % 2 == 0);       f[i] /= 2;     }     queue<int> q;     q.push(1);     vis[1] = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       for (auto p : g[u]) {         int i = p.first;         int v = p.second.first;         int w = p.second.second;         if (vis[v]) continue;         if (x[i] == u)           ans[i] = 0;         else           ans[i] = 1;         if (v == n) continue;         f[v] -= w;         if (f[v] == 0) {           vis[v] = 1;           q.push(v);         }       }     }     for (int i = 1; i <= m; i++) cout << ans[i] <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   int n;   string queue_[6] = {  ,  Sheldon ,  Leonard ,  Penny ,  Rajesh ,  Howard };   int main() {     cin >> n;     double count = 1;     bool used = false;     while (count * 5 < n) {       n -= count * 5;       count *= 2;       used = true;     }     int x = ceil(n / count);     cout << queue_[x];     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 7;   const int logn = 19;   vector<int> adj[maxn];   int idcnt, l[maxn], r[maxn], dep[maxn], anc[maxn][logn];   void dfs1(int u, int up) {     l[u] = ++idcnt;     dep[u] = dep[up] + 1;     anc[u][0] = up;     for (int i = 1; i < logn; i++) {       if (dep[u] <= (1 << i)) break;       anc[u][i] = anc[anc[u][i - 1]][i - 1];     }     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (v == up) continue;       dfs1(v, u);     }     r[u] = idcnt;   }   int qlca(int u, int v) {     if (dep[u] > dep[v]) swap(u, v);     for (int i = logn - 1; i >= 0; i--)       if (dep[v] > (1 << i) && dep[anc[v][i]] >= dep[u]) v = anc[v][i];     if (u == v) return u;     for (int i = logn - 1; i >= 0; i--)       if (dep[u] > (1 << i) && anc[u][i] != anc[v][i]) {         u = anc[u][i];         v = anc[v][i];       }     return anc[u][0];   }   vector<int> bus[maxn];   int nex[maxn][logn];   void dfs2(int u, int up) {     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (v == up) continue;       dfs2(v, u);       if (dep[nex[v][0]] < dep[nex[u][0]]) nex[u][0] = nex[v][0];     }   }   int n, st[maxn];   int lowbit(int x) { return x & (-x); }   void add(int i, int x) {     for (; i <= n; i += lowbit(i)) st[i] += x;   }   int qsum(int i) {     int res = 0;     for (; i > 0; i -= lowbit(i)) res += st[i];     return res;   }   struct node {     int id, v;     node(int id = 0, int v = 0) : id(id), v(v) {}   };   vector<node> ql[maxn];   int ans[maxn], cmp[maxn];   void dfs3(int u, int up) {     for (int i = 0; i < ql[u].size(); i++) {       node cur = ql[u][i];       int id = cur.id, v = cur.v;       cmp[id] = qsum(r[v]) - qsum(l[v] - 1);     }     for (int i = 0; i < bus[u].size(); i++) {       int v = bus[u][i];       add(l[v], 1);     }     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (v == up) continue;       dfs3(v, u);     }     for (int i = 0; i < ql[u].size(); i++) {       node cur = ql[u][i];       int id = cur.id, v = cur.v;       if (qsum(r[v]) - qsum(l[v] - 1) != cmp[id]) ans[id]--;     }   }   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i++) {       int v;       scanf( %d , &v);       adj[i].push_back(v);       adj[v].push_back(i);     }     dfs1(1, 1);     int m;     scanf( %d , &m);     for (int i = 1; i <= n; i++) nex[i][0] = i;     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       bus[a].push_back(b);       bus[b].push_back(a);       int lca = qlca(a, b);       if (dep[lca] < dep[nex[a][0]]) nex[a][0] = lca;       if (dep[lca] < dep[nex[b][0]]) nex[b][0] = lca;     }     dfs2(1, 1);     for (int i = 1; i < logn; i++)       for (int j = 1; j <= n; j++) nex[j][i] = nex[nex[j][i - 1]][i - 1];     int q;     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       int u, v;       scanf( %d%d , &u, &v);       if (u > v) swap(u, v);       int lca = qlca(u, v);       for (int j = logn - 1; j >= 0; j--)         if (dep[nex[v][j]] > dep[lca]) {           v = nex[v][j];           ans[i] += (1 << j);         }       if (u == lca) {         if (dep[nex[v][0]] > dep[lca]) {           ans[i] = -1;           continue;         }         if (dep[v] > dep[lca]) ans[i]++;       } else {         for (int j = logn - 1; j >= 0; j--)           if (dep[nex[u][j]] > dep[lca]) {             u = nex[u][j];             ans[i] += (1 << j);           }         if (dep[nex[u][0]] > dep[lca] || dep[nex[v][0]] > dep[lca]) {           ans[i] = -1;           continue;         }         ans[i] += 2;         if (u > v) swap(u, v);         ql[u].push_back(node(i, v));       }     }     dfs3(1, 1);     for (int i = 1; i <= q; i++) printf( %d n , ans[i]);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long k, res, a[1111], n;   set<long long> s;   int main() {     cin >> n >> k;     for (long long i = 1; i <= sqrt(n); i++) {       if (n % i == 0) s.insert(i), s.insert(n / i);     }     for (long long i : s) {       res++;       if (res == k) {         cout << i;         return 0;       }     }     cout << -1;   }


#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   const long long xx = 2e7;   const long long MOD = 1e9 + 7;   const long long inf = 1e18;   long long isprime(long long n) {     if (n == 2) return 1;     if (n % 2 == 0) return 0;     for (long long i = 3; i * i <= n; i += 2) {       if (n % i == 0) return 0;     }     return 1;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     if (isprime(n)) {       cout << 1 <<   n ;     } else if (n % 2 == 0 || isprime(n - 2)) {       cout << 2 <<   n ;     } else       cout << 3 <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   long long N = 0, M, K;   long long MOD = 998244353;   string S, S1;   struct st {     long long x, i;   };   bool operator<(const st& a, const st& b) {     if (a.x == b.x) return a.i < b.i;     return a.x < b.x;   }   long long gcd(long long a, long long b) {     while (b > 0) {       a %= b;       swap(a, b);     }     return a;   }   long long fact(long long x) {     long long x1 = 1;     while (x >= 1) {       x1 *= x;       x--;     }     return x1;   }   void prime(long long n, vector<long long>& pr) {     vector<long long> lp(n + 90);     for (long long i = 2; i <= n; ++i) {       if (!lp[i]) {         pr.push_back(i);         lp[i] = i;       }       for (long long j = 0; j < pr.size() && pr[j] <= lp[i] && i * pr[j] <= n;            ++j) {         lp[i * pr[j]] = pr[j];       }     }   }   void dfs(long long x, vector<long long>& b, vector<long long>& w,            vector<vector<long long>>& v) {     w[x] = 1;     b.push_back(x);     for (long long i : v[x]) {       if (!w[i]) dfs(i, b, w, v);     }   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s, s1;     long long n, k = 0, m;     long long x = 0, y = 0, ans = 0;     cin >> s >> n;     vector<long long> a;     for (long long i = 0; i < n; i++) {       s1 =   ;       cin >> x >> y >> k;       m = y - x + 1;       k = k % m;       for (long long j = y - k; j <= y - 1; j++) s1 += s[j];       s.erase(y - k, k);       s.insert(x - 1, s1);     }     cout << s <<   n ;     cin >> N;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   long long fastpo(long long a, long long x) {     if (x == 0) return 1ll;     if (x == 1) return a;     long long y = fastpo(a, x / 2);     if (x % 2 == 0) {       return y * y;     }     return y * y * a;   }   long long inv(long long a, long long M) { return fastpo(a, M - 2); }   long long gcdExtended(long long a, long long b, long long *x, long long *y) {     if (a == 0) {       *x = 0, *y = 1;       return b;     }     long long x1, y1;     long long gcd = gcdExtended(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   long long modInverse(long long a, long long m) {     long long x, y;     long long g = gcdExtended(a, m, &x, &y);     if (g != 1)       return -1;     else {       long long res = (x % m + m) % m;       return res;     }   }   long long gcd(long long a, long long b) {     if (a == 0) {       return b;     }     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long N = 2e6 + 5;   vector<long long> dp(N, 0), ci(N, 0), ai(N, 0), bi(N, 0), ans(N, 0);   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (int i = 1; i < N; i++) {       if (i == 1) {         dp[i] = 1;         ci[i] = 0;         ai[i] = 0;         bi[i] = 1;         ans[i] = 0;       } else if (i == 2) {         dp[i] = 2;         ci[i] = 0;         ai[i] = 1;         bi[i] = 1;         ans[i] = 0;       } else {         ci[i - 1] = dp[i - 3];         ai[i - 1] = dp[i - 2] - dp[i - 3];         bi[i - 1] = dp[i - 1] - dp[i - 2];         dp[i] = ((ci[i - 1] + ai[i - 1] * 3 + bi[i - 1] * 2) % M + M) % M;         ans[i] = (ans[i - 3] + bi[i - 2]) % M;       }     }     int t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long res = ((ans[n] * 4) % M + M) % M;       cout << res << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void test() {     int t;     cin >> t;     while (t--) {       int i = 0;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int i = 0;     int n;     cin >> n;     map<int, int> m;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       m[x]++;     }     int g = 0;     for (auto i : m) {       if (i.first != 0) g++;     }     cout << g;     return 0;   }


#include <bits/stdc++.h>   #define rep(i, a, b) for (int i = a; i <= b; i++)   #define per(i, a, b) for (int i = a; i >= b; i--)   using namespace std;      typedef unsigned long long ull;   typedef pair <int, int> pii;   typedef long long ll;      template <typename T>   inline void read(T &f) {       f = 0; T fu = 1; char c = getchar();       while (c <  0  || c >  9 ) { if (c ==  - ) { fu = -1; } c = getchar(); }       while (c >=  0  && c <=  9 ) { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }       f *= fu;   }      template <typename T>   void print(T x) {       if (x < 0) putchar( - ), x = -x;       if (x < 10) putchar(x + 48);       else print(x / 10), putchar(x % 10 + 48);   }      template <typename T>   void print(T x, char t) {       print(x); putchar(t);   }      const int N = 3e5 + 5;      struct seg_t {       int mx[N << 2];          void build(int u, int l, int r) {           mx[u] = 0;           if (l == r) return;           int mid = (l + r) >> 1;           build(u << 1, l, mid);           build(u << 1 | 1, mid + 1, r);       }          void modify(int u, int l, int r, int x, int y) {           mx[u] = max(mx[u], y);           if (l == r) return;           int mid = (l + r) >> 1;           if (mid >= x) modify(u << 1, l, mid, x, y);           else modify(u << 1 | 1, mid + 1, r, x, y);       }          int query(int u, int L, int R, int l, int r) {           if (l <= L && R <= r) return mx[u];           int mid = (L + R) >> 1, ans = 0;           if (mid >= l) ans = max(ans, query(u << 1, L, mid, l, r));           if (mid + 1 <= r) ans = max(ans, query(u << 1 | 1, mid + 1, R, l, r));           return ans;       }   } tr, rmq;      set <int> pos;   set <int> :: iterator it;   int a[N], cando[N], lpos[N], pre[N], ans[N];   int T, n;      int main() {       read(T);       while (T--) {           read(n);           rmq.build(1, 1, n);           for (int i = 1; i <= n; i++) read(a[i]), rmq.modify(1, 1, n, i, min(n, i + a[i]));           tr.build(1, 1, n);           for (int i = n; i >= 1; i--) {               int r = min(i + a[i], n);               if (i + 1 <= r) tr.modify(1, 1, n, i, tr.query(1, 1, n, i + 1, r));               else tr.modify(1, 1, n, i, i);           }           for (int i = 1; i <= n + 1; i++) cando[i] = 0;           cando[1] = 1;           pos.clear();           for (int i = 2; i <= n; i++) {               if (cando[i - 1]) pos.insert(i - 1);               it = pos.lower_bound(i - a[i]);               if (it != pos.end()) {                   pre[i] = lpos[*it];                   int r = i - 1;                   if (lpos[*it] != *it) r = rmq.query(1, 1, n, *it, i - 1);                   else if (*it + 1 <= i - 1) r = rmq.query(1, 1, n, *it + 1, i - 1);                   if (r >= i + 1) r = tr.query(1, 1, n, i + 1, r);                   if (!cando[r + 1]) {                       cando[r + 1] = 1;                       lpos[r + 1] = i;                   }                   if (r == n) break;               }           }           if (cando[n + 1]) {               printf( YES n );               for (int i = 1; i <= n; i++) ans[i] = 0;               int now = lpos[n + 1];               while (now) {                   ans[now] = 1;                   now = pre[now];               }               for (int i = 1; i <= n; i++) {                   if (ans[i]) putchar( L );                   else putchar( R );               }               putchar(  n );           } else {               printf( NO n );           }       }       return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long int M, tp, xx, lll, cc, ndl = 0, N, dl, nf, nef, T;   struct bl {     long long int type;     long long int l, c, x;   };   bl t;   vector<bl> B;   vector<long long int> C;   map<long long int, long long int> MP;   ifstream in( input.txt );   long long int find_bl(long long int n) {     if (MP.count(n) == 0) {       long long int num = (lower_bound(C.begin(), C.end(), n) - C.begin());       t = B[num];       if (t.type == 1) {         T = t.x;         MP[n] = T;         return T;       } else {         nf = n - C[num - 1];         nef = (nf % t.l == 0) ? t.l : (nf % t.l);         T = find_bl(nef);         MP[n] = T;         return T;       }     } else       return MP[n];   }   int main() {     cin >> M;     for (int i = 1; i <= M; i++) {       cin >> tp;       t.type = tp;       if (tp == 1) {         cin >> xx;         t.x = xx;         B.push_back(t);         C.push_back(ndl + 1);         ndl++;       } else {         cin >> lll >> cc;         t.l = lll;         t.c = cc;         B.push_back(t);         C.push_back(ndl + (lll * cc));         ndl += lll * cc;       }     }     cin >> N;     for (int i = 1; i <= N; i++) {       cin >> xx;       cout << find_bl(xx) <<    ;     }   }


#include <bits/stdc++.h>   using namespace std;   const int M = 102, T = 1000 * 1000 * 1000 + 7;   int a[2600][M];   bool mrk[2600][M];   string s;   int ff(long long sum, int n) {     if (sum < 0) return 0;     if (mrk[sum][n]) return a[sum][n];     if (sum > 25 && n == 1) return 0;     if (sum <= 25 && n == 1) return 1;     long long temp = 0;     for (int i = 0; i < 26; i++) temp += ff(sum - i, n - 1), temp %= T;     a[sum][n] = temp;     mrk[sum][n] = true;     return temp;   }   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       long long sum = 0;       for (int i = 0; i < s.length(); i++) sum += s[i] -  a ;       cout << (ff(sum, s.length()) + T - 1) % T << endl;     }     return 0;     ;   }


#include <bits/stdc++.h>   using namespace std;   const int maxv = 10001;   map<string, int> tidx;   map<int, int> fp[maxv];   struct Edge {     int to, next;   } edge[maxv * 2];   int m, idx, head[maxv], ednum, deg[maxv];   char tmp[22];   bool mp[maxv][maxv];   void addedge(int u, int v) {     edge[ednum] = Edge{v, head[u]};     head[u] = ednum++;     edge[ednum] = Edge{u, head[v]};     head[v] = ednum++;   }   void cal(int u) {     int i, j, vi, vj;     deg[u] = 1;     for (i = head[u]; i != -1; i = edge[i].next) {       deg[u]++;       for (j = edge[i].next; j != -1; j = edge[j].next) {         vi = edge[i].to;         vj = edge[j].to;         if (!mp[vi][vj] && !mp[vj][vi]) fp[vi][vj] += 1, fp[vj][vi] += 1;       }     }   }   int main() {     int a, b, i, maxv, num;     string u, v;     memset(head, -1, sizeof(head));     map<string, int>::iterator it;     map<int, int>::iterator jt;     idx = ednum = 0;     scanf( %d , &m);     for (i = 0; i < m; i++) {       scanf( %s , tmp);       u = tmp;       scanf( %s , tmp);       v = tmp;       if (tidx.find(u) == tidx.end())         tidx[u] = a = idx++;       else         a = tidx[u];       if (tidx.find(v) == tidx.end())         tidx[v] = b = idx++;       else         b = tidx[v];       mp[a][b] = mp[b][a] = true;       addedge(a, b);     }     printf( %d n , idx);     for (i = 0; i < idx; i++) cal(i);     for (it = tidx.begin(); it != tidx.end(); it++) {       i = it->second;       maxv = 0, num = idx - fp[i].size() - deg[i];       for (jt = fp[i].begin(); jt != fp[i].end(); jt++) {         if (jt->second > maxv) {           maxv = jt->second;           num = 1;         } else if (jt->second == maxv)           num++;       }       printf( %s %d n , it->first.c_str(), num);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n, x, y;   string s;   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n >> x >> y >> s;     long long zeros = 0;     int last = -1;     for (auto c : s) {       int b = (c -  0 );       if (b != last && !b) zeros++;       last = b;     }     if (zeros == 0) {       cout << 0 << endl;       return 0;     }     long long ans1 = x * (zeros - 1) + y;     long long ans2 = y * (zeros - 1) + y;     cout << min(ans1, ans2) << endl;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   T sq(T x) {     return x * x;   }   const long long inf = 2147383647;   const double pi = 2 * acos(0.0);   const double eps = 1e-9;   const long long maxint = 2147483647;   const long long minint = -2147483648;   int n, m;   long long arr[100010], brr[100010];   long long dp1[100010], dp2[100010];   void input() {     int i;     for (i = 0; i < n; i++) {       scanf( %I64d , &arr[i]);     }     for (i = 0; i < m; i++) {       scanf( %I64d , &brr[i]);     }     sort(arr, arr + n);     sort(brr, brr + m);   }   void dpcalc() {     dp1[0] = 0;     int i;     for (i = 1; i < n; i++) {       dp1[i] = dp1[i - 1];       dp1[i] += i * (arr[i] - arr[i - 1]);     }     dp2[m - 1] = 0;     for (i = m - 2; i >= 0; i--) {       dp2[i] = dp2[i + 1];       int e = m - i - 1;       dp2[i] += e * (brr[i + 1] - brr[i]);     }   }   long long findCost(long long x) {     long long res = 0;     long long pos = upper_bound(arr, arr + n, x) - arr;     if (pos > 0) {       pos--;       res += dp1[pos];       res += (pos + 1) * (x - arr[pos]);     }     pos = lower_bound(brr, brr + m, x) - brr;     if (pos < m) {       res += dp2[pos];       res += (m - pos) * (brr[pos] - x);     }     return res;   }   int main() {     scanf( %d %d , &n, &m);     int i, j;     input();     dpcalc();     long long low = 1, high = 1000000000;     long long res = -1;     while (high - low > 5) {       long long m1 = (2 * low + high) / 3;       long long m2 = (low + 2 * high) / 3;       long long u = findCost(m1);       long long v = findCost(m2);       if (res == -1) res = u;       res = min(res, u);       res = min(res, v);       if (u > v) {         low = m1 + 1;       } else {         high = m2 - 1;       }     }     while (low <= high) {       res = min(res, findCost(low));       low++;     }     printf( %I64d n , res);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 5000 + 100;   const int M = 30;   int n;   string s;   string t;   int mat[M][M][N];   int ones[N];   int ans;   long double javab;   set<char> g;   bool mark[30];   int chand[30];   bool oomade[30];   int main() {     cin >> s;     n = s.size();     for (int i = 0; i < n; i++) {       g.insert(s[i]);       chand[s[i] -  a ]++;       oomade[s[i] -  a ] = 1;     }     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n + i; j++) {         int y = j % n;         int f = (int)s[i] - (int) a ;         int l = (int)s[y] - (int) a ;         mat[f][l][j - i]++;       }     }     for (int i = 0; i < 26; i++) {       if (oomade[i] == 1) {         for (int j = 0; j < n; j++) {           int tmp = 0;           for (int k = 0; k < 26; k++) {             if (mat[i][k][j] == 1) {               tmp++;             }           }           ones[i] = max(ones[i], tmp);         }         ans += ones[i];       }     }     javab = (long double)ans / (n);     cout << fixed << setprecision(10) << javab;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int months[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};     int n, m;     cin >> n >> m;     vector<int> ans;     string s;     int idx = 0;     while (getline(cin, s)) {       int month = (s[5] -  0 ) * 10 + (s[6] -  0 );       int day = (s[8] -  0 ) * 10 + (s[9] -  0 );       int hour = (s[11] -  0 ) * 10 + (s[12] -  0 );       int mnt = (s[14] -  0 ) * 10 + (s[15] -  0 );       int sec = (s[17] -  0 ) * 10 + (s[18] -  0 );       int totalSec = sec + mnt * 60 + hour * 3600 + day * 24 * 3600;       for (int i = 0; i < month - 1; i++) {         totalSec += months[i] * 24 * 3600;       }       while (idx < ans.size() and ans[idx] + n <= totalSec) {         idx++;       }       ans.push_back(totalSec);       if (ans.size() - idx >= m) {         for (int i = 0; i < 19; i++) {           printf( %c , s[i]);         }         puts(  );         return 0;       }     }     puts( -1 );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int fir[5000];   int sec[5000];   int init(int x, int y) {     printf( ? %d %d n , x, y);     fflush(stdout);     scanf( %d , &x);     return x;   }   void print(int sch, const vector<int> &ans) {     printf( ! n );     fflush(stdout);     printf( %d n , sch);     fflush(stdout);     for (int i = 0; i < ans.size(); i++) printf( %d  , ans[i]);     fflush(stdout);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) fir[i] = init(0, i);     for (int i = 0; i < n; i++) sec[i] = init(i, 0);     vector<int> ans;     int sch = 0;     for (int i = 0; i < n; i++) {       bool t = true;       int col[5000], p[5000], b[5000];       b[0] = i;       memset(col, 0, sizeof col);       for (int j = 0; j < n; j++) {         int x = sec[j] ^ b[0];         if (x >= n || col[x]) {           t = false;           break;         }         p[j] = x;         col[x]++;       }       if (t) {         memset(col, 0, sizeof col);         col[i]++;         for (int j = 1; j < n; j++) {           int x = fir[j] ^ p[0];           if (x >= n || col[x]) {             t = false;             break;           }           b[j] = x;           col[x]++;         }       }       if (t) {         for (int j = 0; j < n; j++)           if (j != b[p[j]]) t = false;       }       if (t) {         if (!sch) {           for (int j = 0; j < n; j++) ans.push_back(p[j]);         }         sch++;       }     }     print(sch, ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, m, ans = 999999999999999999, mn = 123456789000LL;     cin >> n >> m;     long long x = n;     vector<pair<long long, long long> > v;     long long cnt = 0;     for (long long i = 2; i <= sqrt(m); i++) {       if (m % i == 0) {         cnt = 0;         while (m % i == 0) {           cnt++;           m = m / i;         }         v.push_back({i, cnt});       }     }     if (m > 1) {       mn = 1;       v.push_back({m, 1});     }     for (int i = 0; i < v.size(); i++) {       long long y = x;       long long temp = 0;       while (y) {         temp += y / v[i].first;         y = y / v[i].first;       }       temp = temp / v[i].second;       ans = min(temp, ans);     }     cout << ans << endl;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     cin >> a >> b >> c;     int min1 = a;     int min2 = b / 2;     int min3 = c / 4;     int res = min(min(min1, min2), min3);     cout << res * 7;     return 0;   }


#include <bits/stdc++.h>   using namespace std;         void solve()   {       int n,i,j=2,x,m,d,k;       cin >> n;       if(n%2==1)       {cout <<  NO  << endl;return;}       while(j<1000000009 && j<=n)       {           if(n==j)           {              // cout <<  loop  << endl;                  cout <<  YES  << endl;               return;           }           //cout << n <<     << j << endl;           j*=2;       }             n=n/2;       j=sqrt(n);       if(j*j < n){          if(n%2==1)       {           cout <<  NO  << endl;return;       }       n/=2;       j=sqrt(n);           if(j*j < n)               {           cout <<  NO  << endl;return;       }       else {           {           cout <<  YES  << endl;return;       }       }          }          //if(j%2==1) {cout <<  NO  << endl;return;}       cout <<  YES  << endl;         }         int main()   {       ios_base::sync_with_stdio(false); cin.tie(NULL);       int t=1;       cin >> t;       while(t--) solve();   }


#include <bits/stdc++.h>   using namespace std;   long long n, k;   vector<long long> v;   long long dp[1001][2001][4];   long long rec(long long i, long long mask, long long comp) {     if (i == n && comp == k)       return 1;     else if (i == n)       return 0;     else if (comp > k)       return 0;     if (dp[i][comp][mask] != -1) return dp[i][comp][mask];     if (i == 0) {       return dp[i][comp][mask] =                  (rec(i + 1, 0, comp + 1) + rec(i + 1, 1, comp + 2) +                   rec(i + 1, 2, comp + 2) + rec(i + 1, 3, comp + 1)) %                  998244353;     }     if (mask == 0) {       return dp[i][comp][mask] =                  (rec(i + 1, 0, comp) + rec(i + 1, 3, comp + 1) +                   rec(i + 1, 1, comp + 1) + rec(i + 1, 2, comp + 1)) %                  998244353;     } else if (mask == 1) {       return dp[i][comp][mask] = (rec(i + 1, 0, comp) + rec(i + 1, 1, comp) +                                   rec(i + 1, 2, comp + 2) + rec(i + 1, 3, comp)) %                                  998244353;     } else if (mask == 2) {       return dp[i][comp][mask] = (rec(i + 1, 0, comp) + rec(i + 1, 1, comp + 2) +                                   rec(i + 1, 2, comp) + rec(i + 1, 3, comp)) %                                  998244353;     } else if (mask == 3) {       return dp[i][comp][mask] =                  (rec(i + 1, 0, comp + 1) + rec(i + 1, 1, comp + 1) +                   rec(i + 1, 2, comp + 1) + rec(i + 1, 3, comp)) %                  998244353;     }   }   void solve() {     memset(dp, -1, sizeof(dp));     cin >> n >> k;     cout << rec(0, 0, 0);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long q = 1;     while (q--) {       v.clear();       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   long long g, x, y, z;   int n, m;   int nn, mm;   deque<long long> q;   long long a[3010][3010];   long long b[3010][3010];   long long c[3010][3010];   int main() {     scanf( %d%d%d%d , &nn, &mm, &n, &m);     scanf( %lld%lld%lld%lld , &g, &x, &y, &z);     for (int i = 1; i <= nn; i++) {       for (int j = 1; j <= mm; j++) {         a[i][j] = g;         g = g * x + y;         g %= z;       }     }     for (int i = 1; i <= nn; i++) {       for (int j = mm; j >= 1; j--) {         while (!q.empty() && a[i][q.back()] >= a[i][j]) {           q.pop_back();         }         q.push_back(j);         while (!q.empty() && q.front() - q.back() + 1 > m) {           q.pop_front();         }         if (j <= mm - m + 1) b[i][j] = a[i][q.front()];       }       while (!q.empty()) q.pop_front();     }     for (int i = 1; i <= mm - m + 1; i++) {       for (int j = nn; j >= 1; j--) {         while (!q.empty() && b[q.back()][i] >= b[j][i]) {           q.pop_back();         }         q.push_back(j);         while (!q.empty() && q.front() - q.back() + 1 > n) {           q.pop_front();         }         if (j <= nn - n + 1) c[j][i] = b[q.front()][i];       }       while (!q.empty()) q.pop_front();     }     long long ans = 0;     for (int i = 1; i <= nn - n + 1; i++) {       for (int j = 1; j <= mm - m + 1; j++) {         ans += c[i][j];       }     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long _pow(long long a, long long b, long long m) {     if (b == 0) return 1;     long long t = _pow(a, b / 2, m);     t = (t * t) % m;     if (b & 1)       return (t * a) % m;     else       return t;   }   int main(int argc, char *argv[]) {     int n;     cin >> n;     vector<string> v;     int cnt = 0;     bool zero = false;     string ex =  1 ;     for (int i = 0; i < n; i++) {       string x;       cin >> x;       v.push_back(x);       bool f = true;       if (x[0] ==  0  and x.size() == 1)         zero = true;       else if (x[0] ==  1 ) {         int cn = 0;         int j;         for (j = 1; j < x.size(); j++)           if (x[j] !=  0 ) {             ex = x;             break;           } else             cn++;         if (j == x.size()) cnt += cn;       } else         ex = x;     }     if (zero)       cout << 0 << endl;     else {       cout << ex;       for (int i = 0; i < cnt; i++) cout << 0;       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int mod = 1e9 + 7;   const int N = 1e5 + 10;   inline int add(int x, int y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   inline int mul(int x, int y) {     x = (1LL * x * y) % mod;     return x;   }   int main() {     string s;     cin >> s;     string a =  abcdefghijklmnopqrstuvwxyz ;     long long k = 0;     for (int i = 0; i <= s.size() - 1; ++i) {       if (s[i] <= a[k]) {         s[i] = a[k];         k++;       }     }     if (k == 26) {       cout << s;     } else {       cout << -1;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     vector<pair<int, int>> a;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a.push_back({x, i});     }     sort(a.begin(), a.end(), greater<pair<int, int>>());     int numRow = a[0].first + 1;     vector<vector<int>> ans(numRow, vector<int>(n, 0));     for (int i = 0; i < a[0].first; i++) ans[i][a[0].second] = 1;     int row = 0;     for (int i = 1; i < n; i++) {       auto [block, col] = a[i];       for (int i = 1; i <= block; i++) ans[(row + i) % numRow][col] = 1;       if (row < numRow - 2) row++;     }     if (!accumulate(ans[numRow - 1].begin(), ans[numRow - 1].end(), 0)) numRow--;     cout << numRow << endl;     for (int i = 0; i < numRow; i++) {       for (auto x : ans[i]) cout << x;       cout << endl;     }   }


#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   int q;   unsigned int a[200002];   unsigned int b[200002];   unsigned int w;   int main() {     scanf( %d , &q);     for (int i = 0; i < q; ++i) {       int t, l, r, k;       scanf( %d%d%d , &t, &l, &r);       --l, --r;       if (t == 1) {         scanf( %d , &k);         if (k > 0) {           w = k;           for (int i = l; i < r; ++i)             if (a[i]) {               a[i] = min(a[i], w);             } else {               a[i] = w;             }         } else {           w = -k;           for (int i = l; i < r; ++i)             if (b[i]) {               b[i] = min(b[i], w);             } else {               b[i] = w;             }         }       } else {         long long ans = 0;         for (int i = l; i < r; ++i)           if (a[i] > 0 && b[i] > 0) ans += a[i] + b[i];         printf(              %lld                n ,             ans);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0;     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x;   }   struct Question {     int x, l, r, dat;     inline Question(int tmp1 = 0, int tmp2 = 0, int tmp3 = 0, int tmp4 = 0) {       x = tmp1, l = tmp2, r = tmp3, dat = tmp4;     }     inline int operator<(const Question &a) const { return x < a.x; }   } opt[100010];   int k;   inline int lowbit(int l, int r) {     int res = 0;     --l;     for (int i = 1; i <= k; i <<= 1)       res |= (((r / i - l / i) -                (((i << 1) <= k) ? (r / (i << 1) - l / (i << 1)) : (0))) &               1) *              i;     return res;   }   struct SegmentTree {     int tot = 0, rot = 0;     int L[100010 * 30], R[100010 * 30], tag[100010 * 30], val[100010 * 30],         low[100010 * 30];     inline void upd(int k) {       if (tag[k])         val[k] = low[k];       else         val[k] = val[L[k]] ^ val[R[k]];     }     inline void Mod(int &k, int l, int r, int x, int y, int dat) {       if (y < l || r < x) return;       if (!k) k = ++tot, low[k] = lowbit(l, r);       if (x <= l && r <= y) return tag[k] += dat, upd(k);       Mod(L[k], l, ((l + r) >> 1), x, y, dat),           Mod(R[k], ((l + r) >> 1) + 1, r, x, y, dat), upd(k);     }   } T;   int main() {     int n = read(), m = read(), ans = 0;     k = read();     int lim = 1, cnt = 0;     for (; lim < k; lim <<= 1)       ;     while (m--) {       int xl = read(), yl = read();       int xr = read(), yr = read();       opt[++cnt] = Question(xl, yl, yr, 1);       opt[++cnt] = Question(xr + 1, yl, yr, -1);     }     sort(opt + 1, opt + cnt + 1);     for (int i = 1; i <= cnt; i++) {       if (opt[i].x != opt[i - 1].x) {         int x = lowbit(opt[i - 1].x, opt[i].x - 1), y = T.val[T.rot];         int a = 0, b = 0, sum = 0;         for (int j = lim; j; j >>= 1) {           sum = -a * b, a += (x & j) > 0, b += (y & j) > 0, sum += a * b;           if (sum & 1) ans ^= j;         }       }       T.Mod(T.rot, 1, n, opt[i].l, opt[i].r, opt[i].dat);     }     if (ans)       puts( Hamed );     else       puts( Malek );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool isgood(const vector<vector<char> > &graph, const vector<char> &choice) {     int n = (int)graph.size() / 2;     assert((int)graph[0].size() == 2 * n);     assert((int)choice.size() == n);     for (int i = 0; i < n; i++) {       bool ok = false;       int lbound = 2 * i;       int rbound = 2 * i + 1;       if (choice[i] != -1) lbound = rbound = 2 * i + choice[i];       for (int who = lbound; who <= rbound; who++) {         bool cur = true;         for (int j = 0; j < n; j++) {           if (choice[j] != -1 && graph[who][2 * j + 1 - choice[j]]) cur = false;           if (graph[who][2 * j] && graph[who][2 * j + 1]) cur = false;         }         ok |= cur;       }       if (!ok) return false;     }     return true;   }   void solve(string alph) {     int n, m;     cin >> n >> m;     vector<vector<char> > graph(2 * n, vector<char>(2 * n));     int pos1, pos2;     char t1, t2;     for (int i = 0; i < m; i++) {       scanf(  %d %c %d %c , &pos1, &t1, &pos2, &t2);       int x1 = 2 * (pos1 - 1) + (t1 ==  V  ? 0 : 1);       int x2 = 2 * (pos2 - 1) + (t2 ==  V  ? 0 : 1);       graph[x1][x2] = 1;       graph[x2 ^ 1][x1 ^ 1] = 1;     }     string word;     cin >> word;     assert((int)word.size() == n);     for (int i = 0; i < 2 * n; i++) graph[i][i] = 1;     for (int k = 0; k < 2 * n; k++)       for (int i = 0; i < 2 * n; i++)         for (int j = 0; j < 2 * n; j++)           graph[i][j] |= (graph[i][k] & graph[k][j]);     for (int i = 0; i < 2 * n; i++)       if (graph[i][i ^ 1] && graph[i ^ 1][i]) {         puts( -1 );         return;       }     vector<char> choice(n, -1);     for (int i = 0; i < n; i++) choice[i] = (alph[word[i] -  a ] ==  V  ? 0 : 1);     vector<int> next_vowel(alph.size() + 1, -1), next_cons(alph.size() + 1, -1);     for (int i = 0; i < (int)alph.size(); i++) {       for (int j = i; j < (int)alph.size(); j++) {         if (alph[j] ==  V  && next_vowel[i] == -1) next_vowel[i] = j;         if (alph[j] ==  C  && next_cons[i] == -1) next_cons[i] = j;       }     }     if (isgood(graph, choice)) {       puts(word.c_str());       return;     }     int lcp;     for (lcp = n - 1; lcp > 0; lcp--) {       int num = word[lcp] -  a  + 1;       if (next_vowel[num] != -1) {         choice[lcp] = 0;         if (isgood(graph, choice)) break;       }       if (next_cons[num] != -1) {         choice[lcp] = 1;         if (isgood(graph, choice)) break;       }       choice[lcp] = -1;     }     choice[lcp] = -1;     string ans = word.substr(0, lcp);     for (int i = lcp; i < n; i++) {       char start = (i == lcp ? word[i] + 1 :  a );       bool was_vowel = false;       bool was_cons = false;       bool ok = false;       for (char ch = start; ch <  a  + (int)alph.size(); ch++) {         if (!was_vowel && alph[ch -  a ] ==  V ) {           was_vowel = true;           choice[i] = 0;           ok |= isgood(graph, choice);           if (ok) {             ans += ch;             break;           }         }         if (!was_cons && alph[ch -  a ] ==  C ) {           was_cons = true;           choice[i] = 1;           ok |= isgood(graph, choice);           if (ok) {             ans += ch;             break;           }         }       }       if (!ok) {         puts( -1 );         return;       }     }     puts(ans.c_str());   }   int main() {     string n;     while (cin >> n) solve(n);   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, s, a, b, c, d;     cin >> n >> s;     d = s;     for (int i = 0; i < n; i++) {       cin >> a >> b;       c = a + b;       d = max(c, d);     }     cout << d;   }


#include <bits/stdc++.h>   using namespace std;   int N, K;   long long Time;   int Free;   multiset<long long> Working;   int main() {     scanf( %d%d , &N, &K);     Free = K;     Time = 0;     long long S, M;     for (int i = 0; i < N; ++i) {       scanf( %I64d%I64d , &S, &M);       S = max(S, Time);       if (Free > 0) {         --Free;         printf( %I64d n , S + M);         Working.insert(S + M);         Time = S;       } else {         Time = *Working.begin();         Time = max(Time, S);         printf( %I64d n , Time + M);         Working.erase(Working.begin());         Working.insert(Time + M);       }       while ((not Working.empty()) and ((*Working.begin()) <= Time)) {         ++Free;         Working.erase(Working.begin());       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 2e5 + 1;   vector<long long int> a[N];   vector<long long int> order, pos(N);   bool topsort(long long int n) {     order.clear();     queue<long long int> q;     vector<long long int> indeg(n + 1, 0);     for (long long int i = 1; i <= n; i++)       for (auto &it : a[i]) indeg[it]++;     for (long long int i = 1; i <= n; i++)       if (!indeg[i]) q.push(i);     long long int idx = 0;     while (!q.empty()) {       int v = q.front();       q.pop();       order.push_back(v);       idx++;       pos[v] = idx;       for (auto &u : a[v]) {         indeg[u]--;         if (!indeg[u]) q.push(u);       }     }     return (order.size() == n);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n;     cin >> n;     vector<long long int> a1(n + 1), b(n + 1), c;     for (long long int i = 1; i <= n; i++) cin >> a1[i];     for (long long int i = 1; i <= n; i++) {       cin >> b[i];       if (b[i] != -1) a[i].push_back(b[i]);     }     topsort(n);     vector<long long int> ans, tmp;     long long int sum1 = 0, k = 0;     for (long long int i = 0; i < order.size(); i++) {       long long int pos = order[i];       sum1 += a1[pos];       if (b[pos] != -1 && a1[pos] < 0)         tmp.push_back(pos);       else {         if (b[pos] != -1) a1[b[pos]] += a1[pos];         ans.push_back(pos);       }     }     reverse(tmp.begin(), tmp.end());     for (long long int i = 0; i < tmp.size(); i++) ans.push_back(tmp[i]);     cout << sum1 <<   n ;     for (long long int i = 0; i < n; i++) cout << ans[i] <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long double optN(long long m, int k) {     long double ret = 1;     m *= k;     long long nowC = k;     for (int i = 1; i <= k; ++i) {       if (m < nowC * i) {         ret += m / i;         return ret;       }       ret += nowC;       m -= nowC * i;       if (m / (i + 1.) / nowC <= (k - i) / (i + 1.)) return ret + m / (i + 1);       nowC *= k - i;       nowC /= (i + 1);     }     return ret;   };   int main() {     int CASE;     cin >> CASE;     for (int TCASE = 1; TCASE <= CASE; ++TCASE) {       long long n, m;       cin >> n >> m;       long long l = 0, r = (0x3f3f3f3f);       while (l < r) {         long long mid = l + r >> 1;         if (optN(m, mid) >= n)           r = mid;         else           l = mid + 1;       }       cout << l << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const int INF = 1 << 28;   const long long INFL = 1LL << 62;   int toi(string x) {     int z;     istringstream iss(x);     iss >> z;     return z;   }   string str[] = { YES ,  NO };   int modulo(int m, int n) { return m >= 0 ? m % n : (n - abs(m % n)) % n; }   using namespace std;   int arr[101] = {0}, n, m;   int main() {     cin >> n >> m;     for (int i = 1, a, b, c; i <= m; i++) {       cin >> a >> b >> c;       arr[a] -= c;       arr[b] += c;     }     int sum = 0;     for (int i = 1; i <= n; i++)       if (arr[i] > 0) sum += arr[i];     cout << sum << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n, b[100005], a[200005];   void solve() {     cin >> n;     for (long long i = 1; i < n / 2 + 1; i++) cin >> b[i];     a[1] = 0;     a[n] = b[1];     for (long long i = 2; i < n / 2 + 1; i++) {       a[i] = max(a[i - 1], b[i] - a[n - i + 2]);       a[n - i + 1] = b[i] - a[i];     }     for (long long i = 1; i < n + 1; i++) cout << a[i] <<    ;     cout <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, x1, x2, y1, y2, i, sum = 0;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x1 >> y1 >> x2 >> y2;       sum += ((x2 - x1) + 1) * ((y2 - y1) + 1);     }     cout << sum << endl;   }


#include <bits/stdc++.h>   using namespace std;   const int Inf = (int)1e9;   const long long InfL = (long long)1e18;   const int MaxN = (int)2e5 + 5;   vector<int> adj[MaxN], ans;   int n, a, deg[MaxN], dead[MaxN];   void dfs2(int x, int p) {     dead[x] = true;     ans.push_back(x);     for (auto u : adj[x]) --deg[u];     for (auto u : adj[x])       if (u != p && !dead[u]) dfs2(u, x);   }   void dfs1(int x, int p) {     for (auto u : adj[x])       if (u != p) dfs1(u, x);     if (!(deg[x] & 1)) dfs2(x, p);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a;       if (!a) continue;       adj[i].push_back(a);       deg[i]++;       adj[a].push_back(i);       deg[a]++;     }     dfs1(1, 0);     if (ans.size() == n) {       cout <<  YES  <<   n ;       for (int i = 0; i < n; i++) cout << ans[i] <<   n ;     } else {       cout <<  NO  <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   int mod = 1000000007;   const int M = INT_MAX;   using namespace std;   int powb(int x, int y) {     int res = 1;     x = x % M;     while (y > 0) {       if (y % 2) res = (res * x) % M;       y /= 2;       x = (x * x) % M;     }     return res;   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int solve() {     int n, t, s = 0, x, s1 = 0, i, j;     cin >> n >> t;     vector<int> v(2 * n);     for (i = 0; i < n; i++) {       cin >> x;       s1 += x;       v[i] = x;       v[i + n] = x;     }     if (s1 <= t) return n;     int max = 0;     x = 0;     for (i = 0; i < 2 * n; i++) {       s += v[i];       if (s > t) {         s -= v[i];         break;       }       x++;       if (x > max) max = x;     }     for (i = 1; i < n; i++) {       s -= v[i - 1];       x--;       for (j = i + x; j < n; j++) {         s += v[j];         if (s > t) {           s -= v[j];           break;         }         x++;         if (x > max) max = x;       }       if (j == n - 1) break;     }     return max;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void read(int &val) {     int x = 0;     int bz = 1;     char c;     for (c = getchar(); (c <  0  || c >  9 ) && c !=  - ; c = getchar())       ;     if (c ==  - ) {       bz = -1;       c = getchar();     }     for (; c >=  0  && c <=  9 ; c = getchar()) x = x * 10 + c - 48;     val = x * bz;   }   const int INF = 0x3f3f3f3f;   const int maxn = 1e6 + 100;   const int mod = 998244353;   long long a[maxn], b[maxn];   int n, k;   long long sum[maxn], tim[maxn];   struct node {     int id;     bool operator<(const node bb) const { return tim[id] > tim[bb.id]; }   };   bool check(long long mid) {     priority_queue<node> q;     for (int i = 1; i <= n; i++) {       tim[i] = a[i] / b[i];       sum[i] = a[i];       q.push(node{i});     }     for (int i = 0; i <= k - 1; i++) {       node top = q.top();       q.pop();       int xx = top.id;       if (tim[xx] < i) return false;       if (tim[xx] >= k) return true;       sum[xx] += mid;       tim[xx] = sum[xx] / b[xx];       if (tim[xx] < i) return false;       q.push(node{xx});     }     return true;   }   int main() {     read(n);     read(k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++) scanf( %lld , &b[i]);     long long ans = -1, l = 0, r = 1e13;     while (l <= r) {       long long mid = l + r >> 1;       if (check(mid)) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n, m, L, start, endP;   vector<vector<long long> > edges;   vector<vector<long long> > neighbors;   vector<vector<long long> > paths;   long long weights[1000][1000] = {0};   long long dijk() {     vector<long long> distances(n, LLONG_MAX);     distances[start] = 0;     vector<bool> visited(n, false);     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq;     pq.push({0, start});     while (!pq.empty()) {       long long currentWeight = pq.top().first;       long long currentNode = pq.top().second;       pq.pop();       if (visited[currentNode]) continue;       visited[currentNode] = true;       if (currentNode == endP) break;       for (long long i = 0; i < neighbors[currentNode].size(); i++) {         long long currNeighbor = neighbors[currentNode][i];         long long currDist = weights[currentNode][currNeighbor];         if (currDist == -1) continue;         if (currentWeight + currDist < distances[currNeighbor])           distances[currNeighbor] = currentWeight + currDist;         if (!visited[currNeighbor])           pq.push({distances[currNeighbor], currNeighbor});       }     }     return distances[endP];   }   long long dijk2() {     vector<long long> distances(n, LLONG_MAX);     distances[start] = 0;     vector<bool> visited(n, false);     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq;     pq.push({0, start});     paths[start].push_back(start);     while (!pq.empty()) {       long long currentWeight = pq.top().first;       long long currentNode = pq.top().second;       pq.pop();       if (visited[currentNode]) continue;       visited[currentNode] = true;       if (currentNode == endP) break;       for (long long i = 0; i < neighbors[currentNode].size(); i++) {         long long currNeighbor = neighbors[currentNode][i];         long long currDist = weights[currentNode][currNeighbor];         if (currDist == -1) currDist = 1;         if (currentWeight + currDist < distances[currNeighbor]) {           distances[currNeighbor] = currentWeight + currDist;           paths[currNeighbor] = paths[currentNode];           paths[currNeighbor].push_back(currNeighbor);         }         if (!visited[currNeighbor])           pq.push({distances[currNeighbor], currNeighbor});       }     }     return distances[endP];   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> L >> start >> endP;     edges.resize(m);     neighbors.resize(n);     paths.resize(n);     long long from, to, weight;     for (long long i = 0; i < m; i++) {       cin >> from >> to >> weight;       if (weight == 0) weight = -1;       weights[from][to] = weight;       weights[to][from] = weight;       edges[i] = {from, to, weight};       neighbors[from].push_back(to);       neighbors[to].push_back(from);     }     long long currMin = dijk();     if (currMin < L) {       cout <<  NO  << endl;       return 0;     }     long long newMin = dijk2();     if (newMin > L) {       cout <<  NO  << endl;       return 0;     }     for (long long i = 1; i < paths[endP].size(); i++) {       long long prev = paths[endP][i - 1];       long long curr = paths[endP][i];       if (weights[prev][curr] == -1) {         weights[prev][curr] = -2;         weights[curr][prev] = -2;       }     }     for (long long i = 0; i < edges.size(); i++) {       long long from = edges[i][0];       long long to = edges[i][1];       long long weight = weights[from][to];       if (weight == -1) {         weights[from][to] = 999999999999;         weights[to][from] = 999999999999;       }     }     for (long long i = 1; i < paths[endP].size(); i++) {       long long prev = paths[endP][i - 1];       long long curr = paths[endP][i];       if (weights[prev][curr] == -2) {         weights[prev][curr] = -1;         weights[curr][prev] = -1;       }     }     while (newMin != L) {       long long diff = L - newMin;       for (long long i = 1; i < paths[endP].size(); i++) {         long long prev = paths[endP][i - 1];         long long curr = paths[endP][i];         if (weights[prev][curr] == -1) {           weights[prev][curr] = diff + 1;           weights[curr][prev] = diff + 1;           break;         }       }       paths.clear();       paths.resize(n);       newMin = dijk2();     }     for (long long i = 1; i < paths[endP].size(); i++) {       long long prev = paths[endP][i - 1];       long long curr = paths[endP][i];       if (weights[prev][curr] == -1) {         weights[prev][curr] = 1;         weights[curr][prev] = 1;       }     }     cout <<  YES  << endl;     for (long long i = 0; i < edges.size(); i++) {       long long from = edges[i][0];       long long to = edges[i][1];       long long weight = weights[from][to];       if (weight == -1) weight = 999999999999;       cout << from <<     << to <<     << weight << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int socks[n + 1];     memset(socks, 0, sizeof(socks));     int maxi = -1;     int brc = 0;     for (int i = 1; i <= 2 * n; i++) {       int x;       cin >> x;       if (socks[x] == 0) {         socks[x]++;         brc++;       } else {         socks[x]++;         brc--;       }       if (maxi < brc) {         maxi = brc;       }     }     cout << maxi;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void Freopen() {     freopen(          title           .in ,          r , stdin);     freopen(          title           .out ,          w , stdout);   }   int read() {     int g = 0, f = 1;     char ch = getchar();     while (ch <  0  ||  9  < ch) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       g = g * 10 + ch -  0 ;       ch = getchar();     }     return g * f;   }   const int N = 1e5 + 5;   const int INF = 1e9 + 1;   struct Seg {     int tag[N << 2], mx[N << 2], cx[N << 2], size[N << 2], ok[N << 2];     long long su[N << 2];     void updata(int v, int w) {       su[v] -= 1ll * ok[v] * size[v] * mx[v];       tag[v] = min(tag[v], w);       mx[v] = min(mx[v], w);       su[v] += 1ll * (ok[v] = 1) * size[v] * mx[v];     }     void down(int v) {       if (!(tag[v] ^ INF)) return void();       updata(v << 1, tag[v]), updata(v << 1 | 1, tag[v]), tag[v] = INF;     }     void up(int v) {       ok[v] = ok[v << 1] & ok[v << 1 | 1];       su[v] = su[v << 1] + su[v << 1 | 1];       mx[v] = max(mx[v << 1], mx[v << 1 | 1]);       cx[v] = max(cx[v << 1], cx[v << 1 | 1]);       if (mx[v << 1] > mx[v << 1 | 1]) cx[v] = max(cx[v], mx[v << 1 | 1]);       if (mx[v << 1] < mx[v << 1 | 1]) cx[v] = max(cx[v], mx[v << 1]);       size[v] = size[v << 1] * (mx[v << 1] == mx[v]) +                 size[v << 1 | 1] * (mx[v << 1 | 1] == mx[v]);     }     void build(int v, int l, int r) {       mx[v] = INF, size[v] = r - l + 1, tag[v] = INF, cx[v] = -INF;       if (l == r) return void();       int mid = l + r >> 1;       build(v << 1, l, mid), build(v << 1 | 1, mid + 1, r);     }     void change(int v, int l, int r, int ql, int qr, int w) {       if (ql <= l && r <= qr) {         if (mx[v] <= w)           return void();         else if (w >= cx[v])           return updata(v, w), void();       }       int mid = l + r >> 1;       down(v);       if (ql <= mid) change(v << 1, l, mid, ql, qr, w);       if (qr > mid) change(v << 1 | 1, mid + 1, r, ql, qr, w);       up(v);     }   } seg[2];   long long query(int v, int l, int r, int ql, int qr) {     if (ql <= l && r <= qr) {       if (seg[0].ok[v] && seg[1].ok[v])         return seg[0].su[v] + seg[1].su[v];       else if (l == r || !seg[0].su[v] || !seg[1].su[v])         return 0;     }     int mid = l + r >> 1;     seg[0].down(v), seg[1].down(v);     if (qr <= mid) return query(v << 1, l, mid, ql, qr);     if (ql > mid) return query(v << 1 | 1, mid + 1, r, ql, qr);     return query(v << 1, l, mid, ql, qr) + query(v << 1 | 1, mid + 1, r, ql, qr);   }   signed main() {     int n = 1e5;     seg[0].build(1, 1, n), seg[1].build(1, 1, n);     for (int T = read(); T--;) {       int opt = read(), l = read(), r = read() - 1, x;       if (opt == 1)         x = read(), seg[x > 0].change(1, 1, n, l, r, abs(x));       else         cout << query(1, 1, n, l, r) <<   n ;     }     return signed();   }


#include <bits/stdc++.h>   using namespace std;   int prime[1000000];   bool status[1000100];   int pos;   void sieve() {     int i, j;     for (i = 0; i < 1000100; i++) {       status[i] = false;     }     int sq = sqrt(1000100);     for (i = 4; i <= 1000100; i += 2) {       status[i] = true;     }     for (i = 3; i <= sq; i += 2) {       if (status[i] == false) {         for (j = 2 * i; j <= 1000100; j += i) {           status[j] = true;         }       }     }     status[1] = true;     pos = 1;     for (int z = 1; z <= 1000100; z++) {       if (status[z] == false) {         prime[pos++] = z;       }     }   }   int main() {     sieve();     long long n;     while (cin >> n) {       long long ans = 1;       for (int i = 1; i < pos; i++) {         if (n == 1) break;         bool f = false;         while (n % prime[i] == 0) {           f = true;           n /= prime[i];         }         if (f) ans *= prime[i];       }       if (n > 1) ans *= n;       cout << ans <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   void solve() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     vector<pair<int, int>> res;     string s2;     int n2 = n - 2 * (k - 1);     for (int i = 0; i < 2 * (k - 1); ++i) {       if (i % 2) {         s2.push_back( ) );       } else {         s2.push_back( ( );       }     }     for (int i = 0; i < n2; ++i) {       if (i < n2 / 2) {         s2.push_back( ( );       } else {         s2.push_back( ) );       }     }     for (int i = 0; i < n; ++i) {       if (s[i] != s2[i]) {         for (int j = i + 1; j < n; ++j) {           if (s[j] == s2[i]) {             reverse(s.begin() + i, s.begin() + j + 1);             res.push_back({i, j});             break;           }         }       }     }     cout << res.size() <<   n ;     for (const auto &p : res) {       cout << p.first + 1 <<     << p.second + 1 <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void solve() {     long long i, j, k, l, n, m, a, b, u;     cin >> n;     vector<long long> v(n);     map<long long, long long> mp;     long long ans = 0LL;     priority_queue<pair<long long, long long>> pq;     for (i = 0; i < n; i++) {       cin >> v[i];       mp[v[i]]++;     }     unordered_set<long long> st;     for (auto it : mp) {       pq.push({it.second, it.first});     }     map<long long, long long> mp2;     while (!pq.empty()) {       auto p = pq.top();       pq.pop();       if (p.first == 0) continue;       if (st.find(p.first) == st.end()) {         st.insert(p.first);         ans += p.first;       } else {         pq.push({p.first - 1, p.second});       }     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) solve();     return 0;   }


#include <bits/stdc++.h>   int main() {     int m, n;     scanf( %d %d , &n, &m);     if (n == 1) {       if (m == 2) {         printf( 0 n );         printf( 1 1 n );         printf( 1 2 n );         printf( 1 1 n );         return 0;       } else {         printf( 1 n );         printf( 1 %d 1 1 n , m);         for (int i = 1; i <= m; ++i) printf( 1 %d n , i);         printf( 1 1 n );       }     } else if (m == 1) {       if (n == 2) {         printf( 0 n );         printf( 1 1 n );         printf( 2 1 n );         printf( 1 1 n );         return 0;       } else {         printf( 1 n );         printf( %d 1 1 1 n , n);         for (int i = 1; i <= n; ++i) printf( %d 1 n , i);         printf( 1 1 n );       }     } else if (n % 2 == 0) {       printf( 0 n );       for (int i = 1; i <= n; ++i) printf( %d 1 n , i);       bool direita = true;       for (int lin = n; lin >= 1; --lin) {         if (direita) {           for (int j = 2; j <= m; ++j) printf( %d %d n , lin, j);         } else {           for (int j = m; j > 1; --j) printf( %d %d n , lin, j);         }         direita = !direita;       }       printf( 1 1 n );     } else if (m % 2 == 0) {       printf( 0 n );       for (int j = 1; j <= m; ++j) printf( 1 %d n , j);       bool baixo = true;       for (int col = m; col >= 1; --col) {         if (baixo) {           for (int i = 2; i <= n; ++i) printf( %d %d n , i, col);         } else {           for (int i = n; i > 1; --i) printf( %d %d n , i, col);         }         baixo = !baixo;       }       printf( 1 1 n );     } else {       printf( 1 n );       printf( %d %d 1 1 n , n, m);       bool direita = true;       for (int i = 1; i <= n; ++i) {         if (direita) {           for (int j = 1; j <= m; ++j) printf( %d %d n , i, j);         } else {           for (int j = m; j >= 1; --j) printf( %d %d n , i, j);         }         direita = !direita;       }       printf( 1 1 n );     }   }


#include<bits/stdc++.h>   #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) ;cout.tie(NULL)   using namespace std;      #define ll long long int   #define pb push_back   #define endn   n    #define mp make_pair   #define ss second   #define ff first   #define deb(x) cout << #x <<     << x << endl   #define deb1(x,y) cout<<#x<<   <<x<<  ,  <<#y<<   <<y<<endl   #define deb2(x,y,z) cout<<#x<<   <<x<<  ,  <<#y<<   <<y<<  ,  <<#z<<   <<z<<endl   const long long INF = 1e18;      int small = INT_MIN;   int large = INT_MAX;      void solve() {    int n, k;    cin >> n >> k;    int a[n];    int i = 2, j = n;    a[0] = 1;    int t = 1;       while (k-- && t < n - 1) {     a[t] = j;     t++;     j--;     a[t] = i;     t++;     i++;    }       if (k != -1) {     cout << -1;    }    else {     while (i <= j) {      a[t] = i;      t++;      i++;     }     for (int x : a) {      cout << x <<    ;     }    }    cout << endn;      }      int main() {       fast_cin();       ll T = 1;    cin >> T;    while (T--) solve();       return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long read() {     long long x = 0;     char s = getchar();     bool w = 0;     while (s <  0  || s >  9 ) {       w |= s ==  - ;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = (x << 3) + (x << 1) + (s ^ 48);       s = getchar();     }     return w ? -x : x;   }   const long long inf = 1e18;   long long n, m, sx, sy, tim;   struct edge {     long long ne, to, dis;   } e[2100], E[2100000];   struct node {     long long t, c;   } a[2100];   long long head[2100], head1[2100000], tot, num, dis[1100];   bool vis[1100];   priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,                  greater<pair<long long, long long> > >       q;   inline void add(long long fr, long long to, long long dis) {     e[++tot].ne = head[fr];     e[tot].to = to;     e[tot].dis = dis;     head[fr] = tot;   }   inline void Add(long long fr, long long to, long long dis) {     E[++num].ne = head1[fr];     E[num].to = to;     E[num].dis = dis;     head1[fr] = num;   }   inline void Dij1(long long s) {     for (long long i = 1; i <= n; i++) {       dis[i] = inf;       vis[i] = 0;     }     dis[s] = 0;     q.push(make_pair(dis[s], s));     while (!q.empty()) {       long long u = q.top().second;       q.pop();       if (vis[u]) continue;       vis[u] = 1;       for (long long i = head[u]; i; i = e[i].ne) {         long long v = e[i].to;         if (dis[v] > dis[u] + e[i].dis && dis[u] + e[i].dis <= a[s].t) {           dis[v] = dis[u] + e[i].dis;           Add(s, v, a[s].c);           if (!vis[v]) q.push(make_pair(dis[v], v));         }       }     }   }   inline void Dij2(long long s) {     for (long long i = 1; i <= n; i++) {       dis[i] = inf;       vis[i] = 0;     }     dis[s] = 0;     q.push(make_pair(dis[s], s));     while (!q.empty()) {       long long u = q.top().second;       q.pop();       if (vis[u]) continue;       vis[u] = 1;       for (long long i = head1[u]; i; i = E[i].ne) {         long long v = E[i].to;         if (dis[v] > dis[u] + E[i].dis) {           dis[v] = dis[u] + E[i].dis;           if (!vis[v]) q.push(make_pair(dis[v], v));         }       }     }   }   signed main() {     n = read();     m = read();     sx = read();     sy = read();     for (long long i = 1; i <= m; i++) {       long long u, v, w;       u = read();       v = read();       w = read();       add(u, v, w);       add(v, u, w);     }     for (long long i = 1; i <= n; i++) a[i].t = read(), a[i].c = read();     for (long long i = 1; i <= n; i++) Dij1(i);     Dij2(sx);     if (dis[sy] != inf)       printf( %I64d n , dis[sy]);     else       printf( -1 n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool prime[10000007];   void SieveOfEratosthenes() {     memset(prime, true, sizeof(prime));     for (long long int p = 2; p * p <= 10000007; p++) {       if (prime[p] == true) {         for (long long int i = p * p; i <= 10000007; i += p) prime[i] = false;       }     }   }   const long long int N = 300500;   long long int fact[N];   long long int invFact[N];   long long int fast_pow(long long int a, long long int p, long long int m) {     long long int res = 1;     while (p) {       if (p % 2 == 0) {         a = (a * a) % m;         p /= 2;       } else {         res = (res * a) % m;         p--;       }     }     return res;   }   void Call_For_nCr() {     fact[0] = invFact[0] = 1;     for (long long int i = 1; i < N; i++) {       fact[i] = (fact[i - 1] * i) % 1000000007;       invFact[i] = fast_pow(fact[i], 1000000007 - 2, 1000000007);     }   }   long long int nCR(long long int n, long long int k, long long int m) {     if (k > n) {       return 0;     }     return fact[n] * invFact[k] % m * invFact[n - k] % m;   }   long long int sumOfDigit(long long int n, long long int b) {     long long int unitDigit, sum = 0;     while (n > 0) {       unitDigit = n % b;       sum += unitDigit;       n = n / b;     }     return sum;   }   long long int factorial(long long int n) {     return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);   }   bool compare(pair<long long int, long long int> a,                pair<long long int, long long int> b) {     if (a.first < b.first) return 1;     if (b.first < a.first) return 0;     if (a.second > b.second) return 1;     return 0;   }   void solve() {     string s;     cin >> s;     long long int ans = 0, one = 0, ok = 0, zero = 0;     for (long long int i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) {         zero = 1;         ok = 1;         if (one && zero) ans = 1;       }       if (s[i] ==  1 ) {         if (zero) one = 1;       }     }     if (!ok) {       cout << 0 <<   n ;       return;     }     if (ans)       cout << 2 <<   n ;     else       cout << 1 <<   n ;   }   void init_code() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   signed main() {     init_code();     long long int t = 1;     cin >> t;     long long int i = 1;     while (t--) {       solve();       i++;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline bool is_palindrome(const string& s) {     return std::equal(s.begin(), s.end(), s.rbegin());   }   const long long MOD = 1000000007;   const long long INF = 1e9 + 5;   const double eps = 1e-7;   const double PI = acos(-1.0);   inline void debug_vi(vector<int> a) {     for (long long i = (long long)(0); i < (long long)(a.size()); i++)       cout << a[i] <<    ;   }   inline void debug_vll(vector<long long> a) {     for (long long i = (long long)(0); i < (long long)(a.size()); i++)       cout << a[i] <<    ;   }   const int N = 1e5 + 5;   int arr[N];   pair<int, int> xpos, ypos;   int main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, l, x, y, j;     cin >> n >> l >> x >> y;     xpos = {-1, -1};     ypos = xpos;     for (long long i = (long long)(0); i < (long long)(n); i++) {       cin >> arr[i];     }     j = 0;     for (long long i = (long long)(0); i < (long long)(n); i++) {       while (j < n && arr[j] - arr[i] < x) j++;       if (j < n && arr[j] - arr[i] == x) {         xpos = {i, j};         break;       }     }     j = 0;     for (long long i = (long long)(0); i < (long long)(n); i++) {       while (j < n && arr[j] - arr[i] < y) j++;       if (j < n && arr[j] - arr[i] == y) {         ypos = {i, j};         break;       }     }     if (xpos.first != -1 && ypos.first != -1) {       cout << 0;     } else if (xpos.first != -1 || ypos.first != -1) {       cout << 1 <<   n ;       if (xpos.first != -1) {         cout << y;       } else {         cout << x;       }     } else {       j = 0;       for (long long i = (long long)(0); i < (long long)(n); i++) {         while (j < n && arr[j] - arr[i] < x + y) j++;         if (j < n && arr[j] - arr[i] == x + y) {           cout << 1 <<   n ;           cout << arr[i] + x <<   n ;           return 0;         }       }       j = 0;       for (long long i = (long long)(0); i < (long long)(n); i++) {         while (j < n && arr[j] - arr[i] < y - x) j++;         if (j < n && arr[j] - arr[i] == y - x) {           if (arr[i] - x >= 0) {             cout << 1 <<   n ;             cout << arr[i] - x;             return 0;           } else if (arr[j] + x <= l) {             cout << 1 <<   n ;             cout << arr[j] + x;             return 0;           }         }       }       cout << 2 <<   n ;       cout << x <<     << y;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   void in(T &x) {     x = 0;     bool f = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = 1;       c = getchar();     }     while ( 0  <= c && c <=  9 ) {       x = (x << 3) + (x << 1) + (c ^ 48);       c = getchar();     }     if (f) x = -x;   }   char tc[1000005];   int a[1000005], b[1000005];   int n, m;   int sum[1000005][3][3];   signed main() {     scanf( %s , tc + 1);     n = strlen(tc + 1);     for (register int i = 1; i <= n; ++i)       a[i] = (tc[i] ==  R  ? 0 : (tc[i] ==  G  ? 1 : 2));     scanf( %s , tc + 1);     m = strlen(tc + 1);     for (register int i = 1; i <= m; ++i)       b[i] = (tc[i] ==  R  ? 0 : (tc[i] ==  G  ? 1 : 2));     for (register int i = 2; i <= m; ++i) {       for (register int j = 0; j < 3; ++j)         for (register int k = 0; k < 3; ++k) sum[i][j][k] = sum[i - 1][j][k];       ++sum[i][b[i - 1]][b[i]];     }     int l = 1, r = 0;     long long ans = 0;     for (register int i = 1; i <= n; ++i) {       ++r;       while (r < m && b[r] != a[i]) ++r;       if (r > m) r = m;       if (i > 1 && b[l] == a[i - 1]) ++l;       if (l > m) break;       ans += r - l + 1;       if (i > 1 && a[i] != a[i - 1])         ans -= sum[r][a[i]][a[i - 1]] - sum[l - 1][a[i]][a[i - 1]];     }     printf( %lld , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long MAX = 100001;   long long n, k, l[MAX], inf = 1000000000000;   multiset<long long> kek;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> l[i + 1];     }     long long a;     cin >> a;     long long ans = 0;     kek.insert(inf);     for (int i = 1; i <= n; i++) {       long long b;       cin >> b;       kek.insert(b);       while (k < l[i]) {         if (*(kek.begin()) == inf) {           cout << -1;           return 0;         }         long long take = *(kek.begin());         kek.erase(kek.find(take));         k += a;         ans += take;       }     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n, m, a, b;   int main() {     scanf( %lld %lld %lld %lld , &n, &m, &a, &b);     long long int mm = n % m;     unsigned long long ans = min((m - mm) * a, mm * b);     printf( %llu n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout << setprecision(20);     auto solve = [&]() -> string {       long long int n, k, a, b;       cin >> n >> k >> a >> b;       long long int remG = a;       long long int remB = b;       string ans;       vector<long long int> rem({remG, remB});       vector<long long int> lab({ G ,  B });       long long int cur = (remG > remB) ? 0 : 1;       while (true) {         if (rem[cur] == 0) {           return  NO ;         } else if (rem[cur] < rem[1 - cur]) {           ans += lab[cur];           rem[cur] -= 1;         } else {           long long int t = min(rem[cur], k);           for (long long int i = 0; i < t; i++) ans += lab[cur];           rem[cur] -= t;         }         if (rem[0] == 0 && rem[1] == 0) return ans;         cur = 1 - cur;       }     };     cout << solve() << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int bit[2][100011], head[100011], tail[100011], name[100011], dist[100011], n,       z, D;   vector<int> adj[100011];   int query(int x, int* bit) {     int r = 0;     while (x) {       r += bit[x];       x -= x & -x;     }     return r;   }   void update(int x, int v, int* bit) {     while (x < 100011) {       bit[x] += v;       x += x & -x;     }   }   void dfs(int p, int h, int d) {     if (name[p]) return;     D = max(D, d);     name[p] = z++;     head[p] = h;     dist[p] = d;     for (int i = 0; i < adj[p].size(); ++i) dfs(adj[p][i], h, d + 1);   }   int main() {     int q, t, v, x, d;     scanf( %d%d , &n, &q);     for (int i = 0; i < n - 1; ++i) {       int a, b;       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     z = 2;     name[1] = head[1] = 1;     for (int i = 0; i < adj[1].size(); ++i) {       int u = adj[1][i];       dfs(u, z, 1);       tail[name[u]] = z - 1;     }     ++D;     while (q--) {       scanf( %d , &t);       if (t == 0) {         scanf( %d%d%d , &v, &x, &d);         int g = d - dist[v];         if (g >= 0) update(max(1, D - g), x, bit[0]);         if (g >= 0) {           int cob = head[v] + g;           if (cob <= tail[head[v]]) {             update(cob, x, bit[1]);             update(min(tail[head[v]] + 1, name[v] + d + 1), -x, bit[1]);           }         } else {           update(name[v] - d, x, bit[1]);           update(min(tail[head[v]] + 1, name[v] + d + 1), -x, bit[1]);         }       } else {         scanf( %d , &v);         int resa = query(D - dist[v], bit[0]);         int resb = query(name[v], bit[1]);         printf( %d n , resa + resb);       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, j, k, p, t, a = 0, b = 0;     cin >> n;     vector<long long int> vec;     for (i = 0; i < n; i++) {       cin >> p;       if (p % 2 == 0)         a++;       else         b++;       vec.push_back(p);     }     if (a == 0 || b == 0) {       for (i = 0; i < n; i++) cout << vec[i] <<    ;     } else {       sort(vec.begin(), vec.end());       for (i = 0; i < n; i++) cout << vec[i] <<    ;     }   }


#include <bits/stdc++.h>   int main() {     int n, p, q, p1[150], q1[150], pq[300], i, j, k, l, m;     scanf( %d , &n);     scanf( %d , &p);     for (i = 0; i < p; i++) {       scanf( %d , &p1[i]);     }     scanf( %d , &q);     for (j = 0; j < q; j++) {       scanf( %d , &q1[j]);     }     if ((p == 0) && (q == 0)) {       printf( Oh, my keyboard! n );       return 0;     } else {       for (k = 0; k < (p + q); k++) {         if (k < p) {           pq[k] = p1[k];         } else {           pq[k] = q1[k - p];         }       }       for (l = 1; l <= n; l++) {         for (m = 0; m < p + q; m++) {           if (pq[m] == l) {             break;           } else if (m == (p + q - 1)) {             printf( Oh, my keyboard! n );             return 0;           }         }       }       printf( I become the guy. n );     }     return 0;   }