#include <bits/stdc++.h>   template <typename T>   inline void rd(T& x) {     int si = 1;     char c = getchar();     x = 0;     while (!isdigit(c)) si = c ==  -  ? -1 : si, c = getchar();     while (isdigit(c)) x = x * 10 + c - 48, c = getchar();     x *= si;   }   template <typename T, typename... Args>   inline void rd(T& x, Args&... args) {     rd(x);     rd(args...);   }   const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;   const long long kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;   long long QPow(long long a, long long b) {     long long ans = 1, bas = a;     for (; b; b >>= 1, bas = bas * bas % kMod)       if (b & 1) ans = ans * bas % kMod;     return ans;   }   struct Edge {     int u, v, c;   } E[kN];   int n, m, fa[kN], s[kN], col[kN], cnt[kN];   std::vector<int> pt[2];   bool flag = false;   int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }   void Merge(int x, int y) {     int fx = Find(x), fy = Find(y);     if (fx == fy) return;     s[fx] += s[fy];     fa[fy] = fx;   }   void Solve(int x) {     memset(col, 0xff, sizeof(col));     for (int i = 1; i <= 2 * n; ++i) {       fa[i] = i;       s[i] = (i <= n);     }     for (int i = 1; i <= m; ++i) {       int u = E[i].u, v = E[i].v, c = E[i].c ^ x;       if (c)         Merge(u, v), Merge(u + n, v + n);       else         Merge(u + n, v), Merge(u, v + n);     }     for (int i = 1; i <= n; ++i)       if (Find(i) == Find(i + n)) return;     flag = true;     for (int i = 1; i <= n; ++i)       if (col[Find(i)] == -1) {         col[Find(i)] = (s[Find(i)] < s[Find(i + n)]);         col[Find(i + n)] = !col[Find(i)];       }     cnt[x] = 0;     for (int i = 1; i <= n; ++i)       if (col[Find(i)] == 1) {         ++cnt[x];         pt[x].push_back(i);       }   }   int main() {     int T = 1;     while (T--) {       rd(n, m);       cnt[0] = cnt[1] = kInf;       for (int i = 1; i <= m; ++i) {         char c[5];         rd(E[i].u, E[i].v);         scanf( %s , c + 1);         E[i].c = (c[1] ==  B );       }       for (int i = 0; i < 2; ++i) Solve(i);       if (flag) {         if (cnt[0] < cnt[1]) {           printf( %d n , cnt[0]);           for (auto i : pt[0]) printf( %d  , i);         } else {           printf( %d n , cnt[1]);           for (auto i : pt[1]) printf( %d  , i);         }       } else         printf( -1 );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int a[N], c[N], f[N], g[N], n, q, m, len, ans[N];   map<int, int> mp;   inline void read(int &x) {     char c = getchar();     x = 0;     while (c >  9  || c <  0 ) c = getchar();     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }   }   inline void write(int x) {     if (x == 0) putchar( 0 );     int a[20];     a[0] = 0;     while (x) {       a[++a[0]] = x % 10;       x /= 10;     }     while (a[0]) putchar(a[a[0]--] +  0 );     putchar(  n );   }   struct data {     int l, r, pos;     bool operator<(const data &a) const {       return l / m == a.l / m ? ((l / m) & 1 ? r > a.r : r < a.r)                               : l / m < a.l / m;     }   } b[N];   inline void add(int x, int y) {     if (f[x] >= m)       mp.erase(x);     else       --g[f[x]];     f[x] += y;     if (f[x] >= m)       mp[x] = f[x];     else       ++g[f[x]];   }   int heap[N];   inline void down(int x) {     int y = x * 2;     if (y > len) return;     if (heap[y] > heap[y + 1] && y + 1 <= len) y = y + 1;     if (heap[x] > heap[y]) {       swap(heap[x], heap[y]);       down(y);     }   }   inline int work() {     int ans = 0, pr = 0;     len = 0;     for (int i = 1; i < m; ++i) c[i] = g[i];     for (int i = 1; i < m; ++i) {       if (!c[i]) continue;       if (pr) {         --c[i];         int p = pr + i;         ans += p;         if (p < m)           ++c[p];         else           heap[++len] = p;         pr = 0;       }       if (c[i] % 2 == 1) pr = i;       ans += i * 2 * (c[i] / 2);       if (i * 2 < m)         c[i * 2] += c[i] / 2;       else {         for (int j = 1; j <= c[i] / 2; ++j) heap[++len] = i * 2;       }     }     if (pr != 0) heap[++len] = pr;     map<int, int>::iterator it;     for (it = mp.begin(); it != mp.end(); ++it) heap[++len] = it->second;     for (int i = len / 2; i >= 1; --i) down(i);     while (len != 1) {       int p = heap[1];       heap[1] = heap[len];       --len;       down(1);       int q = heap[1];       ans += p + q;       heap[1] += p;       down(1);     }     return ans;   }   inline void change(int x, int y) {     if (b[x].l > b[y].l) {       for (int i = b[y].l; i < b[x].l; ++i) add(a[i], 1);     } else {       for (int i = b[x].l; i < b[y].l; ++i) add(a[i], -1);     }     if (b[x].r < b[y].r) {       for (int i = b[x].r + 1; i <= b[y].r; ++i) add(a[i], 1);     } else {       for (int i = b[y].r + 1; i <= b[x].r; ++i) add(a[i], -1);     }   }   int main() {     read(n);     for (int i = 1; i <= n; ++i) read(a[i]);     read(q);     for (int i = 1; i <= q; ++i) {       read(b[i].l);       read(b[i].r);       b[i].pos = i;     }     m = (int)sqrt(n);     sort(b + 1, b + 1 + q);     g[0] = n;     for (int i = b[1].l; i <= b[1].r; ++i) add(a[i], 1);     for (int i = 1; i < q; ++i) {       ans[b[i].pos] = work();       change(i, i + 1);     }     ans[b[q].pos] = work();     for (int i = 1; i <= q; ++i) write(ans[i]);   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     cin >> n;     string s;     cin >> s;     for (i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) break;     }     if (i == s.length())       cout << s.length();     else       cout << i + 1;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool comp(long long x, long long y) { return x > y; }   int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   int n, k;   char s[100000 + 5];   int prefix[100000 + 5];   bool check(int x, int i) {     int tmp = prefix[min(n - 1, i + x)];     if (i - x > 0) tmp -= prefix[i - x - 1];     if (tmp >= k + 1) return true;     return false;   }   int main() {     cin >> n >> k;     cin >> s;     for (int i = 0; i < n; i++) {       if (i != 0) prefix[i] = prefix[i - 1];       prefix[i] += (s[i] ==  0 );     }     int res = 1e9;     for (int i = 0; i < n; i++) {       int ans = 1e9;       if (s[i] ==  0 ) {         int l = 0, r = 1e9;         while (l != r) {           int mid = (l + r - 1) / 2;           if (check(mid, i)) {             r = mid;             ans = min(ans, mid);           } else             l = mid + 1;         }         res = min(res, ans);       }     }     cout << res << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const int maxn = 3000 + 10;   int n, m, A[maxn], B[maxn];   long long f[maxn][maxn];   void init() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &A[i]);       A[i] -= i;       B[i] = A[i];     }   }   void solve() {     sort(B + 1, B + n + 1);     m = 1;     for (int i = 2; i <= n; ++i)       if (B[m] != B[i]) B[++m] = B[i];     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= m; ++j) f[i][j] = inf;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         f[i][j] = min(f[i][j - 1], f[i - 1][j] + abs(A[i] - B[j]));     long long ans = inf;     for (int i = 1; i <= m; ++i) ans = min(ans, f[n][i]);     printf( %I64d n , ans);   }   int main() {     init();     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i != n; ++i) {       cin >> v[i];       v[i] -= (n - i);     }     sort(v.begin(), v.end());     for (int i = 0; i != n - 1; ++i) {       if (v[i] + 1 > v[i + 1]) {         cout <<  :( n ;         return 0;       }     }     for (int i = 0; i != n; ++i) {       cout << v[i] + (n - i) <<    ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m, x, a[100];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (i == 1) m = a[1];       m = min(m, a[i]);     }     for (int i = 1; i <= n; i++) {       x += (a[i] == m);     }     if (x <= n / 2)       printf( Alice );     else       printf( Bob );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 20;   const int mod = 1e9 + 7;   void fwht(long long f[], int n) {     for (int b = 0; b < n; ++b)       for (int i = 0; i < (1 << n); i += (1 << (b + 1)))         for (int j = 0; j < (1 << b); ++j) {           int u = f[i + j];           int v = f[i + j + (1 << b)];           f[i + j] = (u + v) % mod;           f[i + j + (1 << b)] = (u - v + mod) % mod;         }   }   int n;   long long f[N], g[N], mark[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     string s;     cin >> s;     for (int i = 0; i < (1 << n); ++i) mark[i] = f[i] = s[i] -  0 ;     for (int i = 0; i < (1 << n); ++i) g[i] = 1 << (n - __builtin_popcount(i));     fwht(f, n);     fwht(g, n);     for (int i = 0; i < (1 << n); ++i) f[i] = f[i] * g[i] % mod;     fwht(f, n);     long long res = 0;     for (int i = 0; i < (1 << n); ++i) res = (res + mark[i] * f[i]) % mod;     for (int i = 0; i < n; ++i) res = res * ((mod + 1) / 2) % mod;     cout << res * 3 % mod;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const signed long long llf = (signed long long)(~0ull >> 1);   const signed int inf = (signed)(~0u >> 1);   template <typename T>   T __abs(T x) {     return (x < 0) ? (-x) : (x);   }   template <typename T>   void pfill(T* pst, const T* ped, T val) {     for (; pst != ped; *(pst++) = val)       ;   }   template <typename T>   void pcopy(T* pst, const T* ped, T* pv) {     for (; pst != ped; *(pst++) = *(pv++))       ;   }   typedef class Edge {    public:     int ed, nx, cap, f;     Edge() {}     Edge(int ed, int nx, int cap, int f) : ed(ed), nx(nx), cap(cap), f(f) {}   } Edge;   typedef class MapManager {    public:     int* h;     vector<Edge> es;     MapManager() {}     MapManager(int n) {       h = new int[(n + 1)];       pfill(h, h + n + 1, -1);     }     void addEdge(int u, int v, int cap, int f) {       es.push_back(Edge(v, h[u], cap, f));       h[u] = (signed)es.size() - 1;     }     void addArc(int u, int v, int cap) {       addEdge(u, v, cap, 0);       addEdge(v, u, cap, cap);     }     Edge& operator[](int p) { return es[p]; }     void clear() {       delete[] h;       es.clear();     }   } MapManager;   const int N = 605;   int n, m, K;   int s = 0, t;   int mxcap;   int deg[N];   MapManager g;   inline void init() {     scanf( %d%d%d , &n, &m, &K);     pfill(deg, deg + n + 1, 0);     g = MapManager(n + m + 1);     for (int i = 1, u, v; i <= m; i++) {       scanf( %d%d , &u, &v);       deg[u]++, deg[v]++;       g.addArc(0, i, 1);       g.addArc(i, u + m, 1);       g.addArc(i, v + m, 1);     }     t = n + m + 1, mxcap = 0;     for (int i = 1; i <= n; i++)       if (deg[i] > K) g.addArc(i + m, t, (deg[i] - K) << 1), mxcap += deg[i] - K;     mxcap <<= 1;   }   int cur[N << 1], _div[N << 1];   int dfs(int p, int mf) {     if (p == t || !mf) return mf;     int f, flow = 0;     for (int &i = cur[p], e; ~i; i = g[i].nx) {       e = g[i].ed;       if (g[i].f < g[i].cap && _div[e] == _div[p] + 1 &&           (f = dfs(e, min(mf, g[i].cap - g[i].f))) > 0) {         g[i].f += f;         g[i ^ 1].f -= f;         mf -= f;         flow += f;         if (!mf) break;       }     }     return flow;   }   queue<int> que;   bool bfs() {     pfill(_div, _div + t + 1, -1);     _div[s] = 0;     que.push(s);     while (!que.empty()) {       int e = que.front();       que.pop();       for (int i = g.h[e], eu; ~i; i = g[i].nx) {         eu = g[i].ed;         if (g[i].cap == g[i].f) continue;         if (~_div[eu]) continue;         _div[eu] = _div[e] + 1;         que.push(eu);       }     }     return _div[t] != -1;   }   int dinic() {     int rt = 0;     while (bfs()) {       pcopy(cur, cur + t + 1, g.h);       rt += dfs(s, inf);     }     return rt;   }   int lab[N];   vector<int> mat[N];   inline void solve() {     int flow = dinic(), used = 0;     if (flow != mxcap) {       for (int i = 1; i <= m; i++) printf( 0  );       putchar(  n );       return;     }     for (int i = 1; i <= n; i++) mat[i].clear();     for (int i = 1; i <= m; i++)       for (int j = g.h[i]; ~j; j = g[j].nx)         if (g[j].cap == g[j].f && g[j].ed > m) {           mat[g[j].ed - m].push_back(i);           break;         }     pfill(lab + 1, lab + m + 1, 0);     for (int i = 1, a, b; i <= n; i++)       while (!mat[i].empty()) {         a = mat[i].back();         mat[i].pop_back();         b = mat[i].back();         mat[i].pop_back();         lab[a] = lab[b] = ++used;       }     for (int i = 1; i <= m; i++) {       if (!lab[i]) lab[i] = ++used;       printf( %d  , lab[i]);     }     putchar(  n );   }   inline void clear() { g.clear(); }   int T;   int main() {     scanf( %d , &T);     while (T--) {       init();       solve();       clear();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   double low = 0, high = 0, mid = 0;   int binary_sear(const vector<int>& v, int x) {     while (1) {       mid = floor((low + high) / 2);       if (low > high) break;       if (v[mid] == x) {         return mid;         break;       } else if (v[mid] < x) {         low = mid + 1;       } else {         high = mid - 1;       }     }     return -1;   }   int binary(vector<int> v, int x) {     mid = floor((low + high) / 2);     cout << low <<     << mid <<     << high << endl;     if (low > high) return -1;     if (v[mid] == x)       return mid;     else if (v[mid] < x) {       low = mid + 1;       return binary(v, x);     } else {       high = mid - 1;       return binary(v, x);     }   }   string decToBinary(int n) {     string s = {};     int i = 0;     while (n > 0) {       s += (n % 2) + 48;       n = n / 2;       i++;     }     reverse(s.begin(), s.end());     return s;   }   int main() {     long long int a, b = 0, c = 1, n, m, mx = 0, mn = 0;     vector<int> v;     bool flag = true, flag2 = true;     cin >> n;     while (n--) {       cin >> m;       for (int i = 0; i < m; i++) {         cin >> a;         if (i == 0) {           b = a;           c = a;           continue;         }         b += a;         c ^= a;       }       cout << 2 << endl;       cout << c <<     << c + b << endl;       b = 0;       c = 1;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int W, N, M;   vector<int> freq;   vector<uint16_t> quick_count;   int needed(char bit_gate, int bit) {     switch (bit_gate) {       case  A :         return bit == 0 ? 2 : 0;       case  O :         return bit == 0 ? 0 : -1;       case  X :         return bit;       case  a :         return bit == 0 ? -1 : 1;       case  o :         return bit == 0 ? 1 : 2;       case  x :         return bit ^ 1;     }     assert(false);   }   int recurse(string &gate, int position, int mask, int extended) {     if (position >= W) return freq[mask] * quick_count[extended];     int opt0 = needed(gate[position], 0);     int opt1 = needed(gate[position], 1);     int answer = 0;     if (opt0 != -1)       answer +=           recurse(gate, position + 1, mask, extended + (opt0 << 2 * position));     if (opt1 != -1)       answer += recurse(gate, position + 1, mask + (1 << position),                         extended + (opt1 << 2 * position));     return answer;   }   int solve(string gate) {     reverse(gate.begin(), gate.end());     return recurse(gate, 0, 0, 0);   }   int main() {     scanf( %d %d %d , &W, &N, &M);     freq.resize(1 << W);     for (int i = 0; i < N; i++) {       int v;       scanf( %d , &v);       freq[v]++;     }     quick_count.resize(1 << 2 * W);     for (int a = 0; a < 1 << W; a++) {       int expanded = 0;       for (int i = 0; i < W; i++)         if (a & 1 << i) expanded += 1 << 2 * i;       quick_count[expanded] = freq[a];     }     int a = 0;     while (a < 1 << 2 * W) {       for (int i = 0; i < W; i++)         if ((a >> 2 * i) % 4 == 2) {           quick_count[a] =               quick_count[a - (2 << 2 * i)] + quick_count[a - (1 << 2 * i)];           break;         }       int index = W;       for (int i = 0; i < W; i++)         if ((a >> 2 * i) % 4 == 2) {           a ^= a & 3 << 2 * i;         } else {           index = i;           break;         }       a += 1 << 2 * index;     }     for (int i = 0; i < M; i++) {       char gate[100];       scanf( %s , gate);       printf( %d n , solve(gate));     }   }


#include <bits/stdc++.h>   using namespace std;   const long long int inf = 1000000000000000;   string s;   vector<long long> prim;   set<long long> prim2;   void primeFactors(int n) {     while (n % 2 == 0) {       prim.push_back(2);       prim2.insert(2);       n = n / 2;     }     for (int i = 3; i <= sqrt(n); i = i + 2) {       while (n % i == 0) {         prim.push_back(i);         prim2.insert(i);         n = n / i;       }     }     if (n > 2) {       prim.push_back(n);       prim2.insert(n);     }   }   long long dp[3001][3001];   long long n;   pair<long long, long long> arr[4000];   long long get_ans(long long i, long long prev) {     if (i > n) {       return 0;     }     if (dp[i][prev] != -inf) return dp[i][prev];     long long x = 0, y = 0;     x = get_ans(i + 1, i) + arr[i].second;     y = abs(arr[prev].first - arr[i].first) + get_ans(i + 1, prev);     return dp[i][prev] = min(x, y);   }   void func() {     cin >> n;     for (int i = 1; i <= n; i++) {       long long a, b;       cin >> a >> b;       arr[i] = {a, b};     }     sort(arr + 1, arr + n + 1);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         dp[i][j] = -inf;       }     }     cout << get_ans(2, 1) + arr[1].second <<   n ;   }   int main() {     {       ios ::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);     }     { func(); }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void solve();   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       solve();       cout <<   n ;     }     cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  << endl;     return 0;   }   void solve() {     long long n;     cin >> n;     long long a[n];     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long s = 0;     for (long long i = 1; i < n; i++) {       if (a[i] == a[i - 1]) s++;     }     if (s)       cout <<  YES ;     else       cout <<  NO ;   }


#include <bits/stdc++.h>   using namespace std;   long long int n;   int check(long long k) {     long long patsum = 0, nn = n, pat;     while (nn > 0) {       nn = nn - k;       pat = nn / 10;       nn = nn - pat;       patsum += pat;       if (patsum > n / 2) {         return 1;       }     }     return 0;   }   long long bs() {     long long left = 1, right = n, k;     while (left < right) {       k = (right + left) / 2;       if (check(k)) {         left = k + 1;       } else         right = k;     }     return left;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1, k, pat, patsum = 0, ori, flag = 0;     while (t--) {       cin >> n;       long long ans = bs();       cout << ans << endl;     }     return 0;   }


#include <bits/stdc++.h>   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     std::cout.tie(0);     int32_t n;     std::cin >> n;     std::set<std::pair<int32_t, int32_t> > segments;     for (int32_t i = 0; i < n; i++) {       int32_t left, right;       std::cin >> left >> right;       auto it = segments.lower_bound({left, 0});       if (it != segments.begin()) {         it--;         if (it->second < left) it++;       }       int32_t min_left = left, max_right = right;       while (it != segments.end() &&              ((it->second >= left && it->second <= right) ||               (it->first >= left && it->first <= right) ||               (it->first <= left && it->second >= right))) {         min_left = std::min(min_left, it->first);         max_right = std::max(max_right, it->second);         auto next = it;         next++;         segments.erase(it);         it = next;       }       segments.emplace(min_left, max_right);       std::cout << segments.size() <<    ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   vector<int> magic(string t, string s, int sk) {     int tl = t.length();     string x = t +  @  + s;     int n = x.length();     vector<int> pi(n), r(sk + 1, -1);     r[0] = sk - 1;     for (int i = 1, k = 0; i < n; ++i) {       while (k && x[i] != x[k]) k = pi[k - 1];       k += x[i] == x[k];       pi[i] = k;       if (i >= tl + sk) {         while (k > sk) k = pi[k - 1];         for (int j = k; r[j] == -1; j = pi[j - 1]) r[j] = i - tl - 1;       }     }     return r;   }   vector<int> pi_function(const string &s) {     int n = s.length();     vector<int> pi(n);     for (int i = 1, k = 0; i < n; ++i) {       while (k && s[i] != s[k]) k = pi[k - 1];       k += s[i] == s[k];       pi[i] = k;     }     return pi;   }   vector<int> kmp(const string &text, const string &patt) {     int n = text.length(), m = patt.length();     vector<int> ans, pi = pi_function(patt);     for (int i = 0, k = 0; i < n; ++i) {       while (k && text[i] != patt[k]) k = pi[k - 1];       k += text[i] == patt[k];       if (k == m) {         ans.push_back(i - k + 1);         k = pi[k - 1];       }     }     return ans;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int n, m, k;     string s, t;     cin >> n >> m >> k >> s >> t;     if (m <= k) {       auto p = kmp(s, t);       for (auto i : p) {         int l = max(k, i + m);         if (l + k <= n) {           cout <<  Yes n  << l - k + 1 <<     << l + 1 <<   n ;           return 0;         }         int r = min(i + 1, n - k + 1);         if (r - 1 >= k) {           cout <<  Yes n  << r - k <<     << r <<   n ;           return 0;         }       }     }     auto l = magic(t, s, k);     reverse(t.begin(), t.end());     reverse(s.begin(), s.end());     auto r = magic(t, s, k);     for (auto &i : r)       if (i != -1) i = n - 1 - i;     for (int i = 0; i <= m; ++i)       if (i <= k && m - i <= k && l[i] != -1 && r[m - i] != -1 &&           l[i] < r[m - i]) {         cout <<  Yes n  << l[i] - k + 2 <<     << r[m - i] + 1 <<   n ;         return 0;       }     cout <<  No n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:102400000,102400000 )   inline void read(int &x) {     x = 0;     char ch = getchar();     while (ch <  0 ) ch = getchar();     while (ch >=  0 ) {       x = x * 10 + ch - 48;       ch = getchar();     }   }   int a[100010], ans;   bool f[100010];   int main() {     int n;     scanf( %d , &n);     if (n == 1)       puts( 1 );     else if (n == 2)       puts( -1 );     else if (n % 4 > 1)       puts( -1 );     else {       if (n & 1) a[n / 2 + 1] = n / 2 + 1;       for (int i = 1; i <= n / 2; ++i) {         if (!a[i]) {           a[i] = i + 1;           a[i + 1] = n + 1 - i;           a[n + 1 - i] = n - i;           a[n - i] = i;         }       }       for (int i = 1; i <= n; ++i) printf( %d%c , a[i], (i == n) ?   n  :    );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int N;   vector<pair<int, int>> ans, packs;   void sp2(int st, int n) {     if (n < 2) return;     sp2(st, n / 2);     sp2(st + n / 2, n / 2);     for (int i = 0; i < n / 2; ++i) {       ans.push_back({st + i, st + n / 2 + i});     }   }   void getp0(int st, int now, int need) {     while (now < need) {       for (int i = 0; i < now; ++i) {         ans.push_back({st + i, st + now + i});       }       now *= 2;     }   }   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     N = n;     for (int t = 16384, u = 0; t > 0; t /= 2) {       if (n & t) {         sp2(u, t);         packs.push_back({u, t});         u += t;       }     }     int p0 = 0;     while (packs.size() > 2) {       int psz = packs.size();       getp0(packs.back().first, packs.back().second, packs[psz - 2].second);       packs.pop_back();       int nsz = packs.back().second, nst = packs.back().first;       packs.back().second *= 2;       for (int i = 0; i < nsz; ++i) {         ans.push_back({nst + i, nst + nsz + i});       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) {       cout << (ans[i].first % n) + 1 <<     << (ans[i].second % n) + 1 <<   n ;     }   }


#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int BIG = 1e9 + 555;   const int maxN = 100 * 1000 + 9;   long long n, m;   pair<long long, long long> a[maxN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       long long q, w;       cin >> q >> w;       a[i] = make_pair(w, q);     }     sort(a + 1, a + m + 1);     long long res = 0;     for (long long i = m; i > 0; i--) {       long long j = m - i;       long long foo = 0;       if (j & 1) {         foo = (j * (j + 1)) / 2 + j / 2 + 1;       } else {         foo = (j * (j + 1)) / 2 + 1;       }       if (foo > n) {         break;       }       res += a[i].first;     }     cout << res <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   int mod = 1e9 + 7;   long long qpow(long long a, long long b) {     long long ans = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;     }     return ans;   }   long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }   int n, m, T;   int a[maxn];   int fac[maxn];   void init() {     fac[0] = 1;     for (int i = 1; i <= n; i++) {       fac[i] = 1ll * fac[i - 1] * i % mod;     }   }   int main() {     cin >> n >> mod;     init();     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans = (ans + 1ll * (n - i + 1) * fac[n - i + 1] % mod * fac[i] % mod) % mod;     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   struct Edge {     long long to, dis, next;   } edge[100100];   long long n, num_edge;   long long first1[100100];   long long a[100100], b[100100];   double tem;   void dfs(long long x, long long fa, long long p) {     long long k = first1[x];     while (k != 0) {       dfs(edge[k].to, x, edge[k].dis);       k = edge[k].next;     }     if (a[x] < b[x])       b[fa] += b[x] - a[x];     else if (a[x] > b[x]) {       tem = (double)(b[x] - a[x]) * p;       if (tem < -110000000000000000) {         printf( NO );         exit(0);       }       b[fa] -= p * (a[x] - b[x]);       if (b[fa] < -110000000000000000) {         printf( NO );         exit(0);       }     }   }   int main() {     long long i, x, k;     scanf( %lld , &n);     for (i = 1; i <= n; i++) scanf( %lld , &b[i]);     for (i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (i = 2; i <= n; i++) {       scanf( %lld%lld , &x, &k);       edge[++num_edge].to = i;       edge[num_edge].dis = k;       edge[num_edge].next = first1[x];       first1[x] = num_edge;     }     k = first1[1];     while (k != 0) {       dfs(edge[k].to, 1, edge[k].dis);       k = edge[k].next;     }     if (b[1] < a[1])       printf( NO );     else       printf( YES );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int A, B, q;   long long l, t, m;   bool check(long long len) {     long long ind_left = l;     long long ind_righ = ind_left + len - 1;     long long num_left = A + (ind_left - 1) * B;     long long num_righ = A + (ind_righ - 1) * B;     long long need_time;     if (len > m)       need_time = ((num_left + num_righ) * len / 2 + m - 1) / m;     else       need_time = num_righ;     return need_time <= t && num_righ <= t;   }   void work() {     scanf( %d %d %d , &A, &B, &q);     while (q--) {       scanf( %lld %lld %lld , &l, &t, &m);       long long lpt = 0, rpt = 1e6;       while (lpt < rpt) {         long long mid = (lpt + rpt + 1) >> 1;         if (check(mid)) {           lpt = mid;         } else {           rpt = mid - 1;         }       }       if (lpt == 0) {         puts( -1 );       } else {         printf( %lld n , l + rpt - 1);       }     }   }   int main() {     work();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1123456;   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   void vout(T s) {     cout << s <<   n ;     exit(0);   }   long long bp(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2) res *= a;       a *= a;       n >>= 1;     }     return res;   }   char akel_sosat[1001][1001];   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     string a;     cin >> a;     long long kol = 0, mx = 0;     for (int i = 0; i < n; i++) {       if (a[i] ==  [ )         kol++;       else         kol--;       mx = max(mx, kol);     }     long long m = mx * 2 + 3;     long long l = 1, len = mx;     for (int i = 1; i <= 1000; i++)       for (int j = 0; j < 1001; j++) akel_sosat[i][j] =    ;     long long st = 0;     for (int i = 0; i < n; i++, st++) {       if (a[i] ==  [ ) {         akel_sosat[l][st] =  + ;         akel_sosat[l][st + 1] =  - ;         long long l1 = len * 2 - 1;         for (int j = l + 1; j <= l + l1; j++) akel_sosat[j][st] =  | ;         akel_sosat[l + l1 + 1][st] =  + ;         akel_sosat[l + l1 + 1][st + 1] =  - ;         len--;         l++;       } else {         if (a[i] != a[i - 1]) st += 3;         l--;         len++;         akel_sosat[l][st] =  + ;         akel_sosat[l][st - 1] =  - ;         long long l1 = len * 2 - 1;         for (int j = l + 1; j <= l + l1; j++) akel_sosat[j][st] =  | ;         akel_sosat[l + l1 + 1][st] =  + ;         akel_sosat[l + l1 + 1][st - 1] =  - ;       }     }     for (int i = 1; i <= m; i++) {       for (int j = 0; j < st; j++) cout << akel_sosat[i][j];       cout <<   n ;     }     cerr <<  Time execute:   << clock() / (double)CLOCKS_PER_SEC <<   sec           <<   n ;     return 0;   }


#include <bits/stdc++.h>   long long sum(long long val) {     if (val % 2) return (val + 1) / 2 * val;     return val / 2 * (val + 1);   }   int main() {     long long n, x, d[200005], i, xx, l, ans = 0, now, tmp;     scanf( %lld%lld , &n, &x);     for (i = 0; i < n; i++) scanf( %lld , &d[i]);     l = n - 1;     xx = x;     now = 0;     for (i = n - 1; i >= 0; i--) {       while (xx >= d[l]) {         xx -= d[l];         now += sum(d[l]);         l--;         if (l < 0) l += n;       }       tmp = now - sum(d[l] - xx) + sum(d[l]);       if (tmp > ans) ans = tmp;       xx += d[i];       now -= sum(d[i]);     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void umax(T &a, T b) {     if (a < b) a = b;   }   template <class T>   inline void umin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <class T>   inline T gcd(T a, T b) {     return __gcd(a, b);   }   template <class T>   inline T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   long long modpow(long long a, long long n, long long temp) {     long long res = 1, y = a;     while (n > 0) {       if (n & 1) res = (res * y) % temp;       y = (y * y) % temp;       n /= 2;     }     return res % temp;   }   long long ison(long long mask, long long pos) { return (mask & (1 << pos)); }   long long cbit(long long n) {     long long k = 0;     while (n) n &= (n - 1), k++;     return k;   }   long long nbit(long long n) {     long long k = 0;     while (n) n /= 2, k++;     return k;   }   long long mod = 1e9 + 7;   int sgn(long long x) { return x < 0 ? -1 : !!x; }   long long xo(long long i) {     if ((i & 3) == 0) return i;     if ((i & 3) == 1) return 1;     if ((i & 3) == 2) return i + 1;     return 0;   }   long long a[200005];   int main() {     long long n, i, j, k, l, m, ans = 0;     long long pr = 0;     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) {       if (a[i] != pr) {         ans += abs(a[i] - pr);         pr = a[i];       }     }     cout << ans;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     bool t = true;     int n;     cin >> n;     int a[200001] = {0};     vector<int> voz;     vector<int> yb;     for (int i = 0; i < n; i++) {       int c;       cin >> c;       a[c]++;       if (a[c] > 2) {         cout <<  NO ;         t = false;         break;       } else if (a[c] == 1) {         yb.push_back(c);       } else if (a[c] == 2) {         voz.push_back(c);       }     }     if (t) {       sort(voz.begin(), voz.end());       sort(yb.begin(), yb.end());       cout <<  YES  <<   n ;       cout << voz.size() <<   n ;       for (int i = 0; i < voz.size(); i++) {         cout << voz[i] <<    ;       }       cout <<   n ;       cout << yb.size() <<   n ;       reverse(yb.begin(), yb.end());       for (int i = 0; i < yb.size(); i++) {         cout << yb[i] <<    ;       }     }   }


#include <bits/stdc++.h>   using namespace std;   vector<int> a;   vector<vector<int>> graph;   vector<vector<int>> residual;   set<int> primes;   map<pair<int, int>, int> factors;   void sieve(int SQRTN) {     vector<int> isPrime(SQRTN, 1);     for (int i = 2; i < SQRTN; i++) {       if (!isPrime[i]) continue;       primes.insert(i);       for (int j = i * i; j < SQRTN; j += i) {         isPrime[j] = 0;       }     }     for (int i = 0; i < a.size(); i++) {       int num = a[i];       for (int p : primes) {         int acc = 0;         while (num % p == 0) {           acc++;           num /= p;         }         factors[{a[i], p}] = acc;       }       if (num != 1) {         primes.insert(num);         factors[{i, num}] = 1;       }     }   }   int bfs(int source, int sink) {     queue<int> q;     vector<int> anc(graph.size(), -1);     q.push(source);     bool reached = false;     while (!q.empty()) {       int curr = q.front();       q.pop();       if (curr == sink) {         reached = true;         break;       }       for (int neighbor : graph[curr]) {         if (anc[neighbor] == -1 and residual[curr][neighbor] > 0) {           q.push(neighbor);           anc[neighbor] = curr;         }       }     }     if (!reached) {       return 0;     }     int node = sink;     int augment = 12312312;     while (node != source) {       int prev = anc[node];       augment = min(augment, residual[prev][node]);       node = prev;     }     node = sink;     while (node != source) {       int prev = anc[node];       residual[prev][node] -= augment;       residual[node][prev] += augment;       node = prev;     }     return augment;   }   int edmondkarp(int source, int sink) {     int res = 0;     while (true) {       int delta = bfs(source, sink);       if (delta == 0) {         break;       }       res += delta;     }     return res;   }   int main() {     int n, m;     cin >> n >> m;     a.resize(n);     int MAXN = -1;     for (int i = 0; i < n; i++) {       cin >> a[i];       MAXN = max(MAXN, a[i]);     }     sieve(sqrt(MAXN));     int s = n;     int t = n + 1;     graph.resize(n + 2);     residual.resize(n + 2, vector<int>(n + 2));     for (int i = 0; i < m; i++) {       int n1, n2;       cin >> n1 >> n2;       --n1;       --n2;       if (!(n1 & 1)) {         swap(n1, n2);       }       graph[n1].push_back(n2);       graph[n2].push_back(n1);       residual[n1][n2] = 12312312;       residual[n2][n1] = 0;     }     for (int i = 0; i < n; i++) {       if (i & 1) {         graph[s].push_back(i);       } else {         graph[i].push_back(t);       }     }     vector<vector<int>> residualCopy(residual);     int sol = 0;     for (int p : primes) {       residual = residualCopy;       for (int i = 0; i < n; i++) {         int capacity = factors.count({a[i], p}) ? factors[{a[i], p}] : 0;         if (i & 1) {           residual[s][i] = capacity;         } else {           residual[i][t] = capacity;         }       }       sol += edmondkarp(s, t);     }     cout << sol <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   namespace io {   char ibuf[(1 << 18)], *iS, *iT, obuf[(1 << 18)],       *oS = obuf, *oT = oS + (1 << 18) - 1, c, qu[55];   int f, qr;   inline void flush(void) {     fwrite(obuf, 1, oS - obuf, stdout);     oS = obuf;     return;   }   inline char getch(void) {     return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, (1 << 18), stdin),                         (iS == iT ? EOF : *iS++))                      : *iS++);   }   inline void putch(char x) {     *oS++ = x;     if (oS == oT) flush();     return;   }   void putstr(string str, int begin = 0, int end = -1) {     if (end == -1) end = str.size();     for (register int i = begin; i < end; i++) putch(str[i]);     return;   }   template <typename T>   inline T read() {     register T x = 0;     for (f = 1, c = getch(); c <  0  || c >  9 ; c = getch())       if (c ==  - ) f = -1;     for (x = 0; c <=  9  && c >=  0 ; c = getch()) x = x * 10 + (c & 15);     x *= f;     return x;   }   template <typename T>   inline void write(const T& t) {     register T x = t;     if (!x) putch( 0 );     if (x < 0) putch( - ), x = -x;     while (x) qu[++qr] = x % 10 +  0 , x /= 10;     while (qr) putch(qu[qr--]);     return;   }   struct Flusher_ {     ~Flusher_() { flush(); }   } io_flusher_;   }  // namespace io   using io::getch;   using io::putch;   using io::putstr;   using io::read;   using io::write;   pair<int, int> a[100005];   int f[100005];   int main() {     int n = read<int>();     for (register int i = 1; i <= n; i++)       a[i].first = read<int>(), a[i].second = read<int>();     sort(a + 1, a + n + 1);     int answer = f[1] = 1;     for (register int i = 2; i <= n; i++) {       f[i] = 1 + f[lower_bound(a + 1, a + i,                                (pair<int, int>){a[i].first - a[i].second, 0}) -                    a - 1];       answer = max(answer, f[i]);     }     write(n - answer), putch(  n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long N, Q, S[(int)1e5 + 5], i, L, R, p1, p2;   long long Putere(long long p1, long long ex) {     long long i, sol = 1;     for (i = 0; (1 << i) <= ex; i++) {       if (((1 << i) & ex) > 0) sol = (sol * p1) % 1000000007;       p1 = (p1 * p1) % 1000000007;     }     return sol;   }   string str;   int main() {     cin >> N >> Q;     cin >> str;     for (i = 0; i < str.length(); i++) {       if (str[i] ==  1 )         S[i + 1] = S[i] + 1;       else         S[i + 1] = S[i];     }     while (Q--) {       cin >> L >> R;       p1 = S[R] - S[L - 1];       p2 = R - L + 1 - p1;       cout << ((Putere(2, p1) - 1 + (Putere(2, p1) - 1) * (Putere(2, p2) - 1))) %                   1000000007            <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct trip {     int l;     int len;     int t;     int id;   };   const int INF = 1e9;   int main() {     int n, p;     scanf( %d%d , &n, &p);     vector<trip> trips(n);     for (int i = 0; i < n; i++) {       scanf( %d%d%d , &trips[i].l, &trips[i].len, &trips[i].t);       trips[i].id = i;     }     vector<trip> lorder = trips, torder = trips;     sort(lorder.begin(), lorder.end(),          [](const trip& a, const trip& b) { return a.l < b.l; });     sort(torder.begin(), torder.end(),          [](const trip& a, const trip& b) { return a.t < b.t; });     vector<int> dp(1 << n, INF);     vector<int> pj(1 << n, -1);     vector<int> pt(1 << n, -1);     dp[0] = 1;     for (int i = 0; i < (1 << n); i++) {       if (dp[i] == INF) continue;       int c = dp[i];       auto ptr = lorder.begin();       auto ptr_same = lorder.begin();       for (auto j : torder) {         int to = i | (1 << j.id);         if (to == i) continue;         while (true) {           while (ptr != lorder.end() && ptr->l + ptr->len <= c) ptr++;           while (ptr_same != lorder.end() &&                  (ptr_same->l < c || ((i & (1 << ptr_same->id)) == 0)))             ptr_same++;           if (ptr != lorder.end() && ptr->l <= c) {             c = ptr->l + ptr->len;             continue;           }           if (ptr_same != lorder.end() && c + j.t >= ptr_same->l) {             c = ptr_same->l + ptr->len;             continue;           }           break;         }         if (c + j.t < j.l) {           if (dp[to] > c + j.t) {             dp[to] = c + j.t;             pj[to] = j.id;             pt[to] = c;           }         }       }     }     vector<int> anst(n, -1);     vector<int> ansp(n, -1);     auto restore = [&](int mask, int p) {       while (mask) {         int last = pj[mask];         assert(last != -1 && (mask & (1 << last)));         anst[last] = pt[mask];         ansp[last] = p;         mask ^= (1 << last);       }     };     if (p == 1) {       if (dp[(1 << n) - 1] != INF) {         restore((1 << n) - 1, 1);       }     } else {       for (int i = 0; i < (1 << n) - 1; i++) {         if (dp[i] != INF && dp[(1 << n) - 1 - i] != INF) {           restore(i, 1);           restore((1 << n) - 1 - i, 2);           break;         }       }     }     if (anst[0] == -1) {       printf( NO n );     } else {       printf( YES n );       for (int i = 0; i < n; i++) {         printf( %d %d n , ansp[i], anst[i]);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   struct node {     int t;     int x;     int y;   } tt[maxn];   int main() {     int n, m, s, f;     while (~scanf( %d%d%d%d , &n, &m, &s, &f)) {       memset(tt, 0, sizeof tt);       for (int i = 0; i < m; i++) {         scanf( %d%d%d , &tt[i].t, &tt[i].x, &tt[i].y);       }       int cnt = 0;       int time = 1;       int peo = s;       int jj;       if (f > s)         jj = 1;       else         jj = -1;       while (peo != f) {         if (tt[cnt].t != time) {           peo += jj;           if (jj == 1) {             printf( R );           } else             printf( L );         } else if ((peo < tt[cnt].x || peo > tt[cnt].y) &&                    ((peo + jj) < tt[cnt].x || (peo + jj) > tt[cnt].y)) {           peo += jj;           if (jj == 1) {             printf( R );           } else             printf( L );           cnt++;         } else {           printf( X );           cnt++;         }         time++;       }       printf(  n );     }     return 0;   }


#include <bits/stdc++.h>   int main() {     char jak[1000005], tak[1000005];     gets(jak);     gets(tak);     int k, r, i, t, flag = 0, count = 0, fount = 0, f, x, y, j, p = 0;     k = strlen(jak);     r = strlen(tak);     for (i = 0; i < k; i++) {       t = jak[i] - 48;       if (t != 0 && flag == 0) {         flag = 1;         x = i;       }       if (flag == 1) {         count++;       }     }     flag = 0;     for (i = 0; i < r; i++) {       f = tak[i] - 48;       if (f != 0 && flag == 0) {         flag = 1;         y = i;       }       if (flag == 1) {         fount++;       }     }     if (count > fount) {       printf( > );     } else if (count < fount) {       printf( < );     } else if (count == 0) {       printf( = );     } else {       for (i = x, j = y; i < k, j < r; i++, j++) {         if (jak[i] > tak[j]) {           printf( > );           break;         } else if (jak[i] < tak[j]) {           printf( < );           break;         } else {           p++;         }       }       if (p == count) {         printf( = );       }     }   }


#include <bits/stdc++.h>   using namespace std;   void dbg_out() { cerr <<   b b] n ; }   template <typename Head, typename... Tail>   void dbg_out(Head H, Tail... T) {     cerr << H <<  ,  ;     dbg_out(T...);   }   const int mod = 1e9 + 7;   long long power(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   long long modMul(long long a, long long b) { return a * b % mod; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, k;     cin >> n >> k;     vector<int> A(n / k), B(n / k);     for (int &i : A) cin >> i;     for (int &i : B) cin >> i;     long long ans = 1;     long long tens = power(10, k - 1);     for (int i = 0; i < n / k; ++i) {       long long tot = (tens * 10 - 1) / A[i] + 1;       long long lo = B[i] * tens;       long long hi = B[i] * tens + tens - 1;       long long invalid = hi / A[i] - lo / A[i] + (lo % A[i] == 0);       tot -= invalid;       ans = modMul(ans, tot);     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize(3)   using namespace std;   const long long maxnodes = 1005;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     string t;     cin >> t;     long long n = t.size();     string s1(n,  a ), s2(n,  a ), s3(n,  a );     string t1, t2, t3;     for (long long i = 0; i < n; i++) {       s1[i] = char( a  + i % 26);       s2[i] = char( a  + (i / 26) % 26);       s3[i] = char( a  + ((i / 26) / 26) % 26);     }     cout <<  ?   << s1 << endl;     cin >> t1;     cout <<  ?   << s2 << endl;     cin >> t2;     cout <<  ?   << s3 << endl;     cin >> t3;     string s(n,  a );     for (long long i = 0; i < n; i++) {       long long z = (t1[i] -  a ) + (t2[i] -  a ) * 26 + (t3[i] -  a ) * 26 * 26;       s[z] = t[i];     }     cout <<  !   << s << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, p, q, temp;     cin >> n;     int levels[101] = {0};     cin >> p;     for (int i = 0; i < p; i++) {       cin >> temp;       levels[temp]++;     }     cin >> q;     for (int i = 0; i < q; i++) {       cin >> temp;       levels[temp]++;     }     for (int i = 1; i <= n; i++)       if (levels[i] < 1) {         cout <<  Oh, my keyboard! ;         return 0;       }     cout <<  I become the guy. ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long double dp[1010000][3];   int n, m;   int ranks[1245];   int Prank;   int main() {     cout << fixed << setprecision(12);     cin >> n >> m;     if (m == 1) {       cout <<  1 n ;       return 0;     }     for (int i = 1; i <= (n); ++i) {       cin >> ranks[i];       Prank += ranks[i];     }     for (int i = 1; i <= (Prank); ++i) dp[i][0] = dp[i][1] = dp[i][2] = 0;     for (int i = 1; i <= (m); ++i) {       if (i == ranks[1]) continue;       dp[i][0] = 1.0;     }     for (int i = 2; i <= (n); ++i) {       for (int j = 1; j <= (Prank); ++j) {         dp[j][1] = dp[j][0] + dp[j - 1][1];       }       for (int j = Prank; j >= (1); --j) {         dp[j][2] = dp[j - 1][1];         if (j - m > 0) dp[j][2] -= dp[j - m - 1][1];         if (j - ranks[i] > 0) dp[j][2] -= dp[j - ranks[i]][0];       }       for (int j = 1; j <= (Prank); ++j)         dp[j][0] = dp[j][2] / ((long double)(m - 1));     }     long double sum = 0;     for (int i = 1; i <= (Prank - 1); ++i) {       sum += dp[i][0];     }     sum += 1;     cout << sum << endl;   }


#include <bits/stdc++.h>   using namespace std;   long long a[100005], ac[100005];   int last[100005];   int main() {     int n, m, t, x, v, y, q;     string s;     while (cin >> n >> m) {       for (int i = 1; i <= n; i++) cin >> a[i];       for (int i = 1; i <= m; i++) {         cin >> t;         if (t == 1) {           cin >> v >> x;           a[v] = x;           last[v] = i;           ac[i] = ac[i - 1];         } else {           if (t == 2) {             cin >> y;             ac[i] = ac[i - 1] + y;           } else {             cin >> q;             cout << a[q] + ac[i - 1] - ac[last[q]] << endl;             ac[i] = ac[i - 1];           }         }       }     }   }


#include <bits/stdc++.h>   using namespace std;   const long long int maxn = 5100, inf = 1e17, mod = 1e9 + 7;   vector<long long int> f[maxn];   long long int pref[maxn][maxn];   signed main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     long long int n, m;     cin >> n >> m;     vector<long long int> mas(n, 0);     for (long long int d = 0; d < n; d++) {       cin >> mas[d];       mas[d]--;     }     for (long long int d = 0; d < m; d++) {       long long int f1, h1;       cin >> f1 >> h1;       f1--;       f[f1].push_back(h1);     }     for (long long int d = 0; d < n; d++) {       if (f[d].size() > 0) {         sort(f[d].begin(), f[d].end());       }     }     for (long long int d = 0; d < n; d++) {       pref[0][d] = 0;     }     for (long long int d = 1; d <= n; d++) {       for (long long int i = 0; i < n; i++) {         pref[d][i] = pref[d - 1][i];       }       pref[d][mas[d - 1]]++;     }     long long int max1 = 0, cnt = 1;     for (long long int d = 0; d <= n; d++) {       if (d == 0) {         long long int raz = 0;         long long int cnt1 = 1;         for (long long int i = 0; i < n; i++) {           long long int kol1 = pref[n][i] - pref[d][i];           long long int cnt2 = 1;           bool check1 = 0;           auto it1 = upper_bound(f[i].begin(), f[i].end(), kol1);           if (it1 != f[i].begin()) {             it1--;             long long int dist = (it1 - f[i].begin()) + 1;             cnt2 *= dist;             check1 = 1;           }           if (check1) {             raz += check1;             cnt1 *= cnt2;             cnt1 %= mod;           }         }         if (raz == max1) {           cnt += cnt1;           cnt %= mod;         }         if (raz > max1) {           max1 = raz;           cnt = cnt1;         }         continue;       }       long long int f1 = mas[d - 1];       long long int tkol = pref[d][f1];       bool check = 0;       auto it = lower_bound(f[f1].begin(), f[f1].end(), tkol);       if (it != f[f1].end()) {         if ((*it) == tkol) {           check = 1;         }       }       if (!check) {         continue;       }       long long int raz = 0;       long long int cnt1 = 1;       for (long long int i = 0; i < n; i++) {         long long int kol = pref[d][i];         long long int kol1 = pref[n][i] - pref[d][i];         auto it = upper_bound(f[i].begin(), f[i].end(), kol);         long long int cnt2 = 1;         long long int min1 = inf;         bool check = 0;         bool check1 = 0;         long long int cn = 0;         long long int dist1 = 0, dist2 = 0;         if (i != f1) {           if (it != f[i].begin()) {             --it;             dist1 = (it - f[i].begin()) + 1;             cnt2 *= dist1;             min1 = min(min1, dist1);             check = 1;           } else {             min1 = 0;           }           auto it1 = upper_bound(f[i].begin(), f[i].end(), kol1);           if (it1 != f[i].begin()) {             it1--;             dist2 = (it1 - f[i].begin()) + 1;             cnt2 *= dist2;             min1 = min(min1, dist2);             check1 = 1;           } else {             min1 = 0;           }           cnt2 -= min1;           long long int cn = check + check1;           if (dist1 == 1 && dist2 == 1) {             cn--;             cnt2 = 2;           }           raz += cn;           cnt1 *= cnt2;           cnt1 %= mod;         } else {           check = 1;           auto it = upper_bound(f[i].begin(), f[i].end(), kol1);           if (it != f[i].begin()) {             check1 = 1;             it--;             dist2 = (it - f[i].begin()) + 1;             if ((*it) >= tkol) {               dist2--;             }             if (dist2 == 0) {               check1 = 0;             } else {               cnt2 *= dist2;             }           }           if (check || check1) {             raz += check;             raz += check1;             cnt1 *= cnt2;             cnt1 %= mod;           }         }       }       if (raz == max1) {         cnt += cnt1;         cnt %= mod;       }       if (raz > max1) {         max1 = raz;         cnt = cnt1;       }     }     if (max1 == 0) {       cnt = 1;     }     cout << max1 <<     << cnt;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, i, j, k, x, y, t;     long long a;     cin >> a;     n = 2 * a - 1;     m = 2;     cout << n <<     << m << endl;     cout << 1 <<     << 2 << endl;   }


#include <bits/stdc++.h>   using namespace std;   pair<long long, long long> ar[100005];   long long suf[100007] = {0}, pre[100007] = {0}, sbkoya[100007] = {0},             arr[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     ;     long long n, a, cf, cm, m, temp, revi, cnt = 0;     cin >> n >> a >> cf >> cm >> m;     for (long long i = 0; i < n; ++i) {       cin >> temp;       if (temp == a) cnt++;       ar[i] = make_pair(temp, i);     }     if (cf == 0 && cm == 0) {       cout <<  0  << endl;       for (long long i = 0; i < n; ++i) cout << ar[i].first <<    ;       return 0;     }     sort(ar, ar + n);     long long i;     for (i = n - 1; i >= 0; i--) {       long long tmp = suf[i + 1] + a - ar[i].first;       if (tmp > m) break;       suf[i] = tmp;     }     revi = i + 1;     for (long long i = 0; i < n; ++i) {       if (i == 0)         pre[i] = ar[i].first;       else         pre[i] = pre[i - 1] + ar[i].first;     }     for (long long i = 1; i < n; ++i) {       sbkoya[i] = (ar[i].first) * (i + 1) - pre[i];     }     if (sbkoya[n - 1] + n * (a - ar[n - 1].first) <= m) {       cout << n * cf + a * cm << endl;       for (long long i = 0; i < n; ++i) cout << a <<    ;       return 0;     }     long long j, ans = 0, indj, indk, remain, mini, k, rem, mi, tmp;     rem = m;     k = upper_bound(sbkoya, sbkoya + n, rem) - sbkoya;     k--;     rem -= sbkoya[k];     mi = (ar[k].first) + rem / (k + 1);     tmp = mi * cm + cf * cnt;     ans = tmp;     indk = k;     indj = n;     remain = rem;     mini = mi;     for (j = n - 1; j >= revi; j--) {       tmp = cf * max(n - j, cnt);       rem = m - suf[j];       k = upper_bound(sbkoya, sbkoya + n, rem) - sbkoya;       k--;       if (k >= j) k = j - 1;       rem -= sbkoya[k];       mi = (ar[k].first) + rem / (k + 1);       tmp += mi * cm;       if (tmp >= ans) {         ans = tmp;         indk = k;         indj = j;         remain = rem;         mini = mi;       }     }     cout << ans << endl;     long long du;     for (du = n - 1; du >= indj; du--) ar[du].first = a;     long long ka = remain % (k + 1);     for (du = indk; du >= 0; du--) {       ar[du].first = mini;     }     for (long long i = 0; i < n; ++i) {       arr[ar[i].second] = ar[i].first;     }     for (long long i = 0; i < n; ++i) cout << arr[i] <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int32_t main() {     int n;     cin >> n;     cout << n % 2;   }


#include <bits/stdc++.h>   using namespace std;   using point = complex<long long>;   long long cross(point a, point b) {     return a.real() * b.imag() - a.imag() * b.real();   }   long long dot(point a, point b) {     return a.real() * b.real() + a.imag() * b.imag();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout << fixed << setprecision(8);     int n, px, py;     cin >> n >> px >> py;     point p = point(px, py);     double maxi = 0.0, mini = HUGE_VAL;     vector<point> polygon(n);     for (auto &v : polygon) {       int x, y;       cin >> x >> y;       v = point(x, y);       maxi = max(maxi, M_PI * norm(v - p));     }     for (int i = 0; i < n; ++i) {       int j = (i + 1) % n;       point a = polygon[i], b = polygon[j];       point v = a - b;       if ((dot(v, a) < dot(v, p)) == (dot(v, p) < dot(v, b))) {         mini = min(mini, M_PI * cross(v, p - b) * cross(v, p - b) / norm(v));       } else {         mini = min(mini, M_PI * min(norm(a - p), norm(b - p)));       }     }     cout << maxi - mini <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   int a[200005];   int main() {     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       for (int i = 1; i <= n; i++) {         int t;         cin >> t;         a[t] = i;       }       int l, r, num;       string s =   ;       for (int i = 1; i <= n; i++) {         if (i == 1) {           num = 0;           l = r = a[i];           s +=  1 ;           continue;         }         if (r < a[i])           num += a[i] - r - 1, r = a[i];         else if (l > a[i])           num += l - a[i] - 1, l = a[i];         else           num--;         if (!num)           s +=  1 ;         else           s +=  0 ;       }       cout << s << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using LL = long long;   const int MX[4] = {0, 0, -1, 1};   const int MY[4] = {-1, 1, 0, 0};   int n, m, k;   bool z[26];   bool Inside(int a, int b) { return 0 <= a && a < n && 0 <= b && b < m; }   char GetC(int a, int b, int c, int d, vector<vector<char>>& x) {     memset(z, 0, sizeof(z));     for (int t = 0; t < 4; ++t) {       int p = a + MX[t], q = b + MY[t];       if (Inside(p, q) && x[p][q] !=  + ) {         z[x[p][q] -  a ] = true;       }       p = c + MX[t], q = d + MY[t];       if (Inside(p, q) && x[p][q] !=  + ) {         z[x[p][q] -  a ] = true;       }     }     for (int i = 0; i < 26; ++i) {       if (!z[i]) return  a  + i;     }     return  a ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int times;     cin >> times;     while (times--) {       cin >> n >> m >> k;       vector<vector<char>> x(n, vector<char>(m,  + ));       if (n & 1) {         if (k < m / 2) {           cout <<  NO n ;           continue;         }         for (int i = 0; i < m; i += 2) {           x[0][i] = x[0][i + 1] =  a  + (i / 2 % 2);         }         k -= m / 2;         if (k & 1) {           cout <<  NO n ;           continue;         }         for (int j = 0; j < m; j += 2) {           if (k == 0) break;           for (int i = 1; i < n; ++i) {             if (k == 0) break;             char t = GetC(i, j, i, j + 1, x);             x[i][j] = x[i][j + 1] = t;             --k;           }         }         for (int i = 0; i < n; ++i) {           for (int j = 0; j < m; ++j) {             if (x[i][j] !=  + ) continue;             char t = GetC(i, j, i + 1, j, x);             x[i][j] = x[i + 1][j] = t;           }         }       } else if (m & 1) {         if (k & 1) {           cout <<  NO n ;           continue;         }         if (k > n * (m - 1) / 2) {           cout <<  NO n ;           continue;         }         for (int j = 0; j < m; j += 2) {           if (k == 0) break;           for (int i = 0; i < n; ++i) {             if (k == 0) break;             char t = GetC(i, j, i, j + 1, x);             x[i][j] = x[i][j + 1] = t;             --k;           }         }         for (int i = 0; i < n; ++i) {           for (int j = 0; j < m; ++j) {             if (x[i][j] !=  + ) continue;             char t = GetC(i, j, i + 1, j, x);             x[i][j] = x[i + 1][j] = t;           }         }       } else {         if (k & 1) {           cout <<  NO n ;           continue;         }         for (int j = 0; j < m; j += 2) {           if (k == 0) break;           for (int i = 0; i < n; ++i) {             if (k == 0) break;             char t = GetC(i, j, i, j + 1, x);             x[i][j] = x[i][j + 1] = t;             --k;           }         }         for (int i = 0; i < n; ++i) {           for (int j = 0; j < m; ++j) {             if (x[i][j] !=  + ) continue;             char t = GetC(i, j, i + 1, j, x);             x[i][j] = x[i + 1][j] = t;           }         }       }       cout <<  YES n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct dbg_ {     template <typename T>     dbg_& operator,(const T& x) {       cerr << x <<    ;       return *this;     }   } dbg_t;   struct cin_ {     template <typename T>     cin_& operator,(T& x) {       cin >> x;       return *this;     }   } cin_;   template <typename T1, typename T2>   static inline ostream& operator<<(ostream& os, std::pair<T1, T2> const& p) {     os <<  {  << p.first <<  ,   << p.second <<  } ;     return os;   }   int main() {     string str;     getline(cin, str);     int ret = 1;     for (int i = (1), _i = (7); i < _i; ++i) {       ret += str[i] -  0 ;       if (str[i] ==  0 ) ret += 9;     }     cout << ret << endl;     return 0;   }


#include <bits/stdc++.h>      #define mp make_pair   #define mt make_tuple   #define fi first   #define se second   #define pb push_back   #define all(x) (x).begin(), (x).end()   #define rall(x) (x).rbegin(), (x).rend()   #define forn(i, n) for (int i = 0; i < (int)(n); ++i)   #define for1(i, n) for (int i = 1; i <= (int)(n); ++i)   #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)   #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)      using namespace std;      typedef pair<int, int> pii;   typedef vector<int> vi;   typedef vector<pii> vpi;   typedef vector<vi> vvi;   typedef long long i64;   typedef vector<i64> vi64;   typedef vector<vi64> vvi64;   typedef pair<i64, i64> pi64;   typedef double ld;      template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }   template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }      const int maxn = 200001, maxk = 30;   vector<pii> e[maxn];   int ban[maxn];   int fib[maxk];   int w[maxn];      void dfsw(int v, int p, int k, int &c) {       bool isC = true;       w[v] = 1;       for (auto [u, id]: e[v]) {           if (u == p || ban[id]) continue;           dfsw(u, v, k, c);           isC &= 2 * w[u] <= fib[k];           w[v] += w[u];       }       isC &= 2 * (fib[k] - w[v]) <= fib[k];       if (isC) c = v;   }      void dfsw2(int v, int p, int k, vector<pii> &es) {       w[v] = 1;       for (auto [u, id]: e[v]) {           if (u == p || ban[id]) continue;           dfsw2(u, v, k, es);           w[v] += w[u];           if (w[u] == fib[k - 2]) {               es.pb({id, u});           }       }   }      bool check(int v, int k) {       if (k <= 3) return true;       dfsw(v, -1, k, v);       int trash;       vector<pii> es;       dfsw2(v, -1, k, es);       for (auto [id, u]: es) {           ban[id] = 1;           if (check(u, k - 2) && check(v, k - 1)) return true;       }       return false;   }      int main() {       ios::sync_with_stdio(false);       cin.tie(nullptr);       cout.precision(10);       cout << fixed;   #ifdef LOCAL_DEFINE       freopen( input.txt ,  rt , stdin);   #endif          int n;       cin >> n;       forn(i, n - 1) {           int u, v;           cin >> u >> v;           --u; --v;           e[u].pb({v, i});           e[v].pb({u, i});       }       fib[0] = fib[1] = 1;       int p;       for (p = 2; fib[p - 1] < n; ++p) {           fib[p] = fib[p - 1] + fib[p - 2];       }       --p;       if (n == fib[p] && check(0, p)) cout <<  YES n ;       else cout <<  NO n ;      #ifdef LOCAL_DEFINE       cerr <<  Time elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;   #endif       return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, y, k, t;     cin >> t;     for (int i = 0; i < t; i++) {       cin >> x >> y >> k;       long long br;       br = (k * (y + 1) - 1) / (x - 1);       if (((k * (y + 1) - 1) % (x - 1)) != 0) {         br += 1;       }       br += k;       cout << br << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       vector<long long> v;       for (int i = 0; i < n; i++) {         long long x;         cin >> x;         v.push_back(x);       }       sort(v.begin(), v.end());       long long sum = 0;       for (long long i = 0; n - k + i < n; i++) {         sum += v[n - 2 * k + i] / v[n - k + i];       }       for (long long i = 0; i < n - 2 * k; i++) {         sum += v[i];       }       cout << sum;       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 4010, K = 80;   const int p = 998244353;   int n1, n2, k, px[2][N], py[2][N], a1[K], a2[K], fac[K], inv[K], f[2][N];   int tot, fi[N], a[N << 1], ne[N << 1], cnt;   inline void A(int &x, int y) { x = (x + y >= p ? x + y - p : x + y); }   inline int C(int x, int y) {     return 1ll * fac[x] * inv[y] % p * inv[x - y] % p;   }   inline void Add(int x, int y) {     a[++tot] = y;     ne[tot] = fi[x];     fi[x] = tot;   }   inline void Dfs(int x, int fa, int ty) {     for (int i = fi[x]; i; i = ne[i])       if (a[i] != fa) {         ++cnt;         px[ty][cnt] = x;         py[ty][cnt] = a[i];         px[!ty][cnt] = a[i];         py[!ty][cnt] = x;         Dfs(a[i], x, !ty);       }   }   inline void Solve(int n, int k, int ans[]) {     tot = 0;     memset(fi + 1, 0, n * sizeof *fi);     for (int i = 1, x, y; i < n; ++i) {       scanf( %d%d , &x, &y);       Add(x, y);       Add(y, x);     }     ans[0] = n;     for (int x = 1; x <= n; ++x) {       cnt = 0;       Dfs(x, 0, 1);       memset(f[0] + 1, 0, n * sizeof *f[0]);       f[0][x] = 1;       for (int len = 1; len <= k; ++len) {         memset(f[len & 1] + 1, 0, n * sizeof *f[len & 1]);         for (int i = 1; i < n; ++i)           A(f[len & 1][py[len & 1][i]], f[~len & 1][px[len & 1][i]]);         A(ans[len], f[len & 1][x]);       }     }   }   int main() {     scanf( %d%d%d , &n1, &n2, &k);     Solve(n1, k, a1);     Solve(n2, k, a2);     fac[0] = 1;     for (int i = 1; i < K; ++i) fac[i] = 1ll * fac[i - 1] * i % p;     inv[0] = inv[1] = 1;     for (int i = 2; i < K; ++i) inv[i] = 1ll * inv[p % i] * (p - p / i) % p;     for (int i = 2; i < K; ++i) inv[i] = 1ll * inv[i - 1] * inv[i] % p;     int ans = 0;     for (int i = 0; i <= k; ++i)       ans = (ans + 1ll * C(k, i) * a1[i] % p * a2[k - i]) % p;     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t-- > 0) {       char c[100005];       int n;       cin >> n;       string s0 =   ;       string sm =   ;       string s1 =   ;       bool flag0 = true;       int pos1 = -1;       int pos0 = -1;       for (int i = 1; i <= n; i++) {         cin >> c[i];         if (c[i] ==  1 ) {           if (flag0) flag0 = false;           if (pos1 == -1) pos1 = i;           s1 = s1 +  1 ;         } else {           if (flag0) s0 = s0 +  0 ;           s1 =   ;           pos0 = i;         }       }       if (pos1 != -1 && pos0 != -1 && pos0 > pos1) sm =  0 ;       string s = s0 + sm + s1;       cout << s << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   int num, sg[100010], mex[100010], col = 1, ans = -1;   int main() {     scanf( %d , &num);     for (int n = 3; n <= num; n++) {       for (int m = 2;; m++) {         int res = n - (m - 1) * m / 2;         if (res < 0) break;         if (res % m) continue;         int g = 0, x = res / m;         for (int i = 0; i < m; i++) g ^= sg[x + i];         if (!g && num == n && ans < 0) {           ans = m;           break;         }         mex[g] = col;       }       for (int j = 0;; j++)         if (mex[j] != col) {           sg[n] = j;           ++col;           break;         }     }     printf( %d , ans);   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 6010;   int ans, f[maxn], r[maxn], m[maxn][maxn];   void dfs(int x, int y, int p) {     int k = lower_bound(f, f + p, r[x]) - f;     int t = f[k];     f[k] = r[x];     ans = max(ans, k);     p = max(k + 1, p);     for (int i = 1; i <= m[x][0]; i++)       if (m[x][i] != y) dfs(m[x][i], x, p);     f[k] = t;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , r + i);     for (int i = 1; i < n; i++) {       int a, b;       scanf( %d%d , &a, &b);       m[a][++m[a][0]] = b;       m[b][++m[b][0]] = a;     }     for (int i = 1; i <= n; i++) dfs(i, 0, 1);     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 65, MAXM = 65;   int N, M;   int A[MAXN], B[MAXM];   int Id[40011], Pos[MAXN * MAXM], Pc;   bool VisA[MAXN], VisB[MAXM];   int Ans, Cnt;   int Val[MAXN * MAXM];   int main() {     ios_base::sync_with_stdio(false);     cin >> N >> M;     for (int i = 1; i <= N; ++i) {       cin >> A[i];       A[i] <<= 1;     }     sort(A + 1, A + N + 1);     for (int j = 1; j <= M; ++j) {       cin >> B[j];       B[j] <<= 1;     }     sort(B + 1, B + M + 1);     for (int i = 1; i <= N; ++i)       for (int j = 1, p; j <= M; ++j) {         p = (A[i] + B[j]) >> 1;         if (!Id[p + 20000]) {           ++Pc;           Id[p + 20000] = Pc;           Pos[Pc] = p;         }       }     for (int a = 1; a <= N; ++a) {       for (int b = 1, p; b <= M; ++b) {         p = (A[a] + B[b]) >> 1;         for (int i = 1; i <= N; ++i) VisA[i] = false;         for (int j = 1; j <= M; ++j) VisB[j] = false;         for (int i = 1; i <= N; ++i)           for (int j = 1; j <= M; ++j) {             if (((A[i] + B[j]) >> 1) == p) {               VisA[i] = true;               VisB[j] = true;             }           }         Cnt = 0;         for (int i = 1; i <= N; ++i)           if (VisA[i]) ++Cnt;         for (int j = 1; j <= M; ++j)           if (VisB[j]) ++Cnt;         for (int i = Pc; i >= 1; --i) Val[i] = 0;         for (int i = 1; i <= N; ++i) {           if (VisA[i]) continue;           for (int j = 1; j <= M; ++j) {             if (j != 1 && B[j] == B[j - 1]) continue;             ++Val[Id[((A[i] + B[j]) >> 1) + 20000]];           }         }         for (int j = 1; j <= M; ++j) {           if (VisB[j]) continue;           for (int i = 1; i <= N; ++i) {             if (i != 1 && A[i] == A[i - 1]) continue;             ++Val[Id[((A[i] + B[j]) >> 1) + 20000]];           }         }         Ans = max(Ans, Cnt);         for (int i = Pc; i >= 1; --i) Ans = max(Ans, Val[i] + Cnt);       }     }     cout << Ans << endl;     return 0;   }


#include <bits/stdc++.h>   long long p[1000010] = {0}, cur[1000010 * 2] = {0};   inline long long read() {     char c;     while (!isdigit(c)) c = getchar();     long long x = 0;     while (isdigit(c)) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x;   }   int main() {     long long sum, ans, L, R, k, n;     scanf( %lld , &n);     sum = L = R = k = 0;     for (int i = 1; i <= n; i++) {       p[i] = read();       sum += abs(p[i] - i);       if (p[i] >= i) {         L++;         cur[p[i] - i]++;       } else         R++;     }     ans = sum;     for (int i = 0; i < n - 1; i++) {       L -= cur[i];       R += cur[i];       sum = sum - L + R - abs(p[n - i] - n - 1) + p[n - i] - 1;       cur[p[n - i] + i]++;       L++;       R--;       if (sum < ans) {         ans = sum;         k = i + 1;       }     }     printf( %lld %lld n , ans, k);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long pow(long long a, int p) {     if (p == 0) return 1;     if (p % 2 == 0) {       long long kek = pow(a, p / 2);       return kek * kek;     }     return pow(a, p - 1) * a;   }   int main() {     int n, m;     cin >> n >> m;     if (m == 0) {       cout << 2 * n;       return 0;     }     if (n == 0) {       cout << 3 * m;       return 0;     }     int a = n * 2, b = m * 3;     int k = min(n / 3, m / 2);     while (k > 0) {       if (a + 2 < b + 3) {         k--, a += 2;         if (a % 6 == 0 && a <= b) k++;       } else {         k--, b += 3;         if (b % 6 == 0 && b <= a) k++;       }     }     cout << max(a, b);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INF = 2e9;   const long long LINF = 2e16;   const int magic = 348;   const int MOD = 998244353;   const double eps = 1e-10;   const double pi = acos(-1);   struct fastio {     static const int S = 1e7;     char rbuf[S + 48], wbuf[S + 48];     int rpos, wpos, len;     fastio() { rpos = len = wpos = 0; }     inline char Getchar() {       if (rpos == len) rpos = 0, len = fread(rbuf, 1, S, stdin);       if (!len) return EOF;       return rbuf[rpos++];     }     template <class T>     inline void Get(T &first) {       char ch;       bool f;       T res;       while (!isdigit(ch = Getchar()) && ch !=  - ) {       }       if (ch ==  - )         f = false, res = 0;       else         f = true, res = ch -  0 ;       while (isdigit(ch = Getchar())) res = res * 10 + ch -  0 ;       first = (f ? res : -res);     }     inline void getstring(char *s) {       char ch;       while ((ch = Getchar()) <= 32) {       }       for (; ch > 32; ch = Getchar()) *++s = ch;       *(s + 1) =   0 ;     }     inline void flush() {       fwrite(wbuf, 1, wpos, stdout);       fflush(stdout);       wpos = 0;     }     inline void Writechar(char ch) {       if (wpos == S) flush();       wbuf[wpos++] = ch;     }     template <class T>     inline void Print(T first) {       char s[20];       int pt = 0;       if (first == 0)         s[++pt] =  0 ;       else         while (first) s[++pt] =  0  + first % 10, first /= 10;       while (pt) Writechar(s[pt--]);       Writechar(  n );     }     inline void printstring(char *s) {       int pt = 1;       while (s[pt] !=   0 ) Writechar(s[pt++]);     }   } io;   int n, ans;   int a[48];   string method[48];   inline bool solve(int pos) {     if (pos == ans + 1) {       if (a[pos] != n) return false;       io.Print(ans);       io.flush();       for (register int i = 1; i <= ans; i++) cout << method[i] << endl;       return true;     }     for (register int i = 1; i <= pos; i++)       for (register int j = 1; j <= pos; j++)         for (register int k = 1; k <= 8; k <<= 1) {           if (a[i] + k * a[j] <= a[pos] || a[i] + k * a[j] > n) continue;           a[pos + 1] = a[i] + k * a[j];           method[pos] =  lea e  + string(1,  a  + pos) +  x, [e  +                         string(1,  a  + i - 1) +  x +   + string(1,  0  + k) +                          *e  + string(1,  a  + j - 1) +  x] ;           if (solve(pos + 1)) return true;         }     for (register int i = 1; i <= pos; i++)       for (register int k = 1; k <= 8; k <<= 1) {         if (k * a[i] <= a[pos] || k * a[i] > n) continue;         a[pos + 1] = k * a[i];         method[pos] =  lea e  + string(1,  a  + pos) +  x, [  +                       string(1,  0  + k) +  *e  + string(1,  a  + i - 1) +  x] ;         if (solve(pos + 1)) return true;       }     return false;   }   int main() {     memset(a, 0, sizeof(a));     a[1] = 1;     io.Get(n);     for (;; ++ans)       if (solve(1)) break;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200200;   int n;   const long long neutro = 0;   struct RMQ {     int sz;     long long tope;     long long t[4 * MAXN];     long long &operator[](int p) { return t[sz + p]; }     void init(int n, long long tope_) {       sz = 1 << (32 - __builtin_clz(n));       tope = tope_;       for (int i = (0); i < (2 * sz); i++) t[i] = neutro;     }     void updall() {       for (int i = sz - 1; i >= 0; i--) t[i] = (t[2 * i] + t[2 * i + 1]);     }     long long get(int i, int j) {       if (j <= i) return 0;       return get(i, j, 1, 0, sz);     }     long long get(int i, int j, int n, int a, int b) {       if (j <= a || i >= b) return neutro;       if (i <= a && b <= j) return t[n];       int c = (a + b) / 2;       return (get(i, j, 2 * n, a, c) + get(i, j, 2 * n + 1, c, b));     }     void set(int p, long long val) {       p += sz;       val = min(tope, t[p] + val);       for (; p > 0 && t[p] != val;) {         t[p] = val;         p /= 2;         val = (t[p * 2] + t[p * 2 + 1]);       }     }   } rmqa, rmqb;   int k, a, b, q;   int main() {     ios::sync_with_stdio(0);     while (cin >> n >> k >> a >> b >> q) {       rmqa.init(n, a);       rmqb.init(n, b);       for (int _ = (0); _ < (q); _++) {         int t;         cin >> t;         if (t == 1) {           int d, a;           cin >> d >> a;           rmqa.set(d - 1, a);           rmqb.set(d - 1, a);         } else {           int p;           cin >> p;           p--;           cout << rmqb.get(0, p) + rmqa.get(p + k, n) << endl;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 100;   const int lg = 31;   const int mod = 1e9 + 7;   const int inf = 1e9;   struct node {     int mn, cnt[lg], lz;     node() {       mn = 0;       lz = 0;       fill(cnt, cnt + lg, 0);     }     void operator+=(int x) {       mn += x;       lz += x;       return;     }   };   int n, k, q, cnt[lg];   pair<pair<int, int>, pair<int, int> > b[maxn];   node seg[maxn << 2];   vector<int> vec, v2;   vector<pair<pair<int, int>, int> > g[maxn];   int cal(int x, int y) { return ((x + (1 << y)) >> (y + 1)) & 1; }   void bld(int id, int s, int e) {     if (e - s == 1) {       seg[id].mn = 0;       for (int i = 0; i < lg; i++) {         seg[id].cnt[i] = cal(vec[e], i) - cal(vec[s], i);       }       return;     }     int mid = (s + e) >> 1;     bld((id << 1), s, mid);     bld((id << 1 | 1), mid, e);     seg[id].mn = min(seg[(id << 1)].mn, seg[(id << 1 | 1)].mn);     for (int i = 0; i < lg; i++) {       seg[id].cnt[i] = 0;       if (seg[id].mn == seg[(id << 1)].mn)         seg[id].cnt[i] += seg[(id << 1)].cnt[i];       if (seg[id].mn == seg[(id << 1 | 1)].mn)         seg[id].cnt[i] += seg[(id << 1 | 1)].cnt[i];       seg[id].cnt[i] &= 1;     }     return;   }   void upd(int id, int s, int e, int l, int r, int x) {     if (r <= s || e <= l) return;     if (l <= s && e <= r) {       seg[id] += x;       return;     }     int mid = (s + e) >> 1;     seg[(id << 1)] += seg[id].lz;     seg[(id << 1 | 1)] += seg[id].lz;     seg[id].lz = 0;     upd((id << 1), s, mid, l, r, x);     upd((id << 1 | 1), mid, e, l, r, x);     seg[id].mn = min(seg[(id << 1)].mn, seg[(id << 1 | 1)].mn);     for (int i = 0; i < lg; i++) {       seg[id].cnt[i] = 0;       if (seg[id].mn == seg[(id << 1)].mn)         seg[id].cnt[i] += seg[(id << 1)].cnt[i];       if (seg[id].mn == seg[(id << 1 | 1)].mn)         seg[id].cnt[i] += seg[(id << 1 | 1)].cnt[i];       seg[id].cnt[i] &= 1;     }     return;   }   bool oh = 1;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> q >> k;     if (n != 1000000000 || q != 50000 || k != 4) oh = 0;     for (int i = 0; i < q; i++) {       cin >> b[i].first.first >> b[i].first.second >> b[i].second.first >>           b[i].second.second;       vec.push_back(b[i].first.second - 1);       vec.push_back(b[i].second.second);       v2.push_back(b[i].first.first - 1);       v2.push_back(b[i].second.first);     }     if (b[0].first.first != 7543) oh = 0;     vec.push_back(0);     vec.push_back(n);     sort((vec).begin(), (vec).end());     vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());     int N = int((vec).size()) - 1;     bld(1, 0, N);     sort((v2).begin(), (v2).end());     v2.resize(unique((v2).begin(), (v2).end()) - v2.begin());     for (int i = 0; i < q; i++) {       int x = lower_bound((v2).begin(), (v2).end(), b[i].first.first - 1) -               v2.begin();       int y =           lower_bound((v2).begin(), (v2).end(), b[i].second.first) - v2.begin();       int x2 = lower_bound((vec).begin(), (vec).end(), b[i].first.second - 1) -                vec.begin();       int y2 = lower_bound((vec).begin(), (vec).end(), b[i].second.second) -                vec.begin();       g[x].push_back(make_pair(make_pair(x2, y2), 1));       g[y].push_back(make_pair(make_pair(x2, y2), -1));     }     int prv = 0;     int t = 0;     while ((1 << (t + 1)) <= k) t++;     for (int i = 0; i < int((v2).size()); i++) {       node p = seg[1], d;       for (int j = 0; j < lg; j++) {         if (p.mn == 0)           p.cnt[j] = cal(n, j) - p.cnt[j];         else           p.cnt[j] = cal(n, j);         d.cnt[j] = cal(v2[i], j) - cal(prv, j);       }       int x = 0, y = 0;       for (int j = lg; j--;) {         x += p.cnt[j];         x &= 1;         cnt[min(j, t)] += (d.cnt[j] * x + p.cnt[j] * y) & 1;         y += d.cnt[j];         y &= 1;       }       for (auto j : g[i]) {         upd(1, 0, N, j.first.first, j.first.second, j.second);       }       prv = v2[i];     }     for (int i = 0; i < lg; i++) {       if (cnt[i] & 1) {         cout <<  Hamed ;         return 0;       }     }     cout <<  Malek ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10;   const int N2 = 2e6 + 5;   long long cs[N2], csn[N2];   int main() {     int n, x, y;     scanf( %d%d%d , &n, &x, &y);     int mx = 0;     for (int i = 0, a; i < n; i++) {       scanf( %d , &a);       cs[a]++;       mx = max(mx, a);     }     long long temp = 0;     int am = 0;     for (int i = 1; i < N2; i++) {       if (cs[i]) am += cs[i];       cs[i] += cs[i - 1];       csn[i] = temp;       temp += am;     }     int d = x / y;     for (int i = d - 2; i <= d + 2; i++) {       if (1LL * i * y < x) d = i;     }     long long ans = 1e18;     for (int i = 2; i < N2; i++) {       int h = min(d, i - 1), g = 0;       long long s = 0;       for (int j = i; j < N2; j += i) {         g += cs[j] - cs[max(j - h - 1, 0)];         s += csn[j] - csn[max(j - h - 1, 0)] -              cs[max(j - h - 1, 0)] * 1LL * (h + 1);       }       ans = min(ans, y * s + x * 1LL * (n - g));     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimization( unroll-loops, no-stack-protector )   #pragma GCC target( avx,avx2,fma )   using namespace std;   using pii = pair<int, int>;   using pll = pair<long long, long long>;   using vb = vector<bool>;   using vi = vector<int>;   using vl = vector<long long>;   using vvb = vector<vector<bool>>;   using vvi = vector<vector<int>>;   using vvl = vector<vector<long long>>;   using vpii = vector<pair<int, int>>;   using mii = map<int, int>;   using umii = unordered_map<int, int>;   using seti = set<int>;   using useti = unordered_set<int>;   template <typename... ArgTypes>   void print(ArgTypes... args);   template <typename... ArgTypes>   void input(ArgTypes &...args);   template <>   void print() {}   template <>   void input() {}   template <typename T, typename... ArgTypes>   void print(T t, ArgTypes... args) {     cout << t;     print(args...);   }   template <typename T, typename... ArgTypes>   void input(T &t, ArgTypes &...args) {     cin >> t;     input(args...);   }   template <class T>   T OP(T a, T b) {     if (a.first > b.first) return b;     if (a.first == b.first && b.second > a.second) return b;     return a;   }   template <class T>   class SegmentTree {    private:     void propagate(int node, T val, int nodes) {       tree[node].first += val.first;       lazy[node].first += val.first;     }     T buildUtil(vector<T> &a, int node, int l, int r) {       if (l == r) {         tree[node] = a[l];         return tree[node];       }       int mid = (l + r) >> 1;       int leftNode = (node << 1) + 1;       int rightNode = leftNode + 1;       return tree[node] = OP(buildUtil(a, leftNode, l, mid),                              buildUtil(a, rightNode, mid + 1, r));     }     T queryUtil(int node, int l, int r, int ql, int qr) {       if (ql > r || qr < l) return (T)make_pair(1000000005, -1);       if (l >= ql && r <= qr) return tree[node];       int mid = (l + r) >> 1;       int leftNode = (node << 1) + 1;       int rightNode = leftNode + 1;       if (lazy[node].first) {         propagate(leftNode, lazy[node], mid - l + 1);         propagate(rightNode, lazy[node], r - mid);         lazy[node].first = 0;       }       return OP(queryUtil(leftNode, l, mid, ql, qr),                 queryUtil(rightNode, mid + 1, r, ql, qr));     }     T updateUtil(int node, int l, int r, int ql, int qr, T val) {       if (ql > r || qr < l) return tree[node];       if (l >= ql && r <= qr) {         tree[node].first += val.first;         lazy[node].first += val.first;         return tree[node];       }       int mid = (l + r) >> 1;       int leftNode = (node << 1) + 1;       int rightNode = leftNode + 1;       if (lazy[node].first) {         propagate(leftNode, lazy[node], mid - l + 1);         propagate(rightNode, lazy[node], r - mid);         lazy[node].first = 0;       }       return tree[node] = OP(updateUtil(leftNode, l, mid, ql, qr, val),                              updateUtil(rightNode, mid + 1, r, ql, qr, val));     }       public:     int n;     vector<T> tree;     vector<T> lazy;     SegmentTree(int n) {       this->n = n;       tree = vector<T>(4 * n);       lazy = vector<T>(4 * n);     }     void build(vector<T> &a) { buildUtil(a, 0, 0, n - 1); }     SegmentTree(vector<T> &a) {       this->n = a.size();       tree = vector<T>(4 * n);       lazy = vector<T>(4 * n);       build(a);     }     T query(int l, int r) { return queryUtil(0, 0, n - 1, l, r); }     void update(int l, int r, T val) { updateUtil(0, 0, n - 1, l, r, val); }   };   template <class T, class OP>   class FST {     vector<T> t;     void build() {       for (int i = n - 1; i > 0; --i) t[i] = OP()(t[i << 1], t[i << 1 | 1]);     }       public:     int n;     FST(int nn) {       n = nn;       t = vector<T>(n << 1);     }     FST(vector<T> v) {       n = v.size();       t = vector<T>(n << 1);       for (int i = 0; i < n; ++i) t[i + n] = v[i];       build();     }     void update(int p, T value) {       value += query(p, p);       for (t[p += n] = value; p > 1; p >>= 1) t[p >> 1] = OP()(t[p], t[p ^ 1]);     }     T query(int l, int r) {       r++;       T res = OP::initVal;       for (l += n, r += n; l < r; l >>= 1, r >>= 1) {         if (l & 1) res = OP()(res, t[l++]);         if (r & 1) res = OP()(res, t[--r]);       }       return res;     }   };   template <class T>   class Add {    public:     static const T initVal = T(0);     T operator()(T x, T y) { return x + y; }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, q;     cin >> n >> q;     vpii a(n);     for (int i = 0; i < (n); (i)++) {       cin >> a[i].first;       a[i].second = i + 1;       a[i].first = a[i].second - a[i].first;       if (a[i].first < 0) a[i].first = 1000000005;     }     SegmentTree<pii> st(a);     vi seq(n, -1);     vi taken(n);     int parent = n;     while (1) {       auto d = st.query(0, n - 1);       if (d.first != 0) break;       seq[d.second - 1] = parent;       parent = min(parent, d.second - 1);       taken[d.second - 1] = 1;       st.update(d.second - 1, n - 1, {-1, 0});       st.update(d.second - 1, d.second - 1, {1000000005 + 1, 0});     }     FST<int, Add<int>> track(n + 3);     vector<pair<pii, pii>> queries;     for (int qq = 0; qq < (q); (qq)++) {       int x, y;       cin >> x >> y;       int l = x;       int r = n - 1 - y;       queries.push_back({{l, r}, {qq, 0}});     }     int sq = (int)sqrt(q);     sort((queries).begin(), (queries).end(),          [=](pair<pii, pii> x, pair<pii, pii> y) -> bool {            int blockX = x.first.first / sq;            int blockY = y.first.first / sq;            if (blockX < blockY) return true;            if (blockX == blockY)              return (blockX & 1) ^ (x.first.second < y.first.second);            return false;          });     int l = 0, r = 0;     if (seq[0] != -1) track.update(seq[0], 1);     for (pair<pii, pii> &qq : queries) {       int x = qq.first.first;       int y = qq.first.second;       while (l < x) {         int d = seq[l];         l++;         if (d != -1) track.update(d, -1);       }       while (l > x) {         int d = seq[l - 1];         l--;         if (d != -1) track.update(d, 1);       }       while (r < y) {         int d = seq[r + 1];         r++;         if (d != -1) track.update(d, 1);       }       while (r > y) {         int d = seq[r];         r--;         if (d != -1) track.update(d, -1);       }       int temp = 0;       if (x != 0) temp = track.query(0, x - 1);       qq.second.second = track.query(0, n + 1) - temp;     }     sort((queries).begin(), (queries).end(),          [=](pair<pii, pii> x, pair<pii, pii> y) -> bool {            return x.second.first < y.second.first;          });     for (auto qq : queries) cout << qq.second.second <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long int sum = 0;       for (int i = 0; i < 3; i++) {         long long int temp;         cin >> temp;         sum += temp;       }       cout << sum / 2 << endl;     }     return 0;   }


#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:512000000 )   using namespace std;   using li = long long;   using ld = long double;   void solve(bool);   void precalc();   clock_t start;   int main() {     start = clock();     int t = 1;     cout.sync_with_stdio(0);     cin.tie(0);     cout.precision(20);     cout << fixed;     precalc();     while (t--) {       solve(true);     }     cout.flush();     return 0;   }   template <typename T>   T binpow(T q, T w, T mod) {     if (!w) return 1 % mod;     if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;     return binpow(q * 1LL * q % mod, w / 2, mod);   }   template <typename T>   T gcd(T q, T w) {     while (w) {       q %= w;       swap(q, w);     }     return q;   }   template <typename T>   T lcm(T q, T w) {     return q / gcd(q, w) * w;   }   template <typename T>   void make_unique(vector<T>& vec) {     sort(vec.begin(), vec.end());     vec.erase(unique(vec.begin(), vec.end()), vec.end());   }   template <typename T>   void relax_min(T& cur, T val) {     cur = min(cur, val);   }   template <typename T>   void relax_max(T& cur, T val) {     cur = max(cur, val);   }   mt19937 rng(       (unsigned long long)chrono::steady_clock::now().time_since_epoch().count());   void precalc() {}   void solve(__attribute__((unused)) bool read) {     string s;     cin >> s;     li n = (li)s.length();     li res = n * (n + 1) / 2;     for (li l = 0; l < n; ++l) {       bool flag = false;       for (li r = l; r < n && !flag; ++r) {         for (li i = r - 2; i >= l; i -= 2) {           if (s[i] == s[r] && s[i] == s[i + (r - i) / 2]) {             flag = true;             break;           }         }         if (flag) {           break;         }         --res;       }     }     cout << res << endl;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int num, sum = 0;     for (int i = 0; i < 5; ++i) {       cin >> num;       sum += num;     }     if (!(sum % 5) && sum > 0)       cout << sum / 5 << endl;     else       cout <<  -1  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long double dp[4005][4005];   long double absf(long double a) {     if (a < 0) return a * (-1);     return a;   }   long double solve(vector<long double> &a, long long idx, long long left) {     if (idx >= a.size()) return left == 0 ? 0 : 100000;     if (dp[idx][left] != -100000) {       return dp[idx][left];     }     long double cur_up = ceil(a[idx]);     long double cur_down = floor(a[idx]);     if (left > 0) {       long double pt1 = a[idx] - cur_down + solve(a, idx + 1, left - 1);       long double pt2 = a[idx] - cur_up + solve(a, idx + 1, left);       if (absf(pt1) < absf(pt2)) {         return dp[idx][left] = pt1;       } else {         return dp[idx][left] = pt2;       }     } else {       long double pt2 = a[idx] - cur_up + solve(a, idx + 1, left);       return dp[idx][left] = pt2;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     vector<long double> a;     for (long long i = 0; i < 2 * n; i++) {       long double temp;       cin >> temp;       a.push_back(temp);     }     for (long long i = 0; i < 4005; i++) {       for (long long j = 0; j < 4005; j++) {         dp[i][j] = -100000;       }     }     long double res = abs(solve(a, 0, n));     cout << fixed << setprecision(3);     cout << res <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int cur, hasans, ptr;   vector<int> adj[500004];   vector<int> ans(500004);   void dfs(int now) {     cur--;     for (auto u : adj[now]) {       if (u == cur) {         dfs(u);       } else {         hasans = 0;       }     }     ans[ptr++] = now;   }   void solve() {     int n;     cin >> n;     for (int i = 1; i <= n + 1; i++) {       adj[i].clear();       ans[i] = 0;     }     cur = n + 1, hasans = 1, ptr = 1;     vector<int> a(n + 1);     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] == -1) a[i] = i + 1;     }     for (int i = 1; i <= n; i++) {       adj[a[i]].push_back(i);     }     for (int i = 1; i <= n + 1; i++) {       sort(adj[i].begin(), adj[i].end(), greater<int>());     }     dfs(n + 1);     if (!hasans) {       cout <<  -1 n ;     } else {       vector<int> res(n + 1);       for (int i = 1; i <= n; i++) {         res[ans[i]] = i;       }       for (int i = 1; i <= n; i++) {         cout << res[i] <<    ;       }       cout <<   n ;     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void _print(long long int t) { cerr << t; }   void _print(int t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(unordered_map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   const long long int MOD = 1e9 + 7;   const long long int MX = 1e5 + 1;   long long int n;   long long int arr[MX];   long long int a, b, c, d, e, f, g, h;   void sourav() {     int cnt1 = 0, cnt2 = 0;     string s;     cin >> s;     if (s.size() & 1) {       cout <<  NO n ;       ;       return;     }     for (long long int i = 0; i < s.size(); i++) {       if (s[i] ==  A ) {         cnt1++;       } else if (s[i] ==  C ) {         cnt2++;       }     }     if ((cnt1 + cnt2) == (s.size() - (cnt1 + cnt2))) {       cout <<  YES n ;       ;     } else {       cout <<  NO n ;       ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int t;     cin >> t;     for (int i = 1; i <= t; i++) {       sourav();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void gmin(T &x, const T &y) {     x = x > y ? y : x;   }   template <class T>   inline void gmax(T &x, const T &y) {     x = x < y ? y : x;   }   template <class T>   inline bool Gmin(T &x, const T &y) {     return x > y ? x = y, 1 : 0;   }   template <class T>   inline bool Gmax(T &x, const T &y) {     return x < y ? x = y, 1 : 0;   }   const int BufferSize = 1 << 16;   char buffer[BufferSize], *Bufferhead, *Buffertail;   bool Terminal;   inline char Getchar() {     if (Bufferhead == Buffertail) {       int l = fread(buffer, 1, BufferSize, stdin);       if (!l) {         Terminal = 1;         return 0;       }       Buffertail = (Bufferhead = buffer) + l;     }     return *Bufferhead++;   }   template <class T>   inline bool read(T &x) {     x = 0;     char c = Getchar(), rev = 0;     while (c <  0  || c >  9 ) {       rev |= c ==  - ;       c = Getchar();       if (Terminal) return 0;     }     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = Getchar();     if (c ==  . ) {       c = Getchar();       double t = 0.1;       while (c >=  0  && c <=  9 )         x = x + (c -  0 ) * t, c = Getchar(), t = t / 10;     }     x = rev ? -x : x;     return 1;   }   template <class T1, class T2>   inline bool read(T1 &x, T2 &y) {     return read(x) & read(y);   }   template <class T1, class T2, class T3>   inline bool read(T1 &x, T2 &y, T3 &z) {     return read(x) & read(y) & read(z);   }   template <class T1, class T2, class T3, class T4>   inline bool read(T1 &x, T2 &y, T3 &z, T4 &w) {     return read(x) & read(y) & read(z) & read(w);   }   inline bool reads(char *x) {     char c = Getchar();     while (c < 33 || c > 126) {       c = Getchar();       if (Terminal) return 0;     }     while (c >= 33 && c <= 126) (*x++) = c, c = Getchar();     *x = 0;     return 1;   }   template <class T>   inline void print(T x, const char c =   n ) {     if (!x) {       putchar( 0 );       putchar(c);       return;     }     if (x < 0) putchar( - ), x = -x;     int m = 0, a[20];     while (x) a[m++] = x % 10, x /= 10;     while (m--) putchar(a[m] +  0 );     putchar(c);   }   const int inf = 0x3f3f3f3f;   const int N = 200005, M = 100005, mod = 1e9 + 7;   template <class T, class S>   inline void ch(T &x, const S y) {     x = (x + y) % mod;   }   inline long long mul(long long x, long long y, long long mod) {     long long t = x * y - (long long)((long double)x * y / mod) * mod;     return t < 0 ? t + mod : t;   }   inline long long exp(long long x, long long y, long long mod) {     long long ans = 1;     while (y) {       if (y & 1) ans = mul(ans, x, mod);       x = mul(x, x, mod);       y >>= 1;     }     return ans;   }   inline int getlen(long long a) {     int ans = 0;     while (a) a /= 10, ans++;     return ans;   }   inline long long calc(int g, int p, int a, long long x) {     long long mod = p, phi = p - 1, d = 0;     for (int i = 0, pw = 1; i < p; i++) {       if (pw == x % p) {         d = i;         break;       }       pw = (long long)pw * g % p;     }     for (int i = 2; i <= a; i++) {       mod *= p;       for (;; d += phi)         if (exp(g, d, mod) == x % mod) break;       phi *= p;     }     return d;   }   int Main(int argv) {     long long a;     read(a);     int n;     n = getlen(a);     for (int m = 0;; m++) {       long long b = (-a) & ((1ll << n + m) - 1);       cerr <<  m             <<  =  << m << endl;       if (m && b % 5 == 0) b += (1ll << n + m);       if (!m && a % 5 == 0) goto power;       if (getlen(b) <= m) {         print(calc(2, 5, n + m, (a + b) >> n + m) + n + m);         return 0;       }     power:       a *= 10;     }     return 0;   }   void clear() {}   int main() {     int T;     scanf( %d , &T);     for (int i = 1; i <= T; i++) Main(i), clear();     return 0;   }