#include <bits/stdc++.h>   using namespace std;   char buf[1000000];   vector<vector<int> > g;   vector<bool> used;   vector<long long> border, space, w, h;   vector<int> tp;   void dfs(int v) {     used[v] = true;     for (int i = (0); i < (int((g[v]).size())); ++i)       if (!used[g[v][i]]) dfs(g[v][i]);     if (tp[v] == 0) {       long long W = 0, H = 0;       for (int i = (0); i < (int((g[v]).size())); ++i) {         W += w[g[v][i]];         H = max(H, h[g[v][i]]);       }       if (int((g[v]).size()) == 0) return;       W += (int((g[v]).size()) - 1) * space[v] + 2 * border[v];       H += 2 * border[v];       w[v] = W;       h[v] = H;       return;     }     if (tp[v] == 1) {       long long W = 0, H = 0;       for (int i = (0); i < (int((g[v]).size())); ++i) {         H += h[g[v][i]];         W = max(W, w[g[v][i]]);       }       if (int((g[v]).size()) == 0) return;       H += (int((g[v]).size()) - 1) * space[v] + 2 * border[v];       W += 2 * border[v];       w[v] = W;       h[v] = H;       return;     }   }   int main() {     g.resize(110);     map<string, int> M;     int it = 0;     int n;     cin >> n;     vector<string> names;     for (int i = (0); i < (n); ++i) {       string s;       scanf( %s , buf);       s = buf;       if (s ==  HBox ) {         scanf( %s , buf);         s = buf;         M[s] = it;         names.push_back(s);         tp.push_back(0);         w.push_back(0);         h.push_back(0);         border.push_back(0);         space.push_back(0);         it++;         continue;       }       if (s ==  VBox ) {         scanf( %s , buf);         s = buf;         M[s] = it;         names.push_back(s);         tp.push_back(1);         w.push_back(0);         h.push_back(0);         border.push_back(0);         space.push_back(0);         it++;         continue;       }       if (s ==  Widget ) {         scanf( %s , buf);         s = buf;         string nm =   ;         int j = 0;         while (s[j] !=  ( ) {           nm.push_back(s[j]);           j++;         }         M[nm] = it;         names.push_back(nm);         long long W, H;         W = H = 0;         j++;         while (s[j] !=  , ) {           W = W * 10 + (s[j] -  0 );           j++;         }         j++;         while (s[j] !=  ) ) {           H = H * 10 + (s[j] -  0 );           j++;         }         tp.push_back(2);         w.push_back(W);         h.push_back(H);         border.push_back(0);         space.push_back(0);         it++;         continue;       }       for (int j = (0); j < (int((s).size())); ++j)         if (s[j] ==  ,  || s[j] ==  (  || s[j] ==  .  || s[j] ==  ) ) s[j] =    ;       stringstream sin;       sin << s;       vector<string> q;       while (sin >> s) q.push_back(s);       if (q[1] ==  pack ) {         g[M[q[0]]].push_back(M[q[2]]);       } else {         long long t = 0;         for (int j = (0); j < (int((q[2]).size())); ++j)           t = t * 10 + (q[2][j] -  0 );         if (q[1] ==  set_border )           border[M[q[0]]] = t;         else           space[M[q[0]]] = t;       }     }     used.resize(it, false);     for (int i = (0); i < (it); ++i) {       if (!used[i]) dfs(i);     }     vector<pair<string, int> > res;     for (int i = (0); i < (it); ++i) res.push_back(make_pair(names[i], i));     sort((res).begin(), (res).end());     for (int i = (0); i < (it); ++i) {       int j = res[i].second;       cout << names[j] <<     << w[j] <<     << h[j] <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int Array[10005];   int main() {     int N, m, i, j, l, r, x, Count;     scanf( %d%d , &N, &m);     for (i = 1; i <= N; i++) scanf( %d , Array + i);     for (i = 1; i <= m; i++) {       Count = 0;       scanf( %d%d%d , &l, &r, &x);       for (j = l; j <= r; j++) {         if (Array[j] < Array[x]) Count++;       }       if (Count == x - l)         puts( Yes );       else         puts( No );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int M = 105;   const int MOD = 1e6 + 3;   struct matrix {     int val[M][M];     int n;     matrix(int nn, int x = 0) {       n = nn;       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++)           if (i != j)             val[i][j] = 0;           else             val[i][j] = x;     }     int* operator[](int x) { return val[x]; }     matrix operator*(matrix b) {       matrix ans(n, 0);       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++)           for (int k = 0; k < n; k++)             ans[i][k] += 1LL * val[i][j] * b[j][k] % MOD, ans[i][k] %= MOD;       return ans;     }   };   matrix operator^(matrix a, long long b) {     matrix ans(a.n, 1);     while (b) {       if (b & 1) ans = ans * a;       a = a * a;       b >>= 1;     }     return ans;   }   int main() {     long long n;     int w, h;     cin >> n >> w >> h;     matrix mat(w + 1, 0);     for (int i = 0; i < w; i++) mat[i][i + 1] = 1;     int k = 1;     for (int i = w; i >= 0; i--) {       mat[w][i] = k;       k = 1LL * k * h % MOD;     }     mat = mat ^ n;     cout << (mat[w][w - 1] + mat[w][w]) % MOD <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct re {     int x, y;   };   int n, K, f[2001][2001];   char mp[2001][2001];   vector<re> A, B, zy[4001];   string Ans;   void upd(int &x, int y) {     if (y <= K) {       if (x == -1) x = y;       if (y < x) x = y;     }   }   int main() {     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; ++i) scanf( %s , mp[i] + 1);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) {         f[i][j] = -1;         zy[i + j - 1].push_back((re){i, j});       }     if (mp[1][1] ==  a ) {       Ans.push_back( a );       A.push_back((re){1, 1});       f[1][1] = 0;     } else {       if (K >= 1) {         Ans.push_back( a );         A.push_back((re){1, 1});         f[1][1] = 1;       } else {         Ans.push_back(mp[1][1]);         A.push_back((re){1, 1});         f[1][1] = 0;       }     }     for (int i = 2; i <= 2 * n - 1; ++i) {       char Min =  z ;       for (auto u : A) {         if (f[u.x][u.y] + 1 <= K) Min =  a ;         if (u.x + 1 <= n) Min = min(Min, mp[u.x + 1][u.y]);         if (u.y + 1 <= n) Min = min(Min, mp[u.x][u.y + 1]);       }       Ans.push_back(Min);       for (auto u : A) {         if (u.x + 1 <= n) {           upd(f[u.x + 1][u.y], f[u.x][u.y] + (mp[u.x + 1][u.y] != Min));         }         if (u.y + 1 <= n) {           upd(f[u.x][u.y + 1], f[u.x][u.y] + (mp[u.x][u.y + 1] != Min));         }       }       for (auto u : zy[i])         if (f[u.x][u.y] != -1) B.push_back(u);       swap(A, B);       B.clear();     }     printf( %s n , Ans.c_str());     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int mxn = 1e5 + 100;   int a[mxn], b[mxn], c[mxn];   set<int> mp;   void add(int x) {     if (c[x] == 0)       mp.insert(b[x]);     else if (c[x] == 1)       mp.erase(b[x]);     c[x]++;   }   void remove(int x) {     if (c[x] == 2)       mp.insert(b[x]);     else if (c[x] == 1)       mp.erase(b[x]);     c[x]--;   }   int main() {     int n, k, m;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , a + i), b[i - 1] = a[i];     sort(b, b + n), m = unique(b, b + n) - b;     for (int i = 1; i <= n; i++) {       a[i] = lower_bound(b, b + m, a[i]) - b;       add(a[i]);       if (i >= k) {         if (mp.empty())           puts( Nothing );         else           printf( %d n , *mp.rbegin());         remove(a[i - k + 1]);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     long long n;     cin >> t;     while (t--) {       cin >> n;       if (n % 2) {         if ((n / 2) & 1) {           cout << n + 1 << endl;         } else {           cout << 2 * n + 1 << endl;         }       } else {         cout << 4 * n + 1 << endl;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline long long read() {     char c = getchar();     long long f = 1, x = 0;     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 1) + (x << 3) + (c ^  0 );       c = getchar();     }     return x * f;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   char s[3];   char b[3];   int main() {     scanf( %s , s + 1);     long long flag = 0;     long long ff = 0, f = 0, fff = 0;     long long n = read();     for (int i = 1; i <= n; i++) {       memset(b,   0 , sizeof(b));       scanf( %s , b + 1);       if (b[1] == s[1] && b[2] == s[2]) {         fff = 1;       }       if (b[1] == s[2] && b[2] == s[1]) {         flag = 1;       }       if (b[2] == s[1]) {         f = 1;       }       if (b[1] == s[2]) {         ff = 1;       }     }     if (flag != 0 || ff + f == 2 || fff == 1) {       printf( YES n );     } else {       printf( NO n );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long inf = (1LL << 60) - 1;   int dx[] = {-1, 1, 0, 0};   int dy[] = {0, 0, -1, 1};   void solve() {     long long n, x, y, k, c = 0;     cin >> n >> x >> y;     for (long long i = 0; i < n; i++) {       cin >> k;       if (k <= x) c++;     }     if (x > y)       cout << n <<   n ;     else       cout << (c + 1) / 2 <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cout.tie(0);     ;     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(NULL);     cout.tie(NULL);     ios_base::sync_with_stdio(false);     int arr[4];     for (int i = 0; i < 4; i++) cin >> arr[i];     int a, b;     cin >> a >> b;     sort(arr, arr + 4);     if (arr[0] > b)       cout << b - a + 1 << endl;     else if (arr[0] > a)       cout << arr[0] - a << endl;     else       cout << 0 << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int ans = -1;     int n, dol, cent, s, i;     cin >> n >> s;     for (i = 0; i < n; i++) {       cin >> dol >> cent;       if (s > dol && cent != 0 && 100 - cent > ans) ans = 100 - cent;       if (s >= dol && cent == 0 && ans == -1) ans = 0;     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int tree[270000 * 4];   int t;   char opt;   void insert(long long x) {     if (x == 0) {       ++tree[2];       return;     }     int num = x % 10;     x /= 10;     num = (num % 2 == 0 ? 0 : 1);     int root = (num == 0 ? 2 : 3);     ++tree[root];     while (x) {       num = x % 10;       x /= 10;       num = (num % 2 == 0 ? 0 : 1);       root = (num == 0 ? root * 2 : root * 2 + 1);       ++tree[root];     }   }   void erase(long long x) {     if (x == 0) {       --tree[2];       return;     }     int num = x % 10;     x /= 10;     num = (num % 2 == 0 ? 0 : 1);     int root = (num == 0 ? 2 : 3);     --tree[root];     while (x) {       num = x % 10;       x /= 10;       num = (num % 2 == 0 ? 0 : 1);       root = (num == 0 ? root * 2 : root * 2 + 1);       --tree[root];     }   }   void query(string s) {     stack<int> stk;     int lens = s.length(), beg = 0;     for (int i = 0; i < lens; ++i)       if (s[i] !=  0  || i == lens - 1) {         beg = i;         break;       }     for (int i = beg; i < lens; ++i) stk.push(s[i] -  0 );     int now = stk.top();     stk.pop();     int root = (now == 0 ? 2 : 3);     int ans = tree[root];     while (!stk.empty()) {       now = stk.top();       stk.pop();       root = (now == 0 ? root * 2 : root * 2 + 1);       ans = min(tree[root], ans);     }     while (beg) {       root *= 2;       ans -= tree[root + 1];       --beg;     }     while (tree[root * 2] || tree[root * 2 + 1]) {       root *= 2;       ans -= tree[root + 1];     }     cout << ans << endl;   }   int main() {     cin >> t;     for (int i = 1; i <= t; ++i) {       cin >> opt;       if (opt ==  + ) {         long long x;         cin >> x;         insert(x);       } else if (opt ==  - ) {         long long x;         cin >> x;         erase(x);       } else {         string s;         cin >> s;         query(s);       }     }   }


#include <bits/stdc++.h>   using namespace std;   long long ans, tot, n;   long long a[105];   void update(long long d) {     long long sum = 0;     for (int i = 1; i <= n; i++) sum += (a[i] - 1) / d + 1;     if (sum * d <= tot) ans = max(ans, d);   }   int main() {     long long k;     scanf( %lld %lld , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);       tot += a[i];     }     tot += k;     for (long long i = 1; i * i <= tot - 1; i++) {       update(i);       update(tot / i);     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1108864220 )   using namespace std;   const int MOD = 1000000007;   const int INF = 1000000000;   const double EPS = 1e-9;   const int HASH_POW = 29;   const long double PI = acos(-1.0);   mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   long long nextLong(long long l, long long r) {     uniform_int_distribution<long long> foo(l, r);     return foo(rnd);   }   double nextDouble(double l, double r) {     uniform_real_distribution<double> foo(l, r);     return foo(rnd);   }   double workTime() { return double(clock()) / CLOCKS_PER_SEC; }   void myReturn(int code = 0) { exit(code); }   int n;   long long goal = 0;   vector<int> p[15];   vector<long long> sum;   unordered_map<int, pair<int, int> > pos;   pair<int, int> cycles[1 << 15];   bool dp[1 << 15];   int par[1 << 15];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     scanf( %d , &n);     sum.resize(n);     for (int i = 0; i < n; ++i) {       int s;       scanf( %d , &s);       p[i].resize(s);       sum[i] = 0;       for (int j = 0; j < s; ++j) {         scanf( %d , &p[i][j]);         goal += p[i][j];         sum[i] += p[i][j];         pos[p[i][j]] = {i, j};       }     }     if (goal % n != 0) {       printf( No n );       myReturn();     } else {       goal /= n;     }     for (int i = 0; i < (1 << n); ++i) {       cycles[i] = {-1, -1};     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < p[i].size(); ++j) {         int msk = 0, row = i, col = j;         bool good = true;         while (true) {           if (msk & (1 << row)) {             if (row != i) {               good = false;             } else if (col != j) {               good = false;             }             break;           }           msk |= (1 << row);           long long val = goal - sum[row] + p[row][col];           if (abs(val) > 1000000000) {             good = false;             break;           }           int key = (int)val;           if (pos.find(key) == pos.end()) {             good = false;             break;           }           if (pos[key].first == row && pos[key].second != col) {             good = false;             break;           }           row = pos[key].first, col = pos[key].second;         }         if (good) {           cycles[msk] = {i, j};         }       }     }     dp[0] = true;     for (int i = 1; i < (1 << n); ++i) {       for (int s = i; s > 0; s = ((s - 1) & i)) {         if (cycles[s].first != -1 && dp[i ^ s]) {           dp[i] = true;           par[i] = s;         }       }     }     if (!dp[(1 << n) - 1]) {       printf( No n );       myReturn();     }     vector<pair<int, int> > ans(n, {-1, -1});     int q = (1 << n) - 1;     while (q != 0) {       int s = par[q];       q ^= s;       int msk = 0, row = cycles[s].first, col = cycles[s].second;       while (true) {         if (msk & (1 << row)) {           break;         }         msk |= (1 << row);         long long val = goal - sum[row] + p[row][col];         int key = (int)val;         ans[pos[key].first] = {p[pos[key].first][pos[key].second], row + 1};         row = pos[key].first, col = pos[key].second;       }     }     printf( Yes n );     for (int i = 0; i < n; ++i) {       printf( %d %d n , ans[i].first, ans[i].second);     }     myReturn();   }


#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int N = 2100;   int a[N][N], b[N][N], d[N][N];   int c[N], n, tag = -1, res[N];   void print() {     cout << -1;     exit(0);   }   int cnt = 0;   void solve(int id, int T) {     if (T) {       for (int i = 1; i <= n; i++) {         if (i == tag) continue;         if (d[i][id] != c[i]) res[i]++;       }     } else {       for (int i = 1; i <= n; i++) {         if (i == tag) continue;         if (d[i][id] != 0) res[i]++;       }     }   }   int main() {     std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     char ch;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) cin >> ch, a[i][j] = ch -  0 ;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) cin >> ch, b[i][j] = ch -  0 ;     for (int i = 1; i <= n; i++) cin >> ch, c[i] = ch -  0 ;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) d[i][j] = a[i][j] ^ b[i][j];     for (int i = 1; i <= n; i++)       if (c[i]) tag = i;     if (tag == -1) {       bool f = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           if (d[i][j]) f = 1;       if (f) print();     }     for (int i = 1; i <= n; i++)       if (d[tag][i]) cnt++;     for (int i = 1; i <= n; i++) solve(i, d[tag][i]);     for (int i = 1; i <= n; i++) {       if (res[i]) {         cnt++;         for (int j = 1; j <= n; j++) d[i][j] ^= c[j];       }     }     for (int j = 1; j <= n; j++) {       int C = 0;       bool f = 0;       for (int i = 1; i <= n; i++) {         if ((d[i][j] && c[i] == 0) || (!d[i][j] && c[i])) f = 1;         if (d[i][j]) C++;       }       if (C && f) print();     }     cout << cnt <<   n ;     for (int i = 1; i <= n; i++)       if (res[i]) cout <<  row   << i - 1 <<   n ;     for (int i = 1; i <= n; i++)       if (d[tag][i]) cout <<  col   << i - 1 <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int cambio;     cin >> cambio;     vector<int> hansel;     int madera = 0;     int piedra = 0;     int ladrillo;     for (int i = 0; cambio > i; i++) {       int gretel;       cin >> gretel;       piedra = piedra + gretel;       hansel.push_back(gretel);     }     sort(hansel.begin(), hansel.end());     for (int i = 0; i < cambio; i++) {       madera = madera + hansel[i];       piedra = piedra - hansel[i];       if (madera >= piedra) {         ladrillo = cambio - i;         break;       }     }     cout << ladrillo;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline int mod(int a, int k) { return (a % k + k) % k; }   int main() {     int n, k, v;     cin >> n >> k >> v;     vector<int> a(1 + n, 0);     int ss = 0;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       ss += a[i];     }     if (ss < v) {       cout <<  NO n ;       return 0;     }     int target = v % k;     vector<vector<pair<int, int>>> dp(1 + n, vector<pair<int, int>>(k, {0, 0}));     dp[0][0] = {-1, 0};     for (int i = 1; i <= n; ++i) {       for (int j = 0; j < k; ++j) {         auto var1 = dp[i - 1][mod(j - a[i], k)];         auto var2 = dp[i - 1][j];         if (var1.first && var2.first) {           if (var1.second + a[i] % k > var2.second) {             dp[i][j] = {2, var1.second + a[i] % k};           } else {             dp[i][j] = {1, var2.second};           }         } else if (var1.first) {           dp[i][j] = {2, var1.second + a[i] % k};         } else if (var2.first) {           dp[i][j] = {1, var2.second};         }       }     }     if (dp[n][target].first == 0) {       cout <<  NO n ;       return 0;     }     if (n == 1 && a[1] != v) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     int x = -1;     int y = -1;     int curr = n;     int rem1 = target;     while (curr > 0) {       if (dp[curr][rem1].first == 2) {         if (x == -1) {           x = curr;           rem1 = mod(rem1 - a[curr], k);         } else {           if (a[curr] > 0) {             cout << (a[curr] - 1) / k + 1 <<     << curr <<     << x <<   n ;           }           a[x] += a[curr];           rem1 = mod(rem1 - a[curr], k);           a[curr] = 0;         }       } else {         if (y == -1) {           y = curr;         } else {           if (a[curr] > 0) {             cout << (a[curr] - 1) / k + 1 <<     << curr <<     << y <<   n ;           }           a[y] += a[curr];           a[curr] = 0;         }       }       --curr;     }     if (y == -1) {       if (x == 1) {         y = 2;       } else {         y = 1;       }     }     if (x == -1) {       if (y == 1) {         x = 2;       } else {         x = 1;       }     }     if (x != -1) {       if (a[x] < v) {         cout << (v - a[x]) / k <<     << y <<     << x <<   n ;       } else if (a[x] > v) {         cout << (a[x] - v) / k <<     << x <<     << y <<   n ;       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     long long l = 1, u = n, mid;     while (l <= u) {       mid = (l + u) / 2;       long long sum = (mid * (mid + 1)) / 2;       sum = sum - (n - mid);       if (sum == k) {         cout << n - mid << endl;         break;       } else if (sum < k) {         l = mid + 1;       } else         u = mid - 1;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long arr[n];       for (long long i = 0; i < n; i++) cin >> arr[i];       long long x = 0;       vector<long long> v;       map<long long, long long> mp;       for (long long i = 0; i < n; i++) {         if (mp.find(arr[i]) == mp.end()) {           v.push_back(arr[i]);           mp[arr[i]] = 1;           x++;         }       }       if (x > k)         cout << -1 << endl;       else {         long long x = 0;         while (v.size() < k) {           v.push_back(v[x]);           x++;         }         vector<long long> w;         long long j = 0, l = 0;         while (j < n) {           if (arr[j] == v[l]) {             w.push_back(arr[j]);             j++;             l++;           } else {             w.push_back(v[l]);             l++;           }           l %= v.size();         }         cout << w.size() << endl;         for (long long i = 0; i < w.size(); i++) cout << w[i] <<    ;         cout << endl;       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int m = (n << 1) - 1;     vector<int> a(m);     int first = -1;     for (int i = 0; i < m; ++i) {       scanf( %d , &a[i]);       --a[i];       if (!~first && ~a[i]) {         first = i;       }     }     if (!~first) {       puts( yes );       printf( 1 );       for (int i = 1; i < n; ++i) {         printf(  %d 1 , i + 1);       }       putchar(10);       return 0;     }     if (first) {       vector<int> temp;       for (int i = first; i < m; ++i) {         temp.push_back(a[i]);       }       for (int i = 0; i < first; ++i) {         temp.push_back(a[i]);       }       a = temp;     }     if (~a.back() && a.back() != a[0]) {       puts( no );       return 0;     }     a.back() = a[0];     vector<int> free, parity(n, -1);     for (int i = 0; i < m; ++i) {       if (~a[i]) {         if (~parity[a[i]]) {           if (parity[a[i]] != (i & 1)) {             puts( no );             return 0;           }         } else {           parity[a[i]] = i & 1;         }       }     }     for (int i = 0; i < n; ++i) {       if (!~parity[i]) {         free.push_back(i);       }     }     vector<int> prev(m), next(m);     for (int i = 0; i < m; ++i) {       prev[i] = i - 1;       next[i] = i + 1;     }     auto erase = [&](int x) {       if (next[x] != m) {         prev[next[x]] = prev[x];       }       if (~prev[x]) {         next[prev[x]] = next[x];       }     };     auto solve = [&](int l, int r) {       for (int i = next[l]; i < r;) {         if (~a[i] && ~a[next[i]] && !~a[prev[i]]) {           a[prev[i]] = a[next[i]];           erase(i);           erase(next[i]);           i = prev[i];           if (i > l) {             i = prev[i];           }           if (i == l) {             i = next[i];           }         } else if (~a[i] && ~a[prev[i]] && !~a[next[i]]) {           a[next[i]] = a[prev[i]];           erase(i);           erase(next[i]);           i = prev[i];           if (i == l) {             i = next[i];           }         } else {           i = next[i];         }       }       for (int i = next[l]; i < r; i = next[i]) {         erase(i);       }       erase(r);     };     vector<bool> not_first(n), ban(n);     for (int i = 0; i < m; ++i) {       if (~a[i]) {         if (not_first[a[i]]) {           if (ban[a[i]]) {             puts( no );             return 0;           }           int left = prev[i], right = i, numbers = 1, total = 1;           while (a[left] != a[right]) {             if (~a[left]) {               ban[a[left]] = true;               ++numbers;             }             ++total;             left = prev[left];           }           int need = (total >> 1) + 1 - numbers;           if (need < 0) {             puts( no );             return 0;           }           for (int j = left; j < right; j = next[j]) {             if (!~a[j] && need) {               if (free.empty()) {                 puts( no );                 return 0;               } else {                 a[j] = free.back();                 --need;                 free.pop_back();               }             }           }           solve(left, right);         } else {           not_first[a[i]] = true;         }       }     }     puts( yes );     if (first) {       vector<int> temp;       for (int i = m - 1 - first; i < m - 1; ++i) {         temp.push_back(a[i]);       }       for (int i = 0; i < m - 1 - first; ++i) {         temp.push_back(a[i]);       }       temp.push_back(a[m - 1 - first]);       a = temp;     }     for (int i = 0; i < m; ++i) {       printf( %d%c , a[i] + 1, i == m - 1 ?   n  :    );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int answer();   int main() {     long long t;     t = 1;     while (t--) {       answer();     }     return 0;   }   int answer() {     string k;     cin >> k;     int sup[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};     if (k.size() > 1) {       cout << sup[k[0] -  0 ] * sup[k[1] -  0 ] << endl;     } else {       cout << sup[k[0] -  0 ] << endl;     }     return 0;   }


#include <bits/stdc++.h>   int main() {     double n, m;     scanf( %lf %lf , &m, &n);     double ans = 0;     for (int i = 1; i <= m; i++) {       ans += pow(i / m, n);     }     ans = m - ans + 1;     printf( %.10lf , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1 << 20;   const long long MOD = 2305843009255636993, RT = 5;   struct CD {     double r, i;     CD(double r = 0, double i = 0) : r(r), i(i) {}     double real() const { return r; }     void operator/=(const int c) { r /= c, i /= c; }   };   CD operator*(const CD& a, const CD& b) {     return CD(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r);   }   CD operator+(const CD& a, const CD& b) { return CD(a.r + b.r, a.i + b.i); }   CD operator-(const CD& a, const CD& b) { return CD(a.r - b.r, a.i - b.i); }   const double pi = acos(-1.0);   CD cp1[MAXN + 9], cp2[MAXN + 9];   int R[MAXN + 9];   void dft(CD* a, int n, bool inv) {     for (int i = 0, ThxDem = n; i < ThxDem; ++i)       if (R[i] < i) swap(a[R[i]], a[i]);     for (int m = 2; m <= n; m *= 2) {       double z = 2 * pi / m * (inv ? -1 : 1);       CD wi = CD(cos(z), sin(z));       for (int j = 0; j < n; j += m) {         CD w(1);         for (int k = j, k2 = j + m / 2; k2 < j + m; k++, k2++) {           CD u = a[k];           CD v = a[k2] * w;           a[k] = u + v;           a[k2] = u - v;           w = w * wi;         }       }     }     if (inv)       for (int i = 0, ThxDem = n; i < ThxDem; ++i) a[i] /= n;   }   vector<long long> multiply(vector<long long>& p1, vector<long long>& p2) {     int n = p1.size() + p2.size() + 1;     int m = 1, cnt = 0;     while (m <= n) m += m, cnt++;     for (int i = 0, ThxDem = m; i < ThxDem; ++i) {       R[i] = 0;       for (int j = 0, ThxDem = cnt; j < ThxDem; ++j)         R[i] = (R[i] << 1) | ((i >> j) & 1);     }     for (int i = 0, ThxDem = m; i < ThxDem; ++i) cp1[i] = 0, cp2[i] = 0;     for (int i = 0, ThxDem = p1.size(); i < ThxDem; ++i) cp1[i] = p1[i];     for (int i = 0, ThxDem = p2.size(); i < ThxDem; ++i) cp2[i] = p2[i];     dft(cp1, m, false);     dft(cp2, m, false);     for (int i = 0, ThxDem = m; i < ThxDem; ++i) cp1[i] = cp1[i] * cp2[i];     dft(cp1, m, true);     vector<long long> res;     n -= 2;     for (int i = 0, ThxDem = n; i < ThxDem; ++i)       res.push_back((long long)floor(cp1[i].real() + 0.5));     return res;   }   int spf[MAXN];   vector<int> ds;   vector<pair<int, int> > prs;   void gen(int x, int pos) {     if (pos == int(prs.size()))       ds.push_back(x);     else {       for (int i = 0, ThxDem = prs[pos].second + 1; i < ThxDem; ++i) {         if (i || prs[pos].first != 2) gen(x, pos + 1);         x *= prs[pos].first;       }     }   }   vector<int> dis[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (int i = 2, ThxDem = MAXN; i < ThxDem; ++i)       if (!spf[i])         for (int j = i; j < MAXN; j += i)           if (!spf[j]) spf[j] = i;     for (int i = 2, ThxDem = MAXN; i < ThxDem; ++i)       if (i % 2 == 0) {         prs.clear();         ds.clear();         int x = i;         while (x > 1) {           int now = spf[x], pw = 0;           while (x % now == 0) x /= now, pw++;           prs.push_back({now, pw});         }         gen(1, 0);         sort(ds.begin(), ds.end());         reverse(ds.begin(), ds.end());         dis[i] = ds;       }     int n, x, y;     cin >> n >> x >> y;     n++;     vector<int> a(n);     int off = x + 1;     vector<long long> neg(2 * (x + 1)), pos(2 * (x + 1));     for (int i = 0, ThxDem = n; i < ThxDem; ++i) {       cin >> a[i];       neg[x + 1 - a[i]] = 1;       pos[off + a[i]] = 1;     }     auto ws = multiply(neg, pos);     int q;     cin >> q;     vector<int> ans(q, -1);     for (int j = 0, ThxDem = q; j < ThxDem; ++j) {       int v;       cin >> v;       for (auto tt : dis[v]) {         int len = tt - 2 * y;         if (len <= 0 || len % 2) continue;         len /= 2;         if (2 * off + len < int(ws.size()) && ws[2 * off + len] > 0) {           ans[j] = tt;           break;         }       }     }     for (auto x : ans) cout << x <<    ;     cout <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   long long int pow(long long int x, long long int y, long long int m) {     long long int res = 1;     x = x % m;     while (y > 0) {       if (y & 1) res = ((res % m) * (x % m)) % m;       y = y >> 1;       x = ((x % m) * (x % m)) % m;     }     return res % m;   }   template <typename Arg1>   void ZZ(const char* name, Arg1&& arg1) {     std::cerr << name <<   =   << arg1 << endl;   }   template <typename Arg1, typename... Args>   void ZZ(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     std::cerr.write(names, comma - names) <<   =   << arg1;     ZZ(comma, args...);   }   const long long int INF = 0xFFFFFFFFFFFFFFFL;   long long int clz(unsigned long long N) {     return N ? 64LL - __builtin_clzll(N) : -INF;   }   clock_t time_p = clock();   void abhigyan10() {     time_p = clock() - time_p;     cerr <<  Time Taken :   << (float)(time_p) / CLOCKS_PER_SEC <<   n ;   }   long long int seed;   mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());   inline long long int rnd(long long int l = 0, long long int r = INF) {     return uniform_int_distribution<long long int>(l, r)(rng);   }   const long long int mod = 1000000007;   long long int modinv(long long int x) { return pow(x, mod - 2, mod); }   vector<long long int> a;   int bs(long long int x, long long int n) {     long long int l = 0, h = n - 1, m, ans = 0;     while (l <= h) {       m = (l + h) / 2;       if (a[m] <= x) {         l = m + 1;         ans = max(ans, m);       } else {         h = m - 1;       }     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int s = 0, t, n, p, i;     cin >> n >> p;     a.resize(n);     for (i = 0; i < n; i++) cin >> a[i];     sort(a.begin(), a.end());     for (i = 0; i < n; i++) s = max(s, a[i] - i);     t = a[n - 1];     for (i = 0; i < n;) {       int d = t + i;       int u = bs(d, n) + 1 - i;       if (u < p)         i++;       else         t--;       if (t < s) break;     }     cout << max(0LL, t - s + 1) <<   n ;     for (i = s; i <= t; i++) cout << i <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long MOD = 1e9 + 7;   long long powmod(long long a, long long l, long long md) {     long long res = 1;     while (l) {       if (l & 1) res = res * a % md;       l /= 2;       a = a * a % md;     }     return res;   }   long long binpow(long long a, long long l) {     long long res = 1;     while (l) {       if (l & 1) res = res * a;       l /= 2;       a = a * a;     }     return res;   }   long long __set(long long b, long long i) { return b | (1 << i); }   long long __unset(long long b, long long i) { return b & (~(1UL << i)); }   long long __check(long long b, long long i) { return b & (1 << i); }   long long mulmod(long long a, long long b, long long md) {     return ((a % md) * (b % md)) % md;   }   long long addmod(long long a, long long b, long long md) {     return (a + b) % md;   }   long long submod(long long a, long long b, long long md) {     return (((a - b) % md) + md) % md;   }   long long divmod(long long a, long long b, long long md) {     return mulmod(a, powmod(b, md - 2, md), md);   }   const long long inf = 0xFFFFFFFFFFFFFFFL;   priority_queue<long long, vector<long long>, greater<long long> > pq;   clock_t time_p = clock();   void time() {     time_p = clock() - time_p;     cerr <<  Time Taken :   << (float)(time_p) / CLOCKS_PER_SEC <<   n ;   }   long long d[3][10];   signed main(void) {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     for (long long i = 0; i < 3; i++) {       string s;       cin >> s;       if (s[1] ==  m ) {         d[0][s[0] -  0 ]++;       } else if (s[1] ==  p ) {         d[1][s[0] -  0 ]++;       } else {         d[2][s[0] -  0 ]++;       }     }     long long mx = 3;     for (long long i = 0; i < 3; i++) {       for (long long j = 1; j <= 9; j++) mx = min(mx, 3 - min(3ll, d[i][j]));       for (long long j = 1; j <= 7; j++) {         long long tp = 0;         if (!d[i][j]) tp++;         if (!d[i][j + 1]) tp++;         if (!d[i][j + 2]) tp++;         mx = min(mx, tp);       }     }     cout << mx <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   const int N = 1205;   const int INF = 0x3f3f3f3f;   template <class T>   bool read(T& x) {     char c;     while (!isdigit(c = getchar()) && c !=  -  && c != EOF)       ;     if (c == EOF) return false;     T flag = 1;     if (c ==  - ) {       flag = -1;       x = 0;     } else       x = c -  0 ;     while (isdigit(c = getchar())) x = x * 10 + c -  0 ;     x *= flag;     return true;   }   template <class T, class... R>   bool read(T& a, R&... b) {     if (!read(a)) return false;     return read(b...);   }   mt19937 gen(steady_clock::now().time_since_epoch().count());   struct edge {     int to, cap, next;   } e[N * 4];   int head[N], cnt, depth[N], group[N];   void add(int u, int v, int c) {     e[cnt] = {v, c, head[u]};     head[u] = cnt++;   }   void add_edge(int u, int v, int c) {     add(u, v, c);     add(v, u, 0);   }   bool isap_bfs(int s, int t) {     memset(depth, -1, sizeof(depth));     memset(group, 0, sizeof(group));     group[depth[t] = 0]++;     queue<int> q;     q.push(t);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = head[u]; ~i; i = e[i].next) {         int v = e[i].to;         if (~depth[v]) continue;         group[depth[v] = depth[u] + 1]++;         q.push(v);       }     }     return ~depth[s];   }   int isap_dfs(int u, int t, int c) {     if (u == t) return c;     int tmp = c;     for (int i = head[u]; tmp && ~i; i = e[i].next) {       int v = e[i].to;       if (depth[v] + 1 == depth[u] && e[i].cap) {         int d = isap_dfs(v, t, min(tmp, e[i].cap));         e[i].cap -= d;         e[i ^ 1].cap += d;         tmp -= d;       }     }     if (tmp) {       if (!--group[depth[u]]) depth[t] = -1;       group[++depth[u]]++;     }     return c - tmp;   }   int isap(int s, int t) {     if (!isap_bfs(s, t)) return 0;     int max_flow = 0;     while (~depth[t]) max_flow += isap_dfs(s, t, INF);     return max_flow;   }   int deg[N], x[N], y[N], xe[N], ye[N];   vector<int> edg[N];   int main() {     time_point<steady_clock> start = steady_clock::now();     int T, n, m, k;     read(T);     while (T--) {       read(n, m, k);       int s = 0, t = n + m + 1;       cnt = 0;       for (int i = s; i <= t; i++) {         head[i] = -1;         deg[i] = 0;         edg[i].clear();       }       for (int i = 1; i <= m; i++) {         read(x[i], y[i]);         deg[x[i]]++;         deg[y[i]]++;         edg[x[i]].push_back(i);         edg[y[i]].push_back(i);       }       for (int i = 1; i <= n; i++) {         if (deg[i] > 2 * k) {           k = -1;           break;         }       }       if (k == -1) {         for (int i = 1; i <= m; i++) printf( 0  );         puts(  );         continue;       }       int tot = 0;       for (int i = 1; i <= n; i++) {         if (deg[i] > k) {           tot += deg[i] - k;           add_edge(m + i, t, 2 * (deg[i] - k));         }       }       tot *= 2;       for (int i = 1; i <= m; i++) {         add_edge(s, i, 1);         add_edge(i, m + x[i], 1);         xe[i] = cnt - 1;         add_edge(i, m + y[i], 1);         ye[i] = cnt - 1;       }       if (isap(s, t) == tot) {         for (int i = 1; i <= m; i++) deg[i] = 0;         k = 1;         for (int i = 1; i <= n; i++) {           int c = 0;           for (auto j : edg[i]) {             if (x[j] == i && e[xe[j]].cap || y[j] == i && e[ye[j]].cap) {               if (c == 0)                 deg[j] = k;               else                 deg[j] = k++;               c ^= 1;             }           }         }         for (int i = 1; i <= m; i++)           if (!deg[i]) deg[i] = k++;         for (int i = 1; i <= m; i++) printf( %d  , deg[i]);         puts(  );       } else {         for (int i = 1; i <= m; i++) printf( 0  );         puts(  );       }     }     cerr << endl          <<  ------------------------------  << endl          <<  Time:            << duration<double, milli>(steady_clock::now() - start).count() <<   ms.           << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int ans = 1;     for (int i = 6; i <= n; i++) {       if (n % i == 0) {         int k1 = 0, k0 = 0;         int f = 0;         int x = i;         while (x > 1 and f == 0) {           int x2 = x % 2;           if (x2 == 1 and k0 > 0)             k1++;           else if (x2 == 0 and k1 == 0)             k0++;           else             f = 1;           x /= 2;         }         if (k1 - k0 == 0 and f == 0) ans = i;       }     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m, k, ans[2005];   char a[2010][2010];   void load() {     scanf( %d%d%d n , &n, &m, &k);     for (int i = 0; i < n; i++) {       scanf( %s , a[i]);     }   }   void solve() {     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  L ) {           if (j - i >= 0) {             ans[j - i]++;           }         }         if (a[i][j] ==  R ) {           if (j + i < m) {             ans[j + i]++;           }         }         if (a[i][j] ==  U ) {           if (i % 2 == 0) {             ans[j]++;           }         }       }     }     for (int i = 0; i < m; i++) {       if (i > 0) printf(   );       printf( %d , ans[i]);     }     printf(  n );   }   int main() {     load();     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int m;     cin >> m;     int c[m];     int sum1 = 0;     for (int i = 0; i < m; i++) {       cin >> c[i];       sum1 += c[i];     }     int x, y;     cin >> x >> y;     int flag = 0;     int k = 1;     int sum2 = 0;     if (sum2 >= x && sum2 <= y && sum1 - sum2 >= x && sum1 - sum2 <= y) {       flag = 1;       cout <<  1  << endl;     } else {       for (int i = 1; i <= m; i++) {         k = i;         sum2 += c[i - 1];         if (sum2 >= x && sum2 <= y && sum1 - sum2 >= x && sum1 - sum2 <= y) {           flag = 1;           cout << i + 1 << endl;           break;         }       }     }     if (flag == 0) {       cout <<  0  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, x, y;   char a[100005];   int main(void) {     scanf( %d%d%d , &n, &x, &y);     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     if (a[x] == a[y])       puts( 0 );     else       puts( 1 );   }


#include <bits/stdc++.h>   using namespace std;   int kk[(100010)];   map<int, int> possible;   int main() {     int t, m, k, tj, rj, pre(0);     bool first(false), already(false);     scanf( %d , &t);     for (int i = 0; i < t; ++i) {       first = false;       already = false;       pre = 0;       possible.clear();       scanf( %d%d , &m, &k);       for (int j = 1; j <= k; ++j) {         scanf( %d , &kk[j]);       }       for (int j = 0; j < m - 1; ++j) {         scanf( %d%d , &tj, &rj);         if (rj == 1 && !first) {           first = true;           for (int l = 1; l <= k; ++l) {             if (kk[l] == 0) {               already = true;               break;             }           }           if (!already) {             for (int l = 1; l <= k; ++l) {               if (kk[l] <= pre) {                 possible[l] = kk[l];               }             }           }         }         if (tj == 0) {           pre += 1;         } else {           kk[tj] -= 1;           if (first && !already) {             if (possible[tj] != 0) {               possible.erase(tj);             }           }         }       }       if (!already && first) {         int min = 100001;         map<int, int>::iterator it = possible.begin();         while (it != possible.end()) {           int count = (*it).second;           if (count != 0 && count < min) {             min = (*it).second;           }           it++;         }         pre -= min;       }       for (int j = 1; j <= k; ++j) {         if (possible[j] != 0) {           printf( %c ,  Y );         } else if (kk[j] <= pre) {           printf( %c ,  Y );         } else {           printf( %c ,  N );         }       }       printf(  n );     }   }


#include <bits/stdc++.h>   using namespace std;   long long int B = 257;   char s[1000100];   char t[1000100];   int n;   int m;   unsigned long long int hash1[1000100];   unsigned long long int hash2[1000100];   struct resp {     unsigned long long int count;     unsigned long long int indices[1000100];   } indice;   long long int expBinaria(long long int a, long long int b) {     long long int res = 1;     while (b) {       if (b % 2) res = res * a;       b = b / 2;       a = a * a;     }     return res;   }   void armaHashes() {     hash1[0] = 0;     for (int i = 1; i <= n; i++) {       hash1[i] = hash1[i - 1] * B + s[i - 1];     }     hash2[0] = 0;     for (int i = 1; i <= m; i++) {       hash2[i] = hash2[i - 1] * B + t[i - 1];     }   }   long long int h_1(int i, int j) {     return hash1[j] - hash1[i - 1] * expBinaria(B, j - i + 1);   }   long long int h_2(int i, int j) {     return hash2[j] - hash2[i - 1] * expBinaria(B, j - i + 1);   }   void solve() {     long long int cuenta = 0;     if (h_1(2, n) == h_2(1, m)) {       indice.indices[cuenta] = 1;       cuenta++;     }     for (int i = 2; i < n; i++) {       if (h_1(1, i - 1) == h_2(1, i - 1) && h_1(i + 1, n) == h_2(i, m)) {         indice.indices[cuenta] = i;         cuenta++;       }     }     if (h_1(1, n - 1) == h_2(1, m)) {       indice.indices[cuenta] = n;       cuenta++;     }     indice.count = cuenta;     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> s;     cin >> t;     n = strlen(s);     m = strlen(t);     armaHashes();     solve();     cout << indice.count;     cout <<   n ;     for (int i = 0; i < indice.count; i++) {       cout << indice.indices[i];       cout <<   t ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool isPrime(long long int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   vector<int> gr[50005];   int n, k;   bool vis[50005];   int lev[50005][505];   long long int dp[50005];   void dfs(int v) {     vis[v] = true;     lev[v][0] = 1;     for (auto ed : gr[v]) {       if (!vis[ed]) {         dfs(ed);         for (long long int i = 1; i < k + 1; i++) lev[v][i] += lev[ed][i - 1];       }     }   }   void solve(int v) {     vis[v] = true;     for (auto ed : gr[v]) {       if (!vis[ed]) {         solve(ed);         for (long long int i = 1; i < k; i++)           dp[v] += lev[ed][i - 1] * (lev[v][k - i] - lev[ed][k - i - 1]);       }     }     dp[v] /= 2;     dp[v] += lev[v][k];   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     int a, b;     for (long long int i = 0; i < n - 1; i++) {       cin >> a >> b;       gr[a].push_back(b);       gr[b].push_back(a);     }     memset(lev, 0, sizeof(lev));     memset(vis, false, sizeof(vis));     dfs(1);     memset(vis, false, sizeof(vis));     memset(dp, 0, sizeof(dp));     solve(1);     long long int ans = 0;     for (long long int i = 1; i < n + 1; i++) ans += dp[i];     cout << ans;   }


#include <bits/stdc++.h>   using namespace std;   using namespace std;   vector<bool> Prime(20000000 + 1, 1);   vector<bool> Pal(20000000 + 1, 1);   void gen1() {     long long int n = 2000000;     Prime[1] = 0;     for (long long int i = 2; i <= 20000000; i++) {       if (Prime[i]) {         for (long long int j = i + i; j <= n; j += i) Prime[j] = false;       }     }   }   void gen2() {     long long int n = 20000000;     long long int num, rev = 0, digit;     for (long long int i = 1; i <= 20000000; i++) {       num = i;       while (num > 0) {         digit = num % 10;         rev = rev * 10 + digit;         num = num / 10;       }       if (i != rev) Pal[i] = false;       rev = 0;     }   }   long long int a, b;   int main() {     ios::sync_with_stdio(false);     gen1(), gen2();     cin >> a >> b;     long long int ans = 1, primes = 0, pals = 0;     for (long long int i = 1; i <= 20000000; i++) {       if (Prime[i]) primes++;       if (Pal[i]) pals++;       if (b * primes <= a * pals) ans = max(ans, i);     }     cout << ans;   }


#include <bits/stdc++.h>   using namespace std;   bitset<6> a, b;   int main() {     int n;     cin >> n;     a = bitset<6>(n);     b.set(5, a[5]);     b.set(4, a[0]);     b.set(3, a[2]);     b.set(2, a[3]);     b.set(1, a[1]);     b.set(0, a[4]);     cout << b.to_ulong();   }


#include <bits/stdc++.h>   using namespace std;   bool a[30][30];   void fun(int x, int y) { a[x][y] = a[y][x] = true; }   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       memset(a, false, sizeof a);       int n, p;       cin >> n >> p;       if (n % 2 == 0) {         for (int i = 1; i <= n; i++) {           fun(i, i + 1);         }         fun(1, n);         int last;         for (int i = 1; i + 2 <= n; i += 2) {           fun(i, i + 2);           last = i + 2;         }         fun(2, last);         for (int i = 2; i + 2 <= n - 2; i += 2) {           if (i + 2 == n - 2) {             fun(i, i + 4);             last = i + 2;           } else             fun(i, i + 2);           last = i + 2;         }         fun(last, last + 2);         fun(1, last);         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n and p > 0; j++) {             if (i != j and a[i][j] == false) {               p--;               fun(i, j);             }           }         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n; j++)             if (i < j and a[i][j]) cout << i <<     << j << endl;       } else {         for (int i = 1; i <= n; i++) {           fun(i, i + 1);         }         fun(1, n);         int last;         for (int i = 1; i + 2 <= n; i += 2) {           fun(i, i + 2);           last = i + 2;         }         fun(2, last);         for (int i = 2; i + 2 <= n; i += 2) {           fun(i, i + 2);           last = i + 2;         }         fun(1, last);         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n and p > 0; j++) {             if (i != j and a[i][j] == false) {               p--;               fun(i, j);             }           }         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n; j++)             if (i < j and a[i][j]) cout << i <<     << j << endl;       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     if (n < k * 1ll * (k + 1) / 2) {       cout <<  NO  << endl;       return 0;     }     int nn = n - k * (k + 1) / 2;     vector<int> a(k);     for (int i = 0; i < k; ++i) {       a[i] = i + 1 + (nn / k) + (i >= k - nn % k);     }     if (nn != k - 1) {       cout <<  YES  << endl;       for (int i = 0; i < k; ++i) cout << a[i] <<    ;       cout << endl;     } else {       if (k > 3) {         --a[1];         ++a[k - 1];       }       if (k == 2 || k == 3) {         cout <<  NO  << endl;       } else {         cout <<  YES  << endl;         for (int i = 0; i < k; ++i) cout << a[i] <<    ;         cout << endl;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5, mod = 1e9 + 7;   long long a[N], x, n, sum;   long long fastpower(long long b, long long p) {     if (p == 0) return 1;     long long halfpower = fastpower(b, p / 2) % mod;     halfpower *= halfpower;     halfpower %= mod;     if (p % 2) halfpower = (halfpower * (b % mod)) % mod;     return halfpower;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> x;     for (int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     map<long long, long long> mp;     for (int i = 0; i < n; i++) mp[sum - a[i]]++;     for (auto i : mp) {       mp[i.first + 1] += (i.second / x);       if (i.second % x) {         cout << fastpower(x, min(i.first, sum));         return 0;       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n == 1) {       cout <<  1 1  << endl <<  1 ;       return 0;     }     cout << 5 * (n - 1) <<              <<  2  << endl          <<  1 5 ;   }


#include <bits/stdc++.h>   int const maxn = 255;   int const mod = 1e9 + 7;   long long a[maxn];   long long c[maxn][maxn];   long long pow(long long a, long long b, long long p) {     long long r = 1;     while (b) {       if (b & 1) r = (r * a) % p;       a = (a * a) % p;       b >>= 1;     }     return r;   }   int main() {     int n, k, i, j;     for (i = 0; i < maxn; i++) {       c[i][0] = c[i][i] = 1;       for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;     }     scanf( %d%d , &n, &k);     for (i = 1; i <= n; i++)       a[i] = pow(pow(k, i, mod) - pow(k - 1, i, mod), n, mod);     long long ans = a[n];     for (i = 1; i <= n; i++) {       if (i & 1)         ans = (ans - ((c[n][i] * pow(k - 1, i * n, mod)) % mod * a[n - i]) % mod +                mod) %               mod;       else         ans =             (ans + ((c[n][i] * pow(k - 1, i * n, mod)) % mod * a[n - i]) % mod) %             mod;     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b) {     long long res = 1;     a = a % 1000000007;     while (b > 0) {       if (b & 1) {         res = (res * a) % 1000000007;         b--;       }       a = (a * a) % 1000000007;       b >>= 1;     }     return res;   }   long long fermat_inv(long long y) { return power(y, 1000000007 - 2); }   long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       int n, q;       cin >> n >> q;       set<int> s;       for (int i = 0; i < n; i++) {         int a;         cin >> a;         s.insert(a);       }       map<long long, int> m;       for (auto it = s.begin(); it != s.end();) {         int val = *it;         val = -val;         it++;         if (it == s.end()) break;         val += (*it);         m[val]++;       }       auto it = m.end();       if (it == m.begin())         cout <<  0 n ;       else {         auto it1 = s.begin();         auto it2 = s.end();         it2--;         long long ans = (*it2) - (*it1);         it--;         ans -= it->first;         cout << ans <<   n ;       }       while (q--) {         int ty, x;         cin >> ty >> x;         if (ty == 0) {           auto it = s.lower_bound(x);           int ctr = 0;           long long val1 = 0;           if (it != s.begin()) {             it--;             long long val = x - (*it);             val1 += val;             ctr++;             m[val]--;             if (m[val] == 0) m.erase(val);           }           auto it1 = s.upper_bound(x);           if (it1 != s.end()) {             long long val = (*it1) - x;             m[val]--;             ctr++;             val1 += val;             if (m[val] == 0) m.erase(val);           }           if (ctr == 2) m[val1]++;           s.erase(x);         } else {           int ctr = 0;           auto it = s.lower_bound(x);           long long val1 = 0;           if (it != s.begin()) {             it--;             long long val = x - (*it);             val1 += val;             ctr++;             m[val]++;           }           auto it1 = s.upper_bound(x);           if (it1 != s.end()) {             long long val = (*it1) - x;             val1 += val;             ctr++;             m[val]++;           }           if (ctr == 2) m[val1]--;           if (m[val1] == 0) m.erase(val1);           s.insert(x);         }         auto it = m.end();         if (it == m.begin())           cout <<  0 n ;         else {           auto it1 = s.begin();           auto it2 = s.end();           it2--;           long long ans = (*it2) - (*it1);           it--;           ans -= it->first;           cout << ans <<   n ;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1000 * 1000 * 1000 + 7;   const long long int INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;   const long long int MOD2 = 998244353;   const long double PI = 3.141592653589793;   long long int gcd(long long int a, long long int b) {     if (!b) return a;     return gcd(b, a % b);   }   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x %= p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int power1(long long int x, long long int y) {     long long int res = 1;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   long long int lcm(long long int a, long long int b) {     return (a * b) / gcd(a, b);   }   long long int max(long long int a, long long int b) {     if (a > b) return a;     return b;   }   long long int min(long long int a, long long int b) {     if (a > b) return b;     return a;   }   bool sortbysec(const pair<long long int, long long int> &a,                  const pair<long long int, long long int> &b) {     return a.second < b.second;   }   vector<long long int> prime;   bool val[500];   void sieve() {     memset(val, true, sizeof(val));     val[1] = false;     val[0] = false;     for (long long int i = 2 * 2; i <= 500; i += 2) {       val[i] = false;     }     for (long long int i = 3; i <= 500; i++) {       if (val[i] == false) continue;       for (long long int j = i * i; j <= 500; j += i) {         val[j] = false;       }     }     for (int i = 0; i <= 500; i++) {       if (val[i] == true) {         prime.push_back(i);       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long int n, k;       cin >> n >> k;       long long int arr[n];       for (long long int i = 0; i < n; i++) {         cin >> arr[i];       }       if (n == 1) {         cout << k + 1 <<   n ;         continue;       }       if (k < 9) {         cout << k + 1 <<   n ;         continue;       }       long long int ans = 0;       long long int flag = 0;       long long int count = 0;       long long int count1 = 0;       for (long long int i = 1; i < n; i++) {         long long int num = power1(10, arr[i]) - 1;         count = 0;         for (long long int j = i - 1; j >= 0; j--) {           count += num / power1(10, arr[j]);           num -= ((num / power1(10, arr[j])) * power1(10, arr[j]));         }         if (count > k) {           cout << power1(10, arr[i - 1]) * (k - count1 + 1) +                       power1(10, arr[i - 1]) - 1                <<   n ;           flag = 1;           break;         }         count1 = count;       }       if (flag == 0) {         cout << (power1(10, arr[n - 1]) - 1) +                     power1(10, arr[n - 1]) * (k - count1 + 1)              <<   n ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long a, b;   int ans[60];   void dfs(int dep) {     long long cur = ans[dep - 1];     long long x = cur << 1;     long long y = cur * 10 + 1;     if (x == b || y == b) {       puts( YES );       cout << dep + 1 << endl;       for (int i = 0; i < dep; i++) cout << ans[i] <<    ;       cout << b << endl;       exit(0);     }     ans[dep] = x;     if (x < b) dfs(dep + 1);     ans[dep] = y;     if (y < b) dfs(dep + 1);   }   int main() {     cin >> a >> b;     ans[0] = a;     dfs(1);     puts( NO );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, x, y, z, r = 0;     scanf( %d%d%d%d%d%d , &a, &b, &c, &x, &y, &z);     if (a > x) {       r += (a - x) / 2;       a -= r * 2;     }     if (b > y) {       r += (b - y) / 2;       b -= (b - y) / 2 * 2;     }     if (c > z) {       r += (c - z) / 2;       c -= (c - z) / 2 * 2;     }     if (a < x) {       r -= x - a;       a += x - a;     }     if (r < 0) {       printf( No );       return 0;     }     if (b < y) {       r -= y - b;       b += y - b;     }     if (r < 0) {       printf( No );       return 0;     }     if (c < z) {       r -= z - c;       c += z - c;     }     if (r < 0) {       printf( No );       return 0;     }     printf( Yes );     return 0;   }


#include <bits/stdc++.h>   int a[6] = {0, 2, 3, 1, 2, 1};   int main() {     int n;     scanf( %d , &n);     printf( %d n , a[n]);     return 0;   }


#include <bits/stdc++.h>   #pragma comment(linker,  /stack:20000000 )   #pragma warning(disable : 4146)   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int inf = 1e9;   const long long lnf = 1e18;   const long long h1 = 239017, h2 = 731604233;   const long long mod = 1000000007, mod2 = 1000000009;   const long double pi = 3.141592653589793238462643383279;   const long double EPS = 1e-9;   struct rectangle {     int x1, x2;     int y1, y2;     rectangle(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}   };   vector<rectangle> v;   int n, x, y, first, second;   int xm[2005], ym[2005];   bool obs[2005][2005], a[2005][2005];   map<int, int> mx, my;   void dfs(int x, int y) {     if (x < 0 || x >= first || y < 0 || y >= second || obs[x][y] || a[x][y])       return;     a[x][y] = true;     dfs(x + 1, y);     dfs(x - 1, y);     dfs(x, y + 1);     dfs(x, y - 1);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     cout.tie();     cout << setprecision(20);     cin >> n;     for (int i = 0; i < (n); i++) {       char dir;       int d;       cin >> dir >> d;       if (dir ==  L ) {         rectangle r = {x - d, y, x + 1, y + 1};         v.push_back(r);         x -= d;       }       if (dir ==  R ) {         rectangle r = {x, y, x + d + 1, y + 1};         v.push_back(r);         x += d;       }       if (dir ==  U ) {         rectangle r = {x, y, x + 1, y + d + 1};         v.push_back(r);         y += d;       }       if (dir ==  D ) {         rectangle r = {x, y - d, x + 1, y + 1};         v.push_back(r);         y -= d;       }     }     for (int i = 0; i < (n); i++) {       mx[v[i].x1] = mx[v[i].x2] = 0;       my[v[i].y1] = my[v[i].y2] = 0;     }     for (auto &it : mx) {       it.second = first;       xm[first++] = it.first;     }     for (auto &it : my) {       it.second = second;       ym[second++] = it.first;     }     --first, --second;     for (int i = 0; i < (n); i++) {       int x1 = mx[v[i].x1], x2 = mx[v[i].x2], y1 = my[v[i].y1], y2 = my[v[i].y2];       for (int j = x1; j < x2; ++j)         for (int k = y1; k < y2; ++k) obs[j][k] = true;     }     for (int i = 0; i < (first); i++)       for (int j = 0; j < (second); j++)         if (!i || i == first - 1 || !j || j == second - 1) dfs(i, j);     long long ans = 0;     for (int i = 0; i < (first); i++)       for (int j = 0; j < (second); j++)         if (!a[i][j]) {           long long dx = xm[i + 1] - xm[i], dy = ym[j + 1] - ym[j];           ans += dx * dy;         }     cout << ans << endl;     cerr <<  Time used :   << (double)clock() * 1.0 / 1000 <<   seconds. n           << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y;     cin >> n >> x >> y;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (x > y) {       cout << n << endl;       return 0;     }     int cnt = 0;     for (int i = 0; i < n; i++) {       if (a[i] <= x) {         cnt++;       }     }     cout << (cnt + 1) / 2 << endl;   }


#include <bits/stdc++.h>   const int N = 100005;   using namespace std;   long long n, a, b, k;   char s[N];   long long mod = 1e9 + 9;   long long pow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       b >>= 1;       a = a * a % mod;     }     return ans;   }   long long ex_gcd(long long a, long long b, long long &x, long long &y) {     if (!b) {       x = 1, y = 0;       return a;     }     long long tmp = ex_gcd(b, a % b, x, y);     long long t = x;     x = y;     y = t - (a / b) * x;     return tmp;   }   long long inv(long long x) {     long long a, b;     ex_gcd(x, mod, a, b);     return (a + mod) % mod;   }   int main() {     scanf( %lld%lld%lld%lld , &n, &a, &b, &k);     scanf( %s , s);     long long ans = 0, m = (n + 1) / k;     for (int i = 0; i < k; i++) {       long long x = pow(a, n - i), y = pow(b, i);       long long now = x * y % mod;       if (s[i] ==  + )         ans += now;       else         ans -= now;       ans = (ans + mod) % mod;     }     long long q = pow(inv(a), k) * pow(b, k) % mod;     if (q == 1)       ans = ans * m % mod;     else {       long long x = inv(q - 1) % mod;       ans = (ans * (pow(q, m) - 1) % mod) * x % mod;     }     ans = (ans + mod) % mod;     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long mod = 1000000007;   long long r(pair<int, int> a) {     long long x = a.first;     long long y = a.second;     return x * x + y * y;   }   pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {     return make_pair(a.first + b.first, a.second + b.second);   }   pair<int, int> operator-(pair<int, int> a, pair<int, int> b) {     return make_pair(a.first - b.first, a.second - b.second);   }   int main() {     ios_base::sync_with_stdio(false);     int N;     cin >> N;     vector<pair<pair<int, int>, vector<int>>> a;     for (int i = 1; i <= N; i++) {       int x, y;       cin >> x >> y;       a.push_back({{x, y}, {i}});     }     shuffle(a.begin(), a.end(), rng);     while (a.size() >= 3) {       int i = a.size() - 1;       int j = a.size() - 2;       int wj = 1;       pair<int, int> mnn = {1e8, 1e8};       for (int x = a.size() - 3; x < (int)a.size(); x++) {         for (int y = x + 1; y < (int)a.size(); y++) {           if (x == y) continue;           pair<int, int> v1 = a[x].first + a[y].first;           pair<int, int> v2 = a[x].first - a[y].first;           if (r(v1) < r(mnn)) {             mnn = v1;             i = x;             j = y;             wj = 1;           }           if (r(v2) < r(mnn)) {             mnn = v2;             i = x;             j = y;             wj = -1;           }         }       }       a[i].first = a[j].first = mnn;       if (a[j].second.size() < a[i].second.size()) {         for (int c : a[j].second) {           a[i].second.push_back(c * wj);         }         a.erase(a.begin() + j);       } else {         if (wj == 1) {           for (int c : a[i].second) {             a[j].second.push_back(c * wj);           }           a.erase(a.begin() + i);         } else {           a[j].first = make_pair(0, 0) - a[j].first;           for (int c : a[i].second) {             a[j].second.push_back(-c);           }           a.erase(a.begin() + i);         }       }     }     if (a.size() == 2) {       if (r(a[0].first - a[1].first) < r(a[0].first + a[1].first)) {         for (int &i : a[1].second) i *= -1;       }     }     int w[N + 1];     for (auto ii : a) {       for (int i : ii.second) {         if (i > 0)           w[i] = 1;         else           w[-i] = -1;       }     }     for (int i = 1; i <= N; i++) cout << w[i] <<    ;   }


#include <bits/stdc++.h>   using namespace std;   int n, x, y, z, q, sum;   int main() {     ios_base::sync_with_stdio(0);     for (cin >> n; n; --n)       cin >> x >> y >> z >> q, sum += (z - x + 1) * (q - y + 1);     cout << sum <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N(200009);   struct LnkNode {     int v, w, nxt;   } edge[N << 3];   int etot = 1, fst[N], cur[N];   void addedge_(int u, int v, int w) {     ++etot;     edge[etot].v = v;     edge[etot].w = w;     edge[etot].nxt = fst[u];     fst[u] = etot;   }   void addedge(int u, int v, int w) { addedge_(u, v, w), addedge_(v, u, 0); }   void deledge_(int u) { fst[u] = edge[fst[u]].nxt; }   int n, m, r, b, x[N], y[N], cntx[N], cnty[N], x_[N], y_[N], limx[N], limy[N],       dt[N], mf, d[N], q[N], Head, Tail;   bool bfs(int s, int t) {     memset(d + 1, 0x3f, ((n << 1) + 4) << 2);     Head = Tail = 0;     d[q[Tail++] = s] = 0;     while (Head ^ Tail) {       int &x = q[Head++];       for (int i = fst[x]; i; i = edge[i].nxt) {         int &y = edge[i].v, &w = edge[i].w;         if (w && d[y] > d[x] + 1) d[q[Tail++] = y] = d[x] + 1;       }     }     return d[t] != 0x3f3f3f3f;   }   int dfs(int x, int t, int f) {     if (x == t) return f;     int r = f;     for (int &i = cur[x]; i; i = edge[i].nxt) {       int &y = edge[i].v, &w = edge[i].w;       if (w && d[y] == d[x] + 1) {         int k = dfs(y, t, min(r, w));         w -= k, edge[i ^ 1].w += k;         if (!(r -= k)) break;       }     }     return f - r;   }   char res[N];   int main() {     scanf( %d%d%d%d , &n, &m, &r, &b);     for (int i = 1; i <= n; ++i) scanf( %d%d , x + i, y + i);     memcpy(x_ + 1, x + 1, n << 2);     sort(x_ + 1, x_ + 1 + n);     memcpy(y_ + 1, y + 1, n << 2);     sort(y_ + 1, y_ + 1 + n);     for (int i = 1; i <= n; ++i) {       ++cntx[x[i] = lower_bound(x_ + 1, x_ + 1 + n, x[i]) - x_];       ++cnty[y[i] = lower_bound(y_ + 1, y_ + 1 + n, y[i]) - y_];       addedge(x[i], n + y[i], 1);     }     for (int i = 1; i <= n; ++i) limx[i] = limy[i] = n;     int t, l, d;     while (m--) {       scanf( %d%d%d , &t, &l, &d);       switch (t) {         case 1: {           int t_ = lower_bound(x_ + 1, x_ + 1 + n, l) - x_;           if (t_ <= n && x_[t_] == l && limx[t_] > d) limx[t_] = d;           break;         }         case 2: {           int t_ = lower_bound(y_ + 1, y_ + 1 + n, l) - y_;           if (t_ <= n && y_[t_] == l && limy[t_] > d) limy[t_] = d;           break;         }       }     }     for (int i = 1; i <= n; ++i) {       if (cntx[i]) {         int lb = (cntx[i] > limx[i]                       ? (((cntx[i] - limx[i]) >> 1) + ((cntx[i] - limx[i]) & 1))                       : 0),             rb = (cntx[i] + limx[i]) >> 1;         if (lb > rb) return puts( -1 ), 0;         dt[(n << 1) + 1] -= lb, dt[i] += lb, addedge((n << 1) + 1, i, rb - lb);       }       if (cnty[i]) {         int lb = (cnty[i] > limy[i]                       ? (((cnty[i] - limy[i]) >> 1) + ((cnty[i] - limy[i]) & 1))                       : 0),             rb = (cnty[i] + limy[i]) >> 1;         if (lb > rb) return puts( -1 ), 0;         dt[n + i] -= lb, dt[(n << 1) + 2] += lb,             addedge(n + i, (n << 1) + 2, rb - lb);       }     }     for (int i = 1; i <= (n << 1) + 2; ++i) {       if (dt[i] > 0)         addedge((n << 1) + 3, i, dt[i]);       else if (dt[i] < 0)         addedge(i, (n << 1) + 4, -dt[i]);     }     addedge((n << 1) + 2, (n << 1) + 1, 0x7fffffff);     int f;     while (bfs((n << 1) + 3, (n << 1) + 4)) {       memcpy(cur + 1, fst + 1, ((n << 1) + 4) << 2);       while (dfs((n << 1) + 3, (n << 1) + 4, 0x7fffffff))         ;     }     for (int i = fst[(n << 1) + 3]; i; i = edge[i].nxt)       if (edge[i].w) return puts( -1 ), 0;     mf += edge[etot].w;     deledge_((n << 1) + 1), deledge_((n << 1) + 2);     while (bfs((n << 1) + 1, (n << 1) + 2)) {       memcpy(cur + 1, fst + 1, ((n << 1) + 4) << 2);       while ((f = dfs((n << 1) + 1, (n << 1) + 2, 0x7fffffff))) mf += f;     }     printf( %lld n , (long long)mf * min(r, b) + (long long)(n - mf) * max(r, b));     for (int i = 1; i <= n; ++i) putchar((edge[i << 1].w ^ (r < b)) ?  r  :  b );     putchar(10);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int nmax = 123456;   int n;   int a[nmax], b[nmax], c[nmax];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++)       if (i == a[i]) {         printf( YES n );         for (int j = 1; j <= n; j++)           if (j != i) printf( %d %d n , i, j);         return 0;       }     for (int i = 1; i <= n; i++)       if (i == a[a[i]]) {         int bb = 0;         b[i] = 1;         b[a[i]] = 1;         for (int j = 1; j <= n; j++)           if (b[j] != 1) {             int dd = j;             int cc = 0;             while (b[dd] != 1) {               cc++;               b[dd] = 1;               dd = a[dd];             }             bb += cc % 2;           }         if (bb >= 1) {           printf( NO );           return 0;         } else {           printf( YES n );           for (int j = 1; j <= n; j++) b[j] = 0;           b[i] = 1;           b[a[i]] = 1;           int y = i;           for (int j = 1; j <= n; j++)             if (b[j] != 1) {               int x = j;               while (b[x] != 1) {                 printf( %d %d n , y, x);                 b[x] = 1;                 x = a[x];                 y = a[y];               }             }           printf( %d %d , i, a[i]);           return 0;         }       }     printf( NO n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long a[5], b[5], n, cu, medal, x, y;     cin >> a[1] >> a[2] >> a[3];     cu = a[1] + a[2] + a[3];     cin >> b[1] >> b[2] >> b[3];     medal = b[1] + b[2] + b[3];     cin >> n;     if (cu % 5 == 0)       x = cu / 5;     else       x = cu / 5 + 1;     if (medal % 10 == 0)       y = medal / 10;     else       y = medal / 10 + 1;     if (n == 1 && cu > 0 && medal > 0 || x + y > n)       cout <<  NO ;     else       cout <<  YES ;   }


#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int si, lef, t0;   int a1, t1, p1;   int a2, t2, p2;   int main() {     cin >> si >> lef >> t0;     cin >> a1 >> t1 >> p1;     cin >> a2 >> t2 >> p2;     if (t1 > t2) {       swap(a1, a2);       swap(t1, t2);       swap(p1, p2);     }     long long ans = 1LL * inf * inf;     for (int i = 0;; ++i) {       if ((long long)a1 * t1 * (i - 1) > lef) {         break;       }       long long t = 0;       if (i && 1LL * a1 * i >= si && 1LL * a1 * (i - 1) < si) {         t = 1LL * a1 * t1 * (i - 1) + 1LL * (si - 1LL * a1 * (i - 1)) * t1;         if (t <= lef) {           ans = min(ans, (long long)p1 * i);         }       } else if (1LL * a1 * i < si) {         t += 1LL * a1 * t1 * i;         long long ts = si - a1 * i;         if (t + 1LL * ts * t0 <= lef) {           ans = min(ans, (long long)p1 * i);         } else {           if (t2 < t0) {             long long byte = (t + 1LL * ts * t0 - lef + t0 - t2 - 1) / (t0 - t2);             if (byte <= ts) {               long long bug = (byte + a2 - 1) / a2;               ans = min(ans, 1LL * i * p1 + 1LL * bug * p2);             }           }         }       }     }     if (ans == 1LL * inf * inf) {       ans = -1;     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct comp {     double x, y;   } a[65600], b[65600], c[65600], fft[65600], tp[17][65600];   double pi = acos(-1.0);   comp operator+(comp a, comp b) { return (comp){a.x + b.x, a.y + b.y}; }   comp operator-(comp a, comp b) { return (comp){a.x - b.x, a.y - b.y}; }   comp operator*(comp a, comp b) {     return (comp){a.x * b.x - a.y * b.y, a.y * b.x + b.y * a.x};   }   comp operator/(comp a, double b) { return (comp){a.x / b, a.y / b}; }   int rev[65600], n, m, p, s[65600][2], as;   void dft(int s, comp *a, int t) {     for (int i = 0; i < s; i++)       rev[i] = (rev[i >> 1] >> 1) + (i & 1) * (s >> 1), fft[rev[i]] = a[i];     for (int l = 2, lg = 1; l <= s; l <<= 1, lg++)       for (int j = 0; j < s; j += l)         for (int k = j; k < j + (l >> 1); k++) {           comp sp = tp[lg][k - j];           if (t == -1) sp.y *= -1;           comp tp1 = fft[k], tp2 = fft[k + (l >> 1)] * sp;           fft[k] = tp1 + tp2, fft[k + (l >> 1)] = tp1 - tp2;         }     int inv = t == -1 ? s : 1;     for (int i = 0; i < s; i++) a[i] = fft[i] / inv;   }   void solve(int x) {     if (x == 0) return;     if (x == 1) {       s[1][1] = 1;       as = 1;       return;     }     int tp = x / 2;     solve(tp);     int l = 1;     while (l <= n * 2 + 1) l <<= 1;     for (int i = 0; i < l; i++)       a[i].x = a[i].y = b[i].x = b[i].y = c[i].x = c[i].y = 0;     for (int i = 1; i <= n; i++) a[i].x = s[i][0], b[i].x = s[i][1];     dft(l, a, 1), dft(l, b, 1);     for (int i = 0; i < l; i++) c[i] = (a[i] + b[i] + (comp){1, 0}) * a[i];     dft(l, c, -1);     for (int i = 1; i <= n; i++)       s[i][tp & 1] = (s[i][tp & 1] + (long long)(c[i].x + 0.1)) % p;     for (int i = 0; i < l; i++) c[i] = (a[i] + b[i] + (comp){1, 0}) * b[i];     dft(l, c, -1);     for (int i = 1; i <= n; i++)       s[i][~tp & 1] = ((long long)(c[i].x + 0.1) + s[i][~tp & 1]) % p;     if (x & 1)       for (int i = n; i > 1; i--)         s[i][1] = (s[i][1] + s[i - 1][1] + s[i - 1][0]) % p;     if (x & 1) s[1][1] = (s[1][1] + 1) % p;     for (int i = 1; i <= n; i += 2) as = (as + s[i][1]) % p;   }   void init() {     for (int i = 1; i < 17; i++)       for (int j = 0; j < 1 << i; j++)         tp[i][j] = (comp){cos(2 * pi / (1 << i) * j), sin(2 * pi / (1 << i) * j)};   }   int main() {     scanf( %d%d%d , &n, &m, &p);     init();     solve(m / 2);     printf( %d n , as);   }


#include <bits/stdc++.h>   using namespace std;   vector<int> g[26];   int visited[26];   int p[26], deg[26];   string ans;   bool fail;   void dfs(int u) {     visited[u] = 2;     ans += (char)(u +  a );     for (int i = 0; i < (int)g[u].size(); i++) {       int v = g[u][i];       if (visited[v] == 0) {         p[v] = u;         dfs(v);       } else if (visited[v] == 2) {         if (p[u] != v) {           fail = true;         }       }     }     visited[u] = 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       string s;       cin >> s;       int n = s.size();       ans =   ;       for (int i = 0; i < 26; i++) {         g[i].clear();         visited[i] = 0;         p[i] = -1;         deg[i] = 0;       }       map<pair<int, int>, int> m;       for (int i = 1; i < n; i++) {         int v = (s[i] -  a );         int u = (s[i - 1] -  a );         int uu = min(u, v);         int vv = max(u, v);         if (m[make_pair(uu, vv)] == 0) {           g[u].push_back(v);           g[v].push_back(u);           deg[u]++;           deg[v]++;           m[make_pair(uu, vv)]++;         }       }       fail = false;       for (int i = 0; i < 26; i++) {         if (deg[i] > 2) {           fail = true;         }         if (!visited[i] && deg[i] < 2) {           dfs(i);         }       }       if (fail || ans.size() < 26) {         cout <<  NO  <<   n ;       } else {         cout <<  YES  <<   n ;         cout << ans <<   n ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int bench, more, temp;     vector<int> v;     cin >> bench >> more;     for (int i = 0; i < bench; i++) {       cin >> temp;       v.push_back(temp);     }     int min, max = *max_element(v.begin(), v.end());     ;     min = *min_element(v.begin(), v.end());     int max_val = max + more;     for (int i = 0; i < more; i++) {       sort(v.begin(), v.end());       v[0]++;     }     std::sort(v.begin(), v.end(), std::greater<int>());     int min_val = v[0];     cout << min_val <<     << max_val;   }


#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 1e6 + 10;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   inline int read() {     static char buf[1000000], *p1 = buf, *p2 = buf;     register int x = false;     register char ch =         p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)             ? EOF             : *p1++;     ;     register bool sgn = false;     while (ch !=  -  && (ch <  0  || ch >  9 ))       ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)                ? EOF                : *p1++;     ;     if (ch ==  - )       sgn = true,       ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)                ? EOF                : *p1++;     ;     while (ch >=  0  && ch <=  9 )       x = (x << 1) + (x << 3) + (ch ^ 48),       ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)                ? EOF                : *p1++;     ;     return sgn ? -x : x;   }   long long fpow(long long a, int b, int mod) {     long long res = 1;     for (; b > 0; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long a[N];   double ans[N];   long long sum[N];   int s[N];   int idx = 1;   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       sum[i] = sum[i - 1] + a[i];     }     for (int i = 1; i <= n; i++) {       while (idx > 1 && (sum[i] - sum[s[idx]]) * (i - s[idx - 1]) <=                             (sum[i] - sum[s[idx - 1]]) * (i - s[idx]))         idx--;       s[++idx] = i;     }     for (int i = 2; i <= idx; i++) {       double res = 1.0 * (sum[s[i]] - sum[s[i - 1]]) / (s[i] - s[i - 1]);       for (int j = 1; j <= s[i] - s[i - 1]; j++) {         printf( %.10f n , res);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10;   int n, k;   int v[MAXN];   int f[MAXN];   int search(int num) {     int l = 1, r = n;     while (l < r) {       int mid = (l + r) / 2;       if (v[mid] < num) {         l = mid + 1;       } else {         r = mid;       }     }     return l;   }   bool check(int len) {     memset(f, 0, sizeof(f));     for (int i = 1; i <= n; i++) {       int t = search(v[i] - len);       if (t == 1 && i - t + 1 >= k) {         if (i == n) {           return true;         }         f[i] += f[i - 1] + 1;       } else if (t >= 2 && i - t + 1 >= k && f[i - k] - f[t - 2] > 0) {         if (i == n) {           return true;         }         f[i] += f[i - 1] + 1;       } else {         f[i] = f[i - 1];       }     }     return false;   }   int main(int argc, const char* argv[]) {     scanf( %d , &(n));     scanf( %d , &(k));     for (int i = 1; i <= n; i++) {       scanf( %d , &(v[i]));     }     sort(v + 1, v + 1 + n);     int l = 0, r = 1000000000;     while (l < r) {       int mid = (l + r) / 2;       if (check(mid)) {         r = mid;       } else {         l = mid + 1;       }     }     printf( %d n , l);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct node {     bool visited;     short prex;     short prey;     short val;     node() { visited = false; }     void print() {       cout << visited <<   (  << prex <<  ,   << prey <<  )   << val << endl;     }   };   struct coord {     int x, y;     coord(int x, int y) {       this->x = x;       this->y = y;     }   };   class SpecialNum {    public:     SpecialNum(int d, int s) {       this->d = d;       this->s = s;       init();     }     bool get() { return get(0, s); }     bool get(int x, int y);       private:     int d, s;     node** table = 0;     void init() {       table = new node*[d];       for (int i = 0; i < d; i++) table[i] = new node[s + 1];       bfs();     }     void bfs();   };   void SpecialNum::bfs() {     queue<coord> que;     int nextx = 0, nexty = 0;     que.push(coord(0, 0));     while (!que.empty()) {       coord cur = que.front();       que.pop();       for (int i = 0; i < 10; i++) {         nextx = (10 * cur.x + i) % d;         nexty = cur.y + i;         if (table[nextx][nexty].visited || nexty > s) continue;         table[nextx][nexty].visited = true;         table[nextx][nexty].prex = cur.x;         table[nextx][nexty].prey = cur.y;         table[nextx][nexty].val = i;         que.push(coord(nextx, nexty));       }     }   }   bool SpecialNum::get(int x, int y) {     if (!table[x][y].visited || (x == 0 && y == 0)) return false;     get(table[x][y].prex, table[x][y].prey);     cout << table[x][y].val;     return true;   }   int main() {     int d, s;     cin >> d >> s;     SpecialNum* sn = new SpecialNum(d, s);     if (!sn->get()) cout << -1;     cout << endl;   }


#include <bits/stdc++.h>   using namespace std;   int n;   void chis(int x) {     switch (x) {       case 0:         cout <<  zero  << endl;         break;       case 1:         cout <<  one  << endl;         break;       case 2:         cout <<  two  << endl;         break;       case 3:         cout <<  three  << endl;         break;       case 4:         cout <<  four  << endl;         break;       case 5:         cout <<  five  << endl;         break;       case 6:         cout <<  six  << endl;         break;       case 7:         cout <<  seven  << endl;         break;       case 8:         cout <<  eight  << endl;         break;       case 9:         cout <<  nine  << endl;         break;     }   }   void chis2(int x) {     switch (x) {       case 2:         cout <<  twenty ;         break;       case 3:         cout <<  thirty ;         break;       case 4:         cout <<  forty ;         break;       case 5:         cout <<  fifty ;         break;       case 6:         cout <<  sixty ;         break;       case 7:         cout <<  seventy ;         break;       case 8:         cout <<  eighty ;         break;       case 9:         cout <<  ninety ;         break;     }   }   void chis3(int x) {     switch (x) {       case 10:         cout <<  ten  << endl;         break;       case 11:         cout <<  eleven  << endl;         break;       case 12:         cout <<  twelve  << endl;         break;       case 13:         cout <<  thirteen  << endl;         break;       case 14:         cout <<  fourteen  << endl;         break;       case 15:         cout <<  fifteen  << endl;         break;       case 16:         cout <<  sixteen  << endl;         break;       case 17:         cout <<  seventeen  << endl;         break;       case 18:         cout <<  eighteen  << endl;         break;       case 19:         cout <<  nineteen  << endl;         break;     }   }   void read() {     cin >> n;     if (n <= 9)       chis(n);     else {       int des = n / 10;       if (des == 1)         chis3(n);       else {         chis2(des);         int ost = n % 10;         if (ost == 0)           cout << endl;         else {           cout <<  - ;           chis(ost);         }       }     }   }   int main() {     read();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     if (n == 1)       cout <<  1 ;     else if (n <= 5 && n != 3)       cout <<  3 ;     else if (n <= 13)       cout <<  5 ;     else if (n <= 25)       cout <<  7 ;     else if (n <= 41)       cout <<  9 ;     else if (n <= 61)       cout <<  11 ;     else if (n <= 85)       cout <<  13 ;     else       cout <<  15 ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n, x, y, a, b;     cout <<  YES n ;     cin >> n;     while (n--) {       cin >> x >> y >> a >> b;       cout << (abs(2 * (x % 2)) + abs(y % 2)) + 1 << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e3;   int a[N];   int main() {     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + 1 + n);     cout << a[n - k + 1];   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int d, L, v1, v2;     cin >> d >> L >> v1 >> v2;     printf( %lf n , 1.0 * (L - d) / (v1 + v2));   }


#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 77, Mod = 1e9 + 7;   int n, d1[N], d2[N], P1, P2, Mx, deg[N], p1[N], p2[N];   long long A;   vector<pair<int, pair<int, int> > > R;   vector<int> a[N];   void dfs(int v, int prev, bool t) {     for (int u : a[v]) {       if (u == prev) {         continue;       }       if (t) {         d1[u] = d1[v] + 1;         p1[u] = v;       } else {         d2[u] = d2[v] + 1;         p2[u] = v;       }       dfs(u, v, t);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int v, u;       scanf( %d %d , &v, &u);       deg[v]++;       deg[u]++;       a[v].push_back(u);       a[u].push_back(v);     }     dfs(1, 1, 1);     for (int i = 1; i <= n; i++) {       if (d1[i] > Mx) {         Mx = d1[i];         P1 = i;       }     }     d1[P1] = 0;     dfs(P1, P1, 1);     Mx = 0;     for (int i = 1; i <= n; i++) {       if (d1[i] > Mx) {         Mx = d1[i];         P2 = i;       }     }     dfs(P2, P2, 0);     vector<int> Leaves;     for (int i = 1; i <= n; i++) {       if (i == P1 || i == P2 || deg[i] > 1) continue;       Leaves.push_back(i);     }     while (Leaves.size()) {       int v = Leaves.back();       Leaves.pop_back();       if (d1[v] >= d2[v]) {         A += d1[v];         R.push_back(make_pair(v, make_pair(P1, v)));       } else {         A += d2[v];         R.push_back(make_pair(v, make_pair(P2, v)));       }       deg[v]--;       for (int u : a[v]) {         deg[u]--;         if (deg[u] == 1) Leaves.push_back(u);       }     }     while (p2[P1]) {       R.push_back(make_pair(P1, make_pair(P2, P1)));       A += d2[P1];       P1 = p2[P1];     }     printf( %I64d n , A);     for (auto x : R)       printf( %d %d %d n , x.first, x.second.first, x.second.second);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long int a, b, c;     cin >> a >> b >> c;     long int temp = b - a;     if (c == 0 || b == a) {       if (b == a)         cout <<  YES ;       else         cout <<  NO ;     } else if (temp % c == 0) {       if ((temp < 0 && c < 0) || (temp > 0 && c > 0))         cout <<  YES ;       else         cout <<  NO ;     } else       cout <<  NO ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1.0);   template <typename T>   T abs(T x) {     return x > 0 ? x : -x;   }   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   bool chmin(T &x, T y) {     if (x > y) {       x = y;       return true;     }     return false;   }   template <typename T>   bool chmax(T &x, T y) {     if (x < y) {       x = y;       return true;     }     return false;   }   template <typename U, typename V>   ostream &operator<<(ostream &s, const pair<U, V> &x) {     s <<  (  << x.fst <<  ,   << x.snd <<  ) ;     return s;   }   template <typename U>   ostream &operator<<(ostream &s, const vector<U> &x) {     s <<  [ ;     bool was = false;     for (auto it : x) {       if (was) {         s <<  ,  ;       }       was = true;       s << it;     }     s <<  ] ;     return s;   }   template <typename U>   ostream &operator<<(ostream &s, const set<U> &x) {     s <<  { ;     bool was = false;     for (auto it : x) {       if (was) {         s <<  ,  ;       }       was = true;       s << it;     }     s <<  } ;     return s;   }   template <int sz>   ostream &operator<<(ostream &s, const bitset<sz> &x) {     for (int i = 0; i < sz; i++) {       s << x[i];     }     return s;   }   int main() {     srand(time(0));     int k;     cin >> k;     int maxi = 25;     while (k--) {       int p;       cin >> p;       chmax(maxi, p);     }     cout << maxi - 25 << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n, A, cf, cm, m;   long long L, ans[100005], f, ansA, ansL;   long long s[100005];   struct data {     long long id, v;   } a[100005];   bool cmp(data a, data b) { return a.v < b.v || a.v == b.v && a.id < b.id; }   long long findL(long long m, long long R) {     long long l = 0, r = A, ans = 0;     while (l <= r) {       long long mid = (l + r) >> 1;       int p = lower_bound(a + 1, a + n + 1, (data){0, mid}, cmp) - a - 1;       if (p > R) p = R;       if (p * mid - s[p] <= m) {         ans = mid;         l = mid + 1;       } else         r = mid - 1;     }     return ans;   }   void init() {     cin >> n >> A >> cf >> cm >> m;     for (int i = 1; i <= n; i++) {       cin >> a[i].v;       a[i].id = i;     }     sort(a + 1, a + n + 1, cmp);     for (int i = 1; i <= n; i++) {       s[i] = s[i - 1] + a[i].v;     }     for (int i = 0; i <= n; i++) {       long long p = A * i - s[n] + s[n - i];       if (p <= m) {         L = findL(m - p, n - i);         if (cm * L + cf * i > f) {           f = cm * L + cf * i;           ansA = i;           ansL = L;         }       }     }     cout << f << endl;     for (int j = 1; j <= n; j++) {       if (j > n - ansA) {         ans[a[j].id] = A;       } else if (a[j].v <= ansL) {         ans[a[j].id] = ansL;       } else         ans[a[j].id] = a[j].v;     }     for (int i = 1; i <= n; i++) {       cout << ans[i] <<    ;     }   }   int main() {     init();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long N = 3E5 + 7, mod = 998244353;   long long n, a[N], inv[N], ans;   signed main() {     scanf( %lld , &n);     for (long long i = 1; i <= n << 1; i++) scanf( %lld , &a[i]);     sort(a + 1, a + 2 * n + 1);     for (long long i = 1; i <= n; i++) ans = (ans - a[i] + mod) % mod;     for (long long i = n + 1; i <= n << 1; i++) ans = (ans + a[i]) % mod;     for (long long i = n << 1; i >= n + 1; i--) ans = ans * i % mod;     inv[1] = 1;     for (long long i = 2; i <= n; i++) {       inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;       ans = 1ll * ans * inv[i] % mod;     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long int n;     cin >> n;     int a[n], b[n], i;     for (i = 0; i < n; ++i) cin >> a[i] >> b[i];     for (i = 0; i < n; ++i) {       if (a[i] != b[i]) break;     }     if (i == n) {       for (i = 1; i < n; ++i) {         if (a[i] <= a[i - 1])           continue;         else           break;       }       if (i == n)         cout <<  maybe ;       else         cout <<  unrated ;     } else       cout <<  rated ;     return 0;   }