#include <bits/stdc++.h>   using namespace std;   inline int toInt(string s) {     int v;     istringstream sin(s);     sin >> v;     return v;   }   inline long long toLongLong(string s) {     long long v;     istringstream sin(s);     sin >> v;     return v;   }   template <class T>   inline string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   inline vector<char> toVC(string s) {     vector<char> data(s.begin(), s.end());     return data;   }   vector<string> SPRIT(const string &s, const string &delim) {     vector<string> result;     string::size_type pos = 0;     while (pos != string::npos) {       string::size_type p = s.find(delim, pos);       if (p == string::npos) {         result.push_back(s.substr(pos));         break;       } else {         result.push_back(s.substr(pos, p - pos));       }       pos = p + delim.size();     }     return result;   }   string TRIM(const string &str, const char *trimCharacterList =    t v r n ) {     string result;     string::size_type left = str.find_first_not_of(trimCharacterList);     if (left != string::npos) {       string::size_type right = str.find_last_not_of(trimCharacterList);       result = str.substr(left, right - left + 1);     }     return result;   }   string REPLACE_STRING(const string source, const string find,                         const string alt) {     string result = source;     string::size_type pos = 0;     while (pos = result.find(find, pos), pos != string::npos) {       result.replace(pos, find.length(), alt);       pos += alt.length();     }     return result;   }   template <typename T>   bool VECTOR_EXISTS(vector<T> vec, T data) {     auto itr = std::find(vec.begin(), vec.end(), data);     size_t index = distance(vec.begin(), itr);     if (index != vec.size())       return true;     else       return false;   }   template <typename T>   void VECTOR_REMOVE_VALUE_ALL(vector<T> &vec, T data) {     vec.erase(remove(vec.begin(), vec.end(), data), vec.end());   }   template <typename T>   vector<T> VECTOR_REMOVE_VALUE_ALL_FAST(vector<T> vec, T data) {     vector<T> vec2;     for (auto &x : vec)       if (x != data) vec2.push_back(x);     return vec2;   }   bool REG_MATCH(string const &text, regex const &re) {     bool result = regex_match(text, re);     return result;   }   bool REG_MATCH(string const &text, smatch &match, regex const &re) {     bool result = regex_match(text, match, re);     return result;   }   smatch REG_SEARCH(string const &text, regex const &re) {     smatch m;     regex_search(text, m, re);     return m;   }   vector<smatch> REG_ALL_SEARCH(string const &text, regex const &re) {     vector<smatch> matchs;     sregex_iterator iter(text.cbegin(), text.cend(), re);     sregex_iterator end;     for (; iter != end; iter++) matchs.push_back(*iter);     return matchs;   }   string REG_REPLACE(string const &text, regex const &re, string const &replace) {     string result =         regex_replace(text, re, replace, regex_constants::format_first_only);     return result;   }   string REG_ALL_REPLACE(string const &text, regex const &re,                          string const &replace) {     string result = regex_replace(text, re, replace);     return result;   }   template <typename T>   vector<T> COMPRESS(vector<T> v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     return v;   }   template <typename T>   pair<map<T, int>, map<int, T>> MAPPING(const vector<T> v) {     map<T, int> zip;     map<int, T> unzip;     for (int i = 0; i < v.size(); i++) zip[v[i]] = i;     for (int i = 0; i < v.size(); i++) unzip[i] = v[i];     return make_pair(zip, unzip);   }   template <typename T>   vector<pair<T, int>> RUN_LENGTH(const vector<T> &v) {     vector<pair<T, int>> ret;     int len = v.size();     for (int i = 0, j = 0; i < len; i = j) {       while (j < len && v[i] == v[j]) j++;       ret.push_back(make_pair(v[i], j - i));     }     return ret;   }   template <typename T, typename U, typename V, typename W>   auto operator+(const std::pair<T, U> &l, const std::pair<V, W> &r)       -> std::pair<decltype(l.first + r.first), decltype(l.second + r.second)> {     return {l.first + r.first, l.second + r.second};   }   template <typename T, typename U, typename V, typename W>   auto operator-(const std::pair<T, U> &l, const std::pair<V, W> &r)       -> std::pair<decltype(l.first - r.first), decltype(l.second - r.second)> {     return {l.first - r.first, l.second - r.second};   }   double ceil_n(double dIn, long long nLen) {     double dOut;     dOut = dIn * pow(10.0, nLen);     dOut = (double)(long long)(dOut + 0.9);     return dOut * pow(10.0, -nLen);   }   double floor_n(double dIn, long long nLen) {     double dOut;     dOut = dIn * pow(10.0, nLen);     dOut = (double)(long long)(dOut);     return dOut * pow(10.0, -nLen);   }   double round_n(double dIn, long long nLen) {     double dOut;     dOut = dIn * pow(10.0, nLen);     dOut = (double)(long long)(dOut + 0.5);     return dOut * pow(10.0, -nLen);   }   int take_a_n(long long num, int n) {     string str = toString(num);     return str[str.length() - n] -  0 ;   }   int bitcount32(int bits) {     bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);     bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);     bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);     bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);     return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);   }   long long bitcount64(long long bits) {     bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);     bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);     bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);     bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);     bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);     return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff);   }   template <class T1, class T2>   inline bool chmin(T1 &a, T2 b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T1, class T2>   inline bool chmax(T1 &a, T2 b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <typename T1, typename T2>   istream &operator>>(istream &in, pair<T1, T2> &p) {     in >> p.first >> p.second;     return in;   }   template <typename T>   istream &operator>>(istream &in, vector<T> &v) {     for (auto &x : v) in >> x;     return in;   }   template <typename T1, typename T2>   ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {     out <<  [  << p.first <<  ,   << p.second <<  ]          <<   n ;     return out;   }   const double EPS = 1e-10;   const double PI = acos(-1.0);   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, 1, 0, -1};   template <typename T>   inline bool BETWEEN(const T aim, const T min, const T max) {     if (min <= aim && aim <= max) {       return true;     } else {       return false;     }   }   template <typename T1, typename T2>   inline bool IS_OUT(const T1 toY, const T1 toX, const T2 H, const T2 W) {     return (toY < 0 || toY >= H || toX < 0 || toX >= W);   }   template <class T>   inline T SQR(const T x) {     return x * x;   }   template <class T1, class T2>   inline T1 POW(const T1 x, const T2 y) {     if (!y)       return 1;     else if ((y & 1) == 0) {       return SQR(POW(x, y >> 1));     } else       return POW(x, y ^ 1) * x;   }   template <typename T>   constexpr T ABS(T x) {     return x < 0 ? -x : x;   }   template <class Iter>   bool next_partial_permutation(Iter first, Iter middle, Iter last) {     reverse(middle, last);     return next_permutation(first, last);   }   template <class Iter>   bool next_combination(Iter first1, Iter last1, Iter first2, Iter last2) {     if ((first1 == last1) || (first2 == last2)) {       return false;     }     Iter m1 = last1;     Iter m2 = last2;     --m2;     while (--m1 != first1 && !(*m1 < *m2)) {     }     bool result = (m1 == first1) && !(*first1 < *m2);     if (!result) {       while (first2 != m2 && !(*m1 < *first2)) {         ++first2;       }       first1 = m1;       std::iter_swap(first1, first2);       ++first1;       ++first2;     }     if ((first1 != last1) && (first2 != last2)) {       m1 = last1;       m2 = first2;       while ((m1 != first1) && (m2 != last2)) {         std::iter_swap(--m1, m2);         ++m2;       }       std::reverse(first1, m1);       std::reverse(first1, last1);       std::reverse(m2, last2);       std::reverse(first2, last2);     }     return !result;   }   template <typename T>   constexpr bool ODD(T x) {     return x % 2 != 0;   }   template <typename T>   constexpr bool EVEN(T x) {     return x % 2 == 0;   }   template <class T>   inline T GCD(const T x, const T y) {     if (x < 0) return GCD(-x, y);     if (y < 0) return GCD(x, -y);     return (!y) ? x : GCD(y, x % y);   }   template <class T>   inline T LCM(const T x, const T y) {     if (x < 0) return LCM(-x, y);     if (y < 0) return LCM(x, -y);     return x * (y / GCD(x, y));   }   template <class T>   inline T EXTGCD(const T a, const T b, T &x, T &y) {     if (a < 0) {       T d = EXTGCD(-a, b, x, y);       x = -x;       return d;     }     if (b < 0) {       T d = EXTGCD(a, -b, x, y);       y = -y;       return d;     }     if (!b) {       x = 1;       y = 0;       return a;     } else {       T d = EXTGCD(b, a % b, x, y);       T t = x;       x = y;       y = t - (a / b) * y;       return d;     }   }   template <class T>   inline T INV_MOD(const T a, const T m) {     T x, y;     EXTGCD(a, m, x, y);     return (x + m) % m;   }   template <class T>   inline bool ISPRIME(const T x) {     if (x <= 1) return false;     for (T i = 2; i * i <= x; i++)       if (x % i == 0) return false;     return true;   }   template <class T>   vector<bool> ERATOSTHENES(const T n) {     vector<bool> arr(n + 1, true);     arr[0] = arr[1] = false;     for (T i = 2; i * i <= n; i++) {       if (arr[i]) {         for (T j = i * 2LL; j <= n; j += i) {           arr[j] = false;         }       }     }     return arr;   }   template <typename T>   vector<bool> ERATOSTHENES(const T a, const T b) {     vector<bool> small = ERATOSTHENES(b);     vector<bool> prime(b - a, true);     for (T i = 2; i * i <= b; i++) {       if (small[i]) {         for (T j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) {           prime[j - a] = false;         }       }     }     return prime;   }   template <typename T>   vector<T> DIVISOR(T n) {     vector<T> v;     for (T i = 1; i * i <= n; ++i) {       if (n % i == 0) {         v.push_back(i);         if (i != n / i) {           v.push_back(n / i);         }       }     }     sort(v.begin(), v.end());     return v;   }   template <typename T>   vector<vector<T>> DIVISOR_ALL(T n) {     vector<vector<T>> res(n + 1);     for (T i = 1; i <= n; i++) {       for (T j = i; j <= n; j += i) {         res[j].push_back(i);       }     }     return res;   }   template <typename T>   vector<pair<T, T>> FACTORIZATION(T x) {     vector<pair<T, long long>> ans;     for (T i = 2; i * i <= x; i++) {       if (x % i == 0) {         T count = 0;         while (x % i == 0) {           count++;           x /= i;         }         ans.push_back(make_pair(i, count));       }     }     if (x != 1) ans.push_back(make_pair(x, 1));     return ans;   }   long long POW_MOD(long long N, long long P, long long M) {     long long ret = 1;     while (P > 0) {       if (P & 1LL) ret = (ret * N) % M;       N = (N * N) % M;       P >>= 1LL;     }     return ret;   }   template <typename T>   inline T NCR(T n, T r) {     if (r > n - r) r = n - r;     T ans = 1LL;     for (T i = 0; i < r; i++) {       ans = ans * (n - i) / (i + 1);     }     return ans;   }   long long NCR_MOD(long long n, long long r, long long M) {     if (r > n - r) return NCR_MOD(n, n - r, M);     long long numerator = 1LL;     long long denominator = 1LL;     for (long long i = 0; i < r; i++) {       numerator *= (n - i);       numerator %= M;       denominator *= (i + 1);       denominator %= M;     }     return numerator * POW_MOD(denominator, M - 2, M) % M;   }   int main() {     int T;     cin >> T;     while (T--) {       long long n, m, k;       cin >> n >> m >> k;       vector<long long> h(n);       for (int i = (0); i < (n); ++i) scanf( %lld , &h[i]);       bool good = true;       for (int i = 0; i < n - 1; i++) {         long long as = max(0LL, h[i + 1] - k);         if (h[i] >= as) {           m += h[i] - as;           continue;         }         m -= (as - h[i]);         if (m < 0) {           good = false;         }       }       if (good)         printf( YES n );       else         printf( NO n );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int imax = 1e9 + 7;   const long long lmax = 1e18;   const int maxn = 2005;   int P[maxn], C[maxn], A[maxn];   vector<int> adj[maxn];   vector<int> dfs(int cur) {     vector<int> ans(0), v(0);     for (int next : adj[cur]) {       v = dfs(next);       ans.insert(ans.end(), v.begin(), v.end());     }     if (((int)ans.size()) < C[cur]) {       cout <<  NO n ;       exit(0);     }     ans.insert(ans.begin() + C[cur], cur);     return ans;   }   int calc() {     int i, n;     cin >> n;     for (i = 0; i < maxn; ++i) adj[i].clear();     for (i = 1; i < n + 1; ++i) {       cin >> P[i] >> C[i];       adj[P[i]].push_back(i);     }     vector<int> v = dfs(adj[0][0]);     for (i = 0; i < ((int)v.size()); ++i) {       A[v[i]] = i + 1;     }     cout <<  YES n ;     for (i = 1; i < n + 1; ++i) cout << A[i] <<    n [i == n];     return 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     calc();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void fastIO() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.precision(20);   }   long long A[100006];   long long B[100006];   long long C[100006];   long long rev(long long a, long long b) { return a > b; }   int main() {     fastIO();     vector<long long> V;     set<long long> S;     set<long long>::iterator it;     map<string, long long> M;     map<string, long long>::iterator it1;     long long a, b, c;     long long n, m;     long long cnt = 0, cntr = 0, sum = 0, ans = 1;     long long p, q, r;     long long v = 1;     long long check = 0;     long long x, y, z;     long long Max = 0, Min = INT_MAX;     string s, s1[100006], s2[100006], s3, s4;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> A[i];     sort(A, A + n);     for (int i = 0; i < n; i++) {       sum += (A[i] * m--);       if (m == 0) m = 1;     }     cout << sum << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   const long long inf = 1e17 + 7;   string first(long long num) {     string second =   ;     for (long long i = 0; i < num; i++) second +=  * ;     return second;   }   signed main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(0);     cout.precision(10);     map<string, long long> a;     a[ void ] = 0;     long long n;     cin >> n;     while (n--) {       string type, st, to;       cin >> type >> st;       long long l = st.find_first_not_of( & );       long long r = st.find_last_not_of( * );       long long cnt = st.size() - r - 1 - l;       string temp = st.substr(l, r - l + 1);       if (type ==  typeof ) {         if (a.find(temp) == a.end() || a[temp] + min(0ll, cnt) < 0)           cout <<  errtype  << endl;         else           cout <<  void  << first(a[temp] + cnt) << endl;       } else {         cin >> to;         if (a.find(temp) == a.end() || a[temp] < 0)           a[to] = -1;         else           a[to] = a[temp] + cnt;       }     }   }


#include <bits/stdc++.h>   using namespace std;   int n, x;   bool vis[300010];   int a[300010];   int ans = 1;   int main() {     scanf( %d , &n);     x = n;     printf( %d  , ans);     for (int i = 1; i < n; i++) {       scanf( %d , &a[i]);       vis[a[i]] = 1;       bool p = 0;       bool v = 0;       while (vis[x]) {         ans--;         x--;       }       ans++;       printf( %d  , ans);     }     printf( %d  , 1);   }


#include <bits/stdc++.h>   using namespace std;   struct piece {     int x, y;     char p[20][20];     piece(int _x, int _y) : x(_x), y(_y) {}     bool operator<(const piece& rhs) const {       if ((x * y) != (rhs.x * rhs.y))         return (x * y) < (rhs.x * rhs.y);       else         return x < rhs.x;     }   };   struct Piece {     int x, y;     char p[20][20];     Piece() {}     bool operator==(const Piece& rhs) const {       bool eq = true;       for (int i = 0; i < x; i++)         for (int j = 0; j < y; j++)           if (p[i][j] != rhs.p[i][j]) {             eq = false;             goto n1;           }     n1:       if (eq) return true;       char tmp[20][20];       if (x == y) {         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++) tmp[i][j] = rhs.p[y - (j + 1)][i];         eq = true;         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++)             if (p[i][j] != tmp[i][j]) {               eq = false;               goto n2;             }       n2:         if (eq) return true;       }       for (int i = 0; i < x; i++)         for (int j = 0; j < y; j++) tmp[i][j] = rhs.p[x - (i + 1)][y - (j + 1)];       eq = true;       for (int i = 0; i < x; i++)         for (int j = 0; j < y; j++)           if (p[i][j] != tmp[i][j]) {             eq = false;             goto n3;           }     n3:       if (eq) return true;       if (x == y) {         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++) tmp[i][j] = rhs.p[j][x - (i + 1)];         eq = true;         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++)             if (p[i][j] != tmp[i][j]) {               eq = false;               goto n4;             }       n4:         if (eq) return true;       }       return false;     }   };   char p[20][20];   set<int> fa, fb;   set<piece> P;   int a, b;   int good(int x, int y) {     vector<Piece> ps;     int ih = a / x, jh = b / y;     for (int i = 1; i <= ih; i++)       for (int j = 1; j <= jh; j++) {         Piece tmp;         tmp.x = x;         tmp.y = y;         int kh = (i - 1) * x + x - 1, lh = (j - 1) * y + y - 1;         for (int k = (i - 1) * x, m = 0; k <= kh; k++, m++)           for (int l = (j - 1) * y, n = 0; l <= lh; l++, n++)             tmp.p[m][n] = p[k][l];         for (unsigned int k = 0; k < ps.size(); k++)           if (ps[k] == tmp) return false;         ps.push_back(tmp);       }     return true;   }   int main() {     cin >> a >> b;     for (int i = 0; i < a; i++)       for (int j = 0; j < b; j++) cin >> p[i][j];     for (int i = 1; i <= a; i++)       if (!(a % i)) fa.insert(i);     for (int i = 1; i <= b; i++)       if (!(b % i)) fb.insert(i);     for (set<int>::iterator ita = fa.begin(); ita != fa.end(); ita++)       for (set<int>::iterator itb = fb.begin(); itb != fb.end(); itb++) {         int x = *ita, y = *itb;         if (good(x, y)) P.insert(piece(x, y));       }     cout << P.size() << endl;     cout << (*(P.begin())).x <<     << (*(P.begin())).y << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int l, r, i, j, d, tp;     cin >> l >> r;     bool f;     for (i = l; i <= r; i++) {       tp = i;       int arr[10];       for (j = 0; j < 10; j++) arr[j] = 0;       while (tp > 0) {         d = tp % 10;         tp = tp / 10;         arr[d]++;       }       f = true;       for (j = 0; j < 10; j++) {         if (arr[j] <= 1)           f = true;         else {           f = false;           break;         }       }       if (!f)         f = false;       else {         cout << i;         f = true;         break;       }     }     if (!f) cout <<  -1 ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using VI = vector<int>;   using VC = vector<char>;   using VS = vector<string>;   using VL = vector<long long>;   using VVI = vector<VI>;   using VVL = vector<VL>;   using MII = map<int, int>;   using MIVI = map<int, VI>;   using MSS = map<string, string>;   using MLL = map<LL, LL>;   int READ_INT() {     int temp;     cin >> temp;     return temp;   }   LL READ_LONG() {     LL temp;     cin >> temp;     return temp;   }   void mcs(VI &series, int &max_sum) {     int s = 0;     for (auto x : series) {       s += x;       max_sum = max(max_sum, s);       if (s < 0) s = 0;     }   }   template <typename T>   T MAX(T t) {     return t;   }   template <typename T, typename... Args>   T MAX(T t, Args... args) {     return max(t, MAX(args...));   }   const int MOD = int(1e9) + 7;   const int INF = 1e9 + 5;   const double PI = acos(-1.0);   const double EPS = 1e-9;   int n, m, k;   int matrix[105][105][105];   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 1; i < n + 1; ++i) {       for (int j = 1; j < m + 1; ++j) {         string s;         cin >> s;         for (int q = 0; q < k; ++q) {           matrix[i][j][q + 1] = s[q] -  0 ;         }       }     }     int count = 0;     int l = k;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         for (int k = 1; k <= l; ++k) {           if (matrix[i][j][k] == 0) continue;           int t = 0;           t += (matrix[i][j][k - 1] && matrix[i][j][k + 1]);           t += (matrix[i][j - 1][k] && matrix[i][j + 1][k]);           t += (matrix[i - 1][j][k] && matrix[i + 1][j][k]);           if ((matrix[i][j][k - 1] && matrix[i][j + 1][k]) &&               matrix[i][j + 1][k - 1] == 0)             t++;           if ((matrix[i][j - 1][k] && matrix[i][j][k + 1]) &&               matrix[i][j - 1][k + 1] == 0)             t++;           if ((matrix[i][j - 1][k] && matrix[i + 1][j][k]) &&               matrix[i + 1][j - 1][k] == 0)             t++;           if ((matrix[i - 1][j][k] && matrix[i][j + 1][k]) &&               matrix[i - 1][j + 1][k] == 0)             t++;           if ((matrix[i - 1][j][k] && matrix[i][j][k + 1]) &&               matrix[i - 1][j][k + 1] == 0)             t++;           if ((matrix[i][j][k - 1] && matrix[i + 1][j][k]) &&               matrix[i + 1][j][k - 1] == 0)             t++;           if (t) count++;         }       }     }     cout << count <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 15000001;   int64_t primes[N];   int64_t gcd(int64_t a, int64_t b) {     if (a == 0)       return b;     else       return gcd(b % a, a);   }   int64_t Power(int64_t base, int64_t e) {     if (e == 0) return 1;     int64_t ans = base;     e--;     while (e) {       if (e & 1) ans = (ans * base);       base = (base * base);       e >>= 1;     }     return (ans);   }   void sieve() {     for (int64_t i = 2; i <= N; i++) {       if (primes[i] == -1) {         for (int64_t j = i; j <= N; j += i) primes[j] = i;       }     }   }   int main() {     for (int64_t i = 0; i < N; i++) {       primes[i] = -1;     }     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     sieve();     map<int64_t, int64_t> mp;     int64_t n;     cin >> n;     int64_t a[n];     int64_t tmp;     for (int64_t i = 0; i < n; i++) cin >> a[i];     int64_t ggcd;     ggcd = a[0];     for (int64_t i = 0; i < n; i++) {       ggcd = gcd(ggcd, a[i]);     }     int64_t ggcd2 = 1;     for (int64_t i = 0; i < n; i++) {       a[i] = a[i] / ggcd;     }     for (int64_t i = 0; i < n; i++) {       tmp = a[i];       while (tmp > 1) {         int64_t y = primes[tmp];         while (tmp % y == 0) {           tmp = tmp / y;         }         mp[y]++;       }     }     int64_t freq = 0;     int64_t val = ggcd;     for (auto kk : mp) {       if (freq <= kk.second) {         val = kk.first;         freq = kk.second;       }     }     if (freq) {       cout << (n - freq) << endl;     } else       cout << -1 << endl;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t, i, j, cnt, k, lo, hi, mid;     cin >> t;     while (t--) {       string s, t;       cin >> s >> t;       vector<long long int> v[26];       for (i = 0; s[i]; i++) {         v[s[i] -  a ].push_back(i);       }       bool flag = true;       cnt = 1;       j = -1;       for (i = 0; t[i]; i++) {         k = -1;         lo = 0;         hi = (int)v[t[i] -  a ].size() - 1;         while (lo <= hi) {           mid = (lo + hi) / 2LL;           if (v[t[i] -  a ][mid] > j) {             k = v[t[i] -  a ][mid];             hi = mid - 1;           } else {             lo = mid + 1;           }         }         if (j == -1 and k == -1) {           flag = false;           break;         } else if (k != -1) {           j = k;         } else {           j = -1;           i--;           cnt++;         }       }       if (!flag) cnt = -1;       cout << cnt <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (--t >= 0) {       long long a, b, c, d;       cin >> a >> b >> c >> d;       if (a <= b) {         cout << b << endl;         continue;       }       if (c <= d) {         cout << -1 << endl;         continue;       }       a -= b;       long long ans = b;       long long f;       if (a % (c - d) == 0)         f = a / (c - d);       else         f = a / (c - d) + 1;       ans += f * c;       cout << ans << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   vector<int> a[10005];   int main() {     int n, x, k = 0;     cin >> n;     x = (sqrt(1.0 + 8 * n) + 1) / 2;     cout << x << endl;     for (int i = 1; i <= x; i++)       for (int j = i + 1; j <= x; j++) a[i].push_back(++k), a[j].push_back(k);     for (int i = 1; i <= x; i++, cout << endl)       for (int j = 0; j < a[i].size(); j++) cout << a[i][j] <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   char s[200010];   int n, k;   int sa[200010];   int ra[200010], tr[200010];   int lcp[200010];   int l[200010], r[200010];   stack<int> ls, rs;   set<long long> ss;   bool CmpSa(int a, int b) {     if (ra[a] != ra[b]) return ra[a] < ra[b];     int aa = a + k < n ? ra[a + k] : -1;     int bb = b + k < n ? ra[b + k] : -1;     return aa < bb;   }   void GaoSa() {     for (int i = 0; i <= n; ++i) {       sa[i] = i;       ra[i] = i < n ? s[i] : -1;     }     for (k = 1; k <= n; k <<= 1) {       sort(sa, sa + n + 1, CmpSa);       tr[sa[0]] = 0;       for (int i = 1; i <= n; ++i) {         tr[sa[i]] = tr[sa[i - 1]] + CmpSa(sa[i - 1], sa[i]);       }       memcpy(ra, tr, sizeof(int) * (n + 1));     }   }   void GaoLcp() {     int tmp = 0;     for (int i = 0; i < n; ++i) {       int rk = ra[i];       int j = sa[rk - 1];       if (tmp > 0) --tmp;       while (i + tmp < n && j + tmp < n && s[i + tmp] == s[j + tmp]) {         ++tmp;       }       lcp[rk - 1] = tmp;     }   }   inline long long Hash(int b, int c) { return b * 1000000ll + c; }   int main() {     scanf( %s , s);     n = strlen(s);     s[n] =  | ;     memcpy(s + n + 1, s, sizeof(char) * n);     n = 2 * n + 1;     GaoSa();     GaoLcp();     for (int i = 0; i <= n; ++i) {       while (!rs.empty() && lcp[rs.top()] > lcp[i]) {         r[rs.top()] = i;         rs.pop();       }       rs.push(i);     }     for (int i = n; i >= 0; --i) {       while (!ls.empty() && lcp[ls.top()] > lcp[i]) {         l[ls.top()] = i;         ls.pop();       }       ls.push(i);     }     long long ans = 0;     for (int i = 1; i < n - 1; ++i) {       if (lcp[i]) {         if (ss.find(Hash(lcp[i], l[i])) != ss.end()) continue;         long long tmp = (r[i] - l[i]) / 2;         tmp = tmp * (tmp + 1) / 2;         ans += tmp * (lcp[i] - max(lcp[l[i]], lcp[r[i]]));         ss.insert(Hash(lcp[i], l[i]));       }     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <typename G, typename H>   struct triple {     G first, second, T;     triple(G x, G y, G z) : first(x), second(y), T(z) {}     triple() : first(0), second(0), T(0) {}     bool operator<(const triple<G, H> other) const { return first > other.first; }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     vector<int> v(m);     for (auto &i : v) cin >> i;     sort(v.begin(), v.end());     int g, r;     cin >> g >> r;     int oo = 2e9;     vector<vector<int>> dp(m, vector<int>(g + 1, oo));     dp[0][g] = 0;     deque<pair<int, int>> pq;     pq.push_back({0, g});     while (!pq.empty()) {       pair<int, int> t = pq.front();       pq.pop_front();       if (t.second == 0 && dp[t.first][g] > dp[t.first][t.second] + 1) {         dp[t.first][g] = dp[t.first][t.second] + 1;         pq.push_back({t.first, g});       }       if (t.second != 0) {         int i = t.first, j = t.second;         if (i > 0) {           int w = v[i] - v[i - 1];           if (w <= j && dp[i - 1][j - w] > dp[i][j]) {             dp[i - 1][j - w] = dp[i][j];             pq.push_front({i - 1, j - w});           }         }         if (i < m - 1) {           int w = v[i + 1] - v[i];           if (w <= j && dp[i + 1][j - w] > dp[i][j]) {             dp[i + 1][j - w] = dp[i][j];             pq.push_front({i + 1, j - w});           }         }       }     }     int ans = oo;     for (int i = 0; i <= g; i++)       if (dp[m - 1][i] != oo) ans = min(ans, dp[m - 1][i] * (r + g) + g - i);     if (ans == oo) ans = -1;     cout << ans <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e2 + 10;   const int INF = 1 << 30;   char str[MAXN][MAXN];   int Pow(int a, int b) {     if (b == 0) return 1;     int res = 1;     while (b--) res *= a;     return res;   }   int main() {     int a, b, n;     while (scanf( %d%d%d , &a, &b, &n) != EOF) {       if (a == 0) {         if (b == 0)           printf( 1 n );         else           printf( No solution n );         continue;       }       if (b % a) {         printf( No solution n );         continue;       }       a = b / a;       int res = -INF;       if (a < 0) {         a = -a;         if (n % 2 == 0) {           printf( No solution n );           continue;         }         for (int i = 0; i <= 1000; i++) {           if (Pow(i, n) == a) {             res = i;             break;           }           if (Pow(i, n) > a) break;         }         res = -res;       } else {         for (int i = 0; i <= 1000; i++) {           if (Pow(i, n) == a) {             res = i;             break;           }           if (Pow(i, n) > a) break;         }       }       if (res == -INF) {         printf( No solution n );       } else {         printf( %d n , res);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   const int maxn = 2e5 + 10;   int a[maxn];   char s[maxn];   const char *t =  LR ;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     scanf( %s , s);     bool rev = s[0] ==  R ;     int cnt = 0;     for (int i = 1; i < n; i++) {       cnt += s[i] == s[i - 1];     }     printf( %d %c n , a[cnt], t[rev]);     int l = cnt, r = cnt;     for (int i = 1; i < n; i++) {       if (s[i] == s[i - 1])         l--, printf( %d %c n , a[l], t[((cnt - l) & 1) ^ rev]);       else         r++, printf( %d %c n , a[r], t[((r - cnt) & 1) ^ rev]);     }   }


#include <bits/stdc++.h>   using namespace std;   long long po(long long x, long long n) {     long long res = 1;     while (n > 0) {       if (n & 1) res = (res * x) % 998244353;       n = n / 2;       x = (x * x) % 998244353;     }     return res;   }   long long fac[500000 + 1] = {0};   long long ifac[500000 + 1] = {0};   void pre() {     fac[0] = ifac[0] = 1;     for (int i = 1; i <= 500000; i++) {       fac[i] = (i * fac[i - 1]) % 998244353;       ifac[i] = po(fac[i], 998244353 - 2);     }   }   long long nCr(long long n, long long r) {     if (r > n || r < 0 || n < 0) return 0;     return (((fac[n] * ifac[r]) % 998244353) * ifac[n - r]) % 998244353;   }   void func() {     long long n, k;     cin >> n >> k;     long long ans = 0;     pre();     for (int i = 1; i <= n; i++) {       ans = (ans + nCr(n / i - 1, k - 1)) % 998244353;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) func();   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m;     cin >> n >> m;     long long int a[n];     for (long long int i = 0; i < n; i++) {       a[i] = 0;     }     long long int x;     for (long long int i = 0; i < m; i++) {       cin >> x;       a[x - 1] += 1;     }     long long int min = (m > n) ? m : n;     for (long long int i = 0; i < n; i++) {       if (a[i] < min) min = a[i];     }     cout << min << endl;     return 0;   }


#include <bits/stdc++.h>   const int maxn = 11111;   struct dsu {     int f[555];     int c;     void init() {       int i;       c = 0;       for (i = 1; i <= 505; i++) f[i] = i;     }     int find(int a) { return f[a] == a ? a : f[a] = find(f[a]); }     void Union(int x, int y) {       x = find(x), y = find(y);       if (x != y) f[x] = y, c++;     }   } L[maxn], R[maxn];   int l[maxn], r[maxn];   int main() {     int n, m, i, j, k, a, b;     scanf( %d%d , &n, &m);     L[0].init(), R[m + 1].init();     for (i = 1; i <= m; i++) scanf( %d%d , &l[i], &r[i]);     for (i = 1; i <= m; i++) L[i] = L[i - 1], L[i].Union(l[i], r[i]);     for (i = m; i >= 1; i--) R[i] = R[i + 1], R[i].Union(l[i], r[i]);     scanf( %d , &k);     while (k--) {       scanf( %d%d , &a, &b);       dsu t = L[a - 1];       for (i = 1; i <= n; i++) t.Union(i, R[b + 1].f[i]);       printf( %d n , n - t.c);     }   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 2;   vector<int> G[MAXN];   double f[MAXN];   int siz[MAXN];   int pa[MAXN];   void dfs(int u) {     for (int i = 0; i < G[u].size(); ++i) {       int v = G[u][i];       f[v] = f[u] + 1.0 + (siz[u] - siz[v] - 1.0) / 2.0;       dfs(v);     }   }   void solve(int n) {     for (int i = n; i >= 1; --i) {       ++siz[i];       siz[pa[i]] += siz[i];     }     f[1] = 1;     dfs(1);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 2; i <= n; ++i) {       scanf( %d , pa + i);       G[pa[i]].push_back(i);     }     solve(n);     for (int i = 1; i <= n; ++i) printf( %.15f  , f[i]);     puts(  );     return 0;   }


#include <bits/stdc++.h>   void sc(int &x) { scanf( %d , &x); }   void sc(int &x, int &y) { scanf( %d%d , &x, &y); }   void sc(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); }   void sc(long long &x) { scanf( %lld , &x); }   void sc(long long &x, long long &y) { scanf( %lld%lld , &x, &y); }   void sc(long long &x, long long &y, long long &z) {     scanf( %lld%lld%lld , &x, &y, &z);   }   void sc(char *x) { scanf( %s , x); }   void sc(char *x, char *y) { scanf( %s%s , x, y); }   void sc(char *x, char *y, char *z) { scanf( %s%s%s , x, y, z); }   void out(int x) { printf( %d n , x); }   void out(long long x) { printf( %lld n , x); }   void out(int x, int y) { printf( %d %d n , x, y); }   void out(long long x, long long y) { printf( %lld %lld n , x, y); }   void out(int x, int y, int z) { printf( %d %d %d n , x, y, z); }   void out(long long x, long long y, long long z) {     printf( %lld %lld %lld n , x, y, z);   }   void ast(long long x, long long l, long long r) { assert(x >= l && x <= r); }   using namespace std;   const int N = 6e3 + 5, mod = 1e9 + 7;   int n, x[N], y[N];   int vis[2][2];   int gcd(int x, int y) { return !y ? x : gcd(y, x % y); }   int cal(int i, int j) {     int xx = abs(x[i] - x[j]), yy = abs(y[i] - y[j]);     xx = gcd(xx, yy);     return xx * 2;   }   void sol(int cas) {     sc(n);     for (int i = 1; i <= n; i++) sc(x[i], y[i]);     for (int i = 1; i <= n; i++) x[i] >>= 1, y[i] >>= 1, x[i] &= 1, y[i] &= 1;     long long ans = 0;     for (int i = 1; i <= n; i++) {       memset(vis, 0, sizeof(vis));       for (int j = n; j >= i + 1; j--) {         for (int h = 0; h <= 1; h++)           for (int k = 0; k <= 1; k++) {             int s = x[i] * y[j] + x[j] * y[i] + x[i] * k + h * y[i] + x[j] * k +                     h * y[j];             s &= 1;             if (s == 0) ans += vis[h][k];           }         vis[x[j]][y[j]]++;       }     }     out(ans);   }   void init() {}   int main() {     srand(time(0));     init();     int t = 1, cas = 0;     while (t--) {       sol(++cas);     }   }


#include <bits/stdc++.h>   using namespace std;   const int MX = 100009;   int arr[MX];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %d , arr + i);     int add = 0;     for (int i = 0; i < m; ++i) {       int cmd;       scanf( %d , &cmd);       if (cmd == 1) {         int idx, val;         scanf( %d%d , &idx, &val);         --idx;         arr[idx] = val - add;       } else if (cmd == 2) {         int val;         scanf( %d , &val);         add += val;       } else {         int idx;         scanf( %d , &idx);         --idx;         printf( %d n , arr[idx] + add);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p = 1000000000;     cin >> n;     int k[n], i;     for (i = 0; i < n; i++) {       cin >> k[i];     }     i = 0;     int j = 0, sum = 0;     while (n--) {       sum = 0;       while (k[i]--) {         cin >> j;         sum = sum + j * 5 + 15;       }       i++;       if (sum < p) {         p = sum;       }     }     cout << p;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   const double eps = 0.000001;   int q(int i, int j, vector<int> &ps) {     if (i > j) return 0;     if (i) return ps[j] - ps[i - 1];     return ps[j];   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int n = s.size();     vector<int> ps(n + 1, 0);     int ans = 0;     for (int i = 0; i < n; i++) {       ps[i + 1] = ps[i] + (int)(s[i] ==  a );     }     for (int i = 0; i < n; i++) {       for (int j = i; j <= n; j++) {         int cr = i - q(0, i, ps) + (n - j) - q(j + 1, n, ps) + q(i + 1, j, ps);         ans = max(ans, n - cr);       }     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m;   set<int> s;   const int nax = 5e5 + 4;   int link[nax];   set<pair<int, int>> edge;   vector<vector<int>> group;   inline void make_set(int i) { link[i] = i; }   int Find(int a) {     if (link[a] == a) return a;     return (link[a] = Find(link[a]));   }   void Unite(int a, int b) {     a = Find(a);     b = Find(b);     if (a == b) return;     link[a] = b;   }   int component() {     set<int> had;     for (int i = 1; i <= n; ++i) {       had.insert(Find(i));       group[Find(i)].push_back(i);     }     return ((int)had.size());   }   void bfs(int i) {     queue<int> q;     q.push(i);     while (!q.empty()) {       int u = q.front();       q.pop();       s.erase(u);       vector<int> temp;       for (auto &c : s) {         if (edge.find({min(u, c), max(u, c)}) == edge.end()) {           Unite(u, c);           q.push(c);           temp.push_back(c);         }       }       for (auto &c : temp) s.erase(c);     }   }   void solve() {     cin >> n >> m;     group.resize(n + 1);     for (int i = 1; i <= m; ++i) {       int u, v;       cin >> u >> v;       edge.insert({min(u, v), max(u, v)});     }     for (int i = 1; i <= n; ++i) make_set(i);     for (int i = 1; i <= n; ++i) s.insert(i);     for (int i = 1; i <= n; ++i) {       if (s.find(i) != s.end()) bfs(i);     }     cout << component() <<   n ;     for (int i = 1; i <= n; ++i) {       if (!group[i].empty()) {         cout << group[i].size() <<    ;         for (auto &c : group[i]) cout << c <<    ;         cout <<   n ;       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int n;   vector<pair<int, long long> > fa[100], fb[100];   long long powmod(long long a, long long k) {     long long ret = 1;     while (k) {       if (k & 1) {         ret = ret * a % mod;       }       a = a * a % mod;       k >>= 1;     }     return ret;   }   long long exgcd(long long a, long long b, long long& x, long long& y) {     if (!b) {       x = 1;       y = 0;       return a;     }     long long d = exgcd(b, a % b, y, x);     y -= x * (a / b);     return d;   }   long long find(const vector<pair<int, long long> >& f, int p) {     int pos = lower_bound(f.begin(), f.end(), make_pair(p, -1ll)) - f.begin();     if (pos != f.size() && f[pos].first == p) {       return f[pos].second;     }     return 0;   }   vector<pair<int, long long> > factor(int x) {     vector<pair<int, long long> > ret;     for (int i = 2; i * i <= x; ++i) {       long long cnt = 0;       while (x % i == 0) {         cnt++;         x /= i;       }       if (cnt) {         ret.push_back(make_pair(i, cnt));       }     }     if (x > 1) {       ret.push_back(make_pair(x, 1));     }     return ret;   }   void addfirst(vector<int>& s, const vector<pair<int, long long> >& t) {     for (int i = 0; i < t.size(); ++i) {       s.push_back(t[i].first);     }   }   bool solve() {     while (n > 1) {       int cnt = 0;       for (int i = 0; i < n - 1; ++i) {         vector<int> v;         addfirst(v, fa[i]);         addfirst(v, fb[i]);         addfirst(v, fa[i + 1]);         addfirst(v, fb[i + 1]);         sort(v.begin(), v.end());         v.erase(unique(v.begin(), v.end()), v.end());         long long px = -1, py, sx, sy;         for (int j = 0; j < v.size(); ++j) {           long long a1 = find(fa[i], v[j]), a2 = find(fa[i + 1], v[j]);           long long b1 = find(fb[i], v[j]), b2 = find(fb[i + 1], v[j]);           long long x, y, dx, dy;           long long d = exgcd(b1, -b2, x, y);           if (b1 == 0 && b2 == 0) {             if (a1 != a2) {               return false;             }             continue;           } else if (b1 == 0 && a1 >= a2 && (a1 - a2) % b2 == 0) {             x = 0;             y = (a1 - a2) / b2;             dx = 1;             dy = 0;           } else if (b2 == 0 && a2 >= a1 && (a2 - a1) % b1 == 0) {             x = (a2 - a1) / b1;             y = 0;             dx = 0;             dy = 1;           } else if (d == 0 || (a2 - a1) % d != 0) {             return false;           } else {             x *= (a2 - a1) / d;             y *= (a2 - a1) / d;             dx = b2 / abs(d);             dy = b1 / abs(d);             if (x > 0 && dx > 0) {               long long t = (x - 1) / dx + 1;               x -= t * dx;               y -= t * dy;             }             if (y > 0 && dy > 0) {               long long t = (y - 1) / dy + 1;               x -= t * dx;               y -= t * dy;             }             if (x < 0) {               if (dx == 0) {                 return false;               }               long long t = (-x - 1) / dx + 1;               x += t * dx;               y += t * dy;             }             if (y < 0) {               if (dy == 0) {                 return false;               }               long long t = (-y - 1) / dy + 1;               x += t * dx;               y += t * dy;             }           }           if (px == -1) {             px = x;             py = y;             sx = dx;             sy = dy;           } else {             if (sx != 0 || sy != 0) {               if (sx != dx || sy != dy) {                 long long k1 =                     ((x - px) * dy - (y - py) * dx) / (sx * dy - sy * dx);                 long long nx = px + sx * k1, ny = py + sy * k1;                 if (nx < x || ny < y || (nx - x) * dy - dx * (ny - y) != 0) {                   return false;                 }                 px = nx;                 py = ny;                 sx = sy = 0;               } else if ((px - x) * dy - dx * (py - y) != 0) {                 return false;               }             } else if (px < x || py < y || (px - x) * dy - dx * (py - y) != 0) {               return false;             }           }         }         if (px != -1) {           vector<pair<int, long long> > nfa, nfb;           for (int j = 0; j < v.size(); ++j) {             long long a1 = find(fa[i], v[j]), b1 = find(fb[i], v[j]);             if (b1 * px + a1) {               nfa.push_back(make_pair(v[j], b1 * px + a1));             }             if (b1 * sx) {               nfb.push_back(make_pair(v[j], b1 * sx));             }           }           fa[cnt] = nfa;           fb[cnt++] = nfb;         }       }       n = cnt;     }     return true;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       int a, b;       scanf( %d %d , &a, &b);       fa[i] = factor(a);       fb[i] = factor(b);     }     if (solve()) {       long long ans = 1;       for (int i = 0; i < fa[0].size(); ++i) {         ans = ans * powmod(fa[0][i].first, fa[0][i].second) % mod;       }       printf( %I64d n , ans);     } else {       printf( -1 n );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> a(n), b(m);     int an;     cin >> an;     for (int i = 0; i < an; ++i) {       int t;       cin >> t;       a[t] = 1;     }     int bn;     cin >> bn;     for (int i = 0; i < bn; ++i) {       int t;       cin >> t;       b[t] = 1;     }     int lim = n * m;     while (1) {       bool ch = false;       for (int i = 0; i < lim; ++i) {         if (a[i % n] != b[i % m]) {           ch = true;           a[i % n] = b[i % m] = 1;         }       }       if (!ch) break;     }     bool ans = true;     for (int i = 0; i < n; ++i) ans &= a[i];     for (int i = 0; i < m; ++i) ans &= b[i];     cout << (ans ?  Yes  :  No );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     string s, out;     cin >> s;     for (int i = 0; s[i] !=   0 ; i++) {       s[i] = tolower(s[i]);       if (s[i] ==  o  || s[i] ==  u  || s[i] ==  i  || s[i] ==  e  ||           s[i] ==  a  || s[i] ==  y )         ;       else {         out +=  . ;         out += s[i];       }     }     cout << out;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int ans = 0, flag = 1;     for (int i = 0; i < n; i++) {       if (s[i] !=  ? ) {         if (s[i] == s[i + 1]) {           flag = 0;         }       } else if (i == 0 || i == n - 1 || s[i + 1] == s[i - 1] || s[i + 1] ==  ? )         ans = 1;     }     if (flag && ans)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 50 + 10;   int n, m, vis[maxn][maxn], need[maxn][maxn];   struct node {     int x, y, a, b;   } p[maxn];   vector<node> vec;   inline void move(int id, int x, int y) {     vec.push_back((node){p[id].x, p[id].y, p[id].x + x, p[id].y + y});     vis[p[id].x][p[id].y] = 0;     p[id].x += x;     p[id].y += y;     vis[p[id].x][p[id].y] = id;   }   inline void work1() {     int cnt = 0;     for (int i = 1; i <= n; ++i)       if (vis[1][i]) {         ++cnt;         int id = vis[1][i];         while (p[id].y > cnt) move(id, 0, -1);       }     for (int i = 2; i <= n; ++i)       for (int j = n; j; --j)         if (vis[i][j]) {           ++cnt;           int id = vis[i][j];           while (p[id].y < cnt) move(id, 0, 1);           while (p[id].x > 1) move(id, -1, 0);           while (p[id].y > cnt) move(id, 0, -1);         }   }   inline void work2() {     int cnt = 0;     for (int i = n; i > 2; --i)       for (int j = n; j; --j)         if (need[i][j]) {           int id = need[i][j];           move(id, 1, 0);           while (p[id].y < j) move(id, 0, 1);           while (p[id].y > j) move(id, 0, -1);           while (p[id].x < i) move(id, 1, 0);         }     for (int i = 1; i <= n; ++i)       if (vis[1][i]) {         ++cnt;         int id = vis[1][i];         while (p[id].y > cnt) move(id, 0, -1);       }     for (int i = n, cntt = cnt; i; --i)       for (int j = 1; j <= 2; ++j)         if (need[j][i]) {           int id = need[j][i];           move(id, 1, 0);           for (int k = p[id].y + 1; k <= cntt; ++k) move(vis[1][k], 0, -1);           while (p[id].y < cntt) move(id, 0, 1);           move(id, -1, 0);           --cntt;         }     for (int i = 1; i <= cnt; ++i)       if (p[vis[1][i]].a == 2) move(vis[1][i], 1, 0);     for (int i = 1; i <= 2; ++i) {       for (int j = 1; j <= n; ++j)         if (vis[i][j]) {           int id = vis[i][j];           while (p[id].y > p[id].b) move(id, 0, -1);         }       for (int j = n; j; --j)         if (vis[i][j]) {           int id = vis[i][j];           while (p[id].y < p[id].b) move(id, 0, 1);         }     }   }   int main() {     cin >> n >> m;     if (n == 1) {       cout << 0 << endl;       return 0;     }     for (int i = 1; i <= m; ++i) {       cin >> p[i].x >> p[i].y;       vis[p[i].x][p[i].y] = i;     }     for (int i = 1; i <= m; ++i) {       cin >> p[i].a >> p[i].b;       need[p[i].a][p[i].b] = i;     }     work1();     work2();     cout << vec.size() << endl;     for (int i = 0; i < vec.size(); ++i)       cout << vec[i].x <<     << vec[i].y <<     << vec[i].a <<     << vec[i].b            << endl;     return 0;   }


#include<cmath>   #include<iostream>   #include<sstream>   #include<cstdio>   #include<cstring>   #include<string>   #include<cstdlib>   #include<istream>   #include<vector>   #include<stack>   #include<set>   //#include<unordered_map>   #include<map>   #include<algorithm>   #include<queue>   #define mmp make_pair   #define inf 0x3f3f3f3f   #define llinf 0x7fffffffffffffff   using namespace std;   typedef long long ll;   typedef pair<ll,ll> PP;   typedef double ld;   vector<int>hh[200010];   int ID[200010];   bool orz[200010];   ll siz[200010];   queue<int>q;   void topsort(int n) {       while(!q.empty()) q.pop();       for(int i=1;i<=n;++i) {           if(ID[i]==1) {               q.push(i);               orz[i]=true;           }       }       while(!q.empty()) {           int temp=q.front();           q.pop();           orz[temp]=true;           for(int i=0;i<hh[temp].size();++i) {               int uu=hh[temp][i];               if(orz[uu]) continue;               ID[uu]--;               ID[temp]--;               if(ID[uu]==1) {                   q.push(uu);               }           }       }   }   void dfs(int u,int f) {       siz[u]=1;       for(int i=0;i<hh[u].size();++i) {           int v=hh[u][i];           if(orz[v]==0 || v==f) continue;           dfs(v,u);           siz[u]+=siz[v];       }   }   int main() {       int T;       scanf( %d ,&T);       while(T--) {           int n;           scanf( %d ,&n);           for(int i=1;i<=n;++i) {               hh[i].clear();               ID[i]=orz[i]=siz[i]=0;           }           for(int i=1;i<=n;++i) {               int x,y; scanf( %d %d ,&x,&y);               hh[x].push_back(y); hh[y].push_back(x);               ++ID[x]; ++ID[y];           }           topsort(n);           ll cnt=0;           for(int i=1;i<=n;++i) {               if(orz[i]==0) {                   ++cnt;                   dfs(i,0);               }           }           ll sum=0;           ll ans=cnt*(cnt-1);           for(int i=1;i<=n;++i) {               if(!orz[i]) {                   ans+=1ll*(cnt-1)*2*(siz[i]-1);                   ans+=1ll*(siz[i]-1)*siz[i]/2;                   sum+=siz[i]-1;               }           }           for(int i=1;i<=n;++i) {               if(!orz[i]) {                   ans+=1ll*(sum-siz[i]+1)*(siz[i]-1);               }           }           printf( %lld n ,ans);       }       return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int mod = 1000000007;   const int inv3 = (mod + 1) / 3;   const int maxn = 3003003;   int fac[maxn], ifac[maxn];   int qpow(int a, int n) {     int ans = 1;     for (; n; n >>= 1, a = (ll)a * a % mod)       if (n & 1) ans = (ll)ans * a % mod;     return ans;   }   int C(int n, int m) {     return fac[n] * (ll)ifac[m] % mod * (ll)ifac[n - m] % mod;   }   int f[maxn], g[maxn];   int main(void) {     int n, q;     scanf( %d%d , &n, &q);     fac[0] = 1;     for (int i = 1; i <= 3 * n + 3; i++) fac[i] = fac[i - 1] * (ll)i % mod;     ifac[3 * n + 3] = qpow(fac[3 * n + 3], mod - 2);     for (int i = 3 * n + 2; i >= 0; i--)       ifac[i] = ifac[i + 1] * (ll)(i + 1) % mod;     for (int i = 0; i < 3 * n + 3; i++) f[i] = C(3 * n + 3, i + 1);     g[0] = n + 1;     g[1] = 3ll * n * (n + 1) / 2 % mod;     for (int i = 2; i <= 3 * n; i++) {       g[i] = ((f[i] - 3ll * g[i - 1] % mod + mod) % mod - g[i - 2] + mod) % mod *              inv3 % mod;     }     for (int i = 0; i < q; i++) {       int x;       scanf( %d , &x);       printf( %d n , g[x]);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, q;   vector<int> l, r, x, y;   vector<long long> sum;   double ans(int x1, int y1, int x, int y) {     long long a = y1 - y;     long long b = x - x1;     long long c = -a * x - b * y;     double xs = -1.0 * c / a;     int ll = 0, rr = n - 1;     while (ll <= rr) {       int md = (ll + rr) / 2;       if (r[md] < xs)         ll = md + 1;       else         rr = md - 1;     }     if (ll == n) return sum[n - 1];     double ans = 0;     if (ll != 0) ans = sum[ll - 1];     if (l[ll] < xs) ans += xs - l[ll];     return ans;   }   int main() {     int y1, a, b;     cin >> y1 >> a >> b;     cin >> n;     l.resize(n);     r.resize(n);     for (int i = 0; i < n; ++i) cin >> l[i] >> r[i];     cin >> q;     x.resize(q);     y.resize(q);     for (int i = 0; i < q; ++i) cin >> x[i] >> y[i];     sum.resize(n);     sum[0] = r[0] - l[0];     for (int i = 1; i < n; ++i) sum[i] = sum[i - 1] + r[i] - l[i];     for (int i = 0; i < q; ++i) {       cout << fixed << setprecision(10)            << (ans(b, y1, x[i], y[i]) - ans(a, y1, x[i], y[i])) * (y[i] - y1) /                   y[i]            <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000009;   struct mat22 {     long long M[2][2];     mat22(int a) { M[0][0] = M[1][1] = 1, M[0][1] = M[1][0] = 0; }     mat22() { M[0][0] = M[1][1] = 0, M[0][1] = M[1][0] = 0; }   };   mat22 pw[500000];   mat22 Spw[500000];   struct node {     int z, k;     long long val, Aup, Bup;     int son[2];   };   struct intervalac {     vector<node> T;     void constI(int akt) {       node n = T[akt];       if (n.k - n.z == 1) return;       for (int i = 0; i < 2; i++) {         if (i == 0)           n.k = (n.z + n.k) / 2;         else {           n.z = n.k;           n.k = T[akt].k;         }         T[akt].son[i] = T.size();         T.push_back(n);         constI(T.size() - 1);       }     }     intervalac(int N) {       node n;       n.son[0] = n.son[1] = -1;       n.z = n.val = n.Aup = n.Bup = 0, n.k = N;       T.reserve(2 * N + 47);       T.push_back(n);       constI(0);     }     void upd(int akt) {       node n = T[akt];       if (n.Aup == 0 && n.Bup == 0) return;       T[akt].val = (T[akt].val + Spw[n.k - n.z].M[1][0] * n.Bup +                     Spw[n.k - n.z].M[1][1] * n.Aup) %                    mod;       if (n.son[0] != -1) {         T[n.son[0]].Bup = (T[n.son[0]].Bup + n.Bup) % mod;         if (T[n.son[0]].Bup < 0) T[n.son[0]].Bup += mod;         T[n.son[0]].Aup = (T[n.son[0]].Aup + n.Aup) % mod;         if (T[n.son[0]].Aup < 0) T[n.son[0]].Aup += mod;       }       if (n.son[1] != -1) {         T[n.son[1]].Bup =             (T[n.son[1]].Bup + pw[(n.k + n.z) / 2 - n.z].M[0][0] * n.Bup +              pw[(n.k + n.z) / 2 - n.z].M[0][1] * n.Aup) %             mod;         if (T[n.son[1]].Bup < 0) T[n.son[1]].Bup += mod;         T[n.son[1]].Aup =             (T[n.son[1]].Aup + pw[(n.k + n.z) / 2 - n.z].M[1][0] * n.Bup +              pw[(n.k + n.z) / 2 - n.z].M[1][1] * n.Aup) %             mod;         if (T[n.son[1]].Aup < 0) T[n.son[1]].Aup += mod;       }       T[akt].Aup = T[akt].Bup = 0;     }     void put(int akt, int zac, int kon, long long a, long long b) {       node n = T[akt];       if (n.z >= kon || zac >= n.k) return;       if (n.z == zac && n.k == kon) {         T[akt].Aup = (T[akt].Aup + a) % mod;         if (T[akt].Aup < 0) T[akt].Aup += mod;         T[akt].Bup = (T[akt].Bup + b) % mod;         if (T[akt].Bup < 0) T[akt].Bup += mod;         return;       }       if (zac < T[n.son[0]].k) {         put(n.son[0], zac, min(T[n.son[0]].k, kon), a, b);         long long Bn = (pw[T[n.son[0]].k - zac].M[0][0] * b +                         pw[T[n.son[1]].z - zac].M[0][1] * a) %                        mod;         if (Bn < 0) Bn += mod;         long long An = (pw[T[n.son[0]].k - zac].M[1][0] * b +                         pw[T[n.son[1]].z - zac].M[1][1] * a) %                        mod;         if (An < 0) An += mod;         put(n.son[1], max(T[n.son[1]].z, zac), kon, An, Bn);       } else         put(n.son[1], max(T[n.son[1]].z, zac), kon, a, b);       T[akt].val =           (T[akt].val + Spw[kon - zac].M[1][0] * b + Spw[kon - zac].M[1][1] * a) %           mod;     }     long long get(int akt, int zac, int kon) {       node n = T[akt];       if (n.k <= zac || kon <= n.z) return 0;       upd(akt);       if (n.z == zac && n.k == kon) return T[akt].val;       return (get(n.son[0], zac, min(T[n.son[0]].k, kon)) +               get(n.son[1], max(T[n.son[1]].z, zac), kon)) %              mod;     }   };   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     int N, Q;     cin >> N >> Q;     vector<int> A(N + 1, 0);     for (int i = 0; i < N; i++) cin >> A[i + 1];     for (int i = 0; i < N; i++) A[i + 1] = (A[i] + A[i + 1]) % mod;     pw[0] = mat22(1);     pw[1] = mat22(1);     pw[1].M[0][1] = pw[1].M[1][0] = 1, pw[1].M[1][1] = 0;     for (int i = 2; i < 400000; i++) {       for (int j = 0; j < 2; j++)         for (int k = 0; k < 2; k++) {           pw[i].M[j][k] = 0;           for (int l = 0; l < 2; l++)             pw[i].M[j][k] += (pw[i - 1].M[j][l] * pw[1].M[l][k]) % mod;           pw[i].M[j][k] %= mod;           if (pw[i].M[j][k] < 0) pw[i].M[j][k] += mod;         }     }     Spw[0] = mat22();     for (int i = 1; i < 400000; i++)       for (int j = 0; j < 2; j++)         for (int k = 0; k < 2; k++) {           Spw[i].M[j][k] = (Spw[i - 1].M[j][k] + pw[i - 1].M[j][k]) % mod;           if (Spw[i].M[j][k] < 0) Spw[i].M[j][k] += mod;         }     intervalac I(N);     for (int q = 0; q < Q; q++) {       int t, l, r;       cin >> t >> l >> r;       l--;       if (t == 2) {         long long ans = (A[r] - A[l] + I.get(0, l, r)) % mod;         if (ans < 0) ans += mod;         cout << ans <<   n ;         continue;       }       I.put(0, l, r, 1, 1);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   long long n, s, ans, ans2, ret;   struct Node {     long long val, tmp;     int id;   } node[N];   bool cmp(Node A, Node B) { return A.tmp < B.tmp; }   bool check(int x) {     for (int i = 1; i <= n; i++) {       node[i].tmp = node[i].val + node[i].id * 1ll * x;     }     sort(node + 1, node + 1 + n, cmp);     ret = 0;     for (int i = 1; i <= x; i++) {       ret += node[i].tmp;     }     if (ret <= s) {       return 1;     }     return 0;   }   int main() {     scanf( %lld%lld , &n, &s);     for (int i = 1; i <= n; i++) {       scanf( %lld , &node[i].val);       node[i].id = i;     }     int L = 0, R = n, mid;     while (L <= R) {       mid = (L + R) >> 1;       if (check(mid)) {         ans = mid;         ans2 = ret;         L = mid + 1;       } else {         R = mid - 1;       }     }     cout << ans <<     << ans2 << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct node {     int val;     int mx[32];   };   int n, k, p;   vector<int> a[200005];   node st[4 * 200005];   int b[5];   void build(int si, int ss, int se) {     if (ss == se) {       st[si].val = 0;       for (int i = 0; i < p; i++) {         int val = 0;         for (int j = 0; j < k; j++) {           if (i & (1 << j)) {             val += a[ss][j];           } else {             val -= a[ss][j];           }         }         st[si].mx[i] = val;       }       return;     }     int mid = (ss + se) >> 1;     build(2 * si + 1, ss, mid);     build(2 * si + 2, mid + 1, se);     st[si].val = max(st[2 * si + 1].val, st[2 * si + 2].val);     for (int i = 0; i < p; i++) {       st[si].mx[i] = max(st[2 * si + 1].mx[i], st[2 * si + 2].mx[i]);       st[si].val =           max(st[si].val, st[2 * si + 1].mx[i] + st[2 * si + 2].mx[(p - 1) ^ i]);     }     return;   }   void update(int si, int ss, int se, int ind) {     if (ind < ss || ind > se) {       return;     }     if (ss == se) {       st[si].val = 0;       for (int i = 0; i < p; i++) {         int val = 0;         for (int j = 0; j < k; j++) {           if (i & (1 << j)) {             val += b[j];           } else {             val -= b[j];           }         }         st[si].mx[i] = val;       }       return;     }     int mid = (ss + se) >> 1;     update(2 * si + 1, ss, mid, ind);     update(2 * si + 2, mid + 1, se, ind);     st[si].val = max(st[2 * si + 1].val, st[2 * si + 2].val);     for (int i = 0; i < p; i++) {       st[si].mx[i] = max(st[2 * si + 1].mx[i], st[2 * si + 2].mx[i]);       st[si].val =           max(st[si].val, st[2 * si + 1].mx[i] + st[2 * si + 2].mx[(p - 1) ^ i]);     }     return;   }   node query(int si, int ss, int se, int l, int r) {     if (r < ss || l > se) {       node ans;       ans.val = -(k * 1e6 + 5);       for (int i = 0; i < p; i++) {         ans.mx[i] = -k * 1e6 + 5;       }       return ans;     }     if (ss >= l && se <= r) {       return st[si];     }     int mid = (ss + se) >> 1;     node x = query(2 * si + 1, ss, mid, l, r);     node y = query(2 * si + 2, mid + 1, se, l, r);     node ans;     ans.val = max(x.val, y.val);     for (int i = 0; i < p; i++) {       ans.mx[i] = max(x.mx[i], y.mx[i]);       ans.val = max(ans.val, x.mx[i] + y.mx[(p - 1) ^ i]);     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> k;     p = (1 << k);     for (int i = 0; i < n; i++) {       a[i].resize(k);       for (int j = 0; j < k; j++) {         cin >> a[i][j];       }     }     build(0, 0, n - 1);     int q;     cin >> q;     while (q--) {       int t;       cin >> t;       if (t == 1) {         int ind;         cin >> ind;         ind--;         for (int i = 0; i < k; i++) {           cin >> b[i];         }         update(0, 0, n - 1, ind);       } else {         int l, r;         cin >> l >> r;         l--, r--;         cout << query(0, 0, n - 1, l, r).val << endl;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   struct Seg {     const T ID = 0;     T comb(T a, T b) { return a + b; }     long long n;     vector<T> seg;     void init(long long _n) {       n = _n;       seg.assign(2 * n, ID);     }     void pull(long long p) { seg[p] = comb(seg[2 * p], seg[2 * p + 1]); }     void upd(long long p, T val) {       seg[p += n] = val;       for (p /= 2; p; p /= 2) pull(p);     }     T query(long long l, long long r) {       T ra = ID, rb = ID;       for (l += n, r += n + 1; l < r; l /= 2, r /= 2) {         if (l & 1) ra = comb(ra, seg[l++]);         if (r & 1) rb = comb(seg[--r], rb);       }       return comb(ra, rb);     }   };   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long m;     cin >> m;     string s;     cin >> s;     long long n = s.size();     long long a[n];     for (long long i = 0; i < n; ++i) {       a[i] = s[i] -  a ;     }     vector<long long> ans;     set<array<long long, 2>> ranges;     Seg<long long> st;     st.init(n);     for (long long i = 0; i < n; ++i) {       if (i + m - 1 >= n) break;       ranges.insert({i, i + m - 1});     }     for (long long i = 0; i < 26; ++i) {       bool fin = 1;       for (long long j = 0; j < n; ++j) {         if (a[j] == i) {           st.upd(j, 1);         }       }       for (auto [l, r] : ranges) {         fin &= st.query(l, r) > 0;       }       if (fin) {         vector<long long> pos;         for (long long j = 0; j < n; ++j) {           if (a[j] == i) {             st.upd(j, 0);             pos.push_back(j);           }         }         for (auto [l, r] : ranges) {           if (st.query(l, r)) continue;           auto lb = --(lower_bound((pos).begin(), (pos).end(), r + 1));           st.upd(*lb, 1);           ans.push_back(i);         }         break;       } else {         for (long long j = 0; j < n; ++j) {           if (a[j] == i) {             ans.push_back(i);           }         }         vector<array<long long, 2>> rem;         for (auto [l, r] : ranges) {           if (st.query(l, r)) {             rem.push_back({l, r});           }         }         for (auto [l, r] : rem) {           ranges.erase({l, r});         }       }     }     for (long long i : ans) {       cout << (char)(i +  a );     }     cout <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s = 0, t = 0;     string road;     cin >> n >> road;     for (int i = 1; i < n; ++i) {       if (road[i] ==  L ) {         t = i;         for (int j = i + 1; j < n; ++j) {           if (road[j] ==  . ) {             s = j;             break;           }         }         break;       } else if (road[i] ==  R ) {         s = i + 1;         for (int j = i + 1; j < n; ++j) {           if (road[j] !=  R ) {             t = (road[j] ==  .  ? j + 1 : j);             break;           }         }         break;       }     }     cout << s <<     << t << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   void in(T &x) {     x = 0;     bool f = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = 1;       c = getchar();     }     while ( 0  <= c && c <=  9 ) {       x = (x << 3) + (x << 1) + (c ^ 48);       c = getchar();     }     if (f) x = -x;   }   char s[1005];   int n, p;   char can(int x) {     for (register int i = s[x] + 1; i <=  a  + p - 1; ++i)       if (i != s[x - 1] && i != s[x - 2]) return i;     return 0;   }   signed main() {     in(n), in(p);     scanf( %s , s + 1);     int pos = 0;     for (register int i = n; i >= 1; --i) {       if (can(i)) {         s[i] = can(i);         pos = i;         break;       }     }     if (!pos) {       puts( NO );       return 0;     }     for (register int i = pos + 1; i <= n; ++i) {       for (register int j =  a ; j <=  a  + p - 1; ++j)         if (j != s[i - 1] && j != s[i - 2]) {           s[i] = j;           break;         }     }     for (register int i = 1; i <= n; ++i) putchar(s[i]);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int T, n;     cin >> T;     double R1, R2, R3;     while (T--) {       scanf( %lf%lf%d , &R1, &R2, &n);       R3 = R1 - R2;       double k1 = -1 / R1;       double k2 = 1 / R2;       double k3 = 1 / R3;       double k4 = k1 + k2 + k3;       double ans;       for (int i = 1; i <= n; i++) {         double R4 = 1 / k4;         ans = R4;         double k5 = 2 * (k1 + k2 + k4) - k3;         k3 = k4;         k4 = k5;       }       printf( %0.10lf n , fabs(ans));     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       set<int> s;       for (int i = 0, x; i < n; i++) {         cin >> x;         s.insert(((x + i) % n + n) % n);       }       puts(s.size() == n ?  YES  :  NO );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     scanf( %d%d , &a, &b);     for (int i = b + 1; i <= a + b + 1; i++) printf( %d  , i);     for (int i = b; i >= 1; i--) printf( %d  , i);     return 0;   }


#include<iostream>   #include<math.h>   #include<bits/stdc++.h>   #include <string>    #include <vector>    using namespace std;   #define pi (2*acos(0.0))   #define ll long long int    #define ull unsigned long long int    #define lp(i , start , n) for(int i = start ; i < n; i++)         int main(){       ios::sync_with_stdio(false);       cin.tie(0);        int t; cin>>t;       while(t--){           int n; cin>>n;           if(n==2) cout<<-1<<endl;           else{               int a[n][n];               bool odd = true;               int oddnum= 1;               int evennum=1;               int cnt = 0;                  for(int i = 0 ; i < n ; i++){                   for(int j = 0 ; j < n ; j++){                       if(odd){                           a[i][j]=2*oddnum-1;                           oddnum++;                           cnt++;                           if(cnt>=(n*n+1)/2){                               odd=false;                           }                       }                       else{                           a[i][j]=2*evennum;                           evennum++;                       }                   }               }                  for(int i = 0 ; i < n ; i++){                   for(int j = 0 ; j < n ; j++){                       cout<<a[i][j]<<   ;                   }                   cout<<endl;               }                 }       }       return 0;   }


#include <bits/stdc++.h>   using namespace std;   int a[10000000], b[10010000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       b[i] = a[i];     }     int p = 0;     sort(a, a + n);     for (int i = 0; i < n; i++) {       if (a[i] != b[i]) p++;     }     if (p > 2)       cout <<  NO  << endl;     else       cout <<  YES  << endl;   }


#include <bits/stdc++.h>   using namespace std;   const int MAX_INT = INT32_MAX;   const long long MAX_LL = INT64_MAX;   const long long mod = 1e9 + 7;   const int N = 1;   bool primes[N + 1];   int npr(int n, int r) {     int res = 1;     for (auto i = n - r + 1; i <= n; i++) res *= i;     return res;   }   int ncr(int n, int r) {     int res = 1;     int rFact = 1;     for (auto i = n - r + 1; i <= n; i++) {       res *= i;       if (res % rFact == 0 && rFact <= r) res /= rFact, rFact++;     }     return res;   }   void sieve() {     memset(primes, true, sizeof(primes));     primes[0] = primes[1] = false;     for (int i = 2; i * i <= N; i++) {       if (primes[i]) {         for (int j = i * i; j <= N; j += i) primes[j] = false;       }     }   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n == 2) return true;     for (auto i = 2; i <= sqrt(n); i++)       if (n % i == 0) return false;     return true;   }   set<long long> getDivisors(long long val) {     set<long long> st;     for (auto i = 1; i <= sqrt(val); i++)       if (val % i == 0) st.insert(i), st.insert(val / i);     return st;   }   long long fastPow(long long base, long long power) {     long long res = 1;     while (power > 0) {       if (power % 2 != 0) res = (res * base) % mod;       base = (base * base) % mod;       power /= 2;     }     return res;   }   bool palindrome(string s) {     string reversedS = s;     reverse(reversedS.begin(), reversedS.end());     if (s == reversedS)       return true;     else       return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<long long> v(n), A, B;     int winner = -1;     long long mxA = -1, mxB = -1;     bool lexi = false;     long long sum = 0;     for (auto i = 0; i < n; i++) {       cin >> v[i];       sum += v[i];       if (v[i] > 0)         A.push_back(v[i]);       else         B.push_back(abs(v[i]));     }     for (auto i = 0; i < min(A.size(), B.size()); i++) {       if (A[i] > B[i]) {         lexi = true;         winner = 0;         break;       } else if (B[i] > A[i]) {         lexi = true;         winner = 1;         break;       }     }     if (sum == 0) {       if (lexi)         cout << ((winner == 0) ?  first  :  second );       else         cout << ((v.back() > 0) ?  first  :  second );     } else       cout << ((sum > 0) ?  first  :  second );     cout << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   FILE* in = stdin;   FILE* out = stdout;   const int MAX = 100001;   const int INF = 1000000001;   int n;   int dist[MAX];   long long a[MAX];   int main(void) {     fscanf(in,  %d , &n);     for (int i = 0; i < n; i++) fscanf(in,  %lld , &a[i]);     sort(a, a + n);     reverse(a, a + n);     while (n > 0 && a[n - 1] == 0) n--;     for (int bit = 0; bit < 60; bit++) {       int cnt = 0;       for (int i = 0; i < n; i++)         if (a[i] & (1LL << bit)) cnt++;       if (cnt >= 3) {         fprintf(out,  3 n );         return 0;       }     }     int ans = INF;     for (int origin = 0; origin < n; origin++) {       if (ans <= 3) break;       memset(dist, 63, sizeof(dist));       queue<int> q;       q.push(origin);       dist[origin] = 0;       int curDist = 0;       while (!q.empty()) {         curDist++;         vector<int> nnodes;         vector<int> cnt(n, 0);         while (!q.empty()) {           int node = q.front();           q.pop();           for (int i = 0; i < n; i++) {             if (dist[i] > INF && (a[node] & a[i])) {               dist[i] = curDist;               nnodes.push_back(i);             }             if (dist[i] == curDist && (a[node] & a[i])) cnt[i]++;           }         }         for (int i = 0; i < n; i++) {           if (cnt[i] >= 2) {             ans = min(ans, curDist + curDist);           }         }         for (int i1 = 0; i1 < (int)nnodes.size(); i1++) {           if (ans <= 3) break;           for (int i2 = i1 + 1; i2 < (int)nnodes.size(); i2++) {             if (a[nnodes[i1]] & a[nnodes[i2]]) {               ans = min(ans, curDist + curDist + 1);             }           }         }         for (int i = 0; i < (int)nnodes.size(); i++) {           q.push(nnodes[i]);         }       }     }     fprintf(out,  %d n , ans >= INF ? -1 : ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class TH>   void _dbg(const char *sdbg, TH h) {     cerr << sdbg <<  =  << h << endl;   }   template <class TH, class... TA>   void _dbg(const char *sdbg, TH h, TA... a) {     while (*sdbg !=  , ) cerr << *sdbg++;     cerr <<  =  << h <<  , ;     _dbg(sdbg + 1, a...);   }   template <class L, class R>   ostream &operator<<(ostream &os, pair<L, R> p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class Iterable,             class = typename enable_if<!is_same<string, Iterable>::value>::type>   auto operator<<(ostream &os, Iterable v) -> decltype(os << *begin(v)) {     os <<  [ ;     for (auto vv : v) os << vv <<  ,  ;     return os <<  ] ;   }   const int inf = 0x3f3f3f3f;   const long long infll = 0x3f3f3f3f3f3f3f3fll;   template <class T>   int sign(T x) {     return (x > 0) - (x < 0);   }   template <class T>   T abs(const T &x) {     return (x < T(0)) ? -x : x;   }   template <class T>   T gcd(T a, T b, T &x, T &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     T x1, y1;     T d = gcd(b, a % b, x1, y1);     x = y1;     y = x1 - y1 * (a / b);     return d;   }   template <class T>   T mod_inverse(T a, T m) {     T x, y;     assert(gcd(a, m, x, y) == 1);     return (x % m + m) % m;   }   template <long long mod>   struct mod_num {     long long x;     explicit mod_num(long long x = 0) : x(x % mod) {}     mod_num operator+(mod_num b) { return mod_num(x + b.x); }     mod_num operator-(mod_num b) { return mod_num(x - b.x + mod); }     mod_num operator*(mod_num b) { return mod_num(x * b.x); }     mod_num operator/(mod_num b) { return mod_num(x * mod_inverse(b.x, mod)); }     mod_num operator^(long long e) {       mod_num ans(1);       mod_num b = *this;       for (; e; b = b * b, e /= 2)         if (e & 1) ans = ans * b;       return ans;     }     void operator+=(mod_num b) { x = (x + b.x) % mod; }   };   template <long long mod>   ostream &operator<<(ostream &os, mod_num<mod> x) {     return os << x.x;   }   vector<int> graph[512345];   int been[512345];   vector<int> st;   vector<vector<int>> rings;   vector<pair<int, int>> edges;   mod_num<1000000007> vertex_rings_factor[512345];   void dfs(int a, int p) {     been[a] = 1;     st.push_back(a);     for (int i = 0; i < ((int)(graph[a]).size()); i++) {       if (graph[a][i] != p) {         if (been[graph[a][i]] == 0)           dfs(graph[a][i], a);         else if (been[graph[a][i]] == 1) {           vector<int> tmp;           for (int j = ((int)(st).size()) - 1; st[j] != graph[a][i]; j--)             tmp.push_back(st[j]);           tmp.push_back(graph[a][i]);           rings.push_back(tmp);         }       }     }     st.pop_back();     been[a] = 2;   }   bool intersect(const vector<int> &v1, const vector<int> &v2) {     for (int i = 0; i < ((int)(v1).size()); i++)       if (find(v2.begin(), v2.end(), v1[i]) != v2.end()) return true;     return false;   }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     int n, m, a, b;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a >> b;       edges.push_back({min(a, b), max(a, b)});       graph[a].push_back(b);       graph[b].push_back(a);     }     dfs(1, 1);     vector<mod_num<1000000007>> pot2div(max(11, n + 1));     pot2div[0] = mod_num<1000000007>(1);     pot2div[1] = pot2div[0] / mod_num<1000000007>(2);     for (int i = 2; i < ((int)(pot2div).size()); i++)       pot2div[i] = pot2div[i - 1] * pot2div[1];     mod_num<1000000007> sum_rings_factors(0);     for (int i = 0; i < ((int)(rings).size()); i++) {       sum_rings_factors += pot2div[((int)(rings[i]).size())];       for (int x : rings[i]) {         vertex_rings_factor[x] += pot2div[((int)(rings[i]).size())];       }     }     vector<mod_num<1000000007>> intersecting_rings_factors(((int)(rings).size()));     for (int i = 0; i < ((int)(rings).size()); i++)       for (int x : rings[i])         intersecting_rings_factors[i] +=             vertex_rings_factor[x] - pot2div[((int)(rings[i]).size())];     mod_num<1000000007> ex = (mod_num<1000000007>(2) ^ 0) *                                  mod_num<1000000007>(n) / mod_num<1000000007>(2) -                              mod_num<1000000007>(m) / mod_num<1000000007>(4);     for (int i = 0; i < ((int)(rings).size()); i++)       ex += pot2div[((int)(rings[i]).size())];     mod_num<1000000007> ex2(0);     mod_num<1000000007> ev2 =         mod_num<1000000007>(n) * mod_num<1000000007>(n - 1) /             (mod_num<1000000007>(2) ^ 2) +         mod_num<1000000007>(n) / (mod_num<1000000007>(2) ^ 1);     mod_num<1000000007> ee2(0);     for (int i = 0; i < m; i++) {       ee2 += pot2div[2];       ee2 += mod_num<1000000007>(((int)(graph[edges[i].first]).size()) +                                  ((int)(graph[edges[i].second]).size()) - 2) *              pot2div[3];       ee2 +=           mod_num<1000000007>(m - (((int)(graph[edges[i].first]).size()) +                                    ((int)(graph[edges[i].second]).size()) - 1)) *           pot2div[4];     }     mod_num<1000000007> er2(0);     for (int i = 0; i < ((int)(rings).size()); i++) {       er2 += pot2div[((int)(rings[i]).size())];       er2 +=           pot2div[((int)(rings[i]).size()) - 1] * intersecting_rings_factors[i];       er2 += pot2div[((int)(rings[i]).size())] *              (sum_rings_factors - intersecting_rings_factors[i] -               pot2div[((int)(rings[i]).size())]);     }     mod_num<1000000007> eve;     for (int i = 1; i <= n; i++) {       eve += mod_num<1000000007>(((int)(graph[i]).size())) * pot2div[2];       eve += mod_num<1000000007>(m - ((int)(graph[i]).size())) * pot2div[3];     }     mod_num<1000000007> eer;     for (int j = 0; j < ((int)(rings).size()); j++) {       int k = ((int)(rings[j]).size());       eer += mod_num<1000000007>(((int)(rings[j]).size())) *              pot2div[((int)(rings[j]).size())];       for (int x : rings[j]) {         eer += mod_num<1000000007>(((int)(graph[x]).size()) - 2) *                pot2div[((int)(rings[j]).size()) + 1];         k += ((int)(graph[x]).size()) - 2;       }       eer += mod_num<1000000007>(m - k) * pot2div[((int)(rings[j]).size()) + 2];     }     mod_num<1000000007> evr;     for (int i = 1; i <= n; i++) {       evr += vertex_rings_factor[i];       evr += (sum_rings_factors - vertex_rings_factor[i]) * pot2div[1];     }     ex2 = ev2 + ee2 + er2 - mod_num<1000000007>(2) * eve -           mod_num<1000000007>(2) * eer + mod_num<1000000007>(2) * evr;     cout << (mod_num<1000000007>(2) ^ (1000000007)) * (ex2 - ex * ex) *                 (mod_num<1000000007>(2) ^ (1000000005))          << endl;   }


#include <bits/stdc++.h>   using namespace std;   long long int sum1, sum2;   inline void in(long long int &_8) {     long long int _6 = 1;     char _0;     while (((_0 = getchar()) <  0  || _0 >  9 ) && _0 !=  - )       ;     _0 ==  -  ? (_6 = -1, _8 = 0) : (_8 = _0 -  0 );     while ((_0 = getchar()) >=  0  && _0 <=  9 ) _8 = _8 * 10 + _0 -  0 ;     _8 *= _6;   }   int main() {     long long int digit, base, tmp, sum;     in(digit);     in(base);     for (int i = 1; i <= digit; i++) {       in(tmp);       sum1 = sum1 * base + tmp;     }     in(digit);     in(base);     for (int i = 1; i <= digit; i++) {       in(tmp);       sum2 = sum2 * base + tmp;     }     sum1 == sum2 ? putchar( = ) : sum1 > sum2 ? putchar( > ) : putchar( < );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     int n;     scanf( %d , &n);     vector<int> a(n), b(n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       --a[i];     }     for (int i = 0; i < n; ++i) {       scanf( %d , &b[i]);       --b[i];     }     vector<int> posa(n), posb(n);     for (int i = 0; i < n; ++i) {       posa[a[i]] = i;       posb[b[i]] = i;     }     multiset<int> left, right;     for (int i = 0; i < n; ++i) {       if (posb[i] < posa[i]) {         left.insert(posa[i] - posb[i]);       } else {         right.insert(posb[i] - posa[i]);       }     }     int x = 0;     vector<int> r;     while (x < n) {       int ans = n + 10;       if (!left.empty()) {         ans = min(ans, *left.begin() - x);       }       if (!right.empty()) {         ans = min(ans, *right.begin() + x);       }       r.push_back(ans);       x++;       if (x == n) {         break;       }       while (!left.empty() && *left.begin() - x == 0) {         left.erase(left.begin());         right.insert(-x);       }       int e = b[n - x];       if (posb[e] + x < posa[e]) {         left.erase(left.find(posa[e] - posb[e]));       } else {         right.erase(right.find(posb[e] - posa[e]));       }       if ((posb[e] + x) % n < posa[e]) {         left.insert(posa[e] - (posb[e] + x) % n + x);       } else {         right.insert((posb[e] + x) % n - posa[e] - x);       }     }     reverse(r.begin() + 1, r.end());     for (int x : r) {       printf( %d n , x);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     vector<long long> v;     set<long long> myset;     set<long long>::iterator it;     long long n, k, q, t;     map<long long, int> mp;     cin >> n >> k;     for (long long i = 0; i < n; i++) {       scanf( %I64d , &t);       v.push_back(t);       myset.insert(t);       mp[t]++;     }     sort(v.begin(), v.end());     if (v.size() == myset.size()) {       if (k % n != 0 && n < k) {         long long m = k / n;         long long p = m * n;         long long u = v[m];         long long x = 0;         for (long long i = p + 1; i <= k; i++) {           q = v[x];           ++x;         }         cout << u <<     << q << endl;         return 0;       }       if (k % n == 0 && n <= k) {         cout << v[(k / n) - 1] <<     << v[n - 1] << endl;         return 0;       }       if (k < n) {         cout << v[0] <<     << v[k - 1] << endl;         return 0;       }     } else {       long long sum = 0, b;       for (it = myset.begin(); it != myset.end(); ++it) {         sum += (mp[*it] * n);         if (k <= sum) {           b = *it;           sum -= (mp[*it] * n);           break;         }       }       long long cnt = sum;       for (long long i = 0; i < n; i++) {         cnt += mp[b];         if (cnt >= k) {           cout << b <<     << v[i] << endl;           break;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int nmax = 2e5 + 42;   int n, k;   int main() {     cin >> n >> k;     int d = (n - k) / 2;     int cycle = d + 1;     for (int i = 1; i <= n; i++)       if (i % cycle == 0)         cout <<  1 ;       else         cout <<  0 ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   char s[105];   int main() {     int n;     cin >> n;     cin >> s;     int flag = 0;     for (int i = 1; i < n; i++) {       if (s[i] !=  ?  && s[i] == s[i - 1]) {         flag = 1;         break;       }     }     if (flag)       cout <<  No  << endl;     else {       if (s[0] ==  ?  || s[n - 1] ==  ? )         flag = 1;       else {         for (int i = 1; i < n - 1; i++) {           if (s[i] ==  ?  && s[i - 1] ==  ?  ||               s[i] ==  ?  && s[i + 1] == s[i - 1])             flag = 1;         }       }       if (flag)         cout <<  Yes  << endl;       else         cout <<  No  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 6, m = 8;     vector<string> a(n);     vector<vector<int>> u;     vector<int> loc(m);     loc = {3, 3, -1, 4, 4, -1, 3, 3};     u.push_back(loc);     u.push_back(loc);     loc = {2, 2, -1, 3, 3, -1, 2, 2};     u.push_back(loc);     u.push_back(loc);     loc = {1, 1, -1, 2, 2, -1, 1, 1};     u.push_back(loc);     u.push_back(loc);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int max = 0, x, y;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  .  && u[i][j] > max) {           x = i;           y = j;           max = u[i][j];         }       }     }     a[x][y] =  P ;     for (auto i : a) {       cout << i <<   n ;     }   }


#include <bits/stdc++.h>   using namespace std;   bool solve(const vector<int>& hps, const vector<int>& hero, vector<int>& soln,              int frm, int dir) {     soln.clear();     int n = hps.size();     if (n == 0) return true;     vector<int> heroes;     heroes.push_back(0);     for (int i = 1; i < n; i++) {       if (hero[i]) heroes.push_back(i);     }     int h = heroes.size();     if (h == 1) {       if (hero[0]) {         soln.push_back(frm);       }       return true;     }     vector<int> dp(h, -1);     dp[0] = 0;     for (int i = 1; i < h; i++) {       int health = hero[heroes[i]];       assert(health > 0);       for (int j = i - 1; j >= 0; j--) {         bool gone = false;         for (int k = heroes[j + 1] - 1; k >= heroes[j]; k--) {           health += hps[k];           if (health < 0) {             gone = true;             break;           }         }         if (gone) break;         if (dp[j] != -1) {           dp[i] = j;           break;         }       }     }     if (dp[h - 1] == -1) return false;     vector<int> taken(h, 0);     int x = h - 1;     while (1) {       taken[x] = 1;       if (hero[heroes[x]]) soln.push_back(x);       if (x == 0) break;       x = dp[x];     }     reverse(soln.begin(), soln.end());     for (int i = 0; i < h; i++)       if (!taken[i]) soln.push_back(i);     for (int& x : soln) {       x = heroes[x];       if (dir > 0) {         x += frm;       } else {         x = frm - x;       }     }     return true;   }   const int MAXN = 107;   int heroHealth[MAXN];   int healthPnts[MAXN];   int heroMap[MAXN];   int n;   bool checkDirection(int rp, int dir, int bahir, vector<int>& soln) {     vector<int> hps;     vector<int> hero;     for (int i = rp + bahir * dir; i <= n && i > 0; i += dir) {       hps.push_back(healthPnts[i]);       hero.push_back(heroHealth[i]);     }     return solve(hps, hero, soln, rp + bahir * dir, dir);   }   bool rally(int rp, vector<int>& soln) {     soln.clear();     vector<int> bamsoln;     vector<int> dansoln;     bool x = checkDirection(rp, 1, 0, dansoln);     bool y = checkDirection(rp, -1, 1, bamsoln);     if (x && y) {       if (healthPnts[rp] >= 0 || dansoln.size() > 0) {         for (int g : dansoln) {           soln.push_back(heroMap[g]);         }         for (int g : bamsoln) {           soln.push_back(heroMap[g]);         }         return true;       }     }     if (healthPnts[rp] < 0) {       x = checkDirection(rp, 1, 1, dansoln);       y = checkDirection(rp, -1, 0, bamsoln);       if (x && y && bamsoln.size() > 0) {         for (int g : bamsoln) {           soln.push_back(heroMap[g]);         }         for (int g : dansoln) {           soln.push_back(heroMap[g]);         }         return true;       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     int m;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int s, h;       cin >> s >> h;       heroHealth[s] = h;       heroMap[s] = i;     }     for (int i = 1; i <= n; i++) {       cin >> healthPnts[i];     }     vector<int> soln;     for (int rp = 1; rp <= n; rp++) {       if (rally(rp, soln)) {         cout << rp << endl;         for (int x : soln) cout << x <<    ;         return 0;       }     }     cout << -1 << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool SortbySecDesc(const pair<long long, long long> &a,                      const pair<long long, long long> &b) {     return a.second > b.second;   }   bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     ;     int t;     cin >> t;     while (t--) {       long long a, b;       cin >> a >> b;       long long low = 1, high = 1e18, ans;       while (low <= high) {         long long mid = (low + high) / 2;         long long vag = mid / a;         long long baki = mid - vag;         if (baki >= b) {           ans = mid;           high = mid - 1;         } else {           low = mid + 1;         }       }       cout << ans << endl;     }     return 0;   }


#include <bits/stdc++.h>   int main() {     int k, tk;     long long n, ck, a;     scanf( %I64d %d , &n, &k);     long long menor = n;     scanf( %I64d , &a);     tk = 1;     ck = n / a;     menor = n % a;     for (int i = 1; i < k; i++) {       scanf( %I64d , &a);       if (n % a < menor) {         tk = i + 1;         ck = n / a;         menor = n % a;       }     }     printf( %d %I64d , tk, ck);   }


#include <bits/stdc++.h>   std::vector<std::vector<int>> ad;   std::vector<int> fm;   std::vector<bool> tmp;   int f(int x) {     if (fm[x] >= 0) return fm[x];     for (int y : ad[x]) f(y);     for (int y : ad[x]) tmp[fm[y]] = true;     fm[x] = int(std::find(begin(tmp), end(tmp), false) - begin(tmp));     for (int y : ad[x]) {       tmp[fm[y]] = false;     }     return fm[x];   }   int main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     int n, m;     std::cin >> n >> m;     std::vector<int> h(n);     for (int& x : h) std::cin >> x;     ad.resize(n);     for (int z = m; z--;) {       int u, v;       std::cin >> u >> v;       --u;       --v;       ad[u].push_back(v);     }     std::vector<int> val(n);     fm.assign(n, -1);     tmp.resize(n);     for (int i = n; i--;) val[f(i)] ^= h[i];     while (!val.empty() && val.back() == 0) val.pop_back();     if (val.empty()) {       std::cout <<  LOSE n ;       return 0;     }     std::cout <<  WIN n ;     int i = 0;     while (fm[i] != val.size() - 1 || (h[i] ^ val.back()) > h[i]) {       ++i;     }     h[i] ^= val.back();     std::vector<bool> ok(val.size() - 1);     for (int j : ad[i])       if ((unsigned)fm[j] < ok.size() && !ok[fm[j]]) {         ok[fm[j]] = true;         h[j] ^= val[fm[j]];       }     for (auto x : h) std::cout << x <<    ;     std::cout <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, i;     long long h, k, a[100005], cnt = 0;     cin >> n >> h >> k;     for (i = 0; i < n; i++) cin >> a[i];     long long carry = 0;     for (i = 0; i < n; i++) {       if (carry + a[i] <= h) {         carry += a[i];       } else {         cnt += 1;         carry = a[i];       }       cnt += (carry / k);       carry %= k;     }     cnt += carry / k;     carry %= k;     cnt += (carry > 0);     cout << cnt <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int L = 50500, C = 27, N = 11, root = 0, None = -987958798;   const char END =  { ;   struct node {     int s[C], b[N], par, val;   } t[L * 22] = {};   char ch[L * 22] = {};   int n, l = 0, tot = 0, x[N] = {}, y[N] = {}, d[N] = {}, in[L * 22] = {},          q[L * 22] = {}, head = 0, tail = 0;   long long ans = 0;   void add(int p, int c) {     int np = ++tot;     t[np].val = t[p].val + 1;     while (p != None && t[p].s[c] == 0) t[p].s[c] = np, p = t[p].par;     if (p == None)       t[np].par = root;     else {       int q = t[p].s[c];       if (t[p].val + 1 == t[q].val)         t[np].par = q;       else {         int nq = ++tot;         t[nq] = t[q];         t[nq].val = t[p].val + 1;         t[q].par = t[np].par = nq;         for (int i = p; i != None && t[i].s[c] == q; i = t[i].par) t[i].s[c] = nq;       }     }   }   int main() {     t[root].par = None;     d[0] = ++l;     cin >> (ch + d[0]) >> n;     l += strlen(ch + d[0]);     for (int i = 1; i <= n; ++i) {       ch[l] = END;       d[i] = ++l;       cin >> (ch + d[i]) >> x[i] >> y[i];       l += strlen(ch + d[i]);     }     ch[l] = END;     for (int i = 1, p = root; i < l; p = t[p].s[ch[i++] -  a ])       add(p, ch[i] -  a );     for (int i = 0; i <= n; ++i)       for (int j = d[i], p = t[root].s[ch[j] -  a ]; ch[j] != END;            p = t[p].s[ch[++j] -  a ])         ++t[p].b[i];     for (int i = 1; i <= tot; ++i) ++in[t[i].par];     for (int i = 1; i <= tot; ++i)       if (!in[i]) q[++tail] = i;     for (int tmp = 1; tmp <= tot; ++tmp) {       int s = q[++head];       bool flag = t[s].b[0];       for (int i = 1; i <= n; ++i) flag &= x[i] <= t[s].b[i] && t[s].b[i] <= y[i];       if (flag) ans += t[s].val - t[t[s].par].val;       for (int i = 0; i <= n; ++i) t[t[s].par].b[i] += t[s].b[i];       if ((--in[t[s].par]) == 0) q[++tail] = t[s].par;     }     cout << ans << endl;   }


#include <bits/stdc++.h>   using namespace std;   struct node {     int co, key;   } num[1010];   int seven;   char str[1010 * 100];   int init;   bool cmp(node x, node y) { return x.co < y.co; }   int main() {     scanf( %d , &init);     scanf( %s , str);     seven = 1;     int cnt = 1;     int length = strlen(str);     int now = 0;     int pre = -1;     for (int i = 1; i <= 1000; i++) num[i].co = 1;     while (now < length) {       if (str[now] ==  - ) {         seven = -1;         now++;       } else if (str[now] ==  *  || str[now] ==  + )         now++;       else if (str[now] ==  a ) {         if (now - 2 > pre && str[now - 1] ==  +  && str[now - 2] ==  + ) {           pre = now;           num[cnt].co *= seven;           num[cnt].key = 0;           cnt++;           now++;         } else {           pre = now + 2;           num[cnt].co *= seven;           num[cnt].key = 1;           cnt++;           now += 3;         }         seven = 1;       } else {         int sum = 0;         while (str[now] >=  0  && str[now] <=  9 ) {           sum = sum * 10 + (str[now] -  0 );           now++;         }         num[cnt].co = sum;       }     }     cnt--;     sort(num + 1, num + 1 + cnt, cmp);     int ans = 0;     for (int i = 1; i <= cnt; i++) {       if (!num[i].key) {         init++;         ans += (num[i].co * init);       } else {         ans += (num[i].co * init);         init++;       }     }     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   const long long p1 = 737;   const long long p2 = 3079;   const long long m1 = 1000000123;   const long long m2 = 1000000321;   vector<long long> p_pow1(N), p_pow2(N);   pair<vector<long long>, vector<long long> > H[3];   void init() {     p_pow1[0] = 1;     p_pow2[0] = 1;     for (int i = 1; i < N; i++) {       p_pow1[i] = (p_pow1[i - 1] * p1) % m1;       p_pow2[i] = (p_pow2[i - 1] * p2) % m2;     }   }   pair<vector<long long>, vector<long long> > Hash(string const& s) {     int n = s.size();     vector<long long> h1(n + 1), h2(n + 1);     for (int i = 0; i < n; i++) {       h1[i + 1] = ((h1[i] * p1) % m1 + (s[i] -  a  + 1)) % m1;       h2[i + 1] = ((h2[i] * p2) % m2 + (s[i] -  a  + 1)) % m2;     }     return {h1, h2};   }   pair<long long, long long> get_Hash(int idx, int l, int r) {     long long x =         (H[idx].first[r] - (H[idx].first[l - 1] * p_pow1[r - l + 1]) % m1 + m1) %         m1;     long long y = (H[idx].second[r] -                    (H[idx].second[l - 1] * p_pow2[r - l + 1]) % m2 + m2) %                   m2;     return {x, y};   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     ;     init();     string s, t1, t2;     char ch[2005];     scanf( %s , ch);     s = ch;     scanf( %s , ch);     t1 = ch;     scanf( %s , ch);     t2 = ch;     int n = s.size();     int a = t1.size();     int b = t2.size();     H[0] = Hash(s);     H[1] = Hash(t1);     H[2] = Hash(t2);     vector<pair<long long, long long> > v;     for (int i = 1; i <= (n - a + 1); i++) {       for (int j = i; j <= (n - b + 1); j++) {         int len1 = i + a - 1;         int len2 = j + b - 1;         if (get_Hash(0, i, len1) == get_Hash(1, 1, a) &&             get_Hash(0, j, len2) == get_Hash(2, 1, b)) {           if (len1 <= len2) v.push_back(get_Hash(0, i, len2));         }       }     }     sort(v.begin(), v.end());     int res = 0;     if (v.size()) res = 1;     for (int i = 1; i < v.size(); i++) {       if (v[i - 1] != v[i]) res++;     }     printf( %d n , res);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, l, c, d, p, nl, np;     {       cin >> n >> k >> l >> c >> d >> p >> nl >> np;       int D = k * l;       D /= nl;       cout << min(D, min((c * d), (p / np))) / n << endl;     }   }