#include <bits/stdc++.h>   using namespace std;   using std::ios;   constexpr int MOD = 1e9 + 7;   constexpr int mod = 998244353;   template <typename T>   T power(T a, T b) {     T r = 1;     while (b) {       if (b & 1) r *= a;       b /= 2;       a *= a;     }     return r;   }   int d[100005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int tt = 1;     while (tt--) {       int n;       cin >> n;       vector<int> b(n), d(n);       map<int, int> ans;       for (int i = 0; i < n; i++) {         cin >> b[i] >> d[i];         ans[b[i]]++;         ans[d[i]]--;       }       int mx = 0, id = 0;       int sum = 0;       for (auto i : ans) {         i.second += sum;         sum = i.second;         if (i.second > mx) {           mx = i.second;           id = i.first;         }       }       cout << id <<     << mx;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 0; i < t; i++) {       int n;       string s;       cin >> n;       cin >> s;       int flag = 0;       int p = n / 2;       p = p - 1;       for (int i = 0; i <= p; i++) {         if ((abs(s[i] - s[n - 1 - i]) != 2) && (s[i] != s[n - 1 - i])) {           cout <<  NO  << endl;           flag = 1;           break;         }       }       if (flag == 1) {         continue;       }       cout <<  YES  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int o[100100];   int ans[6000100];   int main() {     int i, j, n;     int e = 0;     long long x, y;     long long m, tmp, st, ed, mid;     scanf( %d %I64d , &n, &m);     for (i = 1; i <= n; i++) scanf( %d , &o[i]);     sort(o + 1, o + n + 1);     o[0] = 0;     o[n + 1] = 1000000001;     for (i = 0; i <= n; i++) {       x = o[i] + 1;       y = o[i + 1] - 1;       if (x <= y) {         tmp = ((x + y) * (y - x + 1)) >> 1;         if (m - tmp >= 0) {           m -= tmp;           for (j = x; j <= y; j++) ans[e++] = j;         } else {           st = x;           ed = y;           while (st < ed) {             mid = (st + ed) >> 1;             tmp = ((x + mid) * (mid - x + 1)) >> 1;             if (tmp <= m)               st = mid + 1;             else               ed = mid;           }           st--;           tmp = 0;           if (x <= st) {             tmp = ((x + st) * (st - x + 1)) >> 1;             m -= tmp;             for (j = x; j <= st; j++) ans[e++] = j;           }         }       }     }     printf( %d n , e);     for (i = 0; i < e; i++) printf( %d  , ans[i]);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 110;   int n, m, x, y, c[maxn];   int lowbit(int x) { return x & -x; }   void add(int x, int k) {     for (; x <= n; x += lowbit(x)) {       c[x] += k;     }   }   int Query(int x) {     int ans = 0;     for (; x; x -= lowbit(x)) {       ans += c[x];     }     return ans;   }   int main() {     scanf( %d%d , &n, &m);     while (m--) {       scanf( %d%d , &x, &y);       add(x, 1), add(y + 1, -1);     }     for (int i = 1; i <= n; ++i) {       if (Query(i) != 1) {         printf( %d %d , i, Query(i));         return 0;       }     }     puts( OK );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   int n, m, q, v[maxn], lp[maxn];   vector<int> e[maxn], t[maxn];   vector<long long> ps[maxn];   int mx, argmx;   void dfs(int id, int p, int d, int cpn) {     if (cpn) v[id] = cpn;     lp[id] = max(lp[id], d);     if (d > mx) {       mx = d;       argmx = id;     }     if (cpn) t[cpn].push_back(lp[id]);     for (int i = 0; i < e[id].size(); i++)       if (e[id][i] != p) dfs(e[id][i], id, d + 1, cpn);   }   int main() {     scanf( %d %d %d , &n, &m, &q);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d %d , &x, &y);       e[x].push_back(y);       e[y].push_back(x);     }     int cpn = 0;     for (int i = 1; i <= n; i++)       if (!v[i]) {         mx = -1;         dfs(i, 0, 0, 0);         mx = -1;         dfs(argmx, 0, 0, 0);         mx = -1;         dfs(argmx, 0, 0, ++cpn);         sort(t[cpn].begin(), t[cpn].end());         ps[cpn].push_back(0);         for (int j = 0; j < t[cpn].size(); j++)           ps[cpn].push_back(ps[cpn].back() + t[cpn][j]);       }     map<pair<int, int>, double> res;     for (int i = 0; i < q; i++) {       int x, y;       scanf( %d %d , &x, &y);       x = v[x];       y = v[y];       if (x == y)         printf( -1 n );       else {         if (t[x].size() > t[y].size()) swap(x, y);         if (!res.count({x, y})) {           auto ans = 0LL;           int mxd = max(t[x].back(), t[y].back());           for (int j = 0; j < t[x].size(); j++) {             int l = lower_bound(t[y].begin(), t[y].end(), mxd - 1 - t[x][j]) -                     t[y].begin();             ans += 1LL * l * mxd + 1LL * (t[y].size() - l) * (t[x][j] + 1) +                    ps[y].back() - ps[y][l];           }           res.insert({{x, y}, ans * 1.0 / t[x].size() / t[y].size()});         }         printf( %.10lf n , res[{x, y}]);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1, 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;   }   inline void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   inline void writeln(long long x) {     write(x);     puts(  );   }   const long long N = 5e5 + 5;   long long q, sum[N], a[N], cnt;   inline double f(long long x) {     return (double)a[cnt] - (sum[x] + a[cnt]) / (double)(x + 1);   }   signed main() {     q = read();     for (long long i = 1; i <= q; i++) {       long long l, r, opt = read();       if (opt == 1) {         a[++cnt] = read();         sum[cnt] = sum[cnt - 1] + a[cnt];       } else {         l = 1, r = cnt - 1;         while (l < r - 2) {           long long k = (r - l) / 3;           long long lmid = l + k, rmid = r - k;           if (f(lmid) > f(rmid)) {             r = rmid;           } else {             if (f(lmid) < f(rmid)) {               l = lmid;             } else {               l = lmid;               r = rmid;             }           }         }         double ans = 0;         for (long long j = l; j <= r; j++) ans = max(ans, f(j));         printf( %.8lf n , ans);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   struct PP {     int l, r, k;     int rank, ans;     bool operator<(const PP& b) const {       if (r == b.r) return l < b.l;       return r < b.r;     }   } a[MAXN], b[MAXN];   struct Point {     int l, r, rank;     bool operator<(const Point& b) const {       if (l == b.l) {         if (r == b.r) return rank < b.rank;         return r < b.r;       }       return l < b.l;     }   };   int n, m;   int res[MAXN];   void input() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i].l >> a[i].r;       a[i].rank = i;     }     cin >> m;     for (int i = 0; i < m; i++) {       cin >> b[i].l >> b[i].r >> b[i].k;       b[i].rank = i;     }   }   bool cmp(const PP& a, const PP& b) { return a.rank < b.rank; }   void solve() {     sort(a, a + n);     sort(b, b + m);     set<Point> s;     int cnt = n;     for (int i = 0, j = 0; i < m; i++) {       while (j < n && a[j].r <= b[i].r) {         s.insert((Point){a[j].l, a[j].r, j});         j++;       }       for (int z = 0; z < b[i].k; z++) {         auto it = s.lower_bound((Point){b[i].l, 0, 0});         if (it == s.end()) break;         a[it->rank].ans = b[i].rank + 1;         s.erase(it);         cnt--;       }     }     if (s.size() != 0 || cnt != 0) {       cout <<  NO  << endl;       return;     }     sort(a, a + n, cmp);     cout <<  YES  << endl;     cout << a[0].ans;     for (int i = 1; i < n; i++) cout <<     << a[i].ans;     cout << endl;   }   int main() {     ios::sync_with_stdio(false);     input();     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int a, b, c;   int main() {     cin >> a >> b >> c;     int i, s = 0;     for (i = 1; i <= a - 1; i++) s += i;     cout << (c + a - 1) * (b + a - 1) - 2 * s;   }


#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     string s;     cin >> s;     int i, j, res = 0;     for (i = 0; i < n; i++) {       if (s[i] ==  . ) {         res++;       } else if (s[i] ==  L ) {         res = 0;       } else {         for (j = i + 1; j < n; j++) {           if (s[j] ==  L ) {             break;           }         }         if (j >= n) {           break;         }         res += (j - i - 1) % 2;         i = j;       }     }     cout << res << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int n, m, p;   int a[200004], b[200004];   int sol[200004];   int ns = 0;   int main() {     scanf( %d%d%d , &n, &m, &p);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= m; ++i) scanf( %d , &b[i]);     int num = m;     for (int i = 1; i <= p && i + (m - 1) * 1ll * p <= n; ++i) {       mp.clear();       num = m;       for (int j = 1; j <= m; ++j) mp[b[j]]++;       for (int j = i, cc = 0; j <= n; j += p) {         ++cc;         mp[a[j]]--;         if (mp[a[j]] == 0) mp.erase(a[j]);         if (mp.empty()) sol[ns++] = j - (m - 1) * p;         if (cc == m) {           --cc;           int x = a[j - cc * p];           mp[x]++;           if (mp[x] == 0) mp.erase(x);         }       }     }     sort(sol, sol + ns);     cout << ns << endl;     for (int i = 0; i < ns; ++i) printf( %d  , sol[i]);   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     for (int i = 0; i < n; i++) {       cout << 3 * n + i;       if (i == n - 1)         cout << endl;       else         cout <<    ;     }   }


#include <bits/stdc++.h>   using namespace std;   const long long maxn = 65 + 5, maxk = (1 << 15) + 5, mod = 1e9 + 7,                   inf = 0x3f3f3f3f;   long long n, m, Q, K, T, S;   long long read() {     long long x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * f;   }   long long a[maxn], jc[maxn], inv[maxn], du[maxn], ST[maxn];   long long q[maxn], top, cont[maxk], val[maxn];   long long cnt, tot, dp[maxn][maxk];   long long ans = 1;   long long kpow(long long x, long long k) {     long long ans = 1, now = x;     while (k) {       if (k & 1) ans = 1ll * ans * now % mod;       now = 1ll * now * now % mod, k >>= 1;     }     return ans;   }   bool cmp(long long x, long long y) { return x > y; }   long long C(long long a, long long b) {     if (a < b) return 0;     return 1ll * jc[a] * inv[b] % mod * inv[a - b] % mod;   }   void dfs(long long x, long long st) {     if (ST[x]) return;     ++tot, ST[x] = st;     for (long long i = (1); i <= (n); ++i)       if ((a[i] % a[x] == 0) || (a[x] % a[i] == 0)) dfs(i, st);   }   void clear() {     top = 0;     tot = 0;     memset(cont, 0, sizeof(cont));     memset(dp, 0, sizeof(dp));   }   signed main() {     n = read();     jc[0] = inv[0] = 1;     for (long long i = (1); i <= (n); ++i)       jc[i] = 1ll * jc[i - 1] * i % mod, inv[i] = kpow(jc[i], mod - 2);     for (long long i = (1); i <= (n); ++i) a[i] = read();     sort(a + 1, a + 1 + n);     for (long long i = (1); i <= (n); ++i)       for (long long j = (i + 1); j <= (n); ++j)         if (!(a[j] % a[i])) ++du[j];     for (long long T = (1); T <= (n); ++T) {       if (ST[T]) continue;       clear();       dfs(T, T);       for (long long i = (1); i <= (n); ++i)         if (!du[i] && ST[i] == T) q[++top] = a[i];       if (tot - top <= 1) continue;       for (long long i = (1); i <= (n); ++i) {         if (!du[i] || ST[i] != T) continue;         for (long long j = (1); j <= (top); ++j)           if (!(a[i] % q[j])) val[i] |= (1 << (j - 1));       }       S = (1 << top) - 1;       for (long long s = (0); s <= (S); ++s)         for (long long j = (1); j <= (n); ++j)           if (ST[j] == T && du[j] && ((s & val[j]) == val[j])) ++cont[s];       for (long long i = (1); i <= (n); ++i)         if (ST[i] == T && du[i]) ++dp[1][val[i]];       for (long long i = (1); i <= (tot - top - 1); ++i)         for (long long s = (0); s <= (S); ++s) {           if (!dp[i][s]) continue;           if (cont[s] > i)             dp[i + 1][s] =                 (dp[i + 1][s] + 1ll * dp[i][s] * (cont[s] - i) % mod) % mod;           for (long long j = (1); j <= (n); ++j)             if (ST[j] == T && du[j] && (s & val[j]) && ((s & val[j]) != val[j]))               dp[i + 1][s | val[j]] = (dp[i + 1][s | val[j]] + dp[i][s]) % mod;         }       long long res = 0;       tot -= top;       for (long long s = (0); s <= (S); ++s) res = (res + dp[tot][s]) % mod;       ans = 1ll * ans * res % mod * C(cnt + tot - 1, tot - 1) % mod;       cnt += tot - 1;     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     while (cin >> n) {       long long g[200000] = {0};       long long a[200000] = {0}, i;       long long sum = 0;       for (i = 1; i <= n; i++) cin >> a[i];       long long ans = 0;       long long m1 = 0, m2 = 0;       while (sum < n) {         long long p = 0;         for (int i = 1; i <= n; i++) {           while (g[i] == 0) {             g[i] = 1;             i = a[i];             p++;           }           if (p) {             sum += p;             ans += p * p;             if (p >= m1) {               m2 = m1;               m1 = p;             } else if (p > m2)               m2 = p;             break;           }         }       }       ans += 2 * m1 * m2;       cout << ans << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, k, t;   int a[25][25];   int vis[25];   int dfs(int x, int sum, int limit) {     if (sum > limit) return 0;     if (x == n + 1) return 1;     int ans = dfs(x + 1, sum, limit);     for (int i = 1; i <= n; i++)       if (vis[i] == 0 && a[x][i])         vis[i] = 1, ans += dfs(x + 1, sum + a[x][i], limit), vis[i] = 0;     return ans;   }   int check(int x) { return dfs(1, 0, x) >= t; }   int main() {     scanf( %d%d%d , &n, &k, &t);     for (int i = 1; i <= k; i++) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       a[x][y] = z;     }     int l = 0, r = 2e5;     int ans = -1;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid))         r = mid - 1, ans = mid;       else         l = mid + 1;     }     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c, a, b;     scanf( %d %d %d %d , &n, &c, &a, &b);     a--;     b--;     int ca = a % c, cb = b % c;     if (ca == 0) {       if ((cb == (c - 1)) or b == (n - 1))         printf( 1 n );       else if (b / c == a / c)         printf( 1 n );       else         printf( 2 n );     } else if (cb == (c - 1)) {       if (b / c == a / c)         printf( 1 n );       else         printf( 2 n );     } else if (a / c == b / c)       printf( 1 n );     else if (b / c == a / c + 1)       printf( 2 n );     else if (b == (n - 1))       printf( 2 n );     else if (b % c == (a % c) - 1)       printf( 2 n );     else       printf( 3 n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool checkThree(char cc, char lc, char nc) { return (cc != lc && cc != nc); }   int main() {     int t;     cin >> t;     while (t--) {       string s, t;       cin >> s >> t;       for (int i = 0; i < s.length(); i++) {         int x = t.find(s[i]);         if (x < t.length()) {           cout <<  YES  << endl;           goto label;         }       }       cout <<  NO  << endl;     label:;     }     return 0;   }


#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000000000 )   using namespace std;   int n, m;   vector<pair<int, int> > ans;   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       ans.clear();       cin >> n >> m;       int k = 0;       for (int i = 0; i < n; i++)         for (int j = i + 1; j < n; j++) {           if (k == (2 * n + m)) {             i = n;             break;           }           k++;           ans.push_back(make_pair(i + 1, j + 1));         }       for (int i = 0; i < ans.size(); i++)         cout << ans[i].first <<     << ans[i].second << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   signed main(void) {     vector<long long> in(101, 0);     long long sum = 0;     for (long long i = 0; i < (5); i++) {       long long a;       cin >> a;       in[a]++;       sum += a;     }     long long ans = sum;     for (long long i = 0; i < (101); i++)       if (in[i] > 1) ans = min(ans, sum - min(in[i], 3LL) * i);     cout << ans << endl;   }


#include <bits/stdc++.h>   using namespace std;   int a[1000 + 5], b[1000 + 5];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) scanf( %d , &b[i]);     int ans = 0;     for (int i = 1, j = 1; i <= n; i++) {       if (b[j] >= a[i]) {         j++;         ans++;       }     }     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long a[300010], po[300010], ans;   int n, p = 1e9 + 7;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     sort(a + 1, a + n + 1);     po[0] = 1;     for (int i = 1; i <= n; i++) po[i] = po[i - 1] * 2 % p;     for (int i = 1; i <= n; i++)       (ans += a[i] * (p + po[i - 1] - po[n - i]) % p) %= p;     printf( %I64d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int matrix[101][101];   struct HATE {     int t, r, c, x;     HATE(int t, int r, int c, int x) {       this->t = t;       this->r = r;       this->c = c;       this->x = x;     }   };   HATE* hates[10001];   int main() {     int n, m, q;     cin >> n >> m >> q;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         matrix[i][j] = 1e9 + 1;       }     }     for (int heh = 0; heh < q; heh++) {       int t;       cin >> t;       if (t == 1) {         int r;         cin >> r;         hates[heh] = new HATE(t, r, 0, 0);       } else if (t == 2) {         int c;         cin >> c;         hates[heh] = new HATE(t, 0, c, 0);       } else {         int r, c, x;         cin >> r >> c >> x;         hates[heh] = new HATE(t, r, c, x);       }     }     for (int heh = q - 1; heh >= 0; heh--) {       int t = hates[heh]->t;       int r = hates[heh]->r;       int c = hates[heh]->c;       int x = hates[heh]->x;       if (t == 1) {         r--;         int temp = matrix[r][m - 1];         for (int i = m - 1; i >= 1; i--) {           matrix[r][i] = matrix[r][i - 1];         }         matrix[r][0] = temp;       } else if (t == 2) {         c--;         int temp = matrix[n - 1][c];         for (int i = n - 1; i >= 1; i--) {           matrix[i][c] = matrix[i - 1][c];         }         matrix[0][c] = temp;       } else {         r--;         c--;         matrix[r][c] = x;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (matrix[i][j] == 1e9 + 1) {           cout << 1488 <<    ;         } else {           cout << matrix[i][j] <<    ;         }       }       cout << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   pair<pair<int, int>, pair<int, int> > a[60000];   int ans[60000], b[60000], n, m, maxx;   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++)       cin >> a[i].first.first >> a[i].first.second >> a[i].second.first >>           a[i].second.second;     for (int i = 1; i <= n; i++) ans[i] = (int)(1e9);     for (int i = m; i >= 1; i--) {       if (a[i].first.first == 1) {         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] < (int)(1e9)) ans[j] -= a[i].second.second;       } else {         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] > a[i].second.second) ans[j] = a[i].second.second;       }     }     for (int i = 1; i <= n; i++) b[i] = ans[i];     for (int i = 1; i <= m; i++) {       if (a[i].first.first == 1) {         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] < (int)(1e9)) ans[j] += a[i].second.second;       } else {         maxx = -(int)(1e9);         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] > maxx) maxx = ans[j];         if (maxx != a[i].second.second) {           cout <<  NO n ;           return 0;         }       }     }     cout <<  YES n ;     for (int i = 1; i <= n; i++) cout << b[i] <<    ;     return 0;   }


#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000000 )   using namespace std;   const double EPS = 1e-9;   const int INF = (int)(2e9 + 0.5);   const int MAXN = 201000;   int n, k, a;   vector<int> mass;   set<int> minima;   map<int, int> bad;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %d , &a);       mass.push_back(-a);     }     for (int i = 0; i < k; ++i) {       bad[mass[i]]++;       if (bad[mass[i]] != 1) {         if (minima.count(mass[i])) minima.erase(mass[i]);       } else         minima.insert(mass[i]);     }     for (int l = 0, r = k - 1; r < n; ++l, ++r) {       if (!minima.size())         printf( Nothing n );       else         printf( %d n , -(*minima.begin()));       bad[mass[l]]--;       if (bad[mass[l]] == 1) minima.insert(mass[l]);       if (bad[mass[l]] != 1)         if (minima.count(mass[l])) minima.erase(mass[l]);       if (r + 1 < n) {         bad[mass[r + 1]]++;         if (bad[mass[r + 1]] != 1) {           if (minima.count(mass[r + 1])) minima.erase(mass[r + 1]);         } else           minima.insert(mass[r + 1]);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100000;   const int delt = 255;   long long fa[N], fb[N], fc[N];   int main() {     ios::sync_with_stdio(false);     string a, b, c;     cin >> a;     cin >> b;     cin >> c;     for (int i = 0; i < a.size(); i++) {       fa[a[i] + delt]++;     }     for (int i = 0; i < b.size(); i++) {       fb[b[i] + delt]++;     }     for (int i = 0; i < c.size(); i++) {       fc[c[i] + delt]++;     }     pair<long long, pair<long long, long long> > ans = {0, {0, 0}};     for (int j = 0; j <= a.size(); j++) {       long long kb = j;       bool was = 0;       for (char i =  a ; i <=  z ; i++) {         if (fa[i + delt] < kb * fb[i + delt]) {           was = 1;           break;         }       }       if (was) continue;       long long kc = (long long)1e15;       for (char i =  a ; i <=  z ; i++) {         if (fc[i + delt] > 0)           kc = min(kc, (fa[i + delt] - kb * fb[i + delt]) / fc[i + delt]);       }       ans = max(ans, make_pair(kb + kc, make_pair(kb, kc)));     }     for (char i =  a ; i <=  z ; i++) {       fa[i + delt] -= ans.second.first * fb[i + delt];       fa[i + delt] -= ans.second.second * fc[i + delt];     }     string str =   ;     for (int i = 0; i < ans.second.first; i++) {       str += b;     }     for (int i = 0; i < ans.second.second; i++) {       str += c;     }     for (char i =  a ; i <=  z ; i++) {       while (fa[i + delt] > 0) {         str += i;         fa[i + delt]--;       }     }     cout << str <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int nos;   void split(int n) {     if (nos == 0 || n == 1)       cout << n <<    ;     else {       --nos;       split(n / 2);       split(n / 2);     }   }   int main() {     ios::sync_with_stdio(false);     int n, k;     cin >> k >> n;     if (n > k)       cout <<  NO  << endl;     else {       vector<int> nums;       for (int i = 0; k; k /= 2, ++i) {         if (k % 2) nums.push_back(pow(2, i));       }       nos = n - nums.size();       if (nos < 0)         cout <<  NO  << endl;       else {         cout <<  YES  << endl;         for (auto &i : nums) split(i);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int iinf = 1e9 + 7;   const int oo = 0x3f3f3f3f;   const long long linf = 1ll << 60;   const double dinf = 1e60;   template <typename T>   inline void scf(T &x) {     bool f = 0;     x = 0;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) {       f = 1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     if (f) x = -x;     return;   }   template <typename T1, typename T2>   void scf(T1 &x, T2 &y) {     scf(x);     return scf(y);   }   template <typename T1, typename T2, typename T3>   void scf(T1 &x, T2 &y, T3 &z) {     scf(x);     scf(y);     return scf(z);   }   template <typename T1, typename T2, typename T3, typename T4>   void scf(T1 &x, T2 &y, T3 &z, T4 &w) {     scf(x);     scf(y);     scf(z);     return scf(w);   }   inline char mygetchar() {     char c = getchar();     while (c ==     || c ==   n ) c = getchar();     return c;   }   template <typename T>   inline bool chkmax(T &x, const T &y) {     return y > x ? x = y, 1 : 0;   }   template <typename T>   inline bool chkmin(T &x, const T &y) {     return y < x ? x = y, 1 : 0;   }   const int maxn = 1e6 + 10;   struct node {     node *go[26], *par;     int len, siz, tag;     node() {       memset(go, 0, sizeof go);       par = 0;       len = siz = tag = 0;     }     inline void cpy(node *u) {       memcpy(go, u->go, sizeof go);       par = u->par;       return;     }   } * root, *last;   vector<node *> lvl[maxn];   char s[maxn];   inline void expand(int id) {     node *p = last, *np = new node;     np->len = p->len + 1;     np->siz = 1;     while (p && !p->go[id]) p->go[id] = np, p = p->par;     if (!p)       np->par = root;     else {       node *q = p->go[id];       if (q->len == p->len + 1)         np->par = q;       else {         node *nq = new node;         nq->cpy(q);         q->par = np->par = nq;         nq->len = p->len + 1;         while (p && p->go[id] == q) p->go[id] = nq, p = p->par;       }     }     last = np;     return;   }   inline void dfs(node *u) {     if (!~u->tag) return;     u->tag = -1;     lvl[u->len].push_back(u);     for (int i = 0, _end_ = (26); i < _end_; ++i)       if (u->go[i]) dfs(u->go[i]);     return;   }   int main() {     root = new node;     last = root;     char c = getchar();     while (c <  a  || c >  z ) c = getchar();     while (c >=  a  && c <=  z ) expand(c -  a ), c = getchar();     dfs(root);     for (int i = last->len; i; --i)       for (int j = 0, _end_ = ((int)lvl[i].size()); j < _end_; ++j)         if (lvl[i][j]->par) lvl[i][j]->par->siz += lvl[i][j]->siz;     int q;     scf(q);     while (q--) {       scanf( %s , s);       int n = strlen(s), matched = 0, ans = 0;       node *u = root;       for (int i = 0, _end_ = (n << 1); i < _end_; ++i) {         int id = s[i % n] -  a ;         while (u && !u->go[id]) u = u->par, matched = u ? u->len : 0;         if (!u)           u = root;         else {           u = u->go[id];           ++matched;           while (u->par && u->par->len >= n) u = u->par, matched = u->len;           if (matched >= n && u->tag != q) u->tag = q, ans += u->siz;         }       }       printf( %d n , ans);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e3 + 7;   const int mod = 998244353;   int col[maxn];   namespace DSU {   int far[maxn];   void init() {     for (int i = 0; i < maxn; i++) far[i] = i;   }   int Find(int x) { return x == far[x] ? x : far[x] = Find(far[x]); }   void Union(int x, int y) {     x = Find(x), y = Find(y);     if (x < y) swap(x, y);     far[y] = x;   }   };  // namespace DSU   string s;   int var, w, b;   bool isp[maxn];   vector<int> G[maxn];   bool dfs(int u) {     for (auto &v : G[u]) {       if (col[v] == -1) {         col[v] = col[u] ^ 1;         if (!dfs(v)) return false;       } else {         if (col[v] == col[u]) return false;       }     }     return true;   }   long long solve(int len) {     for (int i = 0; i <= b; i++) G[i].clear();     memset(isp, 0, sizeof(isp));     DSU::init();     for (int i = 0; i < s.length() / 2; i++) DSU::Union(i, s.length() - i - 1);     for (int i = 0; i < len / 2; i++) DSU::Union(var + i, var + len - 1 - i);     isp[w] = isp[b] = 1;     DSU::Union(var + len - 1, b);     for (int i = 0; i < s.length(); i++) isp[i] = 1;     for (int i = 0; i < len; i++) isp[i + var] = 1;     for (int i = 0; i < len; i++)       if (s[i] ==  0 ) DSU::Union(i, var + i);     for (int i = len; i < s.length(); i++) {       if (s[i] ==  1 )         DSU::Union(i, b);       else if (s[i] ==  0 )         DSU::Union(i, w);     }     DSU::Union(s.length() - 1, b);     if (DSU::Find(b) == DSU::Find(w)) return 0;     for (int i = 0; i < len; i++) {       if (s[i] ==  1 ) {         G[DSU::Find(i)].push_back(DSU::Find(var + i));         G[DSU::Find(var + i)].push_back(DSU::Find(i));       }     }     G[DSU::Find(w)].push_back(DSU::Find(b));     G[DSU::Find(b)].push_back(DSU::Find(w));     long long ret = 1;     memset(col, -1, sizeof(col));     for (int i = b; i >= 0; i--) {       if (isp[i]) {         int cur = DSU::Find(i);         if (col[cur] == -1) {           if (cur == b)             col[cur] = 1;           else             col[cur] = 0;           if (!dfs(cur))             return 0;           else {             if (cur != b && cur != w) ret = ret * 2 % mod;           }         }       }     }     return ret;   }   int main() {     cin >> s;     var = s.length();     reverse(s.begin(), s.end());     w = var * 2 + 1, b = var * 2 + 2;     long long ans = 0;     for (int i = 1; i < s.length(); i++) ans = (ans + solve(i)) % mod;     cout << ans << endl;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     string a;     string b;     cin >> a >> b;     int order = 0;     while (a[order] ==  0 ) {       order++;     }     a = a.substr(order);     order = 0;     while (b[order] ==  0 ) {       order++;     }     b = b.substr(order);     if (a.size() > b.size()) {       cout <<  > ;     } else if (a.size() < b.size()) {       cout <<  < ;     } else {       for (int i = 0; i < a.size(); i++) {         if (a[i] > b[i]) {           cout <<  > ;           return 0;         } else if (a[i] < b[i]) {           cout <<  < ;           return 0;         }       }       cout <<  = ;     }   }


#include <bits/stdc++.h>   using namespace std;   using SI = set<int>;   using ULL = unsigned long long;   using LL = long long;   using VI = vector<int>;   using LD = long double;   using PULL = pair<ULL, ULL>;   using UI = unsigned int;   using PLL = pair<LL, LL>;   using PDD = pair<LD, LD>;   using MII = map<int, int>;   using TDD = pair<PDD, LD>;   using TLL = pair<PLL, LL>;   using PII = pair<int, int>;   using TII = pair<PII, int>;   using QDD = pair<PDD, PDD>;   using QII = pair<PII, PII>;   using QLL = pair<PLL, PLL>;   using STII = set<TII>;   using VTII = vector<TII>;   using MTII = map<TII, TII>;   using MITII = map<int, TII>;   using UMITII = unordered_map<int, TII>;   using SQII = set<QII>;   using VQII = vector<QII>;   using MQII = map<QII, QII>;   using MIQII = map<int, QII>;   using UMIQII = unordered_map<int, QII>;   using SLL = set<LL>;   using VLL = vector<LL>;   using MLL = map<LL, LL>;   using MILL = map<int, LL>;   using UMILL = unordered_map<int, LL>;   using SULL = set<ULL>;   using VULL = vector<ULL>;   using MULL = map<ULL, ULL>;   using MIULL = map<int, ULL>;   using UMIULL = unordered_map<int, ULL>;   using SPULL = set<PULL>;   using VPULL = vector<PULL>;   using MPULL = map<PULL, PULL>;   using MIPULL = map<int, PULL>;   using UMIPULL = unordered_map<int, PULL>;   using SQLL = set<QLL>;   using VQLL = vector<QLL>;   using MQLL = map<QLL, QLL>;   using MIQLL = map<int, QLL>;   using UMIQLL = unordered_map<int, QLL>;   using SLD = set<LD>;   using VLD = vector<LD>;   using MLD = map<LD, LD>;   using MILD = map<int, LD>;   using UMILD = unordered_map<int, LD>;   using SPDD = set<PDD>;   using VPDD = vector<PDD>;   using MPDD = map<PDD, PDD>;   using MIPDD = map<int, PDD>;   using UMIPDD = unordered_map<int, PDD>;   using SVI = set<VI>;   using VVI = vector<VI>;   using MVI = map<VI, VI>;   using MIVI = map<int, VI>;   using UMIVI = unordered_map<int, VI>;   using STLL = set<TLL>;   using VTLL = vector<TLL>;   using MTLL = map<TLL, TLL>;   using MITLL = map<int, TLL>;   using UMITLL = unordered_map<int, TLL>;   using SUI = set<UI>;   using VUI = vector<UI>;   using MUI = map<UI, UI>;   using MIUI = map<int, UI>;   using UMIUI = unordered_map<int, UI>;   using SPII = set<PII>;   using VPII = vector<PII>;   using MPII = map<PII, PII>;   using MIPII = map<int, PII>;   using UMIPII = unordered_map<int, PII>;   using SPLL = set<PLL>;   using VPLL = vector<PLL>;   using MPLL = map<PLL, PLL>;   using MIPLL = map<int, PLL>;   using UMIPLL = unordered_map<int, PLL>;   using SSI = set<SI>;   using VSI = vector<SI>;   using MSI = map<SI, SI>;   using MISI = map<int, SI>;   using UMISI = unordered_map<int, SI>;   using SVVI = set<VVI>;   using VVVI = vector<VVI>;   using MVVI = map<VVI, VVI>;   using MIVVI = map<int, VVI>;   using UMIVVI = unordered_map<int, VVI>;   using UMII = unordered_map<int, int>;   ULL randULL() {     return ((ULL)rand()) ^ ((ULL)rand() << 15) ^ ((ULL)rand() << 30) ^            ((ULL)rand() << 45) ^ ((ULL)rand() << 60);   }   using STDD = set<TDD>;   using VTDD = vector<TDD>;   using MTDD = map<TDD, TDD>;   using MITDD = map<int, TDD>;   using UMITDD = unordered_map<int, TDD>;   using SQDD = set<QDD>;   using VQDD = vector<QDD>;   using MQDD = map<QDD, QDD>;   using MIQDD = map<int, QDD>;   using UMIQDD = unordered_map<int, QDD>;   int popc(int x) { return __builtin_popcount(x); }   int popc(UI x) { return __builtin_popcount(x); }   int popc(LL x) { return __builtin_popcountll(x); }   int popc(ULL x) { return __builtin_popcountll(x); }   int ctz(int x) { return __builtin_ctz(x); }   int ctz(UI x) { return __builtin_ctz(x); }   int ctz(LL x) { return __builtin_ctzll(x); }   int ctz(ULL x) { return __builtin_ctzll(x); }   int clz(int x) { return __builtin_clz(x); }   int clz(UI x) { return __builtin_clz(x); }   int clz(LL x) { return __builtin_clzll(x); }   int clz(ULL x) { return __builtin_clzll(x); }   int bit_parity(int x) { return __builtin_parity(x); }   int bit_parity(UI x) { return __builtin_parity(x); }   int bit_parity(LL x) { return __builtin_parityll(x); }   int bit_parity(ULL x) { return __builtin_parityll(x); }   template <class T, class U>   bool one_of(T x, U y) {     return x == y;   }   template <class T, class U, class... V>   bool one_of(T x, U y, V... z) {     return x == y || one_of(x, z...);   }   template <class T>   bool diff(T _) {     return true;   }   template <class T, class... U>   bool diff(T x, U... y) {     return !one_of(x, y...) && diff(y...);   }   template <class T, class U>   bool equal(T x, U y) {     return x == y;   }   template <class T, class U, class... V>   bool equal(T x, U y, V... z) {     return x == y && equal(x, z...);   }   template <class T, class U>   bool in_order(T x, U y) {     return x <= y;   }   template <class T, class U, class... V>   bool in_order(T x, U y, V... z) {     return x <= y && in_order(y, z...);   }   template <class T, class U>   bool in_strorder(T x, U y) {     return x < y;   }   template <class T, class U, class... V>   bool in_strorder(T x, U y, V... z) {     return x < y && in_strorder(y, z...);   }   template <class T>   void swap3(T &x, T &y, T &z) {     swap(x, y);     swap(x, z);   }   template <class T>   pair<T, T> dup(T x) {     return make_pair(x, x);   }   template <class T>   pair<pair<T, T>, T> thrice(T x) {     return make_pair(make_pair(x, x), x);   }   template <class T>   pair<pair<T, T>, pair<T, T>> fourfold(T x) {     return make_pair(make_pair(x, x), make_pair(x, x));   }   template <class T, class U, class V>   T safvec(const vector<T> &v, int i, U low, V high) {     if (i < 0) return low;     if (i >= ((int)(v).size())) return high;     return v[i];   }   template <class T, class U>   T safar(T *a, int i, U low) {     if (i < 0) return low;     return a[i];   }   template <class T, class U, class V>   auto med(const T &a, const U &b, const V &c) -> decltype(1 ? a : (1 ? b : c)) {     return my_min(my_max(a, b), my_max(my_min(a, b), c));   }   namespace std {   template <class T, class U>   struct hash<pair<T, U>> {     size_t operator()(const pair<T, U> &a) const {       return (hash<T>()(a.first) * 1420343LL ^ hash<U>()(a.second) * 923275LL) %              1463984161;     }   };   }  // namespace std   template <class T, class U>   auto my_min(const U &x, const T &y) -> decltype(1 ? x : y) {     return x < y ? x : y;   }   template <class T, class U>   bool mini(U &x, T y) {     if (y < x) {       x = y;       return true;     }     return false;   }   template <class T, class U, class V>   auto my_min(const T &a, const U &b, const V &c)       -> decltype(1 ? a : (1 ? b : c)) {     return my_min(a, my_min(b, c));   }   template <class T, class U, class V, class W>   auto my_min(const T &a, const U &b, const V &c, const W &d)       -> decltype(1 ? a : (1 ? b : (1 ? c : d))) {     return my_min(a, my_min(b, c, d));   }   template <class T, class U>   auto my_max(const U &x, const T &y) -> decltype(1 ? x : y) {     return x > y ? x : y;   }   template <class T, class U>   bool maxi(U &x, T y) {     if (y > x) {       x = y;       return true;     }     return false;   }   template <class T, class U, class V>   auto my_max(const T &a, const U &b, const V &c)       -> decltype(1 ? a : (1 ? b : c)) {     return my_max(a, my_max(b, c));   }   template <class T, class U, class V, class W>   auto my_max(const T &a, const U &b, const V &c, const W &d)       -> decltype(1 ? a : (1 ? b : (1 ? c : d))) {     return my_max(a, my_max(b, c, d));   }   template <class T>   T brange(int l, int r) {     return ~(~((T)0) << (r - l + 1)) << l;   }   template <class T>   T brange(int l, int r, int second) {     return (brange<T>(l, l + (r - l) / second * second - 1) /             brange<T>(0, second - 1)) |            ((T)1 << (l + (r - l) / second * second));   }   template <class T>   auto O2kQ(T x, int i, int j)       -> vector<typename remove_reference<decltype(*x.end())>::type> {     vector<typename remove_reference<decltype(*x.end())>::type> ans;     for (auto c : x)       if ((--i < 0) & (j-- >= 0)) ans.push_back(c);     return ans;   }   template <class T>   vector<T> O2kQ(const T *x, int i, int j) {     vector<T> ans;     for (int _ = i; _ <= (int)(j); _++) ans.push_back(x[_]);     return ans;   }   int CON_BOUND = 10;   string E0ms() { return   ; }   template <class T>   string E0ms(T x) {     stringstream os;     os << boolalpha << x;     return os.str();   }   template <class T, class... U>   string E0ms(T x, U... y) {     return E0ms(x) +  ,   + E0ms(y...);   }   string SqC6(bool x) { return x ?  true  :  false ; }   template <class T>   typename enable_if<is_integral<T>::value, string>::type SqC6(T r) {     string a;     for (int i = 8 * sizeof(T) - 1; i >= (int)(0); i--) {       if (i % 5 == 4) a +=  . ;       a +=  0  + !!(((T)1 << i) & r);     }     return a;   }   template <class T, class C>   string SqC6(pair<T, C>);   template <class T>   auto SqC6(T x) -> decltype(x.end(), string()) {     string a =   ;     for (auto c : x) {       if (((int)(a).size())) a +=  ,  ;       a += SqC6(c);     }     return  {  + a +  }_  + to_string(((int)(x).size()));   }   template <class T, class C>   string SqC6(pair<T, C> x) {     return  <  + SqC6(x.first) +  ,   + SqC6(x.second) +  > ;   }   template <class T, int N>   T &arrp(T a[][N], PII x) {     return a[x.first][x.second];   }   const int mod = 1e9 + 7;   LL mpow(LL b, int e) {     LL ans = 1;     while (e) {       if (e & 1) ans = ans * b % mod;       b = b * b % mod;       e /= 2;     }     return ans;   }   struct zet_p {     int v;     int get() { return v; }     zet_p(LL x = 0) { v = x % mod; }     zet_p operator+(zet_p x) { return (v + x.v) % mod; }     zet_p operator-(zet_p x) { return v - x.v; }     zet_p operator*(zet_p x) { return v * 1ll * x.v; }     zet_p operator/(zet_p a) { return v * mpow(a.v, mod - 2); }   };   const bool deb = false;   struct frac_mod {     int n, d;     frac_mod(int x = 0) {       n = x % mod;       d = 1;     }     frac_mod(int x, int y) {       n = x;       d = y;     }     frac_mod operator+(frac_mod x) {       return {(int)((x.d * 1ll * n + d * 1ll * x.n) % mod), x.d * d % mod};     }     frac_mod operator-(frac_mod x) {       return {(int)((n * 1ll * x.d - x.n * 1ll * d) % mod), x.d * d % mod};     }     frac_mod operator*(frac_mod x) {       return {(int)((n * (LL)x.n) % mod), (int)((d * (LL)x.d) % mod)};     }     frac_mod operator/(frac_mod x) {       return {(int)(n * (LL)x.d % mod), (int)(d * (LL)x.n % mod)};     }     int get() {       int ans = n * mpow(d, mod - 2) % mod;       if (ans < 0) ans += mod;       return ans;     }   };   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator+(       frac_mod x, T y) {     return x + frac_mod(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator+(       T x, frac_mod y) {     return frac_mod(x) + y;   }   template <class T>   frac_mod &operator+=(frac_mod &x, T y) {     return x = x + y;   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator-(       frac_mod x, T y) {     return x - frac_mod(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator-(       T x, frac_mod y) {     return frac_mod(x) - y;   }   template <class T>   frac_mod &operator-=(frac_mod &x, T y) {     return x = x - y;   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator*(       frac_mod x, T y) {     return x * frac_mod(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator*(       T x, frac_mod y) {     return frac_mod(x) * y;   }   template <class T>   frac_mod &operator*=(frac_mod &x, T y) {     return x = x * y;   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator/(       frac_mod x, T y) {     return x / frac_mod(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator/(       T x, frac_mod y) {     return frac_mod(x) / y;   }   template <class T>   frac_mod &operator/=(frac_mod &x, T y) {     return x = x / y;   }   template <class T, class C>   ostream &operator<<(ostream &ans, pair<T, C> x) {     return ans <<  <  << x.first <<  ,   << x.second <<  > ;   }   template <class T>   auto operator<<(ostream &o, T x) ->       typename enable_if<!is_same<T, string>::value, decltype(x.end(), o)>::type {     o <<  { ;     int i = 0;     for (auto c : x) {       if (i++ == ((int)(x).size()) - 1 || ((int)(x).size()) < CON_BOUND + 2 ||           i < CON_BOUND) {         if (i - 1 &&             (i != ((int)(x).size()) || ((int)(x).size()) < CON_BOUND + 2))           o <<  ,  ;         o << c;       }       if (i == CON_BOUND && ((int)(x).size()) > CON_BOUND + 1) o <<   ...  ;     }     return o <<  }_  << x.size();   }   string b7Pe(string x) {     int dep = 0;     for (char c : x) {       for (char d :  ([{ )         if (c == d) dep++;       for (char d :  }]) )         if (c == d) dep--;       for (char d :  +-*/%^<>=&|?, )         if (c == d && !dep) return  (  + x +  ) ;     }     return x;   }   template <class T, class U>   pair<U, T> pinv(pair<T, U> x) {     return make_pair(x.second, x.first);   }   template <class T>   struct Wt71 {     T c;     int l, r, L, R;   };   template <class T>   ostream &operator<<(ostream &o, Wt71<T> M) {     o <<   n ;     for (int i = M.l; i <= (int)(M.r); i++) {       o <<      << i <<  : |  ;       for (int j = M.L; j <= (int)(M.R); j++) {         o << M.c[i][j] << ((j - M.L + 1) % 5 ?     :  ;  );       }       o <<   n ;     }     return o;   }   template <class T>   Wt71<T> q9cX(T a, int i, int j, int k, int q) {     return {a, i, j, k, q};   }   int primes[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,                   43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,                   103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,                   173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,                   241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,                   317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,                   401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467,                   479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,                   571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,                   647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,                   739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823,                   827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,                   919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997},       big_primes[] = {1307533217, 1336158883, 1339172111, 1367797777, 1376837461,                       1399436671, 1426555723, 1440115249, 1444635091, 1489833511,                       1553111299, 1562150983, 1587763421, 1610362631, 1652547823,                       1666107349, 1700759471, 1782116627, 1797182767, 1810742293,                       1818275363, 1892099449, 1904152361, 1919218501, 1940311097,                       1944830939, 1968936763, 1977976447, 1985509517, 1990029359},       gens[] = {1,   2,   3,   5,   2,   11,  3,   14,  19,  11,  17,  32,  30,                 34,  29,  19,  34,  31,  63,  33,  5,   63,  53,  58,  40,  83,                 21,  18,  99,  33,  106, 40,  85,  109, 40,  77,  91,  120, 105,                 91,  79,  53,  182, 10,  184, 48,  48,  150, 168, 72,  65,  46,                 31,  216, 101, 134, 163, 147, 93,  42,  69,  7,   151, 308, 112,                 12,  227, 185, 214, 305, 163, 234, 154, 316, 3,   11,  233, 390,                 271, 173, 82,  407, 13,  135, 414, 391, 177, 293, 426, 432, 337,                 281, 385, 103, 95,  152, 12,  371, 390, 77,  532, 34,  287, 73,                 308, 493, 258, 549, 528, 411, 12,  283, 614, 596, 622, 309, 91,                 511, 287, 433, 585, 123, 2,   170, 183, 341, 459, 322, 333, 337,                 507, 718, 82,  517, 396, 315, 565, 48,  362, 617, 776, 425, 584,                 231, 578, 395, 127, 27,  506, 435, 727, 659, 697, 385, 290, 109,                 430, 422, 344, 849, 513, 453, 852, 920, 152, 482, 653, 271},       big_gens[] = {661761153,  1315209189, 235649158,  80905954,  861543922,                     677870461,  332266749,  1192707557, 820697698, 93737534,                     1395132003, 176849700,  1113502216, 860516128, 1543755630,                     328298286,  1219407972, 1407392293, 733053145, 400000570,                     1081174233, 847228024,  1516266762, 83276926,  500618997,                     44975430,   47827763,   1411328206, 151880843, 19696955};   LL vbig_primes[] = {       1223771071LL,         2557943639LL,         4625922079LL,       8465729693LL,         16196062793LL,        32628322457LL,       64355194333LL,        128143942897LL,       256728067087LL,       512368953949LL,       1024440714547LL,      2048302681847LL,       4096121499499LL,      8192933500519LL,      16384652744209LL,       32768255472209LL,     65536007832649LL,     131072225217863LL,       262144391360893LL,    524288060819213LL,    1048576249040491LL,       2097152266756471LL,   4194304028438527LL,   8388608209001387LL,       16777216572671047LL,  33554432072300339LL,  67108864903274897LL,       134217728402776373LL, 268435456069367221LL, 536870912016065747LL};   const int inf = 1e9, NONE = -1;   const LL llinf = 3e18;   const char *sc2 =  %d%d , *sc3 =  %d%d%d , *sc4 =  %d%d%d%d , *pr2 =  %d %d n ,              *pr3 =  %d %d %d n , *pr4 =  %d %d %d %d n ;   VI factor(int x) {     VI ans;     for (int p = 2; p * p <= x; ++p)       while (x % p == 0) {         ans.push_back(p);         x /= p;       }     if (x > 1) ans.push_back(x);     return ans;   }   template <class T, class B, class C, class D>   auto operator+(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first + y.first), decltype(x.second + y.second)> {     return make_pair(x.first + y.first, x.second + y.second);   }   template <class T, class B, class C>   auto operator+(pair<T, B> x, C y)       -> pair<decltype(x.first + y), decltype(x.second + y)> {     return make_pair(x.first + y, x.second + y);   }   template <class T, class C, class D>   auto operator+(T x, pair<C, D> y)       -> pair<decltype(x + y.first), decltype(x + y.second)> {     return make_pair(x + y.first, x + y.second);   }   template <class T, class B, class C, class D>   auto operator-(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first - y.first), decltype(x.second - y.second)> {     return make_pair(x.first - y.first, x.second - y.second);   }   template <class T, class B, class C>   auto operator-(pair<T, B> x, C y)       -> pair<decltype(x.first - y), decltype(x.second - y)> {     return make_pair(x.first - y, x.second - y);   }   template <class T, class C, class D>   auto operator-(T x, pair<C, D> y)       -> pair<decltype(x - y.first), decltype(x - y.second)> {     return make_pair(x - y.first, x - y.second);   }   template <class T, class B, class C, class D>   auto operator/(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first / y.first), decltype(x.second / y.second)> {     return make_pair(x.first / y.first, x.second / y.second);   }   template <class T, class B, class C>   auto operator/(pair<T, B> x, C y)       -> pair<decltype(x.first / y), decltype(x.second / y)> {     return make_pair(x.first / y, x.second / y);   }   template <class T, class C, class D>   auto operator/(T x, pair<C, D> y)       -> pair<decltype(x / y.first), decltype(x / y.second)> {     return make_pair(x / y.first, x / y.second);   }   template <class T, class B, class C, class D>   auto operator*(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first * y.first), decltype(x.second * y.second)> {     return make_pair(x.first * y.first, x.second * y.second);   }   template <class T, class B, class C>   auto operator*(pair<T, B> x, C y)       -> pair<decltype(x.first * y), decltype(x.second * y)> {     return make_pair(x.first * y, x.second * y);   }   template <class T, class C, class D>   auto operator*(T x, pair<C, D> y)       -> pair<decltype(x * y.first), decltype(x * y.second)> {     return make_pair(x * y.first, x * y.second);   }   template <class T, class B, class C, class D>   auto operator%(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first % y.first), decltype(x.second % y.second)> {     return make_pair(x.first % y.first, x.second % y.second);   }   template <class T, class B, class C>   auto operator%(pair<T, B> x, C y)       -> pair<decltype(x.first % y), decltype(x.second % y)> {     return make_pair(x.first % y, x.second % y);   }   template <class T, class C, class D>   auto operator%(T x, pair<C, D> y)       -> pair<decltype(x % y.first), decltype(x % y.second)> {     return make_pair(x % y.first, x % y.second);   }   template <class T, class B, class C, class D>   auto operator&(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first & y.first), decltype(x.second & y.second)> {     return make_pair(x.first & y.first, x.second & y.second);   }   template <class T, class B, class C>   auto operator&(pair<T, B> x, C y)       -> pair<decltype(x.first & y), decltype(x.second & y)> {     return make_pair(x.first & y, x.second & y);   }   template <class T, class C, class D>   auto operator&(T x, pair<C, D> y)       -> pair<decltype(x & y.first), decltype(x & y.second)> {     return make_pair(x & y.first, x & y.second);   }   template <class T, class B, class C, class D>   auto operator|(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first | y.first), decltype(x.second | y.second)> {     return make_pair(x.first | y.first, x.second | y.second);   }   template <class T, class B, class C>   auto operator|(pair<T, B> x, C y)       -> pair<decltype(x.first | y), decltype(x.second | y)> {     return make_pair(x.first | y, x.second | y);   }   template <class T, class C, class D>   auto operator|(T x, pair<C, D> y)       -> pair<decltype(x | y.first), decltype(x | y.second)> {     return make_pair(x | y.first, x | y.second);   }   template <class T, class B, class C, class D>   auto operator^(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first ^ y.first), decltype(x.second ^ y.second)> {     return make_pair(x.first ^ y.first, x.second ^ y.second);   }   template <class T, class B, class C>   auto operator^(pair<T, B> x, C y)       -> pair<decltype(x.first ^ y), decltype(x.second ^ y)> {     return make_pair(x.first ^ y, x.second ^ y);   }   template <class T, class C, class D>   auto operator^(T x, pair<C, D> y)       -> pair<decltype(x ^ y.first), decltype(x ^ y.second)> {     return make_pair(x ^ y.first, x ^ y.second);   }   template <class T, class B, class C, class D>   auto operator&&(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first && y.first), decltype(x.second && y.second)> {     return make_pair(x.first && y.first, x.second && y.second);   }   template <class T, class B, class C>   auto operator&&(pair<T, B> x, C y)       -> pair<decltype(x.first && y), decltype(x.second && y)> {     return make_pair(x.first && y, x.second && y);   }   template <class T, class C, class D>   auto operator&&(T x, pair<C, D> y)       -> pair<decltype(x && y.first), decltype(x && y.second)> {     return make_pair(x && y.first, x && y.second);   }   template <class T, class B, class C, class D>   auto operator||(pair<T, B> x, pair<C, D> y)       -> pair<decltype(x.first || y.first), decltype(x.second || y.second)> {     return make_pair(x.first || y.first, x.second || y.second);   }   template <class T, class B, class C>   auto operator||(pair<T, B> x, C y)       -> pair<decltype(x.first || y), decltype(x.second || y)> {     return make_pair(x.first || y, x.second || y);   }   template <class T, class C, class D>   auto operator||(T x, pair<C, D> y)       -> pair<decltype(x || y.first), decltype(x || y.second)> {     return make_pair(x || y.first, x || y.second);   }   template <class T, class B>   pair<T, B> &operator++(pair<T, B> &x) {     ++x.first, ++x.second;     return x;   }   template <class T, class B>   pair<T, B> operator++(pair<T, B> &x, int _) {     return make_pair(x.first++, x.second++);   }   template <class T, class B>   pair<T, B> &operator--(pair<T, B> &x) {     --x.first, --x.second;     return x;   }   template <class T, class B>   pair<T, B> operator--(pair<T, B> &x, int _) {     return make_pair(x.first--, x.second--);   }   template <class T, class B, class C, class D>   pair<T, B> &operator+=(pair<T, B> &x, pair<C, D> y) {     x.first += y.first;     x.second += y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator+=(pair<T, B> &x, C y) {     x.first += y;     x.second += y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator-=(pair<T, B> &x, pair<C, D> y) {     x.first -= y.first;     x.second -= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator-=(pair<T, B> &x, C y) {     x.first -= y;     x.second -= y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator*=(pair<T, B> &x, pair<C, D> y) {     x.first *= y.first;     x.second *= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator*=(pair<T, B> &x, C y) {     x.first *= y;     x.second *= y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator/=(pair<T, B> &x, pair<C, D> y) {     x.first /= y.first;     x.second /= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator/=(pair<T, B> &x, C y) {     x.first /= y;     x.second /= y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator%=(pair<T, B> &x, pair<C, D> y) {     x.first %= y.first;     x.second %= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator%=(pair<T, B> &x, C y) {     x.first %= y;     x.second %= y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator^=(pair<T, B> &x, pair<C, D> y) {     x.first ^= y.first;     x.second ^= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator^=(pair<T, B> &x, C y) {     x.first ^= y;     x.second ^= y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator&=(pair<T, B> &x, pair<C, D> y) {     x.first &= y.first;     x.second &= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator&=(pair<T, B> &x, C y) {     x.first &= y;     x.second &= y;     return x;   }   template <class T, class B, class C, class D>   pair<T, B> &operator|=(pair<T, B> &x, pair<C, D> y) {     x.first |= y.first;     x.second |= y.second;     return x;   }   template <class T, class B, class C>   pair<T, B> &operator|=(pair<T, B> &x, C y) {     x.first |= y;     x.second |= y;     return x;   }   template <class T, class B>   auto operator*(pair<T, B> x)       -> pair<typename remove_reference<decltype(*x.first)>::type,               typename remove_reference<decltype(*x.second)>::type> {     return make_pair(*x.first, *x.second);   }   template <class T, class B>   auto operator~(pair<T, B> x)       -> pair<typename remove_reference<decltype(~x.first)>::type,               typename remove_reference<decltype(~x.second)>::type> {     return make_pair(~x.first, ~x.second);   }   template <class T, class B>   auto operator!(pair<T, B> x)       -> pair<typename remove_reference<decltype(!x.first)>::type,               typename remove_reference<decltype(!x.second)>::type> {     return make_pair(!x.first, !x.second);   }   template <class T, class B>   auto operator-(pair<T, B> x)       -> pair<typename remove_reference<decltype(-x.first)>::type,               typename remove_reference<decltype(-x.second)>::type> {     return make_pair(-x.first, -x.second);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator+(zet_p x,                                                                      T y) {     return x + zet_p(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator+(T x,                                                                      zet_p y) {     return zet_p(x) + y;   }   template <class T>   zet_p &operator+=(zet_p &x, T y) {     return x = x + y;   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator-(zet_p x,                                                                      T y) {     return x - zet_p(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator-(T x,                                                                      zet_p y) {     return zet_p(x) - y;   }   template <class T>   zet_p &operator-=(zet_p &x, T y) {     return x = x - y;   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator*(zet_p x,                                                                      T y) {     return x * zet_p(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator*(T x,                                                                      zet_p y) {     return zet_p(x) * y;   }   template <class T>   zet_p &operator*=(zet_p &x, T y) {     return x = x * y;   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator/(zet_p x,                                                                      T y) {     return x / zet_p(y);   }   template <class T>   typename enable_if<is_arithmetic<T>::value, zet_p>::type operator/(T x,                                                                      zet_p y) {     return zet_p(x) / y;   }   template <class T>   zet_p &operator/=(zet_p &x, T y) {     return x = x / y;   }   void jGB4A();   const int MN = 1e5 + 44;   SPII best[MN];   void add(SPII &se, PII val) {     ;     auto pre = se.upper_bound(make_pair(val.first, inf));     pre--;     if (pre->second > val.second) {       ;       return;     }     while (pre != se.end() && pre->second <= val.second) {       if (pre->first >= val.first)         se.erase(pre++);       else         pre++;     }     se.insert(val);     ;   }   int main() {     SPII test;     for (int i = 0; i < (int)(10); i++) test.insert(make_pair(i * 3, i * 3));     add(test, make_pair(6, 6));     add(test, make_pair(6, 7));     add(test, make_pair(6, 6));     add(test, make_pair(0, 7));     ;     ;     ;     ;     cerr << setprecision(10);     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= (int)(n); i++) {       best[i].insert(make_pair(-inf, 0));     }     for (int i = 0; i < (int)(m); i++) {       int a, b, x;       scanf( %d%d%d , &a, &b, &x);       auto it = best[a].upper_bound(make_pair(x, -inf));       ;       ;       it--;       ;       add(best[b], make_pair(x, it->second + 1));     }     int ans = 0;     for (int i = 1; i <= (int)(n); i++) {       auto l = best[i].end();       l--;       maxi(ans, l->second);     }     printf( %d n , ans);     jGB4A();   }   void jGB4A() {   #pragma GCC diagnostic ignored  -Woverflow      ;     ;     ;     ;     ;     ;     ;     ;     ;     ;     while (deb && getchar() != EOF)       ;     exit(0);   }


#include <bits/stdc++.h>   using namespace std;   const int MXN = 1e5 + 1;   int n, dp[MXN], k[MXN], ans = 1, rg[MXN], res, maxi;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> k[i];       dp[k[i]] += dp[k[i] - 1] + 1;     }     for (int i = 1; i <= n; i++) {       if (dp[k[i]] > maxi) {         maxi = dp[k[i]];       }     }     cout << n - maxi;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void base() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (a > b) swap(a, b);       if (a * 2 < b)         cout <<  NO n ;       else {         int dif = b - a;         if (a - dif >= 0 && b - 2 * dif >= 0 && (a - dif) % 3 == 0) {           cout <<  YES n ;         } else {           cout <<  NO n ;         }       }     }     return 0;   }


#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;     }   };   long long int power(long long int x, long long int y,                       long long int mod = 1000000007) {     long long int ret = 1;     x = x % mod;     while (y) {       if (y & 1) ret = (ret * x) % mod;       y = y >> 1;       x = (x * x) % mod;     }     return ret % mod;   }   long long int isprime(long long int x) {     for (long long int i = 2; i * i <= x; i++)       if (x % i == 0) return 0;     return 1;   }   void solve() {     long long int n, k;     cin >> n >> k;     if (n <= k) {       cout << 1 << endl;       return;     }     vector<long long int> fact;     for (long long int i = 1; i * i <= n; i++) {       if (n % i == 0) {         if (i <= k) fact.push_back(i);         if ((n / i) <= k) fact.push_back(n / i);       }     }     sort(fact.begin(), fact.end());     cout << n / fact.back() << endl;   }   signed main() {     long long int t;     cin >> t;     while (t--) solve();   }


#include <bits/stdc++.h>   using namespace std;   int main(void) {     char sav[200];     scanf( %s , sav);     int flag = 0;     int len = strlen(sav);     for (int i = 0; i < len; i++) {       if (sav[i] ==  1 )         continue;       else if (sav[i] ==  4 ) {         if (i - 1 >= 0 && sav[i - 1] ==  1 )           continue;         else if (i - 1 >= 0 && sav[i - 1] ==  4 ) {           if (i - 2 >= 0 && sav[i - 2] ==  1 )             continue;           else             flag = 1;         } else           flag = 1;       } else         flag = 1;     }     if (flag)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2, class T3>   bool _IN(T1 x, T2 y, T3 z) {     return x <= y && x >= z || x <= z && x >= y;   }   unsigned long long gcd(unsigned long long a, unsigned long long b) {     if (!b) return a;     while (b ^= a ^= b ^= a %= b)       ;     return a;   }   extern const long long mod;   long long ksm(long long a, long long b) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   char DATaJNTFnlmAoya[2];   double PDlaQLoCkCjCKyr;   bool S(char* a) { return scanf( %s , a) == 1; }   bool S(int& a) { return scanf( %d , &a) == 1; }   bool S(bool& a) { return scanf( %d , &a) == 1; }   bool S(unsigned& a) { return scanf( %u , &a) == 1; }   bool S(float& a) { return scanf( %f , &a) == 1; }   bool S(double& a) { return scanf( %lf , &a) == 1; }   bool S(long long& a) { return scanf( %I64d , &a) == 1; }   bool S(unsigned long long& a) { return scanf( %I64u , &a) == 1; }   bool S(long double& a) {     if (scanf( %lf , &PDlaQLoCkCjCKyr) == -1) return 0;     a = PDlaQLoCkCjCKyr;     return 1;   }   bool S(char& a) {     if (scanf( %1s , DATaJNTFnlmAoya) == -1) return 0;     a = *DATaJNTFnlmAoya;     return 1;   }   bool SL(char* a) {     a[0] = 0;     while (gets(a) && !a[0])       ;     return a[0];   }   void _P(const int& x) { printf( %d , x); }   void _P(const bool& x) { printf( %d , x); }   void _P(const unsigned& x) { printf( %u , x); }   void _P(const char& x) { printf( %c , x); }   void _P(const char* x) { printf( %s , x); }   void _P(const string& x) { printf( %s , x.c_str()); }   void _P(const long long& x) { printf( %I64d , x); }   void _P(const unsigned long long& x) { printf( %I64u , x); }   void _P(const float& x) { printf( %.2f , x); }   void _P(const double& x) { printf( %.2f , x); }   void _P(const long double& x) { printf( %.2f , (double)x); }   template <class T1, class T2>   bool S(T1& a, T2& b) {     return S(a) + S(b) == 2;   }   template <class T1, class T2, class T3>   bool S(T1& a, T2& b, T3& c) {     return S(a) + S(b) + S(c) == 3;   }   template <class T1, class T2, class T3, class T4>   bool S(T1& a, T2& b, T3& c, T4& d) {     return S(a) + S(b) + S(c) + S(d) == 4;   }   template <class T1, class T2, class T3, class T4, class T5>   bool S(T1& a, T2& b, T3& c, T4& d, T5& e) {     return S(a) + S(b) + S(c) + S(d) + S(e) == 5;   }   template <class T1>   void P(const T1& a) {     _P(a);     putchar(   );   }   template <class T1, class T2>   void P(const T1& a, const T2& b) {     _P(a);     putchar(   );     _P(b);     putchar(   );   }   template <class T1>   void PN(const T1& a) {     _P(a);     puts(  );   }   template <class T1, class T2>   void PN(const T1& a, const T2& b) {     _P(a);     putchar(   );     _P(b);     puts(  );   }   template <class T1, class T2, class T3>   void PN(const T1& a, const T2& b, const T3& c) {     _P(a);     putchar(   );     _P(b);     putchar(   );     _P(c);     puts(  );   }   template <class T1, class T2, class T3, class T4>   void PN(const T1& a, const T2& b, const T3& c, const T4& d) {     _P(a);     putchar(   );     _P(b);     putchar(   );     _P(c);     putchar(   );     _P(d);     puts(  );   }   template <class T1, class T2, class T3, class T4, class T5>   void PN(const T1& a, const T2& b, const T3& c, const T4& d, const T5& e) {     _P(a);     putchar(   );     _P(b);     putchar(   );     _P(c);     putchar(   );     _P(d);     putchar(   );     _P(e);     puts(  );   }   template <class T>   void PA(T* a, int n) {     for (long long i = 0, pJNwFPtlXiwFoIv = (n - 1); i < pJNwFPtlXiwFoIv; i++)       _P(a[i]), putchar(   );     PN(a[n - 1]);   }   template <class T>   void PA(const T& x) {     for (__typeof((x).begin()) it = (x).begin(), CluhxSchFuDeugk = (x).end();          it != CluhxSchFuDeugk; it++) {       _P(*it);       if (it == --x.end())         puts(  );       else         putchar(   );     }   }   int kase;   const double pi = 4 * atan(1);   const double ep = 1e-9;   const int INF = 0x3f3f3f3f;   const long long INFL = 0x3f3f3f3f3f3f3f3fll;   const long long mod = 1000000007;   template <long long mod, long long lim, int MAX_D>   struct Hash_set {     struct node {       string x;       node* next;       node(node* a = 0, const string& b =   ) : next(a), x(b) {}       void add(const string& a) {         erase(a);         next = new node(next, a);       }       bool find(const string& a) {         node* cur = next;         while (cur) {           if (cur->x == a) return 1;           cur = cur->next;         }         return 0;       }       void clear() {         while (next) {           node* tmp = next->next;           delete next;           next = tmp;         }       }       void erase(const string& a) {         node *cur = next, *p = this;         while (cur) {           if (cur->x == a) {             node* tmp = cur;             p->next = cur->next;             delete cur;             cur = p->next;           }           if (!cur) break;           p = cur;           cur = cur->next;         }       }     };     long long* d;     node* ha;     Hash_set() {       ha = new node[mod];       d = new long long[MAX_D];       d[0] = 1;       for (int i = 1; i < MAX_D; i++) d[i] = d[i - 1] * lim % mod;     }     ~Hash_set() {       for (int i = 0; i < mod; i++) ha[i].clear();       delete[] ha;       delete[] d;     }     long long hash(const string& x) {       long long res = 0;       for (int i = 0; i < x.size(); i++) res = (res + x[i] * d[i]) % mod;       return res;     }     bool find(const string& x, int h = -1) {       if (h == -1) h = hash(x);       return ha[h].find(x);     }     void insert(const string& x, int h = -1) {       if (h == -1) h = hash(x);       ha[h].add(x);     }     void erase(const string& x, int h = -1) {       if (h == -1) h = hash(x);       ha[h].erase(x);     }     void clear() {       for (int i = 0; i < mod; i++) ha[i].clear();     }     int convert(long long h, int where, char from, char to) {       return ((h + ((long long)to - from) * d[where]) % mod + mod) % mod;     }   };   char bf[600005];   Hash_set<600011, 311, 600000> x;   bool OK() {     S(bf);     string cur = bf;     long long ha = x.hash(cur);     for (long long i = 0, pJNwFPtlXiwFoIv = (cur.size()); i < pJNwFPtlXiwFoIv;          i++) {       char c = cur[i];       for (long long j = ( a ), alVDbhLBoMEGSwA = ( c ); j <= alVDbhLBoMEGSwA;            j++) {         if (j == c) continue;         cur[i] = j;         long long ch = x.convert(ha, i, c, j);         if (x.find(cur, ch)) return 1;       }       cur[i] = c;     }     return 0;   }   int main() {     ;     int n, m;     S(n, m);     while (n--) {       S(bf);       x.insert(bf);     }     while (m--) {       puts(OK() ?  YES  :  NO );     }   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T bigmod(T p, T e, T M) {     long long ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   int Set(int N, int pos) { return N = N | (1 << pos); }   int Reset(int N, int pos) { return N = N & ~(1 << pos); }   bool Chkbit(int N, int pos) { return (bool)(N & (1 << pos)); }   int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   const double eps = 1e-6;   int n, m, k;   int vis[2000005];   int achhe[2000005];   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= m; i++) {       int x;       scanf( %d , &x);       vis[x] = 1;     }     int ans = 1;     int fl = 0;     achhe[1] = 1;     for (int i = 1; i <= k; i++) {       int x, y;       scanf( %d %d , &x, &y);       if (fl == 0) {         if (achhe[x]) {           achhe[x] = 0;           achhe[y] = 1;           if (vis[y]) {             fl = 1;             ans = y;           } else             ans = y;         } else if (achhe[y]) {           achhe[y] = 0;           achhe[x] = 1;           if (vis[x]) {             fl = 1;             ans = x;           } else             ans = x;         } else {           int nothing;         }       }     }     if (vis[1]) {       cout <<  1  << endl;       return 0;     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n;   void solve() {     cin >> n;     long long x, y, a, b;     cout <<  YES n ;     for (long long i = 1; i <= (n); ++i) {       cin >> x >> y >> a >> b;       cout << 2 * (x & 1) + (y & 1) + 1;       cout <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     solve();     return 0;   }


#include<bits/stdc++.h>   #define ll long long   using namespace std;   int main()   {       ios_base::sync_with_stdio(0);cin.tie(NULL);    int t;    cin>>t;    while(t--)    {     ll n,x;     ll min=0,max=0,s=0;     cin>>n>>x;     ll a[n];     for(ll i=0;i<n;i++)     {      cin>>a[i];      s+=a[i];      if(a[i]%x==0)               max+=(a[i]/x);               else               max+=((a[i]/x)+1);           }         if(s%x==0)               min+=(s/x);               else               min+=((s/x)+1);     cout<<min<<   <<max<<endl;    }    return 0;   }


#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   const long long int MOD = 1000000007;   const long long int MAXN = 100005;   long long int k, dp[MAXN];   long long int recurse(long long int n) {     if (n == 0) return 1;     if (dp[n] != -1) return dp[n];     long long int ans = 0;     if (n >= k) {       ans = (ans + recurse(n - k)) % MOD;     }     if (n > 0) {       ans = (ans + recurse(n - 1)) % MOD;     }     return (dp[n] = ans);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t >> k;     long long int a, b;     memset(dp, -1, sizeof(dp));     dp[0] = 0;     for (long long int i = 1; i < 100001; ++i) {       dp[i] = recurse(i);     }     for (long long int i = 1; i < 100001; ++i) {       dp[i] = (dp[i] + dp[i - 1]) % MOD;     }     while (t--) {       cin >> a >> b;       cout << ((MOD + dp[b] - dp[a - 1])) % MOD << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline long long getint() {     long long _x = 0, _tmp = 1;     char _tc = getchar();     while ((_tc <  0  || _tc >  9 ) && _tc !=  - ) _tc = getchar();     if (_tc ==  - ) _tc = getchar(), _tmp = -1;     while (_tc >=  0  && _tc <=  9 ) _x *= 10, _x += (_tc -  0 ), _tc = getchar();     return _x * _tmp;   }   long long mypow(long long _a, long long _x, long long _mod) {     if (_x == 0) return 1ll;     long long _tmp = mypow(_a, _x / 2, _mod);     _tmp = (_tmp * _tmp) % _mod;     if (_x & 1) _tmp = (_tmp * _a) % _mod;     return _tmp;   }   inline long long add(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x + _y;     if (_ >= _mod) _ -= _mod;     return _;   }   inline long long sub(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x - _y;     if (_ < 0) _ += _mod;     return _;   }   inline long long mul(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x * _y;     if (_ >= _mod) _ %= _mod;     return _;   }   inline bool equal(double _x, double _y) {     return _x > _y - 1e-9 && _x < _y + 1e-9;   }   int __ = 1, _cs;   int n, k;   vector<int> v;   void build() {}   void init() {     n = getint();     k = getint();     for (int i = 1; i <= n; i++) v.push_back(getint());     sort((v).begin(), (v).end());     v.resize(unique((v).begin(), (v).end()) - v.begin());   }   int dp[1001 * 1001];   void solve() {     for (int i = 1; i <= (v.back() - v[0]) * k; i++) {       dp[i] = 1001 * 1001;       for (size_t j = 1; j < v.size(); j++)         if (v[j] - v[0] > i)           break;         else           dp[i] = min(dp[i], dp[i - v[j] + v[0]] + 1);     }     for (int i = 0; i <= (v.back() - v[0]) * k; i++)       if (dp[i] <= k) printf( %d  , i + v[0] * k);     puts(  );   }   int main() {     build();     while (__--) {       init();       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, k;     string s;     while (cin >> n >> s) {       int sum = 0;       int left = 0, right = 0, up = 0, down = 0;       for (i = 0; i < n; i++) {         if (s[i] ==  R ) {           if (left == 1) {             sum++;             left = 0;             up = 0;             down = 0;           }           right = 1;         } else if (s[i] ==  L ) {           if (right == 1) {             sum++;             right = 0;             up = 0;             down = 0;           }           left = 1;         } else if (s[i] ==  U ) {           if (down == 1) {             sum++;             down = 0;             left = 0;             right = 0;           }           up = 1;         } else if (s[i] ==  D ) {           if (up == 1) {             sum++;             up = 0;             left = 0;             right = 0;           }           down = 1;         }       }       cout << sum + 1 << endl;     }     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2 )   using namespace std;   mt19937 mrnd(time(0));   const int INF = 1000000007;   const long long INF_LL = 1152921504606846977;   void solve() {     int n, m;     cin >> n >> m;     vector<set<int>> g(n);     for (int i = 0; i < m; ++i) {       int u, v;       cin >> u >> v;       --u, --v;       if (u > v) swap(u, v);       g[u].insert(v);     }     set<int> dead;     for (int i = 0; i < n; ++i) {       if (!g[i].empty()) {         dead.insert(i);       }     }     int q;     cin >> q;     auto upd = [&](int node) {       if (g[node].empty()) {         dead.erase(node);       } else {         dead.insert(node);       }     };     for (int i = 0; i < q; ++i) {       int z, u, v;       cin >> z;       if (z == 1) {         cin >> u >> v;         --u, --v;         if (u > v) swap(u, v);         g[u].insert(v);         upd(u), upd(v);       } else if (z == 2) {         cin >> u >> v;         --u, --v;         if (u > v) swap(u, v);         g[u].erase(v);         upd(u), upd(v);       } else {         cout << n - int(dead.size()) <<   n ;       }     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(20);     int tests = 1;     while (tests--) {       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, mostleft = 1000000000, mostright = 0, ans = -1;     int l[100000], r[100000];     bool bo_l[100000], bo_r[100000];     cin >> n;     for (int i = 0; i < n; i++) {       bo_l[i] = false;       bo_r[i] = false;     }     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i];       mostleft = min(mostleft, l[i]);       mostright = max(mostright, r[i]);     }     for (int i = 0; i < n; i++) {       if (mostleft == l[i]) bo_l[i] = true;       if (mostright == r[i]) bo_r[i] = true;     }     for (int i = 0; i < n; i++) {       if (bo_l[i] && bo_r[i]) ans = i + 1;     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxN = 200005;   const unsigned long long HA = 41793404541;   int n, m;   int a[maxN], b[maxN];   unsigned long long fac[maxN], pre[maxN], nxt[maxN];   int ansn, ans[maxN];   bool check(int l, int r) {     return pre[r] - pre[l - 1] * fac[r - l + 1] ==            nxt[l] - nxt[r + 1] * fac[r - l + 1];   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i < n; ++i) b[i] = a[i + 1] - a[i];     fac[0] = 1;     for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * HA;     for (int i = 1; i <= n; ++i)       pre[i] = pre[i - 1] * HA + (unsigned long long)b[i];     for (int i = n - 1; i; --i)       nxt[i] = nxt[i + 1] * HA + (unsigned long long)b[i];     for (int i = 1; i <= n; ++i) {       bool pd = true;       if (i != 1) pd &= check(1, i - 1);       if (i != n) {         pd &= (a[1] + a[i] == a[i + 1] + a[n] - m);         if (i != n - 1) pd &= check(i + 1, n - 1);       }       if (pd) ans[++ansn] = (a[1] + a[i]) % m;     }     printf( %d n , ansn);     sort(ans + 1, ans + ansn + 1);     for (int i = 1; i <= ansn; ++i) printf( %d  , ans[i]);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1000000;   int f[N], sz[N], ak, Ak, n, m, ans[N];   struct data {     int a, b, c, d, e;     data(int a = 0, int b = 0, int c = 0, int d = 0, int e = 0)         : a(a), b(b), c(c), d(d), e(e) {}   } S[N];   struct edge {     int x, y, z, id;     bool operator<(const edge& e) const { return z < e.z; }   } e[N], ee[N];   int find(int x) { return x == f[x] ? x : find(f[x]); }   void me(int x, int y) {     int X = find(x), Y = find(y);     if (X == Y) return;     S[Ak++] = data(X, Y, sz[X], sz[Y], ak);     if (sz[X] & 1 & sz[Y]) ak -= 2;     if (sz[X] > sz[Y]) swap(X, Y);     f[X] = Y;     sz[Y] += sz[X];   }   void pop(int tt) {     while (Ak > tt) {       data haha = S[--Ak];       ak = haha.e;       f[haha.a] = haha.a;       f[haha.b] = haha.b;       sz[haha.a] = haha.c;       sz[haha.b] = haha.d;     }   }   void solve(int l, int r, int x, int y) {     if (x > y) return;     if (l == r) {       for (int i = x; i <= y; i++) ans[i] = l;       return;     }     int mid = (l + r) >> 1, t = y + 1, tt = Ak;     for (int i = l; i <= mid; i++)       if (ee[i].id < x) me(ee[i].x, ee[i].y);     for (int i = x; i <= y; i++) {       if (e[i].z <= mid) me(e[i].x, e[i].y);       if (ak == 0) {         t = i;         break;       }     }     pop(tt);     for (int i = x; i < t; i++)       if (e[i].z < l) me(e[i].x, e[i].y);     solve(l, mid, t, y);     pop(tt);     for (int i = l; i <= mid; i++)       if (ee[i].id < x) me(ee[i].x, ee[i].y);     solve(mid + 1, r, x, t - 1);     pop(tt);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) f[i] = i, sz[i] = 1;     ak = n;     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &e[i].x, &e[i].y, &e[i].z);       e[i].id = i;       ee[i] = e[i];     }     sort(ee + 1, ee + 1 + m);     for (int i = 1; i <= m; i++) e[ee[i].id].z = i;     solve(1, m + 1, 1, m);     ee[m + 1].z = -1;     for (int i = 1; i <= m; i++) printf( %d n , ee[ans[i]].z);     return 0;   }


#include <bits/stdc++.h>   const long long mod = 1000000007;   const int maxn = 100000;   using namespace std;   int main() {     long long n, k;     scanf( %I64d , &n);     scanf( %I64d , &k);     vector<long long> fib(n + 1);     fib[1] = 1;     for (int i = 2; i < n + 1; i++) fib[i] = fib[i - 1] + fib[i - 2];     for (int i = 0; i < n; i++) {       if (fib[n - i] < k) {         cout << i + 2 <<     << i + 1 <<    ;         k -= fib[n - i];         i++;       } else         cout << i + 1 <<    ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main(int argc, const char* argv[]) {     int n;     cin >> n;     int x = 0;     for (int i = 1; i < n; i++) {       if (n % i == 0) {         x++;       }     }     cout << x;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   [[maybe_unused]] const int MAX = INT32_MAX, MIN = -INT32_MAX,                              maxInd = 1E6 + 1E5 + 1;   [[maybe_unused]] bool directed = true, end_now = false;   bool possible = false;   int n, k;   struct node_data_structure {     int pre = 0, post = 0;     bool visited = false, processed = false;   } nodes[maxInd];   vector<int> graph[maxInd];   void insert_graph(int pre, int post) {     graph[pre].push_back(post);     nodes[pre].post++;     nodes[post].pre++;     if (!directed) {       graph[post].push_back(pre);       nodes[post].post++;       nodes[pre].pre++;     }   }   [[maybe_unused]] void undoVisit() {     for (auto &i : nodes) {       i.visited = false;       i.processed = false;     }     end_now = false;   }   void dfs(int u, int ac = 1) {     if (end_now) return;     if (u > 1E6) {       if (u - 1E6 < ac) return;       if (u - 1E6 + k > n || u - 1E6 == n) {         end_now = true;         possible = true;         return;       }     } else {       if (u < ac) return;       if (u + k > n || u == n) {         end_now = true;         possible = true;         return;       }     }     nodes[u].visited = true;     for (int v : graph[u]) {       if (!nodes[v].visited) {         dfs(v, ac + 1);       }     }     nodes[u].processed = true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     string s1, s2;     cin >> n >> k >> s1 >> s2;     for (int i = 1; i < n; i++) {       if (i + k <= n) {         if (s1[i - 1] ==  -  && s2[i - 1 + k] ==  - ) {           insert_graph(i, 1E6 + i + k);         }         if (s2[i - 1] ==  -  && s1[i - 1 + k] ==  - ) {           insert_graph(1E6 + i, i + k);         }       }       if (s1[i] ==  -  && s1[i - 1] ==  - ) {         insert_graph(i, i + 1);         insert_graph(i + 1, i);       }       if (s2[i] ==  -  && s2[i - 1] ==  - ) {         insert_graph(1E6 + i, 1E6 + i + 1);         insert_graph(1E6 + i + 1, 1E6 + i);       }     }     dfs(1);     possible ? cout <<  YES  << endl : cout <<  NO  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long mul(long long a, long long b) { return a * b % mod; }   long long add(long long a, long long b) {     long long res = a + b;     if (res >= mod) {       res -= mod;     }     return res;   }   const long long MAXN = 1e6 + 5;   vector<long long> fact(MAXN);   vector<long long> fact_obr(MAXN);   vector<long long> pow_n(MAXN);   vector<long long> pow_m(MAXN);   long long n;   long long m;   long long fast_pow(long long a, long long b) {     if (b == 0) {       return 1;     } else {       if (b % 2 == 1) {         return mul(fast_pow(a, b - 1), a);       } else {         long long res = fast_pow(a, b / 2);         return mul(res, res);       }     }   }   void pre_calc() {     fact[0] = 1;     fact_obr[0] = fast_pow(fact[0], mod - 2);     pow_n[0] = 1;     pow_m[0] = 1;     for (long long i = 1; i < MAXN; ++i) {       fact[i] = mul(fact[i - 1], i);       fact_obr[i] = fast_pow(fact[i], mod - 2);       pow_n[i] = mul(pow_n[i - 1], n);       pow_m[i] = mul(pow_m[i - 1], m);     }   }   long long A(long long n, long long k) { return mul(fact[n], fact_obr[n - k]); }   long long C(long long n, long long k) {     if (k > n) {       return 0;     }     if (n == 0 && k != 0) {       return 0;     }     return mul(A(n, k), fact_obr[k]);   }   long long f(long long y) {     if (y == n) {       return 1;     }     return mul(y, pow_n[n - y - 1]);   }   int32_t main() {     cin >> n >> m;     pre_calc();     long long ans = 0;     for (long long edges = 1; edges < n; ++edges) {       long long _add = 1;       _add = mul(_add, A(n - 2, edges - 1));       _add = mul(_add, f(edges + 1));       _add = mul(_add, C(m - 1, edges - 1));       _add = mul(_add, pow_m[n - edges - 1]);       ans = add(ans, _add);     }     cout << ans;   }


#include <bits/stdc++.h>   using namespace std;   struct creature {     long long hp, dmg;     long long div;     bool operator<(const creature& rhs) const { return div > rhs.div; }   };   int n, a, b;   creature in[200050];   long long ans = 0;   int it, use;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> a >> b;     for (int i = 0; i < n; ++i) {       cin >> in[i].hp >> in[i].dmg;       in[i].div = in[i].hp - in[i].dmg;     }     sort(in, in + n);     use = b;     for (int i = 0; i < n; ++i) {       if (use && in[i].hp > in[i].dmg) {         in[i].dmg = in[i].hp;         --use;       }       ans += in[i].dmg;     }     it = b - use;     int icur = it - 1;     in[n] = {0, 0, 0};     long long dx = 0;     if (b && a)       for (int i = 0; i < n; ++i) {         long long tmp = (in[i].hp << a) - in[i].dmg;         if (use)           dx = dx > tmp ? dx : tmp;         else if (i < it)           dx = tmp > dx ? tmp : dx;         else           dx = (tmp - in[icur].div > dx) ? tmp - in[icur].div : dx;       }     cout << ans + dx;     return 0;   }


#include <bits/stdc++.h>   using LL = long long;   const int kN = 200000 + 5;   const int kLog = 19;   const LL inf = 3e14;   std::vector<std::pair<int, int>> edges[kN];   int n, m, s;   LL dist[kN];   int plca[kLog][kN], depth[kN];   int sz[kN];   int get_lca(int a, int b) {     if (depth[a] < depth[b]) std::swap(a, b);     for (int i = 0; i < kLog; ++i)       if (depth[a] - depth[b] >> i & 1) a = plca[i][a];     if (a == b) return a;     for (int i = kLog - 1; i >= 0; --i)       if (plca[i][a] != plca[i][b]) a = plca[i][a], b = plca[i][b];     return plca[0][a];   }   int main() {     scanf( %d%d%d , &n, &m, &s);     s--;     for (int i = 0; i < m; ++i) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       u--;       v--;       edges[u].emplace_back(w, v);       edges[v].emplace_back(w, u);     }     std::priority_queue<std::pair<LL, int>> pq;     std::fill(dist, dist + n, inf);     dist[s] = 0;     pq.emplace(0, s);     std::vector<int> order;     while (!pq.empty()) {       LL tmp;       int u;       std::tie(tmp, u) = pq.top();       pq.pop();       if (-tmp != dist[u]) continue;       order.emplace_back(u);       int lca = -1;       for (auto e : edges[u]) {         if (dist[e.second] > dist[u] + e.first) {           dist[e.second] = dist[u] + e.first;           pq.emplace(-dist[e.second], e.second);         } else if (dist[e.second] + e.first == dist[u]) {           if (lca == -1)             lca = e.second;           else             lca = get_lca(lca, e.second);         }       }       plca[0][u] = lca;       depth[u] = lca == -1 ? 0 : depth[lca] + 1;       for (int i = 1; i < kLog; ++i)         plca[i][u] = plca[i - 1][u] == -1 ? -1 : plca[i - 1][plca[i - 1][u]];     }     int result = 0;     std::fill(sz, sz + n, 1);     for (int i = (int)order.size() - 1; i > 0; --i) {       int u = order[i];       sz[plca[0][u]] += sz[u];       result = std::max(result, sz[u]);     }     printf( %d n , result);   }


#include <bits/stdc++.h>   using namespace std;   int n, w;   double tmp;   vector<double> a;   vector<double> boy;   vector<double> girl;   double volume;   double base;   int main() {     cin >> n >> w;     for (int i = 0; i < (2 * n); i++) {       cin >> tmp;       a.push_back(tmp);     }     sort(a.begin(), a.end());     girl.assign(a.begin(), a.begin() + n);     boy.assign(a.begin() + n, a.end());     if (boy[0] / 2 > girl[0])       base = girl[0];     else       base = boy[0] / 2;     volume = (3 * base * n);     if (volume > w) volume = w;     cout << fixed << setprecision(10) << volume;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int kase, ks = 0;     int i, j, k;     int n;     int arr[1000];     string s;     cin >> n;     for (i = 1; i < n + 1; i++) cin >> arr[i];     int q;     cin >> q;     int x, y;     while (q--) {       cin >> x >> y;       if (x > 1) arr[x - 1] += (y - 1);       if (x < n) arr[x + 1] += (arr[x] - y);       arr[x] = 0;     }     for (i = 1; i < n + 1; i++) cout << arr[i] << endl;     return 0;   }


#include <bits/stdc++.h>   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) printf( %d , i % 2);     puts(  );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 3000 + 12;   int p[maxn];   int Et[maxn];   int mark[maxn][maxn];   queue<pair<int, int> > act;   void input(int n) {     for (int i = 0; i < n; i++) cin >> p[i];   }   void solve(int n, int k) {     int sef = 0;     bool yek = 0;     for (int j = n - 1; j >= 0; j--) {       if (p[j] == 0) sef++;       if (p[j] == 100) yek = 1;       if (sef == n - j) Et[j] = 1;       if (yek) Et[j] = 2;     }     act.push(make_pair(0, 1));     mark[0][1] = 0;     int ans = 0;     int x = 0, y = 1;     while (act.size() && mark[x][y] <= k) {       pair<int, int> a = act.front();       x = a.first, y = a.second;       if (mark[x][y] <= k) ans++;       if (Et[y] != 1 && p[x] != 0 && y + 2 <= n + 1 &&           mark[y + 1][y + 2] > mark[x][y] + 1)         act.push(make_pair(y + 1, y + 2)), mark[y + 1][y + 2] = mark[x][y] + 1;       if (Et[y] != 2 && p[x] != 0 && y + 1 <= n &&           mark[x][y + 1] > mark[x][y] + 1)         act.push(make_pair(x, y + 1)), mark[x][y + 1] = mark[x][y] + 1;       if (Et[y] != 1 && p[x] != 100 && y + 1 <= n &&           mark[y][y + 1] > mark[x][y] + 1)         act.push(make_pair(y, y + 1)), mark[y][y + 1] = mark[x][y] + 1;       act.pop();     }     cout << ans;   }   int main() {     int n, k;     cin >> n >> k;     input(n);     memset(mark, 31, sizeof mark);     solve(n, k);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using lli = long long;   using pii = pair<int, int>;   using pll = pair<lli, lli>;   template <typename T>   using Vector = vector<vector<T>>;   template <typename T>   using Prior = priority_queue<T>;   template <typename T>   using prior = priority_queue<T, vector<T>, greater<T>>;   const lli mod = 1E9 + 7;   void solve() {     lli x, len;     string s;     cin >> x >> s;     len = s.size();     for (int i = 1; i <= x; ++i) {       if (s.size() < x) {         if (s[i - 1] ==  2 ) s += s.substr(i, s.size() - i);         if (s[i - 1] ==  3 )           s += s.substr(i, s.size() - i) + s.substr(i, s.size() - i);         len = s.size();       } else {         if (s[i - 1] ==  2 ) len = (2 * len - i) % mod;         if (s[i - 1] ==  3 ) len = (3 * len - 2 * i) % mod;       }     }     cout << (len < 0 ? len + mod : len) <<   n ;   }   int main() {     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, min = 1000;     scanf( %d %d , &n, &m);     vector<int> v(m);     for (int i = 0; i < m; i++) scanf( %d , &v[i]);     sort(v.begin(), v.end());     for (int i = 0; n + i - 1 < m; i++) {       if (min > v[n + i - 1] - v[i]) min = v[n + i - 1] - v[i];     }     printf( %d , min);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   char s[N];   int n, a[N], pre[N][26], suf[N][26];   int f[N][26], g[N], mem[27];   inline int mex(int st) { return __builtin_ctz(~st); }   int calc(int l, int r, int c, int fl) {     if (l > r) return 0;     if (~mem[c]) return mem[c];     int st = 0;     for (int j = 0; j < 26; j++) {       int ll = suf[l][j], rr = pre[r][j];       if (rr >= l)         st |= 1 << (g[rr] ^ g[ll] ^ (!fl ? f[ll - 1][c] : calc(l, ll - 1, j, 1)) ^                     (fl ? f[r][j] : calc(rr + 1, r, j, 0)));     }     return mem[c] = mex(st);   }   int main() {     ios::sync_with_stdio(false);     cin >> (s + 1);     n = strlen(s + 1);     for (int i = 1; i <= n; i++) a[i] = s[i] -  a ;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 26; j++) pre[i][j] = pre[i - 1][j];       pre[i][a[i]] = i;     }     for (int j = 0; j < 26; j++) suf[n + 1][j] = n + 1;     for (int i = n; i > 0; --i) {       for (int j = 0; j < 26; j++) suf[i][j] = suf[i + 1][j];       suf[i][a[i]] = i;     }     for (int i = 1; i <= n; i++) {       g[i] = f[i - 1][a[i]] ^ g[pre[i - 1][a[i]]];       memset(mem, -1, sizeof(mem));       for (int j = 0; j < 26; j++) f[i][j] = calc(pre[i][j] + 1, i, j, 0);     }     int q;     cin >> q;     while (q--) {       int l, r;       cin >> l >> r;       memset(mem, -1, sizeof(mem));       if (calc(l, r, 26, 1))         puts( Alice );       else         puts( Bob );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   template <class C>   inline void mini(C& a4, C b4) {     a4 = min(a4, b4);   }   template <class C>   inline void maxi(C& a4, C b4) {     a4 = max(a4, b4);   }   int n, v, e;   int a[307], b[307];   vector<int> GG[307], G[307];   bool del[307], vis[307];   int xx[1000007], yy[1000007], dd[1000007], moves;   long long int go(int x) {     long long int res = a[x] - b[x];     vis[x] = true;     for (__typeof((GG[x]).begin()) i = (GG[x]).begin(); i != (GG[x]).end(); ++i)       if (!vis[*i]) {         G[x].push_back(*i);         G[*i].push_back(x);         res += go(*i);       }     return res;   }   void push(int x, int o, int lim, bool down) {     for (__typeof((G[x]).begin()) i = (G[x]).begin(); i != (G[x]).end(); ++i)       if (*i != o && !del[*i]) {         push(*i, x, INF, down);         int can = lim;         int l = x, r = *i;         if (!down) swap(l, r);         mini(can, a[l]);         mini(can, v - a[r]);         lim -= can;         if (can > 0) {           a[l] -= can;           a[r] += can;           xx[moves] = l;           yy[moves] = r;           dd[moves] = can;           moves++;         }       }   }   int main() {     std::ios_base::sync_with_stdio(0);     cout << setprecision(15) << fixed;     cin >> n >> v >> e;     for (int i = (1); i <= (n); i++) cin >> a[i];     for (int i = (1); i <= (n); i++) cin >> b[i];     while (e--) {       int x, y;       cin >> x >> y;       GG[x].push_back(y);       GG[y].push_back(x);     }     for (int i = (1); i <= (n); i++)       if (!vis[i])         if (go(i) != 0) {           cout <<  NO  << endl;           return 0;         }     bool ok;     do {       ok = false;       for (int i = (1); i <= (n); i++)         if (!del[i]) {           int deg = 0;           for (__typeof((G[i]).begin()) j = (G[i]).begin(); j != (G[i]).end();                ++j)             deg += !del[*j];           if (deg != 1) continue;           if (a[i] != b[i]) push(i, i, abs(a[i] - b[i]), a[i] > b[i]);           del[i] = true;           ok = true;           break;         }     } while (ok);     cout << moves << endl;     for (int i = 0; i < (moves); i++)       cout << xx[i] <<     << yy[i] <<     << dd[i] << endl;     return 0;   }