#include<bits/stdc++.h>   #define fi                first   #define se                 second   #define ll               long long   #define mod              1000000007LL   #define endl                n    #define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);   #define pb                push_back   #define all(v)             v.begin(),v.end()   #define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}   #define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] <<      ;} cout << endl;}   #define pll              pair<long long,long long>   #define pi            3.141592653589793238   using namespace std;   //vector<ll> adj[5000005];   //vector<bool> vis(3000005,false);   ll factorial(ll n)   {       return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);   }   ll gcd(ll a, ll b)   {       if (a == 0)         return b;       return gcd(b % a, a);   }   ll lcm(ll a, ll b)   {      return (a*b)/gcd(a, b);   }   bool sortByVal(const pair<ll,ll> &a,                 const pair<ll,ll> &b)   {         if(a.fi == b.fi)           return a.se < b.se;        else           return a.fi > b.fi;   }   ll Powb(ll b,ll n)   {       if(n==0) return 1LL;       if(n==1) return b;       ll temp = Powb(b,n/2);       if(n%2==0){return (temp*temp)%mod;}       else{return (b*((temp*temp)%mod))%mod;}   }   int main()   {    fast;        int t=1;        //cin>>t;        while(t--)        {        ll q,i,j,m,n,k,sum=0,c=0,d=0,e=0,f=0,g=0,h=0,maxi=0;         cin>>n>>q>>k;         vector<ll> a(n);         inp(a,n);         vector<ll> b(n);         if(n == 1)         {             while(q--)             {                 cin>>c>>d;                 cout<<k-1<<endl;             }         }         else         {             for(i=0;i<n;i++)             {                 if(i == 0)                 {                     c=a[i+1]-2;                     b[i]=c;                 }                 else if(i == n-1)                 {                     c=k-a[n-1];                     b[i]=c;                 }                 else                 {                     c=a[i-1];                     d=a[i+1];                     d-=c;                     d-=2;                     b[i]=d;                 }                }             vector<ll> p(n);             sum=0;             for(i=0;i<n;i++)             {                 sum+=b[i];                 p[i]=sum;             }                //oup(b,n);             //oup(p,n);             while(q--)             {                 sum=0;                 cin>>c>>d;                 c--;                 d--;                 if(c == d)                 {                     cout<<k-1<<endl;                 }                 else if((d-c) == 1)                 {                     e=a[d]-2;                     f=k-a[c]-1;                     cout<<e+f<<endl;                 }                 else                 {                     sum=p[d-1]-p[c];                     e=k-a[d-1]-1;                     sum+=e;                     f=a[c+1]-2;                     sum+=f;                     cout<<sum<<endl;                 }                }         }              }   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 255;   const int MAXM = 30;   const int MAX = 10000;   const int INF = -1U >> 1;   int arr[MAXN];   struct MinCostFlow {     struct edge {       int n, f, c;       edge *next, *rev;       edge(int _n, int _f, int _c, edge* _next)           : n(_n), f(_f), c(_c), next(_next) {}     };     vector<edge*> edges;     int addV() {       edges.push_back((edge*)0);       return edges.size() - 1;     }     edge* makeE(int s, int t, int f, int c) {       return edges[s] = new edge(t, f, c, edges[s]);     }     void addE(int s, int t, int f, int c) {       edge *e1 = makeE(s, t, f, c), *e2 = makeE(t, s, 0, -c);       e1->rev = e2, e2->rev = e1;     }     void mcflow(int vs, int vt, int vr, int vn, int vm) {       int n = edges.size();       int cflow = 0, ccost = 0;       vector<int> dist(n);       vector<int> flow(n);       vector<edge*> from(n);       vector<bool> in(n);       queue<int> que;       while (1) {         fill(dist.begin(), dist.end(), INF);         fill(flow.begin(), flow.end(), 0);         dist[vs] = 0;         flow[vs] = INF;         que.push(vs);         while (!que.empty()) {           int v = que.front();           que.pop();           in[v] = 0;           for (edge* e = edges[v]; e; e = e->next)             if (e->f) {               int nc = dist[v] + e->c;               if (nc < dist[e->n]) {                 dist[e->n] = nc;                 flow[e->n] = min(flow[v], e->f);                 from[e->n] = e;                 if (!in[e->n]) {                   que.push(e->n);                   in[e->n] = 1;                 }               }             }         }         if (!flow[vt]) break;         int f = flow[vt];         cflow += f;         ccost += f * dist[vt];         int cur = vt;         while (cur != vs) {           edge* e = from[cur];           e->f -= f;           e->rev->f += f;           cur = e->rev->n;         }       }       vector<int> var(vn);       vector<pair<int, int> > ans;       for (int i = 0; i < vm; i++) {         int cur = vr;         while (cur != vt) {           for (edge* e = edges[cur]; e; e = e->next) {             if (!e->f) {               e->f++;               if (e->n < vn) var[e->n] = i;               cur = e->n;               break;             }           }         }       }       vector<int> num(vn, -1);       for (int i = 0; i < vn; i++) {         if (num[var[i]] != arr[i])           ans.push_back(pair<int, int>(var[i], 0)), num[var[i]] = arr[i];         ans.push_back(pair<int, int>(var[i], 1));       }       cout << ans.size() <<     << ccost + MAX * vn <<   n ;       int cnt = 0;       for (int i = 0; i < ans.size(); i++) {         if (!ans[i].second)           cout << char(ans[i].first +  a ) <<  =  << arr[cnt] <<   n ;         else {           cout <<  print(  << char(ans[i].first +  a ) <<  ) n ;           cnt++;         }       }     }   };   int n, m;   int main() {     ios ::sync_with_stdio(0);     if (fopen( input.txt ,  r )) freopen( input.txt ,  r , stdin);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> arr[i];     MinCostFlow net;     for (int i = 0; i < n + n; i++) net.addV();     int vs = net.addV(), vt = net.addV(), vr = net.addV();     net.addE(vs, vr, m, 0);     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         if (arr[i] == arr[j])           net.addE(i + n, j, 1, 0);         else           net.addE(i + n, j, 1, __builtin_popcount(arr[j]));     for (int i = 0; i < n; i++) {       net.addE(vr, i, 1, __builtin_popcount(arr[i]));       net.addE(i, i + n, 1, -MAX);     }     for (int i = 0; i < m; i++) net.addE(vr, vt, 1, 0);     for (int i = 0; i < n; i++) net.addE(i + n, vt, 1, 0);     net.mcflow(vs, vt, vr, n, m);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     cin >> n;     while (n % 10 == 0) n /= 10;     stringstream ss;     ss << n;     string str = ss.str();     string tmp = str;     reverse(tmp.begin(), tmp.end());     if (str == tmp)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   inline int read() {     int x = 0, w = 1;     char ch = 0;     while (ch <  0  || ch >  9 ) {       ch = getchar();       if (ch ==  - ) w = -1;     }     while (ch <=  9  && ch >=  0 ) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * w;   }   int p[10];   int k1[10], k2[10], ans1[10], ans2[10];   int a, b, p1, p2, flag;   inline void chk(int n, int c1, int c2) {     int cnt1 = 0, cnt2 = 0;     memset(k1, 0, sizeof(k1));     memset(k2, 0, sizeof(k2));     if ((c1 - c2 <= p1 - p2)) return;     for (int i = 1; i <= n; ++i) {       if (p[i] == 1)         cnt1 += (k1[i] = (i == 5) ? 15 : 25);       else         cnt2 += (k2[i] = (i == 5) ? 15 : 25);     }     if (cnt1 > a || cnt2 > b) return;     if (n == 5) {       if (p[5]) {         if (cnt2 + 13 <= b) {           cnt2 += 13;           k2[5] = 13;           int now = min(a - cnt1, b - cnt2);           cnt1 += now, cnt2 += now;           k1[5] += now, k2[5] += now;         }       } else {         if (cnt1 + 13 <= a) {           cnt1 += 13;           k1[5] = 13;           int now = min(a - cnt1, b - cnt2);           cnt1 += now, cnt2 += now;           k1[5] += now, k2[5] += now;         }       }       for (int i = 1; i <= n; ++i) {         int k = (i == 5) ? 13 : 23;         if (!p[i]) {           if (k1[i]) continue;           if (cnt1 + k > a)             k1[i] = a - cnt1;           else             k1[i] = k;           cnt1 += k1[i];         } else {           if (k2[i]) continue;           if (cnt2 + k > b)             k2[i] = b - cnt2;           else             k2[i] = k;           cnt2 += k2[i];         }       }       if (cnt1 == a && cnt2 == b && c1 - c2 > p1 - p2) {         p1 = c1, p2 = c2;         flag = 1;         for (int i = 1; i <= n; ++i) ans1[i] = k1[i], ans2[i] = k2[i];         return;       }     }     cnt1 = 0, cnt2 = 0;     memset(k1, 0, sizeof(k1));     memset(k2, 0, sizeof(k2));     for (int i = 1; i <= n; ++i) {       if (p[i] == 1)         cnt1 += (k1[i] = (i == 5) ? 15 : 25);       else         cnt2 += (k2[i] = (i == 5) ? 15 : 25);     }     if (p[1]) {       if (cnt2 + 23 <= b) {         cnt2 += 23;         k2[1] = 23;         int now = min(a - cnt1, b - cnt2);         cnt1 += now, cnt2 += now;         k1[1] += now, k2[1] += now;       }     } else {       if (cnt1 + 23 <= a) {         cnt1 += 23;         k1[1] = 23;         int now = min(a - cnt1, b - cnt2);         cnt1 += now, cnt2 += now;         k1[1] += now, k2[1] += now;       }     }     for (int i = 1; i <= n; ++i) {       int k = (i == 5) ? 13 : 23;       if (!p[i]) {         if (k1[i]) continue;         if (cnt1 + k > a)           k1[i] = a - cnt1;         else           k1[i] = k;         cnt1 += k1[i];       } else {         if (k2[i]) continue;         if (cnt2 + k > b)           k2[i] = b - cnt2;         else           k2[i] = k;         cnt2 += k2[i];       }     }     if (cnt1 != a || cnt2 != b) return;     if (c1 - c2 > p1 - p2) {       p1 = c1, p2 = c2;       flag = 1;       for (int i = 1; i <= n; ++i) ans1[i] = k1[i], ans2[i] = k2[i];     }   }   void dfs(int x, int c1, int c2) {     if (c1 >= 3 || c2 >= 3) {       chk(x - 1, c1, c2);       return;     }     p[x] = 1;     dfs(x + 1, c1 + 1, c2);     p[x] = 0;     dfs(x + 1, c1, c2 + 1);   }   int main() {     int T = read();     while (T--) {       a = read();       b = read();       flag = 0;       p1 = 0, p2 = 5;       dfs(1, 0, 0);       if (!flag) {         printf( Impossible n );         continue;       }       printf( %d:%d n , p1, p2);       for (int i = 1; i <= p1 + p2; ++i) printf( %d:%d  , ans1[i], ans2[i]);       printf(  n );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int Maxn = 500, Maxm = 500;   int n, m, x[Maxn], y[Maxn], seq[Maxm];   bool canGet(int from) {     bool taken[Maxm] = {};     vector<int> ans;     for (int i = 0; i < n; i++)       if ((i - from) % 2)         ans.push_back(-1);       else {         int prv = (i - 1 + n) % n;         int nxt = (i + 1) % n;         int need = 0;         if (x[prv] == x[i])           need += abs(y[prv] - y[i]);         else           need += abs(x[prv] - x[i]);         if (x[i] == x[nxt])           need += abs(y[i] - y[nxt]);         else           need += abs(x[i] - x[nxt]);         int j;         for (j = 0; j < m; j++)           if (!taken[j] && seq[j] == need) break;         if (j == m) return false;         ans.push_back(j + 1);         taken[j] = true;       }     cout <<  YES n ;     for (int i = 0; i < ans.size(); i++) {       if (i) cout <<    ;       cout << ans[i];     }     cout << endl;     return true;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     for (int i = 0; i < m; i++) cin >> seq[i];     if (!canGet(0))       if (!canGet(1)) cout <<  NO n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};   int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};   int gcd(int a, int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   bool cmp(vector<long long> a, vector<long long> b) { return a[2] > b[2]; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<vector<long long>> v;     for (long long i = 0; i < n; i++) {       long long a, b, c;       cin >> a >> b >> c;       v.push_back({a, b, c});     }     sort((v).begin(), (v).end(), cmp);     vector<int> adj[n + 1];     for (int i = 0; i < n; i++) {       for (int j = i - 1; j >= 0; j--) {         long double dis = (v[j][0] - v[i][0]) * (v[j][0] - v[i][0]) +                           (v[j][1] - v[i][1]) * (v[j][1] - v[i][1]);         long double dis1 = v[i][2] + v[j][2];         if (dis1 * dis1 <= dis) {           continue;         } else {           adj[i].push_back(j);           adj[j].push_back(i);           break;         }       }     }     vector<int> vis(n, 0);     vector<int> dis(n, 0);     for (int i = 0; i < n; i++) {       if (vis[i] == 0) {         queue<int> q;         q.push(i);         vis[i] = 1;         dis[i] = 1;         while (!q.empty()) {           auto a = q.front();           q.pop();           for (auto i : adj[a]) {             if (vis[i] == 0) {               vis[i] = 1;               dis[i] = dis[a] + 1;               q.push(i);             }           }         }       }     }     long double ans = 0;     for (int i = 0; i < n; i++) {       if (dis[i] % 2 == 0 || dis[i] == 1) {         ans =             ans +             3.141592653589793238462643383279502884197169399375105820974944592307816406286 *                 v[i][2] * v[i][2];       } else {         ans =             ans -             3.141592653589793238462643383279502884197169399375105820974944592307816406286 *                 v[i][2] * v[i][2];       }     }     cout << setprecision(15) << ans <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T, typename L>   inline bool smax(T &x, L y) {     return x < y ? (x = y, true) : false;   }   template <typename T, typename L>   inline bool smin(T &x, L y) {     return y < x ? (x = y, true) : false;   }   constexpr int MAXN = 1e5 + 15;   int n;   int a[MAXN];   int ttime[MAXN];   stack<int> dq;   int mx;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       ttime[i] = 1;       while (!dq.empty() && a[i] > a[dq.top()]) {         smax(ttime[i], ttime[dq.top()] + 1);         dq.pop();       }       if (!dq.empty()) {         smax(mx, ttime[i]);       } else {         ttime[i] = 1e6 + 15;       }       dq.push(i);     }     return cout << mx <<   n , false;   }


#include <bits/stdc++.h>   using namespace std;   const long long N = 1111;   long long fact[N], invfact[N];   long long n, m, k;   long long powmod(long long x, long long n, long long m = 1000000007) {     long long ans = 1;     while (n) {       if (n & 1) {         ans = ans * x % m;       }       x = x * x % m;       n >>= 1;     }     return ans;   }   inline long long invmod(long long x, long long m = 1000000007) {     return powmod(x, m - 2);   }   inline long long ncr(long long n, long long r) {     if (r < 0 || r > n) return 0;     return fact[n] * invfact[r] % 1000000007 * invfact[n - r] % 1000000007;   }   signed main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     fact[0] = 1;     invfact[0] = 1;     for (long long i = (1); i <= (N - 1); i++) {       fact[i] = fact[i - 1] * i % 1000000007;       invfact[i] = invmod(fact[i]);     }     long long ans = ncr(n - 1, 2 * k) * ncr(m - 1, 2 * k) % 1000000007;     cout << ans <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline int read() {     int data = 0, w = 1;     char ch = getchar();     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) w = -1, ch = getchar();     while (ch >=  0  && ch <=  9 )       data = (data << 3) + (data << 1) + (ch ^ 48), ch = getchar();     return data * w;   }   const int maxn(200010);   long long n, a[maxn], x, f, ans;   int main() {     n = read();     for (register int i = 1; i <= n; i++) a[i] = read();     x = read();     f = read();     for (register int i = 1; i <= n; i++) {       a[i] -= x;       if (a[i] > 0) {         if (!(a[i] % (x + f)))           ans += (a[i] / (x + f)) * f;         else           ans += (1 + a[i] / (x + f)) * f;       }     }     printf( %I64d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     long long int n, l, r;     cin >> n >> l >> r;     if (n == 0) {       cout << 0 << endl;       return 0;     } else if (n == 1) {       cout << 1 << endl;       return 0;     } else if (n == 2) {       vector<long long int> a;       a.push_back(1), a.push_back(0), a.push_back(1);       int i;       int c = 0;       for (i = l - 1; i < r; i++) {         if (a[i] == 1) c++;       }       cout << c << endl;       return 0;     } else if (n == 3) {       vector<long long int> a;       a.push_back(1), a.push_back(1), a.push_back(1);       int i;       int c = 0;       for (i = l - 1; i < r; i++) {         if (a[i] == 1) c++;       }       cout << c << endl;       return 0;     }     long long int t = n;     long long int ct = 1;     while (t != 3 && t != 2) {       ct++;       t = t / 2;     }     long long int tt = n;     long long int ans3 = 0;     while (tt > 3) {       long long int kk = 0;       long long int vv = 0;       long long int ll, rr;       vv = pow(2, ct);       ll = l - vv - 1;       if (ll >= 0) {         ll = ll / pow(2, ct + 1) + 1;       }       rr = r - vv + 1;       if (rr >= 0) {         rr = rr / pow(2, ct + 1) + 1;       }       if (ll < 0) ll = 0;       if ((rr >= 0 && ll >= 0) && (tt & 1)) {         ans3 += rr - ll;       }       kk++;       ct--;       tt = tt / 2;     }     if (t == 2) {       long long int ans;       long long int left = 0;       long long int right = 0;       left = 2 * ((l - 1) / 4);       if ((l - 1) % 4 == 1 || ((l - 1) % 4) == 2)         left++;       else if ((l - 1) % 4 == 3)         left += 2;       right = 2 * (r / 4);       if ((r % 4) == 1 || (r % 4) == 2)         right++;       else if ((r % 4) == 3)         right += 2;       ans = right - left;       t = 2 * t + t % 2;       cout << ans + ans3 << endl;     } else if (t == 3) {       long long int ans;       long long int left = 0;       long long int right = 0;       left = 3 * ((l - 1) / 4);       left += (l - 1) % 4;       right = 3 * (r / 4);       right += r % 4;       ans = right - left;       cout << ans + ans3 << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   const int MaxN = 1010;   const int INF = 1000000000;   int n;   int x[MaxN], y[MaxN], tx[MaxN], ty[MaxN];   long double L, R;   long double det(long double x1, long double y1, long double x2, long double y2,                   long double x3, long double y3) {     return x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3;   }   void line(long double x1, long double y1, long double x2, long double y2,             long double y0, long double& x0) {     long double A = y1 - y2;     long double B = x2 - x1;     long double C = A * x1 + B * y1;     x0 = (C - B * y0) / A;   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i];     L = x[1], R = x[2];     if (L > R) {       for (int i = 1, j = 2; i <= n; ++i) {         tx[i] = x[j];         ty[i] = -y[j];         --j;         if (!j) j = n;       }       for (int i = 1; i <= n; ++i) {         x[i] = tx[i];         y[i] = ty[i];       }       swap(L, R);     }     for (int i = 3; i <= n; ++i) {       int px = x[1], py = y[1];       for (int j = i + 1; j <= n; ++j)         if (det(x[i], y[i], x[j], y[j], px, py) > 0) {           px = x[j];           py = y[j];         }       long double tmp;       line(x[i], y[i], px, py, y[1], tmp);       L = max(L, tmp);       px = x[2], py = y[2];       for (int j = 3; j < i; ++j)         if (det(x[i], y[i], px, py, x[j], y[j]) > 0) {           px = x[j];           py = y[j];         }       line(x[i], y[i], px, py, y[1], tmp);       R = min(R, tmp);     }     int ans = 0;     for (int i = L - 1; i <= R + 1; ++i)       if (L <= i && i <= R) ++ans;     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T>   istream& operator>>(istream& is, vector<T>& v) {     for (T& x : v) is >> x;     return is;   }   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& v) {     for (int i = 0; i < (int)v.size(); i++) {       os << v[i] << (i + 1 == (int)v.size() ?    :    );     }     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const pair<T, U>& p) {     os <<  (  << p.first <<  ,  << p.second <<  ) ;     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const map<T, U>& m) {     os <<  { ;     for (auto itr = m.begin(); itr != m.end();) {       os <<  (  << itr->first <<  ,  << itr->second <<  ) ;       if (++itr != m.end()) os <<  , ;     }     os <<  } ;     return os;   }   template <typename T, typename U>   ostream& operator<<(ostream& os, const unordered_map<T, U>& m) {     os <<  { ;     for (auto itr = m.begin(); itr != m.end();) {       os <<  (  << itr->first <<  ,  << itr->second <<  ) ;       if (++itr != m.end()) os <<  , ;     }     os <<  } ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const set<T>& s) {     os <<  { ;     for (auto itr = s.begin(); itr != s.end();) {       os << *itr;       if (++itr != s.end()) os <<  , ;     }     os <<  } ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const multiset<T>& s) {     os <<  { ;     for (auto itr = s.begin(); itr != s.end();) {       os << *itr;       if (++itr != s.end()) os <<  , ;     }     os <<  } ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const unordered_set<T>& s) {     os <<  { ;     for (auto itr = s.begin(); itr != s.end();) {       os << *itr;       if (++itr != s.end()) os <<  , ;     }     os <<  } ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const deque<T>& v) {     for (int i = 0; i < (int)v.size(); i++) {       os << v[i] << (i + 1 == (int)v.size() ?    :    );     }     return os;   }   template <int i, typename T>   void print_tuple(ostream&, const T&) {}   template <int i, typename T, typename H, class... Args>   void print_tuple(ostream& os, const T& t) {     if (i) os <<  , ;     os << get<i>(t);     print_tuple<i + 1, T, Args...>(os, t);   }   template <typename... Args>   ostream& operator<<(ostream& os, const tuple<Args...>& t) {     os <<  { ;     print_tuple<0, tuple<Args...>, Args...>(os, t);     return os <<  } ;   }   void debug_out() { cerr <<   n ; }   template <class Head, class... Tail>   void debug_out(Head&& head, Tail&&... tail) {     cerr << head;     if (sizeof...(Tail) > 0) cerr <<  ,  ;     debug_out(move(tail)...);   }   template <typename T>   T gcd(T x, T y) {     return y != 0 ? gcd(y, x % y) : x;   }   template <typename T>   T lcm(T x, T y) {     return x / gcd(x, y) * y;   }   int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }   int topbit(long long t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }   int botbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }   int botbit(long long a) { return a == 0 ? 64 : __builtin_ctzll(a); }   int popcount(signed t) { return __builtin_popcount(t); }   int popcount(long long t) { return __builtin_popcountll(t); }   bool ispow2(int i) { return i && (i & -i) == i; }   template <class T>   T ceil(T x, T y) {     assert(y >= 1);     return (x > 0 ? (x + y - 1) / y : x / y);   }   template <class T>   T floor(T x, T y) {     assert(y >= 1);     return (x > 0 ? x / y : (x - y + 1) / y);   }   template <class T1, class T2>   inline bool chmin(T1& a, T2 b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T1, class T2>   inline bool chmax(T1& a, T2 b) {     if (a < b) {       a = b;       return true;     }     return false;   }   const int INF = 1e9;   const long long IINF = 1e18;   const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};   const char dir[4] = { D ,  R ,  U ,  L };   const long long MOD = 1000000007;   void solve() {     long long n;     cin >> n;     long long l = -(n - 1), r = n;     cout << l <<     << r <<   n ;   }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int t;     cin >> t;     for (; t--;) solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string s1, s2;       cin >> s1 >> s2;       int len1 = s1.length(), len2 = s2.length();       int a[26] = {0}, mark = 0;       multiset<char, greater<int> > st1, st2;       for (int i = 0; i < len1; i++) {         a[s1[i] - 97]++;         st1.insert(s1[i]);       }       for (int i = 0; i < len2; i++) {         if (a[s2[i] - 97] > 0) {           int b[26] = {0};           st2.clear();           for (int j = i; j < len2; j++) {             b[s2[j] - 97]++;             if (b[s2[j] - 97] > a[s2[j] - 97]) {               break;             } else {               st2.insert(s2[j]);             }           }           if (st1 == st2) {             mark = 1;             break;           }         }       }       if (mark == 0)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 2e5 + 5;   const long long SQRTN = 1003;   const long long LOGN = 22;   const double PI = acos(-1.0);   const long long INF = 1e18;   const long long MOD = 1e9 + 7;   const long long FMOD = 998244353;   const double eps = 1e-9;   void __print(long long x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());   template <typename T>   T gcd(T a, T b) {     if (b == 0) return a;     a %= b;     return gcd(b, a);   }   template <typename T>   T lcm(T a, T b) {     return (a * (b / gcd(a, b)));   }   long long add(long long a, long long b, long long c = MOD) {     long long res = a + b;     return (res >= c ? res % c : res);   }   long long sub(long long a, long long b, long long c = MOD) {     long long res;     if (abs(a - b) < c)       res = a - b;     else       res = (a - b) % c;     return (res < 0 ? res + c : res);   }   long long mul(long long a, long long b, long long c = MOD) {     long long res = (long long)a * b;     return (res >= c ? res % c : res);   }   long long muln(long long a, long long b, long long c = MOD) {     long long res = (long long)a * b;     return ((res % c) + c) % c;   }   long long mulmod(long long a, long long b, long long m = MOD) {     long long q = (long long)(((long double)a * (long double)b) / (long double)m);     long long r = a * b - q * m;     if (r > m) r %= m;     if (r < 0) r += m;     return r;   }   template <typename T>   T binpow(T e, T n) {     T x = 1, p = e;     while (n) {       if (n & 1) x = x * p;       p = p * p;       n >>= 1;     }     return x;   }   template <typename T>   T binpow2(T e, T n, T m = MOD) {     T x = 1, p = e;     while (n) {       if (n & 1) x = mul(x, p, m);       p = mul(p, p, m);       n >>= 1;     }     return x;   }   template <typename T>   T extended_euclid(T a, T b, T &x, T &y) {     T xx = 0, yy = 1;     y = 0;     x = 1;     while (b) {       T q = a / b, t = b;       b = a % b;       a = t;       t = xx;       xx = x - q * xx;       x = t;       t = yy;       yy = y - q * yy;       y = t;     }     return a;   }   template <typename T>   T mod_inverse(T a, T n = MOD) {     T x, y, z = 0;     T d = extended_euclid(a, n, x, y);     return (d > 1 ? -1 : sub(x, z, n));   }   const long long FACSZ = 1e4;   long long fact[FACSZ], ifact[FACSZ];   void precom(long long c = MOD) {     fact[0] = 1;     for (long long i = 1; i < FACSZ; i++) fact[i] = mul(fact[i - 1], i, c);     ifact[FACSZ - 1] = mod_inverse(fact[FACSZ - 1], c);     for (long long i = FACSZ - 1 - 1; i >= 0; i--) {       ifact[i] = mul(i + 1, ifact[i + 1], c);     }   }   vector<long long> primes;   void prime_precom() {     primes.push_back(2);     for (long long x = 3; primes.size() <= MAXN; x += 2) {       bool isPrime = true;       for (auto p : primes) {         if (x % p == 0) {           isPrime = false;           break;         }         if (p * p > x) {           break;         }       }       if (isPrime) {         primes.push_back(x);       }     }   }   long long ncr(long long n, long long k) {     if (n < k) return 0;     if (k == 0) return 1;     long long res = 1;     if (k > n - k) k = n - k;     for (long long i = 0; i < k; ++i) {       res *= (n - i);       res /= (i + 1);     }     return res;   }   long long ncr_modp(long long n, long long k, long long c = MOD) {     if (n < k) return 0;     if (k == 0) return 1;     long long res = 1;     if (k > n - k) k = n - k;     for (long long i = 0; i < k; ++i) {       res = mul(res, n - i, c);       res = mul(res, binpow2(i + 1, c - 2, c), c);     }     return res;   }   vector<long long> factors;   void factorize(long long a) {     factors.clear();     for (long long i = 1; i * i <= a; i++) {       if (a % i == 0) {         factors.push_back(i);         factors.push_back(a / i);       }     }     sort(factors.begin(), factors.end());   }   long long ncr_precom(long long n, long long r, long long c = MOD) {     return mul(mul(ifact[r], ifact[n - r], c), fact[n], c);   }   long long ceil(long long a, long long b) { return (a + b - 1) / b; }   bool is_prime(long long n) {     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) {         return 0;       }     }     return 1;   }   bool diophantine_checker(long long a, long long b, long long n) {     for (long long i = 0; i * a <= n; i++) {       if ((n - (i * a)) % b == 0) {         return true;       }     }     return false;   }   long long count_divisors(long long n) {     long long c;     long long ans = 1;     for (long long i = 2; i * i <= n; i++) {       c = 0;       while (n % i == 0) {         c++;         n /= i;       }       ans *= (c + 1);     }     if (n > 2) {       return ans * 2;     }     return ans;   }   string to_binary(long long n) {     string r;     while (n != 0) {       r = (n % 2 == 0 ?  0  :  1 ) + r;       n /= 2;     }     return r;   }   bool ispower2(long long x) { return x && (!(x & (x - 1))); }   vector<long long> spf;   void sieve() {     spf.resize(MAXN);     spf[1] = 1;     for (long long i = 2; i < MAXN; i++) {       spf[i] = i;     }     for (long long i = 4; i < MAXN; i += 2) {       spf[i] = 2;     }     for (long long i = 3; i * i <= MAXN; i++) {       if (spf[i] == i) {         for (long long j = i * i; j < MAXN; j += i) {           if (spf[j] == j) {             spf[j] = i;           }         }       }     }   }   void pfactor(long long x, vector<long long> &ret) {     while (x != 1) {       ret.push_back(spf[x]);       x = x / spf[x];     }   }   struct point {     long long x, y;     void read() { cin >> x >> y; }     point operator-=(const point &b) { return {x -= b.x, y -= b.y}; }     long long operator*(const point &b) { return x * b.y - y * b.x; }     point operator-(const point &b) { return {x - b.x, y - b.y}; }   };   long long n, k;   long double dist[MAXN], angle[MAXN];   bool check(long double r) {     vector<pair<long double, long long>> val;     long long cnt = 0;     for (long long i = 0; i < n; i++) {       if (dist[i] + eps >= 2 * r) {         continue;       }       long double bd = acos(dist[i] / (2. * r));       long double mn = angle[i] - bd, mx = angle[i] + bd;       while (mn < -PI) {         mn += 2 * PI;       }       while (mx < -PI) {         mx += 2 * PI;       }       while (mn > PI) {         mn -= 2 * PI;       }       while (mx > PI) {         mx -= 2 * PI;       }       val.push_back(make_pair(mn, 1));       val.push_back(make_pair(mx, -1));       if (mn > mx) {         cnt += 1;       }     }     long long ans = cnt;     sort(val.begin(), val.end());     for (auto x : val) {       cnt += x.second, ans = max(ans, cnt);     }     return ans >= k;   }   void solvethetestcase() {     cin >> n >> k;     vector<point> vv;     for (long long i = 0; i < n; i++) {       long long xx, yy;       cin >> xx >> yy;       if (xx == 0 && yy == 0) {         --k, --n, --i;       } else {         vv.push_back(point{xx, yy});       }     }     if (k <= 0) {       cout << 0.0 <<   n ;       return;     }     for (long long i = 0; i < n; i++) {       angle[i] = atan2(vv[i].y, vv[i].x);       dist[i] = sqrtl(1. * vv[i].x * vv[i].x + 1. * vv[i].y * vv[i].y);     }     long double l = 0, r = 2e5;     for (long long i = 0; i < 50; i++) {       long double md = (l + r) * 0.5;       if (check(md)) {         r = md;       } else {         l = md;       }     }     cout << r <<   n ;   }   signed main() {     cout << fixed << setprecision(12);     ;     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     for (long long testcase = 1; testcase < t + 1; testcase++) {       solvethetestcase();     }   }


#include <bits/stdc++.h>   using namespace std;   int a[105];   int n, k;   char s[105];   int main(void) {     int i, j, x, y, z;     scanf( %d %d , &n, &k);     scanf( %s , s);     x = 0;     for (i = 0; i < s[i]; i++) {       a[x++] = s[i] -  a  + 1;     }     sort(a, a + n);     x = 1;     y = a[0];     z = 0;     if (x == k) {       printf( %d n , y);       return 0;     }     for (i = 1; i < n; i++) {       if (a[i] - a[z] > 1) {         x++;         y += a[i];         z = i;         if (x == k) break;       }     }     if (i >= n) {       printf( -1 );       return 0;     }     printf( %d n , y);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, k = 0, k1 = 0, kol1 = 0, kol2 = 0;     cin >> n >> m;     int a[n + 10], b[m + 10];     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] % 2 == 1)         k++;       else         k1++;     }     for (int i = 1; i <= m; i++) {       cin >> b[i];       if (b[i] % 2 == 1)         kol1++;       else         kol2++;     }     cout << min(k, kol2) + min(k1, kol1);   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, a, b, x, y, flag = 0;     cin >> n >> a >> x >> b >> y;     int in = 0;     for (int i = 0; i < n; i++) {       a = a % n + 1;       b = b - 1;       if (b == 0) b = n;       if (a == b) {         cout <<  YES ;         flag = 1;         break;       }       if (a == x or b == y) break;     }     if (flag == 0) cout <<  NO ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[301];   int l[301], r[301];   void INPUT() {     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) cin >> l[i] >> r[i];   }   void SOLVE() {     int res = 0;     int ans[301], tam[301];     int sl = 0;     int i, j, k;     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++)         if (i == j)           continue;         else {           int dem = 0;           for (k = 1; k <= m; k++)             if (l[k] <= j & j <= r[k] & (l[k] > i || r[k] < i)) {               dem++;               tam[dem] = k;             }           if (res < a[i] - a[j] + dem) {             res = a[i] - a[j] + dem;             sl = dem;             for (k = 1; k <= sl; k++) ans[k] = tam[k];           }         }     cout << res << endl;     cout << sl << endl;     for (i = 1; i <= sl; i++) cout << ans[i] <<    ;   }   int main() {     INPUT();     SOLVE();   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 500010;   bool f[MAXN];   int main() {     int n, d;     scanf( %d %d , &n, &d);     f[0] = 1;     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       for (int j = MAXN - 1 - x; j >= 0; --j) f[j + x] |= f[j];     }     int r = 1, sum = 0, ans = 0;     while (r < MAXN) {       int next = -1;       while (r <= sum + d && r < MAXN) {         if (f[r]) next = r;         r++;       }       if (next == -1) break;       sum = next;       ans++;     }     printf( %d %d n , sum, ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 7;   long long a[N];   long long l[N];   long long r[N];   int32_t main() {     long long ans = 0, n, i;     for (i = 1, scanf( %I64d , &n); i <= n; scanf( %I64d , &a[i++]))       ;     for (i = 1; i <= n; l[i] = r[i] = i, i++)       ;     for (i = 2; i <= n; i++) {       long long num = i;       while (num > 1 && a[num - 1] <= a[i]) num = l[num - 1];       l[i] = num;     }     for (i = n - 1; i >= 1; i--) {       long long num = i;       while (num < n && a[num + 1] < a[i]) num = r[num + 1];       r[i] = num;     }     for (i = 1; i <= n; ans += (i - l[i] + 1) * (r[i] - i + 1) * a[i], i++)       ;     for (i = 1; i <= n; l[i] = r[i] = i, i++)       ;     for (i = 2; i <= n; i++) {       long long num = i;       while (num > 1 && a[num - 1] >= a[i]) num = l[num - 1];       l[i] = num;     }     for (i = n - 1; i >= 1; i--) {       long long num = i;       while (num < n && a[num + 1] > a[i]) num = r[num + 1];       r[i] = num;     }     for (i = 1; i <= n; i++) {       ans -= (i - l[i] + 1) * (r[i] - i + 1) * a[i];     }     printf( %I64d n , ans);   }


#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353, inv2 = (mod + 1) / 2;   const int N = (1 << 24);   int n, m, X, Y, Z, mu, v1, v2, v3, v4, inv;   vector<int> a, b, c, ans;   inline int add(const int &x, const int &y) {     return x + y < mod ? x + y : x + y - mod;   }   inline int sub(const int &x, const int &y) {     return x - y < 0 ? x - y + mod : x - y;   }   inline int mul(const int &x, const int &y) {     return (int)((long long)x * y % mod);   }   int ksm(int x, int y = mod - 2) {     int ss = 1;     for (; y; y >>= 1, x = mul(x, x))       if (y & 1) ss = mul(ss, x);     return ss;   }   void fwt(vector<int> &A, int lmt, int opt) {     A.resize(lmt);     for (int mid = 1; mid < lmt; mid <<= 1)       for (int j = 0; j < lmt; j += mid << 1)         for (int k = 0; k < mid; k++) {           int x = A[j + k], y = A[j + mid + k];           A[j + k] = add(x, y), A[j + mid + k] = sub(x, y);           if (opt == -1) {             A[j + k] = mul(A[j + k], inv2);             A[j + mid + k] = mul(A[j + mid + k], inv2);           }         }   }   int main() {     scanf( %d%d , &n, &m), m = 1 << m, inv = ksm(4);     a.resize(m), b.resize(m), c.resize(m), ans.resize(m);     scanf( %d%d%d , &X, &Y, &Z);     for (int i = 1, x, y, z; i <= n; i++) {       scanf( %d%d%d , &x, &y, &z), mu ^= x;       ++a[x ^ y], ++b[x ^ z], ++c[y ^ z];     }     fwt(a, m, 1), fwt(b, m, 1), fwt(c, m, 1);     v1 = add(X, add(Y, Z)), v2 = add(X, sub(Y, Z));     v3 = add(X, sub(Z, Y)), v4 = sub(X, add(Z, Y));     for (int i = 0; i < m; i++) {       int x1 = ksm(           v1, ((long long)n + a[i] + b[i] + c[i] + 4ll * mod) % mod * inv % mod);       int x2 = ksm(           v2, ((long long)n + a[i] - b[i] - c[i] + 4ll * mod) % mod * inv % mod);       int x3 = ksm(           v3, ((long long)n - a[i] + b[i] - c[i] + 4ll * mod) % mod * inv % mod);       int x4 = ksm(           v4, ((long long)n - a[i] - b[i] + c[i] + 4ll * mod) % mod * inv % mod);       ans[i] = mul(x1, mul(x2, mul(x3, x4)));     }     fwt(ans, m, -1);     for (int i = 0; i < m; i++) printf( %d  , ans[i ^ mu]);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   int fans = 1;   long long getnum(long long x) {     long long fx, fy;     if (x >= (n - k + 1)) {       fx = (n - k + 1 + 1) * (n - k + 1) / 2 + (x - (n - k + 1)) * (n - k + 1);     } else {       fx = (x - 1 + 1) * (x - 1) / 2 + (n - k + 1);     }     if (x >= k) {       fy = (k + 1) * k / 2 + (x - k) * k;     } else {       fy = (x - 1 + 1) * (x - 1) / 2 + k;     }     return fx + fy - x;   }   void start(int l, int r) {     if ((l + r) / 2 == l) {       if (getnum((l + r) / 2) <= m) fans = (l + r) / 2;       return;     }     int mid = (l + r) / 2;     if (getnum(mid) <= m) {       fans = max(fans, mid);       start(mid + 1, r);     } else       start(l, mid);   }   int main() {     cin >> n >> m >> k;     start(1, m);     cout << fans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     char ch[106][106];     scanf( %d%d  , &n, &m);     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> ch[i][j];     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j)         if (ch[i][j] ==  C  || ch[i][j] ==  M  || ch[i][j] ==  Y ) {           printf( #Color n );           return 0;         }     printf( #Black&White n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m;   int cnt[2][2];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       cnt[0][x % 2]++;     }     for (int i = 1; i <= m; i++) {       int x;       cin >> x;       cnt[1][x % 2]++;     }     cout << min(cnt[0][0], cnt[1][1]) + min(cnt[0][1], cnt[1][0]) <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     long long ans = 0;     for (int i = (0); i < (n); ++i) {       long long t, T, x, cost;       cin >> t >> T >> x >> cost;       if (t >= T) {         ans += cost + m * x;         continue;       }       long long aux1 = cost;       if (m > (T - t)) aux1 += m * x;       long long aux2 = (long long)ceil((double)(m - (T - t)) / (T - t)) + 1;       aux2 *= cost;       ans += min(aux1, aux2);     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 10;   int ans[maxn];   bool build(int l, int r, int base, int top, int sum) {     if (l > r) return true;     int len = r - l + 1;     int tmp = len * base;     if (tmp > sum) return false;     if (tmp == sum) {       for (int i = l; i <= r; ++i) ans[i] = base;       return true;     }     if (base == top) return false;     if (tmp + len >= sum) {       for (int i = l; i <= r; ++i) {         sum -= base;         ans[i] = base;       }       for (int i = l; i <= r; ++i) {         if (!sum) break;         sum--;         ans[i]++;       }       return true;     }     return false;   }   int main() {     int n, k, l, r, sall, sk;     scanf( %d%d%d%d%d%d , &n, &k, &l, &r, &sall, &sk);     int lim;     for (int i = r; i >= l; --i) {       if (build(1, k, i, r, sk)) {         lim = i;         break;       }     }     for (int i = lim; i >= l; --i) {       if (build(k + 1, n, i, lim, sall - sk)) {         break;       }     }     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     puts(  );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long int INF = 2000000000000000000;   long long int MOD(long long int a, long long int b) {     if (a > b)       return a - b;     else       return b - a;   }   long long int max3(long long int a, long long int b, long long int c) {     return max(c, max(a, b));   }   long long int min3(long long int a, long long int b, long long int c) {     return min(a, min(b, c));   }   long long int power(long long int x, long long int y) {     long long int res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % 1000000007;       y = y >> 1;       x = (x * x) % 1000000007;     }     return res;   }   long long int logg(long long int a) {     long long int x = 0;     while (a > 1) {       x++;       a /= 2;     }     return x;   }   long long int gcd(long long int a, long long int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   int main() {     int n, m;     cin >> n >> m;     vector<string> grid;     grid.resize(n);     for (int i = 0; i < n; i++) {       cin >> grid[i];     }     vector<int> columns;     columns.resize(n, 0);     vector<int> rows;     rows.resize(m, 0);     for (int i = 0; i < n; i++) {       vector<int> cnt;       for (int j = 0; j < m; j++) {         if (grid[i][j] ==  # ) {           cnt.push_back(j);         }       }       if (!cnt.empty()) {         vector<int> b;         for (int j = 0; j < n; j++) {           if (grid[j][cnt[0]] ==  # ) {             b.push_back(j);           }         }         sort(b.begin(), b.end());         sort(cnt.begin(), cnt.end());         for (int j = 0; j < cnt.size(); j++) {           int num = 0;           for (int i = 0; i < n; i++) {             if (grid[i][cnt[j]] ==  #  &&                 binary_search(b.begin(), b.end(), i) == false) {               cout <<  NO ;               return 0;             } else {               if (grid[i][cnt[j]] ==  # ) {                 num++;               }             }           }           if (num != b.size()) {             cout <<  NO ;             return 0;           }         }         for (int i = 0; i < b.size(); i++) {           int num = 0;           for (int j = 0; j < m; j++) {             if (grid[b[i]][j] ==  #  &&                 binary_search(cnt.begin(), cnt.end(), j) == false) {               cout <<  NO ;               return 0;             } else {               if (grid[b[i]][j] ==  # ) {                 num++;               }             }           }           if (num != cnt.size()) {             cout <<  NO ;             return 0;           }         }       }     }     cout <<  YES ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const long long mod = 1e9 + 7;   const int inf = 1 << 30;   const int maxn = 900500;   const double EPS = 1e-7;   struct da {     int x, ty;     double p;     bool operator<(const da& ot) const {       return (make_pair(x, make_pair(ty, p)) <               make_pair(ot.x, make_pair(ot.ty, ot.p)));     }   };   vector<da> ev;   void solve() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < (int)(n); ++i) {       int ai, hi, li, ri;       scanf( %d%d , &ai, &hi);       scanf( %d%d , &li, &ri);       double lp = 1.0 - li / 100., rp = 1.0 - ri / 100.;       ev.push_back({ai - hi, -1, lp});       ev.push_back({ai - 1, 1, lp});       ev.push_back({ai + 1, -1, rp});       ev.push_back({ai + hi, 1, rp});     }     for (int i = 0; i < (int)(m); ++i) {       int bj, zj;       scanf( %d%d , &bj, &zj);       ev.push_back({bj, 0, 1. * zj});     }     sort(ev.begin(), ev.end());     int ze = 0;     double pr = 0, ret = 0;     for (auto e : ev) {       if (e.ty == 0) {         if (!ze) ret += exp(pr) * e.p;       } else if (e.ty == -1) {         if (abs(e.p) < 1e-7)           ++ze;         else           pr += log(e.p);       } else {         if (abs(e.p) < 1e-7)           --ze;         else           pr -= log(e.p);       }     }     printf( %lf n , ret);   }   int main() {     int tc = 1;     for (int tt = 0; tt < (int)(tc); ++tt) {       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   int main(int argc, char *argv[]) {     int t;     cin >> t;     while (t--) {       int len;       cin >> len;       string s1, s2;       cin >> s1 >> s2;       int cnt1 = 0, cnt2 = 0;       if (s1[0] >  2 ) {         cnt1++;         if (s2[0] <=  2 ) {           puts( NO );           continue;         }         cnt2++;       }       bool flag = true;       for (int i = 1; i < s1.size(); ++i) {         if (cnt1 % 2) {           if (s2[i] >  2 ) {             cnt2++;             if (s1[i] <=  2 ) {               flag = false;               break;             }             cnt1++;           }         } else {           if (s1[i] >  2 ) {             cnt1++;             if (s2[i] <=  2 ) {               flag = false;               break;             }             cnt2++;           }         }       }       if (cnt2 % 2 == 0) flag = false;       if (flag) {         puts( YES );       } else {         puts( NO );       }     }   }


#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(time(0));   const long long N = 3e5 + 7;   const long long MOD = 1e9 + 7;   long long pw(long long b, long long p) {     b %= MOD;     long long res = 1;     while (p > 0) {       if (p & 1) res = res * b % MOD;       b = b * b % MOD;       p >>= 1;     }     return res;   }   long long n, m, cur;   vector<vector<pair<long long, char>>> g(107);   bool vis[107][107][26], dp[107][107][26];   bool dfs(long long u, long long v, char ch) {     if (vis[u][v][ch -  a ]) return dp[u][v][ch -  a ];     for (auto i : g[u]) {       if (i.second >= ch && !dfs(v, i.first, i.second)) dp[u][v][ch -  a ] = 1;     }     vis[u][v][ch -  a ] = 1;     return dp[u][v][ch -  a ];   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     long long u, v;     char ch;     for (long long i = 1; i < m + 1; i++) {       cin >> u >> v >> ch;       g[u].emplace_back(v, ch);     }     for (long long i = 1; i < n + 1; i++) {       for (long long j = 1; j < n + 1; j++) {         if (dfs(i, j,  a ))           cout <<  A ;         else           cout <<  B ;       }       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T>   struct number_iterator : iterator<random_access_iterator_tag, T> {     T v;     number_iterator(T _v) : v(_v) {}     operator T &() { return v; }     T operator*() const { return v; }   };   template <typename T>   struct number_range {     T b, e;     number_range(T b, T e) : b(b), e(e) {}     number_iterator<T> begin() { return b; }     number_iterator<T> end() { return e; }   };   template <typename T>   number_range<T> range(T e) {     return number_range<T>(0, e);   }   template <typename T>   number_range<T> range(T b, T e) {     return number_range<T>(b, e);   }   template <typename... Args>   void logger(string vars, Args &&...values) {     cout <<  [  << vars <<  ]           <<   =  ;     string delim =   ;     cout <<  [  << (..., (cout << delim << values, delim =  ,  )) <<  ]           <<   n ;   }   template <typename T>   void debug(vector<T> v) {     cout <<  { ;     for (auto i : range(v.size()))       cout << v[i] << (i + 1 == v.size() ?    :  ,  );     cout <<  }           <<   n ;   }   template <typename T, typename S>   void debug(pair<T, S> &p) {     cout <<  ( ;     cout << p.first <<  ,   << p.second;     cout <<  ) ;   }   template <typename T, typename S>   void debug(vector<pair<T, S>> vp) {     cout <<  { ;     for (auto i : range(vp.size())) {       debug(vp[i]);       cout << (i + 1 == vp.size() ?    :  ,  );     }     cout <<  }           <<   n ;   }   template <typename T>   void debug(vector<vector<T>> vv) {     cout <<  [ ;     for (auto i : range(vv.size())) debug(vv[i]);     cout <<  ]           <<   n ;   }   template <typename T>   void debug(T a[], long long n) {     cout <<  { ;     for (auto i : range(n)) cout << a[i] << (i + 1 == n ?    :  ,  );     cout <<  }           <<   n ;   }   template <typename T>   void debug(set<T> s) {     cout <<  { ;     for (auto i = s.begin(); i != s.end();)       cout << *i << (++i == s.end() ?    :  ,  );     cout <<  }           <<   n ;   }   template <typename T>   void debug(multiset<T> s) {     cout <<  { ;     for (auto i = s.begin(); i != s.end();)       cout << *i << (++i == s.end() ?    :  ,  );     cout <<  }           <<   n ;   }   template <typename T1, typename T2>   void debug(map<T1, T2> make_pair) {     cout <<  { ;     for (auto i = make_pair.begin(); i != make_pair.end();)       cout <<  (  << i->first <<   :   << i->second <<  )             << (++i == make_pair.end() ?    :  , );     cout <<  }           <<   n ;   }   long long modExpo(long long a, long long b, long long m = 1000000007) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % m;       a = (a * a) % m;       b = b >> 1;     }     return res;   }   void extendEuclids(long long a, long long b, long long *v) {     if (b == 0) {       v[0] = 1, v[1] = 0, v[2] = a;       return;     }     extendEuclids(b, a % b, v);     long long x = v[1];     v[1] = v[0] - v[1] * (a / b);     v[0] = x;     return;   }   long long modInv(long long a, long long b) {     long long arr[3];     extendEuclids(a, b, arr);     return arr[0];   }   long long modInv_lil(long long a, long long b) { return modExpo(a, b - 2, b); }   long long add(long long a, long long b, long long c = 1000000007) {     long long res = a + b;     return (res >= c ? res - c : res);   }   long long mod_mul(long long a, long long b, long long c = 1000000007) {     long long res = a * b;     return (res >= c ? res % c : res);   }   long long mod_sub(long long a, long long b, long long m = 1000000007) {     a = a % m;     b = b % m;     return (((a - b) % m) + m) % m;   }   long long mod_div(long long a, long long b, long long m = 1000000007) {     a = a % m;     b = b % m;     return (mod_mul(a, modInv_lil(b, m), m) + m) % m;   }   class Solution {    public:     void Solve() {       string t, s;       cin >> t >> s;       deque<char> a, b;       sort((t).begin(), (t).end());       sort((s).begin(), (s).end(), greater<long long>());       long long n = t.length(), i = 0, j = 0, cnt1, cnt2;       string ansr, ansl;       cnt1 = ceil((double)n / (double)2);       cnt2 = n / 2;       for (auto i : range(cnt1)) a.push_back(t[i]);       for (auto i : range(cnt2)) b.push_back(s[i]);       while (i < n) {         if (i & 1) {           if (!a.empty() && a[0] >= b[0]) {             ansr += b.back();             b.pop_back();           } else {             ansl += b[0];             b.pop_front();           }         } else {           if (!b.empty() && a[0] >= b[0]) {             ansr += a.back();             a.pop_back();           } else {             ansl += a[0];             a.pop_front();           }         }         i += 1;       }       reverse((ansr).begin(), (ansr).end());       cout << ansl + ansr;     }   };   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     Solution ob;     { ob.Solve(); }     return 0;   }   template <typename T>   inline T Max(const T a, const T b) {     return a < b ? b : a;   }   template <typename T, typename... Args>   T Max(const T a, const Args... args) {     return Max(a, Max(args...));   }   template <typename T>   inline T Min(const T a, const T b) {     return a < b ? a : b;   }   template <typename T, typename... Args>   T Min(const T a, const Args... args) {     return Min(a, Min(args...));   }   template <typename T>   inline T LCM(const T a, const T b) {     return ((a) * (b)) / __gcd((a), (b));   }   template <typename T, typename... Args>   T LCM(const T a, const Args... args) {     return LCM(a, LCM(args...));   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     int k;     cin >> k;     int n = 2000;     k += n;     int arr[n];     arr[0] = -1;     for (int i = 1; i < 2000; i++) {       if (k >= 1000000)         arr[i] = 1000000;       else         arr[i] = k;       k -= arr[i];     }     cout << 2000 <<   n ;     for (int i = 0; i < 2000; i++) cout << arr[i] <<    ;   }


#include <bits/stdc++.h>   int ___read_tmp;   using namespace std;   int fwt[1010000];   int query(int sz) {     int sum = 0;     sz++;     while (sz > 0) {       sum += fwt[sz];       sz -= sz & (-sz);     }     return sum;   }   void upd(int id, int add) {     id++;     for (; id < 1010000; id += (id & (-id))) {       fwt[id] += add;     }   }   int range(int from, int to) {     if (to < from) return 0;     int tmp = query(to);     if (from > 0) tmp -= query(from - 1);     return tmp;   }   int main() {     int n, k;     scanf( %d %d , &n, &k);     k = min(k, n - k);     unsigned long long res = 1;     int curr = 0;     for (int i = (0); i < (n); i++) {       if (curr + k <= n) {         res += range(curr + 1, curr + k - 1) + 1;       } else {         res += range(curr + 1, n - 1) + range(0, (curr + k) % n - 1) + 1;       }       printf( %I64d  , res);       upd(curr, 1);       curr = (curr + k) % n;       upd(curr, 1);     }     return 0;   }


#include <bits/stdc++.h>   long long mod = 1000000007;   using namespace std;   int n;   int b1[200005];   struct node {     int x, y;   };   bool cmp(node a, node b) { return a.y - a.x > b.y - b.x; }   node a1[200005];   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   int main() {     int i, j, fl, test, k;     scanf( %d%d , &n, &k);     for (i = 0; i < n; i++) {       scanf( %d , &a1[i].x);     }     for (i = 0; i < n; i++) {       scanf( %d , &a1[i].y);     }     long long ans = 0;     sort(a1, a1 + n, cmp);     for (i = 0; i < n; i++) {       if (k) {         ans += a1[i].x;         k--;       } else         ans += min(a1[i].x, a1[i].y);     }     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int f[100010], r[2][100010];   vector<int> mat[2][100010];   void DFS(int a, int x) {     r[x][a] = 1;     if (x == 1 && f[a] == 1) return;     for (int i = 0; i < mat[x][a].size(); i++) {       int b = mat[x][a][i];       if (!r[x][b]) DFS(b, x);     }   }   int main() {     int n, m, a, b;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> f[i];     for (int i = 0; i < m; i++) {       cin >> a >> b;       a--;       b--;       mat[0][a].push_back(b);       mat[1][b].push_back(a);     }     for (int i = 0; i < n; i++)       if (!r[0][i] && f[i] == 1 && mat[0][i].size())         DFS(i, f[i] - 1);       else if (!r[1][i] && f[i] == 2)         DFS(i, f[i] - 1);     for (int i = 0; i < n; i++)       if (r[0][i] && r[1][i])         cout << 1 <<    ;       else         cout << 0 <<    ;     cout << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long good[3000];   long long fact[20];   int q = 0;   void gen(long long sum, int left) {     if (!left) {       good[q++] = sum;     } else {       if (!sum) {         gen(sum, left - 1);       }       gen(sum * 10 + 4, left - 1);       gen(sum * 10 + 7, left - 1);     }   }   bool is_lucky(int v) {     while (v) {       if (v % 10 != 4 && v % 10 != 7) {         return false;       }       v /= 10;     }     return true;   }   void true_main() {     gen(0, 10);     vector<int> per(20);     vector<bool> fre(20);     int n;     long long k;     fact[0] = 1;     for (int i = 1; i < 20; i++) {       fact[i] = fact[i - 1] * i;     }     cin >> n >> k;     if (n < 15) {       if (k > fact[n]) {         puts( -1 );         return;       }     }     int ans = 0;     for (int i = 1; i < q; i++) {       if (good[i] <= n - 15) {         ans++;       }     }     int m = min(n, 15);     k--;     for (int i = 0; i < m; i++) {       long long q = k / fact[m - i - 1];       k -= q * fact[m - i - 1];       for (int j = 0;; j++) {         if (!fre[j]) {           if (!q) {             fre[j] = true;             per[i] = j;             break;           }           q--;         }       }     }     for (int i = 0; i < m; i++) {       if (is_lucky(n - m + per[i] + 1) && is_lucky(n - m + i + 1)) {         ans++;       }     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) {       true_main();       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     long long int ans = 0;     long long int t = 1;     long long int x = 2;     while (n - (t * (t + 1) / 2) >= 0) {       long long int val = t * (t + 1) / 2;       n -= val;       t += x;       x *= 2;       ans++;     }     cout << ans << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, count[8] = {0};     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       count[x] = count[x] + 1;     }     if ((count[5] == 0) && (count[7] == 0) && (count[2] >= count[4]) &&         (count[1] == count[4] + count[6]) &&         (count[2] + count[3] == count[4] + count[6])) {       for (int i = 0; i < count[4]; i++) {         cout <<  1 2 4  << endl;       }       count[2] -= count[4];       for (int i = 0; i < count[2]; i++) {         cout <<  1 2 6  << endl;       }       for (int i = 0; i < count[3]; i++) {         cout <<  1 3 6  << endl;       }     } else {       cout <<  -1  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int grid[n][n];     int nro = 1;     for (int i = 0; i < n; i++) {       if (!(i & 1))         for (int j = 0; j < n; j++) grid[j][i] = nro++;       else         for (int j = 0; j < n; j++) grid[n - 1 - j][i] = nro++;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) cout << grid[i][j] <<    ;       cout << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   inline long long mod(long long n, long long m) {     long long ret = n % m;     if (ret < 0) ret += m;     return ret;   }   long long gcd(long long a, long long b) {     return (b == 0LL ? a : gcd(b, a % b));   }   long long exp(long long a, long long b, long long m) {     if (b == 0LL) return 1LL;     if (b == 1LL) return mod(a, m);     long long k = mod(exp(a, b / 2, m), m);     if (b & 1LL) {       return mod(a * mod(k * k, m), m);     } else       return mod(k * k, m);   }   vector<int> z_function(string s) {     int n = s.size();     vector<int> z(n);     int L = 0, R = 0;     for (int i = 1; i < n; i++) {       if (i <= R) {         if (i - L + z[i - L] > i - L + (R - i)) {           z[i] = R - i + 1;           while (i + z[i] < n and s[z[i]] == s[z[i] + i]) {             z[i]++;           }         } else           z[i] = z[i - L];       } else {         while (i + z[i] < n and s[z[i]] == s[z[i] + i]) {           z[i]++;         }       }       if (i + z[i] - 1 > R) {         L = i, R = i + z[i] - 1;       }     }     return z;   }   const int N = 1000100;   int n, m, k;   vector<int> order[N];   vector<int> get(string s, string t) {     string aux = t +  #  + s;     vector<int> z = z_function(aux);     for (int i = 0; i < N; i++) order[i].clear();     for (int i = 0; i < n; i++) {       if (z[i + m + 1] > 0) order[z[i + m + 1]].push_back(i);     }     set<int> best;     vector<int> res((int)s.size() + 10, -1);     for (int x = m; x > 0; x--) {       for (int id : order[x]) {         best.insert(id);       }       auto it = best.lower_bound(k - x);       if (it == best.end()) continue;       res[x] = *it;     }     return res;   }   vector<int> lpos, rpos;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m >> k;     string s, t;     cin >> s >> t;     string aux = t +  #  + s;     vector<int> z = z_function(aux);     for (int i = 0; i < n; i++) {       if (z[i + 1 + m] >= m) {         cout <<  Yes               <<   n ;         int l = min(i + 1, n - 2 * k + 1);         int r = l + k;         cout << l <<     << r <<   n ;         return 0;       }     }     lpos = get(s, t);     reverse(s.begin(), s.end());     reverse(t.begin(), t.end());     rpos = get(s, t);     for (int i = 1; i <= min(m - 1, k); i++) {       if (m - i > k) continue;       int id1 = lpos[i], id2 = rpos[m - i];       if (id1 == -1 or id2 == -1) continue;       int L = lpos[i] + i - 1, R = rpos[m - i] + (m - i) - 1;       if (L + R >= n - 1) continue;       id1 = lpos[i] + i - (k - 1);       id2 = n - rpos[m - i] - (m - i) + 1;       if (id1 + k - 1 < id2 and id2 + k - 1 <= n) {         cout <<  Yes               <<   n ;         cout << id1 <<     << id2 <<   n ;         return 0;       }     }     cout <<  No           <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3;   const double eps = 1e-8;   int n;   struct point {     double x, y, z;   } p[maxn], pp;   double dis(point a, point b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) +            (a.z - b.z) * (a.z - b.z);   }   double get(double x, double y, double z) {     double res = 0;     for (int i = 1; i <= n; i++) res = max(res, dis(point{x, y, z}, p[i]));     return res;   }   double findz(double x, double y) {     double l = -1e4, r = 1e4;     while (r - l > eps) {       double m1 = (l + l + r) / 3;       double m2 = (l + r + r) / 3;       if (get(x, y, m1) < get(x, y, m2))         r = m2;       else         l = m1;     }     pp.z = (l + r) / 2;     return get(x, y, (l + r) / 2);   }   double findy(double x) {     double l = -1e4, r = 1e4;     while (r - l > eps) {       double m1 = (l + l + r) / 3;       double m2 = (l + r + r) / 3;       if (findz(x, m1) < findz(x, m2))         r = m2;       else         l = m1;     }     pp.y = (l + r) / 2;     return findz(x, (l + r) / 2);   }   double findx() {     double l = -1e4, r = 1e4;     while (r - l > eps) {       double m1 = (l + l + r) / 3;       double m2 = (l + r + r) / 3;       if (findy(m1) < findy(m2))         r = m2;       else         l = m1;     }     pp.x = (l + r) / 2;     return findy((l + r) / 2);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %lf%lf%lf , &p[i].x, &p[i].y, &p[i].z);     findx();     printf( %.9lf %.9lf %.9lf n , pp.x, pp.y, pp.z);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9, I = 1e18;   const int mxn = 1e5;   int t, n;   string s, pr, ans;   bool fl;   void solve() {     fl = 0;     ans =   ;     cin >> n;     cin >> pr;     ans = pr;     for (int i = 1; i < n - 2; i++) {       cin >> s;       if (pr[1] != s[0]) {         fl = 1;         ans += s[0];       }       ans += s[1];       pr = s;     }     if (!fl) ans =  a  + ans;     cout << ans << endl;   }   int main() {     cin >> t;     while (t--) solve();   }


#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:64000000 )   template <class T>   inline T sqr(T x) {     return x * x;   }   int n, k;   int a[1 << 17];   map<int, int> d;   set<pair<int, int> > s;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     for (int i = 0; i < k; ++i) ++d[a[i]];     for (int i = 0; i < k; ++i) s.insert(make_pair(d[a[i]], -a[i]));     for (int i = 0; i + k - 1 < n; ++i) {       if (s.begin()->first == 1)         printf( %d n , -s.begin()->second);       else         puts( Nothing );       if (i + k == n) continue;       pair<int, int> cur(d[a[i]], -a[i]);       s.erase(cur);       if (--d[a[i]] == 0)         d.erase(a[i]);       else {         --cur.first;         s.insert(cur);       }       cur = make_pair(d[a[i + k]], -a[i + k]);       s.erase(cur);       ++d[a[i + k]];       ++cur.first;       s.insert(cur);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   namespace IO {   static char buf[1 << 20], *fs, *ft;   inline char gc() {     if (fs == ft) {       ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin);       if (fs == ft) return EOF;     }     return *fs++;   }   inline int read() {     int x = 0, f = 1;     char s = getchar();     while (s <  0  || s >  9 ) {       if (s ==  - ) f = -f;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = x * 10 + s -  0 ;       s = getchar();     }     return x * f;   }   }  // namespace IO   using IO::read;   map<pair<int, int>, int> pos;   const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};   int p[256];   void move(int n) {     static char c;     while ((c = getchar()) !=  U  and c !=  L  and c !=  R  and c !=  D )       ;     pos.clear();     pair<int, int> now = make_pair(dx[p[c]], dy[p[c]]);     pos[make_pair(0, 0)] = 1, pos[now] = 2;     int ans = 1 << 30, ansl = 0, ansr = 0;     for (int i = 2; i <= n; i++) {       c = getchar();       int rex = now.first + dx[p[c]], rey = now.second + dy[p[c]];       pair<int, int> Next = make_pair(rex, rey);       if (pos[Next]) {         if (i - pos[Next] + 1 < ans)           ans = i - pos[Next] + 1, ansl = pos[Next], ansr = i;       }       pos[now = Next] = i + 1;     }     if (ansl and ansr)       printf( %d %d n , ansl, ansr);     else       puts( -1 );   }   int main() {     p[ U ] = 1, p[ D ] = 3;     p[ L ] = 2, p[ R ] = 0;     int T = read();     while (T--) move(read());     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAX = 200010;   const long long MOD = (int)1e9 + 7;   const int INF = 1e9;   const long long LLINF = 0x3f3f3f3f3f3f3f3f;   const long double EPS = 1e-8;   int r, g, h, total;   inline int add(int a, int b) { return (a + b) % MOD; }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cin >> r >> g;     total = r + g;     vector<int> ant(MAX, 0);     if (g) ant[r] = 1;     if (r) ant[r - 1] = 1;     int res = 0;     for (int l = 2; true; l++) {       vector<int> cur(MAX, 0);       bool eita = false;       for (int red = 0; red <= r; red++) {         long long minus = (l * (l - 1)) / 2 - (r - red);         if (minus < 0) continue;         int green = g - minus;         if (red - l >= 0 and ant[red]) {           eita = true;           cur[red - l] = add(cur[red - l], ant[red]);         }         if (green - l >= 0 and ant[red]) {           eita = true;           cur[red] = add(cur[red], ant[red]);         }       }       if (!eita) break;       swap(ant, cur);     }     for (int red = 0; red <= r; red++) {       res = (res + ant[red]) % MOD;     }     cout << res <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool check(int x1, int y1, int r1, int x2, int y2, int r2, int R2) {     int l = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);     int rr1 = (r1 - r2) * (r1 - r2);     int rr2 = (r1 + r2) * (r1 + r2);     int RR1 = (r1 - R2) * (r1 - R2);     int RR2 = (r1 + R2) * (r1 + R2);     if (l <= rr1 && l <= RR1 && (r1 <= r2 || r1 >= R2)) return 1;     if (rr2 <= l && RR2 <= l) return 1;     return 0;   }   int main() {     int x1, y1, r1, R1, x2, y2, r2, R2;     while (scanf( %d %d %d %d , &x1, &y1, &r1, &R1) != EOF) {       scanf( %d %d %d %d , &x2, &y2, &r2, &R2);       int ans = 0;       if (check(x1, y1, r1, x2, y2, r2, R2)) ans++;       if (check(x1, y1, R1, x2, y2, r2, R2)) ans++;       if (check(x2, y2, r2, x1, y1, r1, R1)) ans++;       if (check(x2, y2, R2, x1, y1, r1, R1)) ans++;       printf( %d n , ans);     }     return 0;   }


#include <bits/stdc++.h>   int ex[] = {1, -1, 0, 0};   int wye[] = {0, 0, 1, -1};   using namespace std;   vector<int> vt[10005];   bool visit[10005];   int n, x, y, an;   void dfs(int node) {     if (visit[node]) return;     visit[node] = true;     int siz = vt[node].size();     int tmp;     for (int i = 0; i < siz; i++) {       tmp = vt[node][i];       if (visit[tmp]) continue;       dfs(tmp);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &x);       vt[i].push_back(x);       vt[x].push_back(i);     }     for (int i = 1; i <= n; i++) {       if (visit[i]) continue;       dfs(i);       an++;     }     printf( %d n , an);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   constexpr long long inf = 1e9 + 7, base = 541;   constexpr long long mod = 1e9 + 7, N = 1e6 + 7;   struct piii {     long long sm = 0, an = 0, cn = 0;   };   long long n;   long long v[N];   long long sum[4 * N], ans[4 * N];   piii calc(piii x, piii y) {     x.an += y.an + (y.sm * x.cn - x.sm * y.cn);     x.sm += y.sm;     x.cn += y.cn;     return x;   }   inline long long pos(long long l, long long tp) {     if (tp == 0)       return (lower_bound(v, v + n + 1, l) - v);     else       return (upper_bound(v, v + n + 1, l) - v);   }   void build(long long s = 0, long long e = n, long long tag = 1) {     if (e - s == 1) {       sum[tag] = v[s];       return;     }     long long mid = (s + e) / 2;     build(s, mid, tag * 2 + 0);     build(mid, e, tag * 2 + 1);     sum[tag] = sum[tag * 2] + sum[tag * 2 + 1];     ans[tag] = ans[tag * 2] + ans[tag * 2 + 1] +                (sum[tag * 2 + 1] * (mid - s) - sum[tag * 2] * (e - mid));   }   piii query(long long l, long long r, long long tag = 1, long long s = 0,              long long e = n) {     piii x, y;     if (s >= r || e <= l) return x;     if (s >= l && e <= r) {       x.sm = sum[tag], x.cn = e - s, x.an = ans[tag];       return x;     }     long long mid = (s + e) / 2;     x = query(l, r, tag * 2 + 0, s, mid), y = query(l, r, tag * 2 + 1, mid, e);     return calc(x, y);   }   void builq(long long l, long long r, long long tag = 1, long long s = 0,              long long e = n) {     if (s >= r || e <= l) return;     if (s >= l && e <= r) {       build(s, e, tag);       return;     }     long long mid = (s + e) / 2;     builq(l, r, tag * 2 + 0, s, mid), builq(l, r, tag * 2 + 1, mid, e);     sum[tag] = sum[tag * 2] + sum[tag * 2 + 1];     ans[tag] = ans[tag * 2] + ans[tag * 2 + 1] +                (sum[tag * 2 + 1] * (mid - s) - sum[tag * 2] * (e - mid));   }   long long a[N];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> a[i];       v[i] = a[i];     }     sort(v, v + n);     build(0, n, 1);     long long Q;     cin >> Q;     for (long long i = n; i < n + 100; i++) v[i] = 1e18 + 7;     while (Q--) {       long long type, l, r;       cin >> type >> l >> r;       if (type == 2)         cout << query(pos(l, 0), pos(r, 1)).an << endl;       else {         l--;         long long x = (0 < pos(a[l], 0) ? pos(a[l], 0) : 0),                   y = (n - 1 > pos(a[l] + r, 0) ? pos(a[l] + r, 0) : n - 1);         long long ps = x;         v[x] += r, a[l] += r;         while (v[ps] > v[ps + 1]) swap(v[ps], v[ps + 1]), ps++;         while (ps && v[ps] < v[ps - 1]) swap(v[ps], v[ps - 1]), ps--;         builq((x > y ? y : x), (x < y ? y : x) + 1);       }     }   }


#include <bits/stdc++.h>   using namespace std;   long long dp[31][31];   long long solve(int n, int r) {     if (n == r || r == 0) return 1;     if (n < r) return 0;     if (dp[n][r] != -1) {       return dp[n][r];     }     return dp[n][r] = solve(n - 1, r - 1) + solve(n - 1, r);   }   int main() {     int t = 1;     while (t--) {       long long n, m, k;       cin >> n >> m >> k;       if (k == 1) {         long long ans = 1;         for (int i = 0; i < n; i++) {           ans = (ans * m) % 1000000007;         }         cout << ans;       } else if (k == n) {         int s = n / 2;         if (n % 2) s++;         long long ans = 1;         for (int i = 0; i < s; i++) {           ans = (ans * m) % 1000000007;         }         cout << ans;       } else if (k > n) {         long long ans = 1;         for (int i = 0; i < n; i++) {           ans = (ans * m) % 1000000007;         }         cout << ans;       } else {         if (k % 2 == 0) {           cout << m;         } else {           cout << m * m;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long r = 1000000009;   int main() {     long long m, n, k;     cin >> n >> m >> k;     long long d = n % k;     d += (n / k) * (k - 1);     if (m <= d) {       cout << m % r;       return 0;     }     int s = m - d;     long long sc = (m - s * k) % r;     long long c = 2;     if (s < 100000000) {       for (int i = s; i > 0; i--) {         sc = (c * k + sc) % r;         c = (c * 2) % r;       }     } else {       while (s >= 10) {         c = (c * 1024) % r;         s -= 10;       }       while (s > 0) {         c = (c * 2) % r;         s--;       }       if (c >= 2) {         c -= 2;       } else {         c += r;         c -= 2;       }       c = (c * k) % r;       sc = (sc + c) % r;     }     cout << sc;     return 0;   }


#include<bits/stdc++.h>   using namespace std;   const int maxn=1e2+5;   int t,n,m;   int f[maxn<<1];   int main()   {       cin.tie(0); cout.tie(0);       ios::sync_with_stdio(0);       cin>>t;       while(t--){           memset(f,0,sizeof(f));           cin>>n>>m;           for(int i=1;i<=n;++i){               for(int j=1;j<=m;++j){                   int x;                   cin>>x;                   f[i+j]^=x;               }           }           int ans=0;           for(int i=2;i<=n+m;++i){               ans|=f[i];           }           if(ans) cout<< Ashish <<endl;           else cout<< Jeel <<endl;       }       return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m, q, dfn[200005], low[200005], ibcc[200005], dfncnt, bcccnt;   vector<pair<int, int>> g[200005];   vector<int> ng[200005];   int st[200005], stcnt;   void getbcc(int x, int pe) {     dfn[x] = low[x] = ++dfncnt;     st[stcnt++] = x;     for (pair<int, int> &e : g[x])       if (!dfn[e.first]) {         getbcc(e.first, e.second);         low[x] = min(low[x], low[e.first]);       } else if (e.second != pe) {         low[x] = min(low[x], dfn[e.first]);       }     if (dfn[x] == low[x]) {       ibcc[x] = ++bcccnt;       int y;       while ((y = st[--stcnt]) != x) {         ibcc[y] = bcccnt;       }     }   }   int dep[200005];   int fa[200005][18];   bool vis[200005];   void dfs4lca(int x, int p, int cd) {     vis[x] = 1;     fa[x][0] = p;     dep[x] = cd;     for (int &y : ng[x])       if (y != p) {         dfs4lca(y, x, cd + 1);       }   }   void init4lca() {     for (int i = 1; i <= bcccnt; i++)       if (!vis[i]) dfs4lca(i, -1, 0);     for (int j = 0; j < 17; j++) {       for (int i = 1; i <= bcccnt; i++) {         if (fa[i][j] == -1)           fa[i][j + 1] = -1;         else           fa[i][j + 1] = fa[fa[i][j]][j];       }     }   }   int lca(int x, int y) {     if (dep[x] < dep[y]) swap(x, y);     for (int i = 17; i >= 0; i--) {       if (fa[x][i] != -1 && dep[fa[x][i]] >= dep[y]) x = fa[x][i];     }     if (x == y) return x;     for (int i = 17; i >= 0; i--) {       if (fa[x][i] != fa[y][i]) {         x = fa[x][i];         y = fa[y][i];       }     }     return fa[x][0];   }   int up[200005], down[200005];   void calc(int x, int p) {     vis[x] = 1;     for (int &y : ng[x])       if (y != p) {         calc(y, x);         up[x] += up[y];         down[x] += down[y];       }     if (up[x] && down[x]) {       puts( No );       exit(0);     }   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       g[a].emplace_back(b, i);       g[b].emplace_back(a, i);     }     for (int i = 1; i <= n; i++)       if (!dfn[i]) getbcc(i, -1);     for (int x = 1; x <= n; x++) {       for (pair<int, int> &e : g[x]) {         if (ibcc[x] != ibcc[e.first]) {           ng[ibcc[x]].emplace_back(ibcc[e.first]);         }       }     }     init4lca();     memset(vis, 0, sizeof(vis));     while (q--) {       int u, v, anc;       scanf( %d%d , &u, &v);       u = ibcc[u];       v = ibcc[v];       if (u == v) continue;       anc = lca(u, v);       up[u]++;       up[anc]--;       down[v]++;       down[anc]--;     }     for (int i = 1; i <= bcccnt; i++)       if (!vis[i]) calc(i, -1);     puts( Yes );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int otg = 1 << 30, i;     for (i = 0; i < m; i++) {       int l, r;       cin >> l >> r;       if (r - l + 1 < otg) otg = r - l + 1;     }     cout << otg << endl;     for (i = 0; i < n; i++) cout << i % otg <<    ;     cout << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 300005, mod = 998244353;   int qp(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = 1ll * ans * a % mod;       a = 1ll * a * a % mod;       b >>= 1;     }     return ans;   }   int rv[N], w[N];   void ntt(vector<int> &a, int f) {     int n = a.size();     for (int i = 0; i < n; i++) rv[i] = (rv[i >> 1] >> 1) | ((i & 1) * (n >> 1));     int wn = qp(f ? (mod + 1) / 3 : 3, (mod - 1) / n);     w[0] = 1;     for (int i = 1; i < n; i++) w[i] = 1ll * w[i - 1] * wn % mod;     for (int i = 0; i < n; i++)       if (i < rv[i]) swap(a[i], a[rv[i]]);     for (int mid = 1; mid < n; mid <<= 1) {       for (int i = 0; i < n; i += (mid << 1)) {         for (int j = 0; j < mid; j++) {           int x = a[i + j],               y = 1ll * a[i + j + mid] * w[n / (mid << 1) * j] % mod;           a[i + j] = (x + y >= mod ? x + y - mod : x + y);           a[i + j + mid] = (x - y < 0 ? x - y + mod : x - y);         }       }     }     if (f) {       int iv = qp(n, mod - 2);       for (int i = 0; i < n; i++) a[i] = 1ll * a[i] * iv % mod;     }   }   vector<int> mul(vector<int> a, vector<int> b) {     int n = 1, m = a.size() + b.size() - 1;     while (n < m) n <<= 1;     a.resize(n), b.resize(n);     ntt(a, 0), ntt(b, 0);     for (int i = 0; i < n; i++) a[i] = 1ll * a[i] * b[i] % mod;     ntt(a, 1);     a.resize(m);     return a;   }   vector<int> inv(vector<int> a) {     int n = a.size();     if (n == 1) {       a[0] = qp(a[0], mod - 2);       return a;     }     int m = 1;     while (m < (n << 1)) m <<= 1;     vector<int> a0 = a;     a0.resize((n + 1) / 2);     vector<int> b0 = inv(a0);     a.resize(m), b0.resize(m);     ntt(a, 0), ntt(b0, 0);     for (int i = 0; i < m; i++)       a[i] = 1ll * b0[i] * (2 - 1ll * a[i] * b0[i] % mod + mod) % mod;     ntt(a, 1);     a.resize(n);     return a;   }   vector<int> qd(vector<int> a) {     int n = a.size();     for (int i = 1; i < n; i++) a[i - 1] = 1ll * a[i] * i % mod;     a.pop_back();     return a;   }   vector<int> jf(vector<int> a) {     int n = a.size();     a.push_back(0);     for (int i = n; i >= 1; i--) a[i] = 1ll * a[i - 1] * qp(i, mod - 2) % mod;     a[0] = 0;     return a;   }   vector<int> ln(vector<int> a) {     a = mul(qd(a), inv(a));     return jf(a);   }   vector<int> rev(vector<int> &a) {     a[0] = 1;     for (int i = 1; i < a.size(); i++) a[i] = (mod - a[i]) % mod;     return a;   }   int n, m;   int main() {     scanf( %d%d , &n, &m);     vector<int> a(n + 1), b(n + 1);     int h = 1;     int hh = 1;     int cl = m / 2;     for (int i = 1; i <= n; i++) {       int t = (m + i) / 2;       if ((m + i) & 1) {         hh = 1ll * hh * (t - i + 1) % mod;         h = 1ll * h * ((cl - i / 2 + mod) % mod) % mod;       } else {         hh = 1ll * hh * t % mod;         h = 1LL * h * (cl + i / 2) % mod;       }       h = 1ll * h * qp(i, mod - 2) % mod;       hh = 1ll * hh * qp(i, mod - 2) % mod;       if (m & 1) h = hh;       if (i & 1)         b[i] = (((i / 2) & 1 ? -1 : 1) * h + mod) % mod;       else         a[i] = (((i / 2) & 1 ? 1 : -1) * h + mod) % mod;     }     auto d = mul(b, inv(rev(a)));     auto c = rev(d);     auto f = ln(inv(a)), g = ln(inv(c));     int ans = 1ll * n * (f[n] + g[n]) % mod;     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long maxN = 2e5 + 13, mod = 1e9 + 7;   long long r, g, odp[maxN], ans;   bool can(long long x) {     if (x * (x + 1) / 2 <= r + g) return 1;     return 0;   }   int32_t main() {     cin >> r >> g;     long long lf = 0, rg = max(r, g) + 1;     while (rg - lf > 1) {       long long mid = lf + rg >> 1;       if (can(mid))         lf = mid;       else         rg = mid;     }     long long h = lf;     odp[0] = 1;     for (long long j = 0; j <= h; j++) {       for (long long i = r; i >= 0; i--) {         if (!(i == 0 && j == 0))           odp[i] = (odp[i] + ((i >= j) ? odp[i - j] : 0)) % mod;       }     }     for (long long i = r; i + g >= h * (h + 1) / 2 && i >= 0; i--) {       ans = (ans + odp[i]) % mod;     }     cout << ans << endl;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   ostream& operator<<(ostream& out, pair<T1, T2>& p) {     out <<  {  << p.first <<  ,   << p.second <<  }  ;     return out;   }   template <typename T1, typename T2>   istream& operator>>(istream& in, pair<T1, T2>& p) {     in >> p.fi > p.se;     return in;   }   template <typename T>   istream& operator>>(istream& in, vector<T>& arr) {     for (auto& i : arr) in >> i;     return in;   }   template <typename T>   ostream& operator<<(ostream& out, vector<T>& arr) {     for (auto i : arr) out << i + 1 <<    ;     out << endl;     return out;   }   const int64_t MAXN = 2e5 + 10;   vector<pair<int64_t, int64_t>> mon, diam;   int64_t n, c, d, t, t1;   int64_t b_ans = 0;   void read() {     for (int64_t i(0); i < n; i++) {       int64_t b, p;       char c;       cin >> b >> p >> c;       if (c ==  D ) {         diam.push_back({p, b});       } else {         mon.push_back({p, b});       }     }   }   void fnd() {     t = 0;     t1 = 0;     for (int64_t i(0); i < mon.size(); i++) {       if (mon[i].first <= c) {         t = max(t, mon[i].second);       }     }     for (int64_t i(0); i < diam.size(); i++) {       if (diam[i].first <= d) {         t1 = max(t1, diam[i].second);       }     }   }   void solve(vector<pair<int64_t, int64_t>>& mon, int64_t kek) {     multiset<int64_t> s;     for (int64_t i(0); i < mon.size(); i++) {       s.insert(mon[i].second);     }     int64_t pt = (int64_t)mon.size() - 1;     for (int64_t i(0); i < mon.size() && mon[i].first <= kek; i++) {       while (pt >= 0 && mon[pt].first > kek - mon[i].first) {         s.erase(s.find(mon[pt].second));         pt--;       }       if (pt >= i) {         s.erase(s.find(mon[i].second));       }       if (s.size() != 0) {         b_ans = max(b_ans, mon[i].second + *s.rbegin());       }       if (pt >= i) {         s.insert(mon[i].second);       }     }   }   signed main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     cin >> n >> c >> d;     read();     sort(mon.begin(), mon.end());     sort(diam.begin(), diam.end());     fnd();     if (t != 0 && t1 != 0) {       b_ans = t + t1;     }     solve(mon, c);     solve(diam, d);     cout << b_ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long Mod = 1e9 + 7;   long long powmod(long long a, long long b) {     long long res = 1;     a %= Mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % Mod;       a = a * a % Mod;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   const int N = 200005;   int main() {     ios::sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       int n;       string x;       cin >> n >> x;       string ans[2];       bool flag = 0;       for (auto ch : x) {         if (ch ==  0 ) {           ans[0] +=  0 ;           ans[1] +=  0 ;         }         if (ch ==  2 ) {           if (!flag) {             ans[0] +=  1 ;             ans[1] +=  1 ;           } else {             ans[0] +=  0 ;             ans[1] +=  2 ;           }         }         if (ch ==  1 ) {           if (!flag) {             ans[0] +=  1 ;             ans[1] +=  0 ;             flag = 1;           } else {             ans[0] +=  0 ;             ans[1] +=  1 ;           }         }       }       cout << ans[0] <<   n  << ans[1] <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, c, d, l1, r1, l2, r2, k;     while (cin >> l1 >> r1 >> l2 >> r2 >> k) {       if (l2 > r1)         cout << 0 << endl;       else if (l1 > r2)         cout << 0 << endl;       else {         long long int ans = 0;         if (l2 >= l1 && l2 <= r1 && r2 >= r1) {           ans = r1 - l2 + 1;           if (k <= r1 && k >= l2) ans--;         } else if (l2 >= l1 && l2 <= r1 && r2 <= r1) {           ans = r2 - l2 + 1;           if (k >= l2 && k <= r2) ans--;         } else if (l1 >= l2 && r1 >= r2) {           ans = r2 - l1 + 1;           if (k >= l1 && k <= r2) ans--;         } else if (l1 >= l2 && r1 <= r2) {           ans = r1 - l1 + 1;           if (k >= l1 && k <= r1) ans--;         }         cout << ans << endl;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool ok(double a, double b) {     if (a - b >= 0)       return true;     else       return false;   }   double a, b;   double calc(double x) {     int l = 1;     int r = 1000000000;     while (l < r) {       int m = (l + r) / 2 + 1;       if (ok(x / ((double)m * 2.0), b))         l = m;       else         r = m - 1;     }     return l;   }   int main() {     int aa, bb;     cin >> aa >> bb;     if (aa == bb) {       cout << aa << endl;       return 0;     }     if (aa < bb) {       cout << -1 << endl;       return 0;     }     a = aa;     b = bb;     double ans;     double ans0 = (a - b) / (calc(a - b) * 2.0);     double ans1 = (a + b) / (calc(a + b) * 2.0);     if (ans0 < b)       ans = ans1;     else       ans = min(ans0, ans1);     printf( %.10lf n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long TESTS = 1;     while (TESTS--) {       long long n, x, y;       cin >> n >> x >> y;       string s;       cin >> s;       long long cnt = 0;       char c = s[0];       for (auto i : s)         if (i == c)           continue;         else {           if (c ==  0 ) cnt++;           c = i;         }       if (c ==  0 ) cnt++;       if (!cnt) return cout << 0, 0;       if (x < y)         cout << x * (cnt - 1) + y;       else         cout << cnt * y;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;      const long long MOD = 998244353;      int a[1005][505];   vector<int> pos[505][505];   bool removed[505];      void remove1(int x, int n, int layerNum = 0){       if(removed[x]){return;}       removed[x] = true;          vector<int> toRemove;       for(int j = 1; j <= n; j ++){           auto it = find(pos[j][a[x][j]].begin(), pos[j][a[x][j]].end(), x);           if(layerNum == 0){               if(it != pos[j][a[x][j]].end()){                   for(int k: pos[j][a[x][j]]){                       if(k != x){                           toRemove.push_back(k);                       }                   }                   pos[j][a[x][j]] = vector<int>();               }           }else{               if(it != pos[j][a[x][j]].end()){                   pos[j][a[x][j]].erase(it);               }           }       }          for(int k: toRemove){           remove1(k, n, 1);       }   }      void printPosState(int n){       for(int i = 1; i <= n; i ++){           for(int j = 1; j <= n; j ++){               printf( (%d, %d):  , i, j);                  for(int k: pos[i][j]){                   printf( %d  , k);               }                  printf(  n );           }       }   }      int main(){       int t;       scanf( %d , &t);          while(t --){           int n;           scanf( %d , &n);              memset(removed, false, sizeof(removed));              for(int i = 1; i <= n; i ++){               for(int j = 1; j <= n; j ++){                   pos[i][j] = vector<int>();               }           }              for(int i = 1; i <= 2*n; i ++){               for(int j = 1; j <= n; j ++){                   scanf( %d , &a[i][j]);                   pos[j][a[i][j]].push_back(i);               }           }              vector<int> res;              //printPosState(n);              int cnt = 0;           while(1){               bool found = false;               for(int i = 1; i <= n; i ++){                   for(int j = 1; j <= n; j ++){                       if((int)pos[i][j].size() == 1){                           int x = pos[i][j][0];                           remove1(x, n);                           //printf( %d removed n n , x);                           //printPosState(n);                           res.push_back(x);                           found = true;                           break;                       }                   }                   if(found){break;}               }               if(!found){                   cnt ++;                   for(int i = 1; i <= n; i ++){                       for(int j = 1; j <= n; j ++){                           if((int)pos[i][j].size() == 2){                               int x = pos[i][j][0];                               remove1(x, n);                               //printf( %d removed n n , x);                               //printPosState(n);                               res.push_back(x);                               found = true;                               break;                           }                       }                       if(found){break;}                   }               }                  if(!found){break;}           }              //printf( cnt=%d n , cnt);              long long ans = 1;           for(int i = 1; i < cnt; i ++){               ans = (ans+ans)%MOD;           }              printf( %lld n , ans);           for(int x: res){               printf( %d  , x);           }           printf(  n );       }          return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long maxn = 400010;   const long long mod = 1000000007;   const long double eps = 1e-9;   const long long inf = ((1ll << 31ll) - 1ll);   const long long INF = 2000000000000000000ll;   const long double pi = acos(-1);   long long qpow(long long b, long long e) {     if (!e) return 1;     if (e & 1) return qpow(b, e - 1) * b % mod;     long long pwur = qpow(b, e >> 1);     return pwur * pwur % mod;   }   long long modinv(long long x) { return qpow(x, mod - 2); }   long long tc, n, a[maxn];   vector<long long> ans;   bool sorted() {     for (long long i = 1; i < n; i++)       if (a[i] > a[i + 1]) return 0;     return 1;   }   void shft(long long x) {     swap(a[x + 2], a[x + 1]);     swap(a[x + 1], a[x]);   }   void tryl() {     for (long long i = 1; i <= n - 2; i++) {       pair<long long, long long> mn = {mod, -1};       for (long long j = i; j <= n; j++) {         if (mn.first > a[j]) {           mn = {a[j], j};         }       }       while (mn.second != i) {         if (mn.second - 2 >= i) {           shft(mn.second - 2);           mn.second -= 2;           ans.push_back(mn.second);         } else {           shft(mn.second - 1);           shft(mn.second - 1);           mn.second -= 1;           ans.push_back(mn.second);           ans.push_back(mn.second);         }       }     }   }   void tryr() {     for (long long i = n; i >= 3; i--) {       pair<long long, long long> mx = {-1, -1};       for (long long j = 1; j <= i; j++) {         if (mx.first <= a[j]) {           mx = {a[j], j};         }       }       while (mx.second != i) {         if (mx.second + 2 <= i) {           shft(mx.second);           ans.push_back(mx.second);           mx.second += 2;         } else {           shft(mx.second - 1);           ans.push_back(mx.second - 1);           mx.second += 1;         }       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.setf(ios::fixed);     cout.precision(0);     srand(time(NULL));     cin >> tc;     while (tc--) {       ans.clear();       cin >> n;       for (long long i = 1; i <= n; i++) cin >> a[i];       long long bu = 10;       while (bu--) {         tryl();         tryr();       }       for (long long i = 0; i <= 3; i++) {         if (i) shft(n - 2);         if (a[n - 2] <= a[n - 1] && a[n - 1] <= a[n]) {           for (long long j = 1; j <= i; j++) ans.push_back(n - 2);           break;         }       }       if (!sorted()) {         cout << -1 <<   n ;         continue;       }       cout << ans.size() <<   n ;       for (auto i : ans) cout << i <<    ;       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int cases;     cin >> cases;     while (cases--) {       int length, target;       cin >> length >> target;       vector<vector<int>> BGR(3, vector<int>(length, 0));       string inp;       cin >> inp;       for (size_t i = 0, tok; i < inp.length(); ++i) {         if (inp[i] ==  B )           tok = 0;         else if (inp[i] ==  G )           tok = 1;         else           tok = 2;         BGR[(tok + i) % 3][i] = 1;       }       int ans = target;       for (auto x : BGR) {         size_t j = 0;         int init = target;         for (; j < target; ++j) init -= x[j];         ans = init < ans ? init : ans;         for (size_t i = 0; j < x.size(); ++i, ++j) {           init += x[i] - x[j];           ans = init < ans ? init : ans;         }       }       cout << ans <<   n ;     }     return 0;   }