#include <bits/stdc++.h>   using namespace std;   long double x1, x2, y, y2, r1, r2, ab, s = 0, al, be;   const long double pi = acos(-1);   void inp() {     cin >> x1 >> y >> r1;     cin >> x2 >> y2 >> r2;     ab = sqrt((x1 - x2) * (x1 - x2) + (y - y2) * (y - y2));   }   void out() {     if (ab >= (r1 + r2)) {       cout << fixed << setprecision(20) << s;     } else if (ab <= abs(r1 - r2)) {       if (r1 < r2) {         cout << fixed << setprecision(20) << r1 * r1 * pi;       } else {         cout << fixed << setprecision(20) << r2 * r2 * pi;       }     } else {       al = 2.0 * acos((ab * ab - r1 * r1 + r2 * r2) / (2.0 * ab * r2));       be = 2.0 * acos((ab * ab - r2 * r2 + r1 * r1) / (2.0 * ab * r1));       s = be * r1 * r1 - r1 * r1 * sin(be) + al * r2 * r2 - r2 * r2 * sin(al);       s = s / 2.0;       cout << fixed << setprecision(20) << s;     }   }   int main() {     inp();     out();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int dp[2][100100];   int visit[100100];   int v[100100];   int main() {     int i, j;     int n, m;     while (scanf( %d %d , &n, &m) != EOF) {       memset(dp, 0, sizeof(dp));       for (i = 1; i <= n; i++) {         scanf( %d , &v[i]);         if (v[i] < 0) {           dp[0][-v[i]]++;           dp[0][0]++;         } else {           dp[1][v[i]]++;           dp[1][0]++;         }       }       memset(visit, 0, sizeof(visit));       int flag = 0;       for (i = 1; i <= n; i++) {         if (dp[1][i] + dp[0][0] - dp[0][i] == m) {           visit[i] += 1;           flag++;         }       }       for (i = 1; i <= n; i++) {         int now = v[i];         if (now < 0) now = 0 - now;         if (v[i] > 0) {           if (visit[v[i]] != 1)             printf( Lie n );           else if (flag == 1)             printf( Truth n );           else             printf( Not defined n );         } else {           if (visit[-v[i]] == 0)             printf( Truth n );           else if (flag == 1)             printf( Lie n );           else             printf( Not defined n );         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     cin >> n >> m >> k;     if (n <= m && n <= k) {       cout <<  Yes ;     } else {       cout <<  No ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 4;   int n, q, A[N], P[N], R[N], res[N], S[N * 2];   map<int, int> M;   vector<int> Q[N];   inline void Add(int le, int ri, int val) {     le--;     ri--;     for (le += n, ri += n; le < ri; le >>= 1, ri >>= 1) {       if (le & 1) S[le++] ^= val;       if (ri & 1) S[--ri] ^= val;     }   }   inline int Get(int i) {     int ret = 0;     for (i--, i += n; i; i >>= 1) ret ^= S[i];     return (ret);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &A[i]), P[i] = (P[i - 1] ^ A[i]);     scanf( %d , &q);     for (int i = 1, l; i <= q; i++)       scanf( %d%d , &l, &R[i]), Q[l].push_back(i), res[i] = (P[R[i]] ^ P[l - 1]);     for (int i = 1; i <= n; i++) M[A[i]] = n + 1;     for (int i = n; i; i--) {       Add(i, M[A[i]], A[i]);       for (int &id : Q[i]) res[id] ^= Get(R[id]);       M[A[i]] = i;     }     for (int i = 1; i <= q; i++) printf( %d n , res[i]);     return (0);   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, l, x, y;     set<long long> Set;     while (cin >> n >> l >> x >> y) {       for (int i = 1; i <= n; ++i) {         long long t;         scanf( %I64d , &t);         Set.insert(t);       }       bool checkx = 0;       bool checky = 0;       for (set<long long>::iterator it = Set.begin(); it != Set.end(); it++) {         if (Set.find(*it + x) != Set.end()) {           checkx = 1;         }         if (Set.find(*it + y) != Set.end()) {           checky = 1;         }         if (checkx && checky) {           break;         }       }       if (checkx && checky) {         cout << 0 << endl;         break;       }       if (checkx) {         cout << 1 << endl;         cout << y << endl;         break;       }       if (checky) {         cout << 1 << endl;         cout << x << endl;         break;       }       bool find = 0;       long long ans = 0;       for (set<long long>::iterator it = Set.begin(); it != Set.end(); it++) {         if ((*it + x <= l) && Set.find(*it + x + y) != Set.end()) {           find = 1;           ans = *it + x;           break;         }         if ((*it + x <= l) && Set.find(*it + x - y) != Set.end()) {           find = 1;           ans = *it + x;           break;         }         if ((*it - x >= 0) && Set.find(*it - x + y) != Set.end()) {           find = 1;           ans = *it - x;           break;         }         if ((*it - x >= 0) && Set.find(*it - x - y) != Set.end()) {           find = 1;           ans = *it - x;           break;         }       }       if (find) {         cout << 1 << endl;         cout << ans << endl;         break;       }       cout << 2 << endl;       cout << x <<     << y << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int N;   int main() {     int T;     scanf( %d , &T);     while (T--) {       cin >> N;       printf( %d n , (N > 2 ? N - 2 : 0));     }     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   constexpr long long MOD = 1000000007LL;   template <class T>   inline bool chmax(T &a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <class T>   inline bool chmin(T &a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int N, M, K, S;     cin >> N >> M >> K >> S;     vector<pair<long long, long long> > A(N), B(N), C, D;     for (int i = 0; i < (N); ++i) cin >> A[i].first;     for (int i = 0; i < (N); ++i) cin >> B[i].first;     for (int i = 0; i < (M); ++i) {       int com, c;       cin >> com >> c;       if (com == 1)         C.emplace_back(c, i);       else         D.emplace_back(c, i);     }     for (int i = 0; i < (N); ++i) A[i].second = B[i].second = i;     sort((C).begin(), (C).end());     sort((D).begin(), (D).end());     int P = C.size();     int Q = D.size();     vector<long long> E(P + 1), F(Q + 1);     for (int i = 0; i < (P); ++i) {       E[i + 1] = E[i] + C[i].first;     }     for (int i = 0; i < (Q); ++i) {       F[i + 1] = F[i] + D[i].first;     }     vector<pair<long long, long long> > G(N), H(N);     pair<long long, long long> p = {1e9, 1e9}, q = {1e9, 1e9};     for (int i = 0; i < (N); ++i) {       chmin(p, A[i]);       chmin(q, B[i]);       G[i] = p;       H[i] = q;     }     int ng = -1;     int ok = N;     while (ok - ng > 1) {       int mid = (ng + ok) / 2;       long long r = G[mid].first;       long long s = H[mid].first;       bool check = false;       for (int i = 0; i <= K; ++i) {         if (i > P || K - i > Q) continue;         if (E[i] * r + F[K - i] * s <= S) check = true;       }       if (check)         ok = mid;       else         ng = mid;     }     if (ok == N)       cout << -1 <<   n ;     else {       cout << ok + 1 <<   n ;       long long r = G[ok].first;       long long s = H[ok].first;       for (int i = 0; i <= K; ++i) {         if (i > P || K - i > Q) continue;         if (E[i] * r + F[K - i] * s <= S) {           for (int j = 0; j < (i); ++j) {             cout << C[j].second + 1 <<     << G[ok].second + 1 <<   n ;           }           for (int j = 0; j < (K - i); ++j) {             cout << D[j].second + 1 <<     << H[ok].second + 1 <<   n ;           }           return 0;         }       }     }   }


#include <bits/stdc++.h>   using namespace std;   const int N = 500, INF = 1 << 30;   int nxt[N], a[N][N], n, x, Rank[N][N], now;   char s[10];   queue<int> q;   void init() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]);     puts( B );     fflush(stdout);     scanf( %s , s);     if (s[0] ==  I ) {       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++) a[i][j] = -a[i][j];     }     scanf( %d , &x);     if (x > n)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++) a[i][j] = -a[i][j];   }   bool cmp(int x, int y) { return a[now][x - n] > a[now][y - n]; }   void prework() {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) Rank[i][j] = j + n;       now = i;       sort(Rank[i] + 1, Rank[i] + 1 + n, cmp);       q.push(i);     }     for (int i = 1; i <= n; i++) a[0][i] = a[i][0] = INF;     for (int i = 1; i <= n; i++) nxt[i] = nxt[i + n] = Rank[i][0] = 0;     while (!q.empty()) {       int x = q.front();       q.pop();       if (x == 0) continue;       while (nxt[x] == 0) {         int girl = Rank[x][++*Rank[x]];         if (a[x][girl - n] < a[nxt[girl]][girl - n])           nxt[nxt[girl]] = 0, q.push(nxt[girl]), nxt[girl] = x, nxt[x] = girl;       }     }   }   void work() {     prework();     for (int i = 1;; i++) {       if (x == -1 || x == -2) return;       printf( %d n , nxt[x]);       fflush(stdout);       scanf( %d , &x);     }   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       init();       work();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       int mid = sqrt(n + 0.5);       vector<int> ans;       ans.push_back(0);       for (int i = 1; i <= mid; i++) {         ans.push_back(i);         ans.push_back(n / i);       }       sort(ans.begin(), ans.end());       n = unique(ans.begin(), ans.end()) - ans.begin();       cout << n << endl;       for (int i = 0; i < n; i++) cout << ans[i] <<    ;       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, n, a, b;     cin >> x >> y >> n;     long double d = 10000000000, t, q;     t = (long double)x / y;     for (int i = 1; i <= n; i++) {       q = abs(t - floor(t * i) / i);       if (q < d) {         a = floor(t * i);         b = i;         d = q;       }       q = abs(t - ceil(t * i) / i);       if (q < d) {         a = ceil(t * i);         b = i;         d = q;       }     }     cout << a <<  /  << b << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct state {     int x, y, d;     state(){};     state(int _x, int _y, int _d) { x = _x, y = _y, d = _d; };   };   int main() {     int r, c;     int dx[4] = {1, 0, -1, 0};     int dy[4] = {0, 1, 0, -1};     while (cin >> r >> c) {       char temp;       int map[1010][1010];       vector<state> opp;       pair<int, int> start, end;       for (int i = 0; i < r; i++)         for (int j = 0; j < c; j++) {           cin >> temp;           if (temp >  0  && temp <=  9 ) opp.push_back(state(i, j, temp -  0 ));           if (temp ==  S ) start = pair<int, int>(i, j);           if (temp ==  E ) end = pair<int, int>(i, j);           if (temp ==  T )             map[i][j] = -1;           else             map[i][j] = 1222333444;         }       map[end.first][end.second] = 0;       queue<pair<int, int> > next;       next.push(end);       while (!next.empty()) {         pair<int, int> now = next.front();         next.pop();         for (int j = 0; j < 4; j++) {           int tempx = now.first + dx[j];           int tempy = now.second + dy[j];           if (tempx < 0 || tempx > r - 1 || tempy < 0 || tempy > c - 1) continue;           if (map[tempx][tempy] == -1) continue;           if (map[tempx][tempy] == 1222333444) {             map[tempx][tempy] = map[now.first][now.second] + 1;             next.push(pair<int, int>(tempx, tempy));           }         }       }       int sum = 0;       for (int i = 0; i < opp.size(); i++) {         int tempx = opp[i].x;         int tempy = opp[i].y;         if (map[tempx][tempy] <= map[start.first][start.second]) sum += opp[i].d;       }       cout << sum << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INPUT_MAXCHARS = 1 << 16;   char buffer[INPUT_MAXCHARS];   struct FastReader {     char *p;     FastReader() {       fread(buffer, 1, sizeof buffer, stdin);       p = buffer;     }     int next() {       int remchars = INPUT_MAXCHARS - (p - buffer);       if (remchars < 25) {         memcpy(buffer, p, remchars);         size_t cnt = fread(buffer + remchars, 1, sizeof buffer - remchars, stdin);         if (remchars + cnt < sizeof buffer) {           buffer[remchars + cnt] = 0;         }         p = buffer;       }       while (*p <  0 ) {         ++p;       }       int val = 0;       while (*p >=  0 ) {         val = val * 10 + (*p -  0 );         ++p;       }       return val;     }   };   const int inf = 1234567890;   const int MAXN = 100000;   vector<int> arrivals[MAXN];   int arr_idx[MAXN];   vector<pair<int, int> > adj[MAXN];   int best[MAXN];   bool done[MAXN];   int main() {     FastReader reader;     int n = reader.next();     int m = reader.next();     for (int i = 0; i < m; ++i) {       int a = reader.next();       int b = reader.next();       int c = reader.next();       adj[a - 1].push_back(make_pair(b - 1, c));       adj[b - 1].push_back(make_pair(a - 1, c));     }     for (int i = 0; i < n; ++i) {       int k = reader.next();       arrivals[i].reserve(k + 1);       for (int j = 0; j < k; ++j) {         int t = reader.next();         arrivals[i].push_back(t);       }       arrivals[i].push_back(inf);     }     for (int i = 0; i < n; ++i) {       best[i] = inf;     }     priority_queue<pair<int, int> > PQ;     PQ.push(make_pair(0, 0));     best[0] = 0;     while (!PQ.empty()) {       const pair<int, int> tmp = PQ.top();       PQ.pop();       int t = -tmp.first;       int at = tmp.second;       if (done[at] || best[at] < t) {         continue;       }       done[at] = true;       if (at == n - 1) {         printf( %d n , t);         return 0;       }       while (arrivals[at][arr_idx[at]] < t) {         ++arr_idx[at];       }       if (arrivals[at][arr_idx[at]] == t) {         done[at] = false;         best[at] = t + 1;         PQ.push(make_pair(-t - 1, at));       } else {         for (int i = 0; i < (int)adj[at].size(); ++i) {           const pair<int, int> e = adj[at][i];           if (t + e.second < best[e.first]) {             best[e.first] = t + e.second;             PQ.push(make_pair(-best[e.first], e.first));           }         }       }     }     puts( -1 );     return 0;   }


#include <bits/stdc++.h>   using namespace std;         const int maxn = 2e5+5;   typedef long long ll;      char s[maxn],f[maxn];   int t[maxn<<2],lz[maxn<<2];      void pushup(int rt){    t[rt]=t[rt<<1]+t[rt<<1|1];   }   void pushdown(int rt,int l,int r){    if(lz[rt]!=-1){     int mid=l+r>>1;     t[rt<<1]=lz[rt]*(mid-l+1);     t[rt<<1|1]=lz[rt]*(r-mid);     lz[rt<<1]=lz[rt<<1|1]=lz[rt];     lz[rt]=-1;    }   }   void build(int rt,int l,int r){    lz[rt]=-1;    if(l==r){     t[rt]=f[l]- 0 ;     return;    }    int mid=l+r>>1;    build(rt<<1,l,mid);    build(rt<<1|1,mid+1,r);    pushup(rt);   }   void cg(int rt,int l,int r,int ql,int qr,int v){    if(l>=ql && r<=qr){     t[rt]=(r-l+1)*v;     lz[rt]=v;      return;    }    int mid=l+r>>1;    pushdown(rt,l,r);    if(ql<=mid && qr>=l)cg(rt<<1,l,mid,ql,qr,v);    if(ql<=r && qr>=mid+1)cg(rt<<1|1,mid+1,r,ql,qr,v);    pushup(rt);   }   int qry(int rt,int l,int r,int ql,int qr){    if(l>=ql && r<=qr){     return t[rt];    }     pushdown(rt,l,r);    int mid=l+r>>1;    int ans=0;    if(ql<=mid)ans+=qry(rt<<1,l,mid,ql,qr);    if(qr>=mid+1)ans+=qry(rt<<1|1,mid+1,r,ql,qr);    pushup(rt);    return ans;   }      struct Node{    int l,r;   }a[maxn];   int main(){    int t;    scanf( %d ,&t);    while(t--){     int n,q;     scanf( %d%d%s%s ,&n,&q,s+1,f+1);     build(1,1,n);     bool failed=false;     for(int i=1;i<=q;++i){      scanf( %d%d ,&a[i].l,&a[i].r);     }     for(int i=q;i>=1;--i){      int l=a[i].l,r=a[i].r;      int num=qry(1,1,n,l,r),k=(r-l+2)/2-1;      if(r-l+1<=2){       if(num!=r-l+1 && num){        failed=true;        break;       }      }else if(r-l+1-num<=k)cg(1,1,n,l,r,1);else if(num<=k)cg(1,1,n,l,r,0);else{       if(num!=r-l+1 && num){        failed=true;        break;       }      }     }     if(failed){      printf( NO n );      continue;     }     for(int i=1;i<=n;++i){      if(qry(1,1,n,i,i)!=s[i]- 0 ){       failed=true;       break;      }     }     if(failed){      printf( NO n );     }else printf( YES n );    }   }/*test:   2   9 10   111101101   110001101   7 7   9 9   5 5   1 4   7 7   3 3   5 5   9 9   9 9   5 5   */


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, i = 0, j = 0;     cin >> a >> b;     if (a > b) {       i = b;       a = a - b;       j = a / 2;     } else if (a < b) {       i = a;       b = b - a;       j = b / 2;     } else {       i = a;       j = 0;     }     cout << i <<     << j;   }


#include <bits/stdc++.h>   using namespace std;   int n, m;   int l[200000], r[200000];   int a[200000], b[200000], c[200000];   int d[800000], p[800000];   set<int> se;   map<int, int> ma;   int rev[800000];   int mac = 0;   long long ans = 0;   int ansi, ansj;   pair<int, int> fen[800000];   void fenUpdate(int pos, pair<int, int> val) {     for (; pos < mac; pos |= pos + 1) fen[pos] = max(fen[pos], val);   }   pair<int, int> fenGet(int pos) {     pair<int, int> ret = make_pair(-1, -1);     for (; pos >= 0; pos = (pos & (pos + 1)) - 1) ret = max(ret, fen[pos]);     return ret;   }   struct Ev {     int x;     bool i;     int ind;     Ev(int x, bool i, int ind) : x(x), i(i), ind(ind) {}     Ev() {}   };   Ev e[400000];   int ec = 0;   bool cmp(const Ev &lhs, const Ev &rhs) {     if (lhs.x != rhs.x) return lhs.x < rhs.x;     return lhs.i < rhs.i;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < (int)(n); ++i) scanf( %d%d , l + i, r + i);     for (int i = 0; i < (int)(m); ++i) scanf( %d%d%d , a + i, b + i, c + i);     for (int i = 0; i < (int)(n); ++i) se.insert(l[i]), se.insert(r[i]);     for (int i = 0; i < (int)(m); ++i) se.insert(a[i]), se.insert(b[i]);     for (int x : se) ma[x] = mac, rev[mac++] = x;     for (int i = 0; i < (int)(n); ++i) l[i] = ma[l[i]], r[i] = ma[r[i]];     for (int i = 0; i < (int)(m); ++i) a[i] = ma[a[i]], b[i] = ma[b[i]];     for (int i = 0; i < (int)(mac); ++i) d[i] = -1;     for (int i = 0; i < (int)(n); ++i)       if (r[i] > d[l[i]]) {         d[l[i]] = r[i];         p[l[i]] = i;       }     for (int i = 1; i < mac; ++i)       if (d[i - 1] > d[i]) {         d[i] = d[i - 1];         p[i] = p[i - 1];       }     for (int i = 0; i < (int)(m); ++i)       if (d[a[i]] > a[i]) {         int r = min(b[i], d[a[i]]);         long long cur = (rev[r] - rev[a[i]]) * (long long)c[i];         if (cur > ans) {           ans = cur;           ansi = p[a[i]];           ansj = i;         }       }     for (int i = 0; i < (int)(mac); ++i) d[i] = mac;     for (int i = 0; i < (int)(n); ++i)       if (l[i] < d[r[i]]) {         d[r[i]] = l[i];         p[r[i]] = i;       }     for (int i = mac - 2; i >= 0; --i)       if (d[i + 1] < d[i]) {         d[i] = d[i + 1];         p[i] = p[i + 1];       }     for (int i = 0; i < (int)(m); ++i)       if (d[b[i]] < b[i]) {         int l = max(a[i], d[b[i]]);         long long cur = (rev[b[i]] - rev[l]) * (long long)c[i];         if (cur > ans) {           ans = cur;           ansi = p[b[i]];           ansj = i;         }       }     for (int i = 0; i < (int)(mac); ++i) fen[i] = make_pair(-1, -1);     for (int i = 0; i < (int)(n); ++i) e[ec++] = Ev(l[i], true, i);     for (int i = 0; i < (int)(m); ++i) e[ec++] = Ev(a[i], false, i);     sort(e, e + ec, cmp);     for (Ev ev : e) {       if (ev.i) {         pair<int, int> ret = fenGet(mac - 1 - r[ev.ind]);         if (ret.first != -1) {           long long cur =               (long long)ret.first * (rev[r[ev.ind]] - rev[l[ev.ind]]);           if (cur > ans) {             ans = cur;             ansi = ev.ind;             ansj = ret.second;           }         }       } else {         fenUpdate(mac - 1 - b[ev.ind], make_pair(c[ev.ind], ev.ind));       }     }     cout << ans << endl;     if (ans != 0) cout << ansi + 1 <<     << ansj + 1 << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long mo = 998244353;   const long long g = 3;   const int N = 500000;   int n, ax, bx, rev[N + 10];   long long aa[N + 10], bb[N + 10], c[N + 10], fac[N + 10], inv[N + 10];   long long mul(long long x, long long y) {     long long z = 1;     while (y) {       if (y & 1) z = z * x % mo;       y >>= 1;       x = x * x % mo;     }     return z;   }   struct poly {     vector<int> a;     void pre(int n) {       rev[0] = 0;       for (int i = 1; i < n; i++)         if (i & 1)           rev[i] = rev[i ^ 1] + (n >> 1);         else           rev[i] = rev[i >> 1] >> 1;     }     void FFT(long long *a, int n) {       for (int i = 0; i < n; i++) c[rev[i]] = a[i];       for (int i = 2; i <= n; i <<= 1) {         long long wn = mul(g, (mo - 1) / i);         for (int j = 0; j < n; j += i) {           long long w = 1;           for (int k = j; k < j + i / 2; k++, w = wn * w % mo) {             long long ck = c[k];             c[k] = (ck + w * c[k + i / 2]) % mo;             c[k + i / 2] = (ck - w * c[k + i / 2]) % mo;           }         }       }       for (int i = 0; i < n; i++) a[i] = (c[i] + mo) % mo;     }     void IFFT(long long *a, int n) {       FFT(a, n);       for (int i = 1; i < n / 2; i++) swap(a[i], a[n - i]);       long long invn = mul(n, mo - 2);       for (int i = 0; i < n; i++) a[i] = a[i] * invn % mo;     }     poly operator*(poly &p) {       int sz = a.size() + p.a.size() - 1;       int nx = 1;       while (nx < sz) nx <<= 1;       pre(nx);       for (int i = 0; i < nx; i++) {         if (i < (int)a.size())           aa[i] = a[i];         else           aa[i] = 0;         if (i < (int)p.a.size())           bb[i] = p.a[i];         else           bb[i] = 0;       }       FFT(aa, nx);       FFT(bb, nx);       for (int i = 0; i < nx; i++) aa[i] = aa[i] * bb[i] % mo;       IFFT(aa, nx);       poly ans;       ans.a.clear();       for (int i = 0; i < sz; i++) ans.a.push_back(aa[i]);       return ans;     }   };   void prework() {     fac[0] = 1;     for (int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % mo;     inv[N] = mul(fac[N], mo - 2);     for (int i = N - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mo;   }   poly Calc_Stirling(int l, int r) {     poly f;     f.a.clear();     if (l > r) {       f.a.push_back(1);       return f;     }     if (l == r) {       f.a.push_back(l);       f.a.push_back(1);       return f;     }     int mid = (l + r) / 2;     f = Calc_Stirling(l, mid);     poly g = Calc_Stirling(mid + 1, r);     f = f * g;     return f;   }   int main() {     scanf( %d%d%d , &n, &ax, &bx);     if (ax == 0 || bx == 0) {       printf( 0 n );       return 0;     }     prework();     poly f = Calc_Stirling(0, n - 2);     long long ans;     if (ax + bx - 2 < (int)f.a.size())       ans = f.a[ax + bx - 2];     else       ans = 0;     ans =         (ans * fac[ax + bx - 2] % mo * inv[ax - 1] % mo * inv[bx - 1] % mo + mo) %         mo;     printf( %lld n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long m, b;     cin >> m >> b;     long long Max = 0;     for (long long i = b; i >= 0; i--) {       long long p = (m * b - m * i + 1) * (i + 1) * (m * b - m * i + i) / 2;       Max = max(p, Max);     }     printf( %I64d , Max);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int L = 1 << 20;   const int R = 1 << 21;   const int Maxn = 200005;   int tree[R], A, B;   int d[Maxn];   char s[Maxn];   bool vowel(char x) {     x = tolower(x);     if (x ==  a  || x ==  e  || x ==  i  || x ==  o  || x ==  u ) return 1;     return 0;   }   int read(int lo, int hi, int x) {     if (hi < A || lo > B) return Maxn;     if (A <= lo && hi <= B) return tree[x];     int mid = (lo + hi) >> 1;     return min(read(lo, mid, 2 * x), read(mid + 1, hi, 2 * x + 1));   }   void update(int x, int id) {     tree[x] = min(id, tree[x]);     for (x >>= 1; x > 0; x >>= 1) tree[x] = min(tree[2 * x], tree[2 * x + 1]);   }   int main() {     for (int i = 0; i < R; ++i) tree[i] = Maxn;     scanf( %s , s);     int n = strlen(s);     for (int i = 0; i < n; ++i) {       if (i) d[i] = d[i - 1];       if (vowel(s[i]))         --d[i];       else         d[i] += 2;     }     for (int i = 0; i < n; ++i) d[i] += Maxn;     update(L + Maxn, -1);     int sol = 0, cnt = 0;     for (int i = 0; i < n; ++i) {       A = L, B = L + d[i];       int id = read(L, R - 1, 1);       update(L + d[i], i);       if (id == Maxn) continue;       if (i - id > sol)         sol = i - id, cnt = 1;       else if (i - id == sol)         ++cnt;     }     if (!sol)       printf( No solution n );     else       printf( %d %d n , sol, cnt);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int T;   int h, c, t;   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d%d , &h, &c, &t);       if (t * 2 <= (h + c))         printf( %d n , 2);       else {         long long lef = (h - t) / (2 * t - (h + c));         double a1 = (1.0 * h * (lef + 1) + c * lef) / (2 * lef + 1);         lef++;         double a2 = (1.0 * h * (lef + 1) + c * lef) / (2 * lef + 1);         if (abs(a1 - t) <= abs(a2 - t))           printf( %lld n , 2 * (lef - 1) + 1);         else           printf( %lld n , 2 * lef + 1);       }     }   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int gi() {     int x = 0, o = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   int n, d, b, sum[N];   int calc() {     int s1 = 0, s2 = 0;     for (int i = 1; i <= (n + 1) / 2; i++) {       int f1 = sum[min(i + 1ll * d * i, (long long)n)] - s1 * b;       int f2 = sum[n] - sum[max(0ll, n - i - 1ll * d * i)] - s2 * b;       if (i == n - i + 1)         s1 += f1 >= b;       else         s1 += f1 >= b, s2 += f2 >= b;     }     return min(s1 - n % 2, s2);   }   int main() {     cin >> n >> d >> b;     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + gi();     printf( %d n , n / 2 - calc());     return 0;   }


#include <bits/stdc++.h>   template <typename T>   inline void SWAP(T &a, T &b) {     T tmp = a;     a = b;     b = tmp;   }   template <typename T>   inline T ABS(const T &val) {     return val < 0 ? -val : val;   }   template <typename T>   inline T MAX(const T &a, const T &b) {     return a > b ? a : b;   }   template <typename T>   inline T MIN(const T &a, const T &b) {     return a < b ? a : b;   }   template <typename T>   inline T SQR(const T &a) {     return a * a;   }   const int INTinf = 2147483647;   const int nINTinf = 0 - 2147483648;   using namespace std;   int n, m, p;   const int SZ = 20002;   int _X[SZ], _Y[SZ];   int A[142][SZ];   int B[141][SZ];   int F[SZ << 1];   int *m1, *m2;   int kol = 0;   long long answ2 = 0L;   string answ =   ;   inline int f(const int &a, const int &b) { return F[_X[a] + _Y[b]]; }   int main() {     cin >> n >> m >> p;     int SZ2 = SZ << 1;     for (int i = 0; i != SZ2; i++) {       F[i] = i % p;     }     for (int i = 0; i != n; i++) cin >> _X[i];     for (int i = 0; i != m; i++) cin >> _Y[i];     m1 = A[0];     m1[0] = f(0, 0);     for (int i = 1; i <= n - 1; i++) {       m1[i] = m1[i - 1] + f(i, 0);     }     int nPos = 0;     for (int i = 1; i <= m - 1; i++) {       if (!nPos) {         copy(m1, m1 + SZ, B[kol++]);       }       nPos++;       if (nPos == 142) nPos = 0;       m2 = A[nPos];       m2[0] = m1[0] + f(0, i);       for (int j = 1; j <= n - 1; j++) {         m2[j] = MAX(m1[j], m2[j - 1]) + f(j, i);       }       m1 = m2;     }     int Y = n - 1;     int X = m - 1;     while (true) {       while (Y && (A[nPos][Y] - f(Y, X) == A[nPos][Y - 1])) {         answ.push_back( C );         answ2 += f(Y, X);         Y--;       }       answ2 += f(Y, X);       answ.push_back( S );       X--;       if (!nPos) {         break;       }       nPos--;     }     kol--;     if (m % 142 != 1) {       kol--;     }     while (kol > -1) {       copy(B[kol], B[kol] + SZ, A[0]);       int to = (kol + 1) * 142;       m1 = A[0];       for (int i = 142 * kol + 1; i != to; i++) {         nPos++;         m2 = A[nPos];         m2[0] = m1[0] + f(0, i);         for (int j = 1; j <= n - 1; j++) {           m2[j] = MAX(m1[j], m2[j - 1]) + f(j, i);         }         m1 = m2;       }       while (true) {         while (Y && (A[nPos][Y] - f(Y, X) == A[nPos][Y - 1])) {           answ.push_back( C );           answ2 += f(Y, X);           Y--;         }         answ2 += f(Y, X);         answ.push_back( S );         X--;         if (!nPos) {           break;         }         nPos--;       }       kol--;     }     answ = answ.substr(0, answ.size() - 1);     reverse(answ.begin(), answ.end());     cout << answ2 << endl;     cout << answ << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     cin >> s >> t;     if (s ==  monday  && (t ==  thursday  || t ==  wednesday  || t ==  monday ))       cout <<  YES ;     else if (s ==  tuesday  &&              (t ==  friday  || t ==  thursday  || t ==  tuesday ))       cout <<  YES ;     else if (s ==  wednesday  &&              (t ==  friday  || t ==  saturday  || t ==  wednesday ))       cout <<  YES ;     else if (s ==  thursday  &&              (t ==  saturday  || t ==  sunday  || t ==  thursday ))       cout <<  YES ;     else if (s ==  friday  && (t ==  sunday  || t ==  monday  || t ==  friday ))       cout <<  YES ;     else if (s ==  saturday  &&              (t ==  monday  || t ==  tuesday  || t ==  saturday ))       cout <<  YES ;     else if (s ==  sunday  &&              (t ==  tuesday  || t ==  wednesday  || t ==  sunday ))       cout <<  YES ;     else       cout <<  NO ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, t, timer = 0;     scanf( %d%d%d , &n, &m, &t);     deque<int> q;     vector<int> col(n);     char isOk = false;     for (int i = 0, j = 0; i < n; i++) {       int x, y, z, start;       scanf(  n%d:%d:%d , &x, &y, &z);       start = x * 3600 + y * 60 + z;       while (!q.empty() && q.front() <= start) {         j--;         q.pop_front();       }       if (j < m) {         j++;         q.push_back(start + t);         timer++;       } else {         q.back() = start + t;       }       if (j == m) {         isOk = true;       }       col[i] = timer;     }     if (!isOk) {       printf( No solution );       return 0;     }     printf( %d n , timer);     for (int i : col) {       printf( %d n , i);     }     return 0;   }


#include <bits/stdc++.h>   struct vit {     int price;     char vit[4];   };   int main() {     int i, n, min;     scanf( %d , &n);     struct vit t[n];     for (i = 0; i < n; i++) {       scanf( %d %s , &t[i].price, t[i].vit);     }     int A = 300001, B = 300001, C = 300001, AB = 300001, AC = 300001, BC = 300001,         ABC = 300001;     for (i = 0; i < n; i++) {       if (strcmp( A , t[i].vit) == 0) {         if (A > t[i].price) A = t[i].price;       }     }     for (i = 0; i < n; i++) {       if (strcmp( B , t[i].vit) == 0) {         if (B > t[i].price) B = t[i].price;       }     }     for (i = 0; i < n; i++) {       if (strcmp( C , t[i].vit) == 0) {         if (C > t[i].price) C = t[i].price;       }     }     for (i = 0; i < n; i++) {       if ((strcmp( AB , t[i].vit) == 0) || (strcmp( BA , t[i].vit) == 0)) {         if (AB > t[i].price) AB = t[i].price;       }     }     for (i = 0; i < n; i++) {       if ((strcmp( BC , t[i].vit) == 0) || (strcmp( CB , t[i].vit) == 0)) {         if (BC > t[i].price) BC = t[i].price;       }     }     for (i = 0; i < n; i++) {       if ((strcmp( AC , t[i].vit) == 0) || (strcmp( CA , t[i].vit) == 0)) {         if (AC > t[i].price) AC = t[i].price;       }     }     for (i = 0; i < n; i++) {       if ((strcmp( ABC , t[i].vit) == 0) || (strcmp( ACB , t[i].vit) == 0) ||           (strcmp( BAC , t[i].vit) == 0) || (strcmp( BCA , t[i].vit) == 0) ||           (strcmp( CAB , t[i].vit) == 0) || (strcmp( CBA , t[i].vit) == 0)) {         if (ABC > t[i].price) ABC = t[i].price;       }     }     min = ABC;     if (A + B + C < min) min = A + B + C;     if (AB + C < min) min = AB + C;     if (BC + A < min) min = BC + A;     if (AC + B < min) min = AC + B;     if (AB + BC < min) min = AB + BC;     if (AB + AC < min) min = AB + AC;     if (BC + AC < min) min = BC + AC;     if (min > 300000) {       printf( -1 );       return 0;     }     printf( %d , min);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct Edge {     long long to, dis, next, cost;   } edge[24050];   long long num = -1;   bool vis[10010];   long long mincost;   long long pre[10010], head[10010], cost[10010], last[10010], flow[10010], n, k,       a[110], b[110], s, t, maxflow;   long long to[110];   void add(long long f, long long t, long long dis, long long cost) {     edge[++num].to = t;     edge[num].dis = dis;     edge[num].next = head[f];     edge[num].cost = cost;     head[f] = num;     edge[++num].to = f;     edge[num].dis = 0;     edge[num].cost = -cost;     edge[num].next = head[t];     head[t] = num;   }   queue<long long> q;   bool spfa(long long s, long long t) {     memset(cost, 0x3f3f3f3f, sizeof cost);     memset(flow, 0x3f3f3f3f, sizeof flow);     memset(vis, 0, sizeof vis);     q.push(s);     vis[s] = 1;     cost[s] = 0;     pre[t] = -1;     while (!q.empty()) {       long long nowp = q.front();       q.pop();       vis[nowp] = 0;       for (long long i = head[nowp]; i != -1; i = edge[i].next) {         if (edge[i].dis > 0 && cost[edge[i].to] > cost[nowp] + edge[i].cost) {           cost[edge[i].to] = cost[nowp] + edge[i].cost;           pre[edge[i].to] = nowp;           last[edge[i].to] = i;           flow[edge[i].to] = min(flow[nowp], edge[i].dis);           if (!vis[edge[i].to]) {             vis[edge[i].to] = 1;             q.push(edge[i].to);           }         }       }     }     return pre[t] != -1;   }   void MCMF(long long s, long long t) {     while (spfa(s, t)) {       long long now = t;       maxflow += flow[t];       mincost += flow[t] * cost[t];       while (now != s) {         edge[last[now]].dis -= flow[t];         edge[last[now] ^ 1].dis += flow[t];         now = pre[now];       }     }   }   signed main() {     long long T;     cin >> T;     while (T--) {       num = -1;       memset(to, -1, sizeof to);       memset(head, -1, sizeof head);       cin >> n >> k;       for (long long i = 1; i <= n; i++) cin >> a[i] >> b[i];       maxflow = mincost = 0;       s = 0;       t = 2 * n + 1;       for (long long i = 1; i <= n; i++) add(s, i, 1, 0), add(i + n, t, 1, 0);       for (long long i = 1; i <= n; i++) {         for (long long j = 1; j <= n; j++) {           long long nc = 0;           if (j <= k - 1)             nc = a[i] + b[i] * (j - 1ll);           else if (j != n)             nc = b[i] * (k - 1ll);           else             nc = a[i] + b[i] * (k - 1ll);           nc = 0x3f3f3f3f - nc;           add(i, j + n, 1, nc);         }       }       MCMF(s, t);       long long nowi = -1;       for (long long i = n * 4; i <= num; i += 2) {         nowi++;         if (edge[i].dis == 0) to[1 + nowi % n] = 1 + nowi / n;       }       cout << 2 * n - k << endl;       for (long long i = 1; i <= k - 1; i++) cout << to[i] <<    ;       for (long long i = k; i < n; i++) cout << to[i] <<     << -to[i] <<    ;       cout << to[n];       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 29;   const double EPS = 1e-9;   const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};   int n, m;   int main() {     cin >> n >> m;     int ans = 0;     for (int i = 0; i <= n; i++) {       int tmp = 0;       int a1 = i;       int b1 = (m - 2 * i);       if (b1 < 0) break;       int r1, r2;       r1 = n - i;       r2 = (m - 2 * i);       int a2 = (r1 / 2);       int b2 = r2 - a2;       if (b2 < 0) {         tmp = i + r2;       } else {         tmp = i + a2;       }       ans = max(ans, tmp);     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n;   struct hdm {     int first, second, id;     hdm(){};     hdm(int first, int second, int id) : first(first), second(second), id(id){};   };   vector<hdm> v1, v2;   bool cmp1(hdm A, hdm B) { return (A.second < B.second); }   bool cmp2(hdm A, hdm B) { return (A.first > B.first); }   int main() {     ios::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n; i++) {       int A, B;       cin >> A >> B;       pair<int, int> p = make_pair(A, B);       if (A > B) {         v1.push_back(hdm(A, B, i));       } else {         v2.push_back(hdm(A, B, i));       }     }     sort(v1.begin(), v1.end(), cmp1);     sort(v2.begin(), v2.end(), cmp2);     int rs1 = (int)v1.size();     int rs2 = (int)v2.size();     if (rs1 >= rs2) {       cout << rs1 <<   n ;       for (int i = 0; i < v1.size(); i++) cout << v1[i].id <<    ;     } else {       cout << rs2 <<   n ;       for (int i = 0; i < v2.size(); i++) cout << v2[i].id <<    ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll base = 1000000007;   int n;   ll p2[1000000];   class reimu {    public:     ll sum, sum2;     int sz;     ll ans = 0;     void operator+=(reimu x) {       (sum2 += x.sum2) %= base;       (sum += x.sum) %= base;       sz += x.sz;     }     void operator-=(reimu x) {       (sum2 -= x.sum2) %= base;       (sum -= x.sum) %= base;       sz -= x.sz;     }     void cal() {       (ans = sum2 * p2[sz - 1] +              ((sz == 1) ? 0 : ((sum * sum - sum2) % base) * p2[sz - 2])) %= base;     }   } f[1000000];   ll pre[64];   int main() {     p2[0] = 1;     for (int i = 1; i < 1000000; i++) (p2[i] = p2[i - 1] * 2) %= base;     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n;     for (int i = 0; i < 64; i++) {       for (int d = 0, p10 = 1; d < 6; d++, p10 *= 10)         if (i & (1 << d)) {           pre[i] += p10;         }     }     for (int i = 0; i < n; i++) {       ll a;       cin >> a;       reimu temp;       temp.sum = a;       (temp.sum2 = a * a) %= base;       temp.sz = 1;       f[a] += temp;     }     for (int x = 999999; x >= 0; x--) {       int mask = 0;       for (int d = 0, p10 = 1; d < 6; d++, p10 *= 10) {         if ((x / p10) % 10 != 9) mask |= 1 << d;       }       for (int sub = mask; sub; (sub -= 1) &= mask) {         if (__builtin_popcount(sub) % 2 == 1)           f[x] += f[x + pre[sub]];         else           f[x] -= f[x + pre[sub]];       }     }     for (int i = 0; i <= 999999; i++) f[i].cal();     ll ans = 0;     for (int x = 0; x <= 999999; x++) {       int mask = 0;       for (int d = 0, p10 = 1; d < 6; d++, p10 *= 10) {         if ((x / p10) % 10 != 9) mask |= 1 << d;       }       ll res = f[x].ans;       for (int sub = mask; sub; (sub -= 1) &= mask) {         if (__builtin_popcount(sub) % 2 == 0)           res += f[x + pre[sub]].ans;         else           res -= f[x + pre[sub]].ans;       }       ((res %= base) += base) %= base;       (res *= x);       ans ^= res;     }     cout << ans <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   double PI = acos(-1);   long long int mod = 998244353;   double eps = 1e-8;   long long int exp(long long int x, long long int y) {     if (y < 0) return 0;     long long int ret = 1;     for (; y; y >>= 1, x = (x * x) % mod) {       if (y & 1) ret = (ret * x) % mod;     }     return ret;   }   unsigned long long int pexp(unsigned long long int x,                               unsigned long long int y) {     if (y < 0) return 0;     unsigned long long int ret = 1;     for (; y; y >>= 1, x = (x * x)) {       if (y & 1) ret = (ret * x);     }     return ret;   }   long long int gcd(long long int x, long long int y) {     if (!x || !y) return x + y;     return x % y == 0 ? y : gcd(y, x % y);   }   long long int lcm(long long int x, long long int y) {     return x * (y / gcd(x, y));   }   long long int bsum(long long int u, long long int b) {     long long int ret = 0;     if (u < b) return u;     while (u) {       ret += u % b;       u /= b;     }     return ret;   }   long long int prival(long long int u, long long int p) {     long long int cn = 0;     while (u % p == 0) {       cn++;       u = u / p;     }     return cn;   }   long long int extm(long long int a, long long int b) {     long long int ret = 0;     while (a != 0) {       if (a % 2 == 1) {         ret += b;         ret %= mod;       }       a >>= 1;       b = (2 * b) % mod;     }     return ret;   }   long long int minv(long long int a, long long int b) {     return 1 < a ? b - minv(b % a, a) * b / a : 1;   }   long long int eaphi(long long int x) {     long long int t = x, ret = x, i;     for (i = 2; i * i <= t; i++) {       if (t % i == 0) {         ret -= ret / i;         while (t % i == 0) t /= i;       }     }     if (t != 1) ret -= ret / t;     return ret;   }   long long int eadivc(long long int x) {     long long int ret = 0;     long long int i;     for (i = 1; i * i <= x; i++) {       if (x % i == 0 && i * i != x) ret += 2;       if (x % i == 0 && i * i == x) ret += 1;     }     return ret;   }   long long int eadivs(long long int x) {     long long int ret = 0;     long long int i;     for (i = 1; i * i <= x; i++) {       if (x % i == 0 && i * i != x) ret += i + x / i;       if (x % i == 0 && i * i == x) ret += i;     }     return ret;   }   long long int ndig(long long int x, long long int b) {     long long int ret = 0;     while (x) {       x /= b;       ret++;     }     return ret;   }   long long int rev(long long int n, long long int b) {     long long int ret = 0;     while (n) {       ret = b * ret + n % b;       n /= b;     }     return ret;   }   long long int sq(long long int x) {     long long int t = (long long int)sqrt(x);     for (long long int i = t - 2; i <= t + 2; i++)       if (i * i == x) return abs(i);     return -1;   }   long long int extexp(long long int x, long long int y) {     if (y < 0) return 0;     long long int ret = 1;     for (; y; y >>= 1, x = extm(x, x)) {       if (y & 1) ret = extm(ret, x);     }     return ret;   }   bool isprime(long long int x) {     if (x <= 1) return false;     for (long long int i = 2; i * i <= x; i++) {       if (x % i == 0) {         return false;       }     }     return true;   }   int val[755][755], B = 700;   int a[555555], q;   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int i, t, x, y, ans;     cin >> q;     while (q--) {       cin >> t >> x >> y;       if (t == 1) {         a[x] += y;         for (i = 1; i <= B; i++) val[i][x % i] += y;       }       if (t == 2) {         ans = 0;         if (x <= B)           cout << val[x][y] <<   n ;         else {           for (i = y; i <= 500000; i += x) ans += a[i];           cout << ans <<   n ;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool isPrime(int N) {     for (int i = 2; i * i <= N; ++i) {       if (N % i == 0) return false;     }     return true;   }   bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first);   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   bool comp(const pair<int, int> &a, const pair<int, int> &b) {     if (a.first == b.first)       return a.second < b.second;     else       return a.first > b.first;   }   int main() {     int n;     cin >> n;     int flag = 0;     char a[5][5];     int max = 11;     int digit[11] = {0};     for (int i = 0; i < 4; i++) {       for (int j = 0; j < 4; j++) {         cin >> a[i][j];         if (a[i][j] !=  . ) {           digit[a[i][j] - 48]++;         }       }     }     for (int i = 0; i < 10; i++) {       if (digit[i] > 2 * n) {         cout <<  NO ;         flag = 1;         break;       }     }     if (flag == 0) {       cout <<  YES ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T, class L>   bool smax(T& x, L y) {     return x < y ? (x = y, 1) : 0;   }   template <class T, class L>   bool smin(T& x, L y) {     return x > y ? (x = y, 1) : 0;   }   const int maxn = 2e6 + 17;   pair<int, pair<int, int> > a[maxn];   int n, m, par[maxn], mx[maxn], here[maxn];   map<pair<int, int>, int> ans;   int r(int v) { return par[v] < 0 ? v : par[v] = r(par[v]); }   void mrg(int v, int u) {     if ((v = r(v)) == (u = r(u))) return;     if (par[u] < par[v]) swap(v, u);     par[v] += par[u];     par[u] = v;     smax(mx[v], mx[u]);   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0, x; j < m; j++) cin >> x, a[i * m + j] = {x, {i, j}};     sort(a, a + n * m);     for (int l = 0; l < n * m;) {       int r = l;       while (a[r].first == a[l].first) r++;       for (int i = l; i < r; i++) {         mx[a[i].second.first] = mx[a[i].second.second + n] = 0;         par[a[i].second.first] = par[a[i].second.second + n] = -1;       }       for (int i = l; i < r; i++)         smax(mx[a[i].second.first],              max(here[a[i].second.first], here[a[i].second.second + n]) + 1);       for (int i = l; i < r; i++) mrg(a[i].second.first, a[i].second.second + n);       for (int i = l; i < r; i++) {         ans[{a[i].second.first, a[i].second.second}] = mx[::r(a[i].second.first)];         smax(here[a[i].second.first],              ans[{a[i].second.first, a[i].second.second}]);         smax(here[a[i].second.second + n],              ans[{a[i].second.first, a[i].second.second}]);       }       l = r;     }     for (int i = 0; i < n; i++, cout <<   n )       for (int j = 0; j < m; j++) cout << ans[{i, j}] <<    ;     return 0;   }


#include <bits/stdc++.h>   const long long base1 = 131;   const long long base2 = 233;   const long long mod1 = 998244353;   const long long mod2 = 1e9 + 7;   const long long MaxN = 1e6 + 50;   template <class t>   inline void read(t &s) {     s = 0;     register long long f = 1;     register char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     s *= f;     return;   }   template <class t, class... A>   inline void read(t &x, A &...a) {     read(x);     read(a...);   }   template <class t>   inline void write(t x) {     if (x < 0) putchar( - ), x = -x;     long long buf[21], top = 0;     while (x) buf[++top] = x % 10, x /= 10;     if (!top) buf[++top] = 0;     while (top) putchar(buf[top--] ^  0 );     return;   }   inline void setIn(std::string s) {     freopen(s.c_str(),  r , stdin);     return;   }   inline void setOut(std::string s) {     freopen(s.c_str(),  w , stdout);     return;   }   inline void setIO(std::string s =   ) {     setIn(s +  .in );     setOut(s +  .out );     return;   }   template <class t>   inline bool checkmin(t &x, t y) {     if (x > y) {       x = y;       return 1;     }     return 0;   }   template <class t>   inline bool checkmax(t &x, t y) {     if (x < y) {       x = y;       return 1;     }     return 0;   }   inline long long lowbit(long long x) { return x & (-x); }   std::vector<long long> E[MaxN];   std::pair<long long, long long> f[MaxN];   long long e1[MaxN], e2[MaxN], U[MaxN], V[MaxN];   signed main(void) {     long long n, m;     read(n, m);     register long long u, v, ans = 0;     for (long long i = 1; i <= m; ++i)       read(u, v), U[i] = u, V[i] = v, E[u].push_back(v), E[v].push_back(u);     for (long long i = 1; i <= n; ++i) std::sort((E[i]).begin(), (E[i]).end());     for (long long i = 1; i <= n; ++i) {       register long long s1 = 0, s2 = 0;       for (auto v : E[i])         s1 = (s1 * base1 + v) % mod1, s2 = (s2 * base2 + v) % mod2;       f[i] = std::make_pair(s1, s2);       s1 = 0, s2 = 0;       E[i].push_back(i), std::sort((E[i]).begin(), (E[i]).end());       for (auto v : E[i])         s1 = (s1 * base1 + v) % mod1, s2 = (s2 * base2 + v) % mod2;       e1[i] = s1, e2[i] = s2;     }     std::sort(f + 1, f + n + 1);     register long long cnt = 0;     for (long long i = 2; i <= n; ans += cnt, ++i)       cnt = (f[i] == f[i - 1]) ? (cnt + 1) : 0;     for (long long i = 1; i <= m; ++i)       if (e1[U[i]] == e1[V[i]] && e2[U[i]] == e2[V[i]]) ++ans;     write(ans), std::puts(  );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e6 + 5;   char s1[MAX], s2[MAX];   int main() {     cin >> s1 + 1;     cin >> s2 + 1;     int len1 = strlen(s1 + 1);     int len2 = strlen(s2 + 1);     int i = 1, j = 1;     for (; i <= len1 && j <= len2;) {       if (s1[i] == s2[j])         i++, j++;       else         j++;     }     if (i != len1 + 1) {       puts( 0 );       return 0;     }     int tmp1 = j - 1;     for (i = len1, j = len2; j >= 1 && i >= 1;) {       if (s1[i] == s2[j])         i--, j--;       else         j--;     }     if (i != 0) {       puts( 0 );       return 0;     }     int tmp2 = j + 1;     if (tmp2 - tmp1 >= 0) {       printf( %d n , tmp2 - tmp1);     } else       printf( 0 );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-9;   long double PI = acos((long double)-1.0);   struct io_s {     bool negative;     char ch;     inline bool isdigitx(char c) { return c >=  0  && c <=  9 ; }     inline char nextchar() {       static char buf[100000], *p1 = buf, *p2 = buf;       return p1 == p2 &&                      (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                  ? EOF                  : *p1++;     }     template <typename T>     bool rn(T& _v) {       negative = false;       _v = 0;       while (!isdigitx(ch = nextchar()) && ch != EOF) {         negative = ch ==  - ;       };       if (ch == EOF) return false;       do {         _v *= 10;         _v += ch -  0 ;       } while (isdigitx(ch = nextchar()));       if (negative) _v = -_v;       return true;     }     template <typename T>     bool run(T& _v) {       _v = 0;       while (!isdigitx(ch = nextchar()) && ch != EOF) {       };       if (ch == EOF) return false;       do {         _v *= 10;         _v += ch -  0 ;       } while (isdigitx(ch = nextchar()));       return true;     }     template <typename T>     inline T r() {       T v = T();       rn(v);       return v;     }     inline int ri() { return r<int>(); }     inline long long rll() { return r<long long>(); }     inline int gets(char* s) {       char* c = s;       do {         ch = nextchar();       } while (ch ==   n  || ch ==   r );       do {         *(c++) = ch;         ch = nextchar();       } while (ch !=   n  && ch !=   r );       *(c++) =   0 ;       return c - s - 1;     }     inline char get() {       do {         ch = nextchar();       } while (ch <  A  || ch >  Z );       return ch;     }     template <class T>     inline void o(T p) {       static int stk[70], tp;       if (p == 0) {         putchar( 0 );         return;       }       if (p < 0) {         p = -p;         putchar( - );       }       while (p) stk[++tp] = p % 10, p /= 10;       while (tp) putchar(stk[tp--] +  0 );     }     inline void ln() { putchar(  n ); }     inline void space() { putchar(   ); }     template <class T>     inline void oln(T p) {       o(p);       ln();     }   } io;   using namespace std;   const int N = 100005, M = 10000005;   int ls[M], rs[M], rt[N], n, a[N], m, ndc;   set<int> dat[N];   long long sum[M];   void update(int& x, int l, int r, int p, int u) {     if (!x) x = ++ndc;     sum[x] += u;     if (l == r) return;     int mid = (l + r) >> 1;     if (p <= mid)       update(ls[x], l, mid, p, u);     else       update(rs[x], mid + 1, r, p, u);   }   long long ask(int& x, int l, int r, int s, int t) {     if (!x || l == s && r == t) return sum[x];     int mid = (l + r) >> 1;     if (t <= mid) return ask(ls[x], l, mid, s, t);     if (s > mid) return ask(rs[x], mid + 1, r, s, t);     return ask(ls[x], l, mid, s, mid) + ask(rs[x], mid + 1, r, mid + 1, t);   }   void modify(int x, int y, int u) {     while (x <= n) update(rt[x], 1, n, y, u), x += ((x) & -(x));   }   long long query(int x, int y) {     long long ret = 0;     while (x) ret += ask(rt[x], 1, n, 1, y), x &= x - 1;     return ret;   }   void add(int p, int x) {     dat[p].insert(x);     auto it = dat[p].find(x), pre = it, suf = it;     bool f1 = false, f2 = false;     if (pre != dat[p].begin()) --pre, modify(*pre, x, x - *pre), f1 = 1;     ++suf;     if (suf != dat[p].end()) modify(x, *suf, *suf - x), f2 = 1;     if (f1 && f2) modify(*pre, *suf, -(*suf - *pre));   }   void del(int p, int x) {     auto it = dat[p].find(x), pre = it, suf = it;     bool f1 = false, f2 = false;     if (pre != dat[p].begin()) --pre, modify(*pre, x, -(x - *pre)), f1 = 1;     ++suf;     if (suf != dat[p].end()) modify(x, *suf, -(*suf - x)), f2 = 1;     if (f1 && f2) modify(*pre, *suf, *suf - *pre);     dat[p].erase(x);   }   int main() {     io.rn(n);     io.rn(m);     for (int i = 1; i <= n; i++) add(a[i] = io.ri(), i);     for (int i = 1, o, u, v; i <= m; i++) {       io.rn(o);       io.rn(u);       io.rn(v);       if (o == 1)         del(a[u], u), a[u] = v, add(a[u], u);       else {         int t = n;         while (t > 0 && (t & (t - 1)) >= v - 1) t &= (t - 1);         io.oln(query(t, v) - query(u - 1, v));       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MXN = 200;   const int MXK = 5;   int bans = -1;   int t[MXN][MXK];   int a[MXK];   int n;   int c[MXK];   int cc[] = {500, 1000, 1500, 2000, 2500, 3000};   int cat(int c, int n) {     if (c * 2 > n) {       return 0;     }     if (c * 4 > n && c * 2 <= n) {       return 1;     }     if (c * 8 > n && c * 4 <= n) {       return 2;     }     if (c * 16 > n && c * 8 <= n) {       return 3;     }     if (c * 32 > n && c * 16 <= n) {       return 4;     }     if (c * 32 <= n) {       return 5;     }   }   int calc(int i) {     int res = 0;     for (int j = (0); j < (MXK); j++) {       if (t[i][j] != -1) res += cc[a[j]] - t[i][j] * cc[a[j]] / 250;     }     return res;   }   bool ok(int c, int n, int tt, int j) {     return cat(c + tt * (t[0][j] != -1), n + tt) <= a[j] &&            cat(c, n + tt) >= a[j];   }   int T;   void dfs(int i) {     if (i == MXK) {       int mn = 0;       for (int j = (0); j < (MXK); j++) {         if (!ok(c[j], n, T, j)) return;       }       if (calc(0) > calc(1)) {         printf( %d , T);         exit(0);       }       return;     }     for (int j = (0); j < (6); j++) {       a[i] = j;       dfs(i + 1);     }   }   int main() {     scanf( %d , &n);     for (int i = (0); i < (n); i++) {       for (int j = (0); j < (5); j++) {         scanf( %d , &t[i][j]);         if (t[i][j] != -1) {           c[j]++;         }       }     }     for (int i = (0); i < (n * 31 + 1); i++) {       T = i;       dfs(0);     }     cout << bans;   }


#include <bits/stdc++.h>   using namespace std;   int n, l, r, id[1010][1010];   bool tag[1010][1010];   struct node {     int x, y;     pair<vector<node>, int> e() {       vector<node> v;       int c = 0;       v.push_back((node){x + 1, y});       if (x > 0)         v.push_back((node){x - 1, y});       else         c++;       if (x & 1) {         if (x > 0)           v.push_back((node){x - 1, y + 1});         else           c++;       } else {         if (y > 0)           v.push_back((node){x + 1, y - 1});         else           c++;       }       return make_pair(v, c);     }   } a[250010], q[2500010];   vector<node> V;   void dfs(node x, node la) {     if (tag[x.x][x.y]) {       puts( SICK ), exit(0);     }     V.push_back(x), tag[x.x][x.y] = 1;     vector<node> v = x.e().first;     for (int j = 0, sz = v.size(); j < sz; j++)       if (id[v[j].x][v[j].y] && (v[j].x != la.x || v[j].y != la.y)) {         dfs(v[j], x);       }   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i].x >> a[i].y;       tag[a[i].x][a[i].y] = 1;     }     l = 1, r = n;     for (int i = 1; i <= n; i++) q[i] = a[i];     while (l <= r) {       id[q[l].x][q[l].y] = l;       vector<node> u = q[l].e().first, v;       for (int j = 0, sz = u.size(); j < sz; j++) {         if (tag[u[j].x][u[j].y]) continue;         v = u[j].e().first;         for (int k = 0, Sz = v.size(); k < Sz; k++)           if (id[v[k].x][v[k].y] && id[v[k].x][v[k].y] != l) {             q[++r] = u[j], tag[u[j].x][u[j].y] = 1;             break;           }       }       l++;     }     int cnt = 0, ans = 0;     memset(tag, 0, sizeof(tag));     for (int i = 1; i <= r; i++)       if (!tag[q[i].x][q[i].y]) {         V.clear();         cnt++;         dfs(q[i], (node){-1, -1});         if (V.size() == 4) {           int cc = 0;           for (int j = 0; j < 4; j++)             if (id[V[j].x][V[j].y] > n) {               cc++;               vector<node> v = V[j].e().first;               if (v.size() == 3) {                 for (int k = 0; k < 4; k++)                   if (k != j) {                     bool tag = 0;                     for (int l = 0; l < 3; l++)                       if (V[k].x == v[l].x && V[k].y == v[l].y) tag = 1;                     if (tag) cc -= 10;                   }               }             }           if (cc == -29) cnt++;         }       }     for (int i = n + 1; i <= r; i++) id[q[i].x][q[i].y] = 0;     for (int i = 1; i <= n; i++) {       pair<vector<node>, int> v = q[i].e();       ans += v.second;       for (int u, j = 0, sz = v.first.size(); j < sz; j++)         if (!id[v.first[j].x][v.first[j].y]) {           ans++;         }     }     printf( RECOVERED n%d n , ans - 2 * cnt);   }


#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print(T x) {     cout << x << endl;   }   template <typename T1, typename T2>   void print2(T1 x, T2 y) {     cout << x <<     << y << endl;   }   template <typename T1, typename T2, typename T3>   void print3(T1 x, T2 y, T3 z) {     cout << x <<     << y <<     << z << endl;   }   void chandan1() {     int y = 1;     return;   }   void chandan2() {     for (long long int i = 0; i < 10; i++) {       long long int x = 1;     }     return (chandan1());   }   vector<long long int> path;   void bfs(vector<long long int> adj[], long long int v, long long int source,            long long int destin) {     bool vis[v + 1];     long long int parent[v + 1];     for (long long int i = 0; i < v + 1; i++) {       vis[i] = 0;     }     parent[source] = source;     queue<long long int> q;     q.push(source);     vis[source] = 1;     while (q.empty() == false) {       long long int u = q.front();       q.pop();       for (auto xt : adj[u]) {         if (vis[xt] == 0) {           vis[xt] = 1;           parent[xt] = u;           q.push(xt);         }       }     }     vector<long long int> temp;     while (parent[destin] != destin) {       temp.emplace_back(destin);       destin = parent[destin];     }     reverse(temp.begin(), temp.end());     for (auto xt : temp) path.emplace_back(xt);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     chandan2();     while (t--) {       long long int v, e;       cin >> v;       vector<long long int> adj[v + 1];       for (long long int i = 0; i < v - 1; i++) {         long long int a, b;         cin >> a >> b;         adj[a].emplace_back(b);         adj[b].emplace_back(a);       }       vector<long long int> leaves;       leaves.emplace_back(1);       long long int val;       while (cin >> val) {         leaves.emplace_back(val);       }       leaves.emplace_back(1);       path.emplace_back(1);       for (long long int i = 0; i < int(leaves.size()) - 1; i++) {         long long int src = leaves[i];         long long int desti = leaves[i + 1];         bfs(adj, v, src, desti);       }       if (int(path.size()) > (2 * v - 1))         print(-1);       else {         for (auto xt : path) cout << xt <<    ;         cout <<   n ;         ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int dp[10000];     for (int i = 0; i < n; i++) cin >> dp[i];     dp[1] = min(dp[1], dp[0]);     for (int i = 2; i < n; i++) dp[i] = min(dp[i], max(dp[i - 1], dp[i - 2]));     cout << dp[n - 1] << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   template <class T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   const double PI = 2.0 * acos(0.0);   const int mx[] = {0, 1, 0, -1};   const int my[] = {-1, 0, 1, 0};   int check(long long s) {     int res = 0;     while (s > 0) res += s % 10, s /= 10;     return res;   }   int main() {     vector<int> ans;     int a, b, c;     ans.clear();     scanf( %d%d%d , &a, &b, &c);     for (int i = 1; i <= 81; i++) {       long long tmp = b;       for (int j = 1; j <= a; j++) tmp *= i;       tmp += c;       if (tmp < 1e9 && check(tmp) == i) ans.push_back(tmp);     }     sort(ans.begin(), ans.end());     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) {       if (i > 0) putchar(   );       printf( %d , ans[i]);     }     putchar(  n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   using ll = long long;   template <typename T>   void DEBUG(string label, T value) {     cerr <<  [  << label <<   =   << value <<  ] n ;   }   map<string, int> encode;   map<int, string> decode;   int m, n;   vector<vector<int>> adj;   void solve() {     cin >> m;     n = 0;     for (int i = 0; i < m; ++i) {       string a, b;       cin >> a >> b;       if (encode.count(a) == 0) {         encode[a] = n;         decode[n] = a;         n++;       }       if (encode.count(b) == 0) {         encode[b] = n;         decode[n] = b;         n++;       }       while (adj.size() < n) {         adj.push_back(vector<int>());       }       adj[encode[a]].push_back(encode[b]);       adj[encode[b]].push_back(encode[a]);     }     cout << n <<   n ;     for (int i = 0; i < n; ++i) {       vector<bool> vis(n);       vis[i] = true;       for (int nxt : adj[i]) {         vis[nxt] = true;       }       vector<int> cnt(n);       for (int nxt : adj[i]) {         for (int k : adj[nxt]) {           if (!vis[k]) {             cnt[k]++;           }         }       }       int mx = *max_element(cnt.begin(), cnt.end());       int ans = 0;       for (int j = 0; j < n; ++j) {         ans += (!vis[j] && cnt[j] == mx);       }       cout << decode[i] <<     << ans <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     t = 1;     while (t--) solve();   }


#include <bits/stdc++.h>   using namespace std;   int p[201], bag[201];   int n, l, k;   double mem[202][202][202];   double solve(int r, int bagwon, int prizewon) {     if (mem[r][bagwon][prizewon] >= -.5) return mem[r][bagwon][prizewon];     if (r == n)       return mem[r][bagwon][prizewon] =                  bagwon + k >= prizewon && prizewon >= l ? 1 : 0;     if (bag[r] == -1)       return mem[r][bagwon][prizewon] =                  double(p[r] * solve(r + 1, bagwon, prizewon + 1) +                         (100 - p[r]) * solve(r + 1, bagwon, prizewon)) /                  100;     else       return mem[r][bagwon][prizewon] =                  double(p[r] * solve(r + 1, min(200, bagwon + bag[r] + 1),                                      prizewon + 1) +                         (100 - p[r]) * solve(r + 1, bagwon, prizewon)) /                  100;   }   int main() {     memset(mem, -1, sizeof mem);     cin >> n >> l >> k;     for (int i = 0; i < n; i++) cin >> p[i];     for (int i = 0; i < n; i++) cin >> bag[i];     cout.precision(100);     cout << fixed << solve(0, 0, 0) << endl;     return 0;   }


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


#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   vector<string> v(100005);   long long int n, m;   long long int check(string s, string str) {     long long int count = 0;     for (long long int i = 0; i < s.size(); i++) {       if (str[i] != s[i]) count++;     }     return count;   }   bool ok(string s) {     for (long long int i = 0; i < n; i++) {       long long int x = check(s, v[i]);       if (x > 1) return false;     }     return true;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) {       cin >> n >> m;       string ans =  -1 ;       for (long long int i = 0; i < n; i++) {         cin >> v[i];       }       for (long long int i = 0; i < n; i++) {         for (long long int j = 0; j < v[i].size(); j++) {           for (char k =  a ; k <=  z ; k++) {             string str = v[i];             str[j] = k;             if (ok(str)) {               ans = str;             }           }         }       }       cout << ans <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     printf( %d , ((a ^ b) & (c | d)) ^ ((b & c) | (a ^ d)));     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int maxn = 1010;   int Dp[maxn][maxn], dp[maxn][maxn], f[maxn][maxn], g[maxn][maxn];   int a[maxn][maxn];   int n, m;   int main() {     while (~scanf( %d%d , &n, &m)) {       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j) scanf( %d , &a[i][j]);       memset(Dp, 0, sizeof(Dp));       memset(dp, 0, sizeof(dp));       memset(f, 0, sizeof(f));       memset(g, 0, sizeof(g));       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= m; ++j)           dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];       for (int i = n; i >= 1; --i)         for (int j = m; j >= 1; --j)           Dp[i][j] = max(Dp[i + 1][j], Dp[i][j + 1]) + a[i][j];       for (int i = n; i >= 1; --i)         for (int j = 1; j <= m; ++j)           f[i][j] = max(f[i + 1][j], f[i][j - 1]) + a[i][j];       for (int i = 1; i <= n; ++i)         for (int j = m; j >= 1; --j)           g[i][j] = max(g[i - 1][j], g[i][j + 1]) + a[i][j];       int Ans = 0;       for (int i = 2; i < n; ++i)         for (int j = 2; j < m; ++j)           Ans = max(Ans,                     max(dp[i - 1][j] + Dp[i + 1][j] + f[i][j - 1] + g[i][j + 1],                         dp[i][j - 1] + Dp[i][j + 1] + f[i + 1][j] + g[i - 1][j]));       printf( %d n , Ans);     }   }


#include <bits/stdc++.h>   using namespace std;   string s;   int n, m, t, x, g;   int f[100005];   string b[15];   int l[15];   int main() {     cin >> s;     n = s.length();     scanf( %d n , &m);     for (int i = 0; i < m; i++) {       cin >> b[i];       l[i] = b[i].length();       scanf(  n );     }     f[0] = 0;     for (int i = 0; i < n; i++) {       x = f[i] + 1;       t = 0;       for (int j = 0; j < m; j++)         if (l[j] <= x) {           g = 1;           for (int w = 0; w < l[j]; w++)             if (b[j][w] != s[i - l[j] + 1 + w]) {               g = 0;               break;             }           t = g;           if (t) break;         }       if (!t) {         f[i + 1] = x;         continue;       }       x = i + 1;       t = 1000;       for (int j = 0; j < m; j++)         if (l[j] <= x) {           g = 1;           for (int w = 0; w < l[j]; w++)             if (b[j][w] != s[i - l[j] + 1 + w]) {               g = 0;               break;             }           if (g) {             if (l[j] < t) t = l[j];           }         }       f[i + 1] = t - 1;     }     t = 0;     x = -1;     for (int i = 1; i <= n; i++)       if (f[i] > t) {         t = f[i];         x = i - 1;       }     printf( %d %d n , t, x - t + 1);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int N, M, k;     string in;     list<string> ret;     cin >> N >> M;     cin >> in >> k;     if (k == 0) {       for (int i = 0; i < N; i++) in[i] = ((in[i] -  0 ) ^ 1) +  0 ;       ret.push_back(in);     } else {       long long s = (1LL << k) - 1;       while (!(s & 1LL << N)) {         string c = in;         for (int i = 0; i < N; i++)           if (!(s & (1LL << i))) c[i] = ((c[i] -  0 ) ^ 1) +  0 ;         ret.push_back(c);         long long lo = s & ~(s - 1);         long long lz = (s + lo) & ~s;         s |= lz;         s &= ~(lz - 1);         s |= (lz / lo / 2) - 1;       }     }     for (int i = 1; i < M; i++) {       cin >> in >> k;       list<string>::iterator it = ret.begin();       while (it != ret.end()) {         int c = 0;         for (int j = 0; j < N; j++)           if ((*it)[j] == in[j]) c++;         if (c != k)           it = ret.erase(it);         else           it++;       }     }     cout << ret.size();     return 0;   }


#include <bits/stdc++.h>   const double eps = (1e-9);   using namespace std;   int dcmp(long double a, long double b) {     return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;   }   int getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; }   int setBit1(int num, int idx) { return num | (1 << idx); }   long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }   long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }   void M() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int countNumBit1(int mask) {     int ret = 0;     while (mask) {       mask &= (mask - 1);       ++ret;     }     return ret;   }   string st;   int n;   int main() {     M();     cin >> n >> st;     char c1, c2, c3, F, S, T;     int mi = INT_MAX;     for (int i = 1; i <= 3; i++) {       for (int j = 1; j <= 3; j++) {         for (int k = 1; k <= 3; k++) {           int cnt1 = 0, cnt2 = 0, cnt3 = 0;           if (i == j || i == k || j == k) continue;           c1 = (i == 1 ?  R  : (i == 2 ?  B  :  G ));           c2 = (j == 1 ?  R  : (j == 2 ?  B  :  G ));           c3 = (k == 1 ?  R  : (k == 2 ?  B  :  G ));           for (int l = 0; l < n; l += 3) {             if (st[l] != c1) cnt1++;           }           for (int l = 1; l < n; l += 3) {             if (st[l] != c2) cnt2++;           }           for (int l = 2; l < n; l += 3) {             if (st[l] != c3) cnt3++;           }           long long ans = cnt1 + cnt2 + cnt3;           if (ans < mi) {             mi = ans;             F = c1;             S = c2;             T = c3;           }         }       }     }     for (int l = 0; l < n; l += 3) {       st[l] = F;     }     for (int l = 1; l < n; l += 3) {       st[l] = S;     }     for (int l = 2; l < n; l += 3) {       st[l] = T;     }     cout << mi << endl << st << endl;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 520, M = 512;   int f[N], g[N];   int a[int(1e6)];   int n;   int main() {     scanf( %d , &n);     for (register int i = 1; i <= n; ++i) scanf( %d , a + i);     for (register int i = 1; i < M; ++i) f[i] = 1e9;     f[0] = -1;     for (register int i = 1; i <= n; ++i) {       for (register int k = 0; k < M; ++k) {         g[k] = f[k];         if (f[k xor a[i]] < a[i]) g[k] = min(f[k], a[i]);       }       swap(f, g);     }     int cnt = 0;     for (register int i = 0; i < M; ++i)       if (f[i] != int(1e9)) ++cnt;     printf( %d n , cnt);     for (register int i = 0; i < M; ++i)       if (f[i] != int(1e9)) printf( %d  , i);     puts(  );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int m, n, q, x;   int ans;   int a[N], b[N];   char s[N], p[N], t[N];   int main() {     int T;     scanf( %d , &T);     while (T--) {       int pt1, pt2;       pt1 = pt2 = 0;       memset(a, 0, sizeof(a));       memset(b, 0, sizeof(b));       cin >> s >> t >> p;       int f = 0;       int lens = strlen(s);       int lenp = strlen(p);       int lent = strlen(t);       for (pt2 = 0; pt2 < lent; pt2++) {         if (s[pt1] == t[pt2]) {           pt1++;         } else           b[t[pt2] -  a ]++;       }       if (pt1 < lens) {         cout <<  NO  << endl;         continue;       }       for (int i = 0; i < lenp; i++) a[p[i] -  a ]++;       for (int i = 0; i < 26; i++) {         if (b[i] > a[i]) {           f = 1;           cout <<  NO  << endl;           break;         }       }       if (f == 0) cout <<  YES  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline long long getnum() {     char c = getchar();     long long num, sign = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) sign = -1;     for (num = 0; c >=  0  && c <=  9 ;) {       c -=  0 ;       num = num * 10 + c;       c = getchar();     }     return num * sign;   }   int A[540][540][12];   int main() {     int n = getnum();     A[1][1][0] = 1;     for (int i = 1; i <= 9; i++) {       int l = 1 << i;       int fx = l, fy = 1;       int sx = l, sy = l;       int tx = 1, ty = l;       l /= 2;       for (int j = 1; j <= l; j++) {         for (int k = 1; k <= l; k++) {           A[j][k][i] = A[j][k][i - 1];           A[fx][fy][i] = A[j][k][i - 1];           A[sx][sy][i] = A[j][k][i - 1];           A[tx][ty][i] = 1 - A[j][k][i - 1];           fy++, sy--, ty--;         }         fx--, sx--, tx++;         fy = 1, sy = l * 2, ty = l * 2;       }     }     int l = 1 << n;     for (int i = 1; i <= l; i++) {       for (int j = 1; j <= l; j++) {         if (A[i][j][n])           putchar( + );         else           putchar( * );       }       putchar(  n );     }   }


#include <bits/stdc++.h>   using namespace std;   long long a[100005], n, cont[100005];   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i], cont[50 + a[i]]++;     long long res = 0;     for (int i = 0; i <= 10; i++) {       if (i == 0) {         long long x = cont[50];         res += (x * (x - 1)) / 2;       } else {         res += cont[50 + i] * cont[50 - i];       }     }     cout << res << endl;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     int m;     cin >> n >> m;     long long cnt = 0;     if (m == 1) {       cout << n * n << endl;       return 0;     }     if (m < n) {       for (int i = 1; i <= m; i++)         for (int j = 1; j <= m; j++)           if ((i * i + j * j) % m == 0) cnt++;       long long mul = n / m;       mul = mul * mul;       cnt *= mul;       long long index = (n / m) * m;       index++;       if (index <= n) {         long long cnt1 = 0;         for (long long i = index; i <= n; i++)           for (long long j = 1; j <= m; j++) {             long long i1 = i % m;             long long j1 = j % m;             if ((i1 * i1 + j1 * j1) % m == 0) cnt1++;           }         mul = n / m;         mul *= 2;         cnt1 *= mul;         cnt += cnt1;         for (long long i = index; i <= n; i++)           for (long long j = index; j <= n; j++) {             long long i1 = i % m;             long long j1 = j % m;             if ((i1 * i1 + j1 * j1) % m == 0) cnt++;           }       }     } else {       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           if ((i * i + j * j) % m == 0) cnt++;     }     cout << cnt << endl;     return 0;   }


#include <bits/stdc++.h>   const long double eps = 1e-10;   const int MOD = 1000000007;   using namespace std;   int a[200005], K, n;   int main() {     scanf( %d %d , &n, &K);     for (int i = 0; i < n; ++i) scanf( %d , a + i);     sort(a, a + n);     int ret = 0;     for (int i = 0; i < n - 1; ++i) {       int b = a[i] + K;       int low = i + 1, high = n;       while (low <= high) {         int mid = (low + high) >> 1;         if (a[mid] == a[i]) {           low = mid + 1;           continue;         }         if (a[mid] > a[i] && a[mid] <= b) {           ++ret;           break;         } else {           high = mid - 1;         }       }     }     printf( %d n , n - ret);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 501;   int n, vis[maxn][maxn], a[maxn][maxn], x, y, s, cnt;   char p[3000010];   int d[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};   bool J(int x, int y, int i) {     while (true) {       x += d[i][0];       y += d[i][1];       if (!x || !y || x > n || y > n) return 0;       if (vis[x][y]) return 0;       if (a[x][y]) return 1;     }   }   void dfs(int x, int y) {     if (!a[x][y]) p[cnt++] =  1 , s++;     vis[x][y] = 1;     for (int i = 0; i < 4; i++)       if (J(x, y, i)) {         p[cnt++] = (!i ?  R  : i == 1 ?  D  : i == 2 ?  U  :  L );         dfs(x + d[i][0], y + d[i][1]);         p[cnt++] = (!i ?  L  : i == 1 ?  U  : i == 2 ?  D  :  R );       }     p[cnt++] =  2 , s--;   }   int main() {     scanf( %d%d%d , &n, &x, &y);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]), s += a[i][j];     dfs(x, y);     p[cnt++] = 0;     if (s)       printf( NO n );     else       printf( YES n%s n , p);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long fact_a[1000005];   long long factorial() {     fact_a[0] = fact_a[1] = 1;     for (long long i = 2; i < 1000005; i++) fact_a[i] = (fact_a[i - 1] * i);   }   long long power(long long x, long long n) {     long long result = 1;     while (n > 0) {       if (n % 2 == 1) result = result * x;       x = x * x;       n = n / 2;     }     return result;   }   long long nCr(long long n, long long r) {     if (n < r) return 0LL;     if (n == r) return 1LL;     long long ans = fact_a[n];     ans = (ans * power(fact_a[r], 1000000007 - 2)) % 1000000007;     ans = (ans * power(fact_a[n - r], 1000000007 - 2)) % 1000000007;     return ans;   }   long long prime[1000005];   void sieve() {     prime[1000005] = {0};     for (long long i = 2; i < 1000005; i++) {       if (prime[i] == 0) {         for (long long j = i * i; j < 1000005; j += i) {           prime[j] = 1;         }       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tc;     cin >> tc;     while (tc--) {       long long n, k;       cin >> n;       long long a[n];       set<long long> s;       for (long long i = 0; i < n; i++) {         cin >> a[i];         s.insert(a[i]);       }       if (s.size() == 1)         cout << n <<   n ;       else         cout << 1 <<   n ;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     string s, t;     cin >> s;     size_t a, b, c, d, n;     n = s.length();     t.reserve(n);     a = s.find( 0 );     b = s.find( 1 );     c = s.find( 2 );     d = c;     for (size_t i = 0; i < n; i++) {       if (a < d) {         t +=  0 ;         a = s.find( 0 , a + 1);       } else if (b < n) {         t +=  1 ;         b = s.find( 1 , b + 1);       } else {         if (a < c) {           t +=  0 ;           a = s.find( 0 , a + 1);         } else {           t +=  2 ;           c = s.find( 2 , c + 1);         }       }     }     cout << t;   }


#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     long long a[2];     cin >> a[0] >> a[1];     sort(a, a + 2);     n = 2 * a[0];     if (n < a[1]) {       n = a[1];     }     n *= n;     cout << n << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   #define rep(i, n) for(int i = 0; i < n; i++)   #define rep2(i, x, n) for(int i = x; i <= n; i++)   #define rep3(i, x, n) for(int i = x; i >= n; i--)   #define each(e, v) for(auto &e: v)   #define pb push_back   #define eb emplace_back   #define all(x) x.begin(), x.end()   #define rall(x) x.rbegin(), x.rend()   #define sz(x) (int)x.size()   using ll = long long;   using pii = pair<int, int>;   using pil = pair<int, ll>;   using pli = pair<ll, int>;   using pll = pair<ll, ll>;   const int MOD = 1000000007;   //const int MOD = 998244353;   const int inf = (1<<30)-1;   const ll INF = (1LL<<60)-1;   template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};   template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};      struct io_setup{       io_setup(){           ios_base::sync_with_stdio(false);           cin.tie(NULL);           cout << fixed << setprecision(15);       }   } io_setup;      template<typename T, typename Operator_Monoid>   struct Dual_Segment_Tree{       using G = function<T(T, Operator_Monoid)>;       using H = function<Operator_Monoid(Operator_Monoid, Operator_Monoid)>;       int n, height;       vector<T> seg;       vector<Operator_Monoid> lazy;       const G g;       const H h;       const Operator_Monoid e2;          Dual_Segment_Tree(const vector<T> &v, const G &g, const H &h, const Operator_Monoid &e2) : g(g), h(h), e2(e2){           int m = sz(v);           n = 1, height = 0;           while(n < m) n <<= 1, height++;           lazy.assign(2*n, e2);           seg = v;       }          inline void eval(int i){           if(i < n && lazy[i] != e2){               lazy[2*i] = h(lazy[2*i], lazy[i]);               lazy[2*i+1] = h(lazy[2*i+1], lazy[i]);               lazy[i] = e2;           }       }          inline void thrust(int i){           for(int j = height; j > 0; j--) eval(i>>j);       }          void apply(int l, int r, const Operator_Monoid &x){           chmax(l, 0), chmin(r, n);           if(l >= r) return;           l += n, r += n;           thrust(l), thrust(r-1);           while(l < r){               if(l&1) lazy[l] = h(lazy[l], x), l++;               if(r&1) r--, lazy[r] = h(lazy[r], x);               l >>= 1, r >>= 1;           }       }          T get(int i){           thrust(i+n);           return g(seg[i], lazy[i+n]);       }          T operator [] (int i) {return get(i);}   };      int main(){       int T;       cin >> T;       while(T--){           int N;           cin >> N;           vector<int> a(N);           rep(i, N) cin >> a[i];           vector<vector<int>> dp(N, vector<int>(N+1, inf));           vector<vector<int>> M(N, vector<int>(N+2, inf));           rep(i, N+1) M[N-1][i] = 0;              auto f = [](int a, int b) {return a+b;};           Dual_Segment_Tree<int, int> seg(vector<int>(N+1, 0), f, f, 0);              dp[N-1][N] = 0;           rep3(i, N-2, 0){               rep2(j, i+1, i+a[i]){                   if(j >= N) break;                   chmin(dp[i][j], M[j][min(N, i+a[i]+1)]+seg[j]);               }               seg.apply(i+1, min(N, i+a[i]+1), 1);               rep3(j, N, 0) M[i][j] = min(M[i][j+1], dp[i][j]);           }              int ans = inf;           rep(i, N+1) chmin(ans, dp[0][i]);           cout << ans <<   n ;       }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j;     char a[100010];     scanf( %s , &a);     int n = strlen(a);     int b = 10 * (a[n - 2] -  0 ) + (a[n - 1] -  0 );     if (b % 4 == 0)       cout <<  4 ;     else       cout <<  0 ;     return 0;   }


#include <bits/stdc++.h>   #pragma comment(linker,  /stack:256000000 )   using namespace std;   int main() {     int n;     cin >> n;     if (n % 2 == 0) {       puts( -1 );     } else {       for (int(i) = 0; (i) < (n); (i)++) printf( %d  , i);       printf(  n );       for (int(i) = 0; (i) < (n); (i)++) printf( %d  , i);       printf(  n );       for (int(i) = 0; (i) < (n); (i)++) printf( %d  , 2 * i % n);       printf(  n );     }     return 0;   }


#include <bits/stdc++.h>   long long max(long long a, long long b) { return a > b ? a : b; }   long long min(long long a, long long b) { return a < b ? a : b; }   void swap(long long &a, long long &b) {     long long tmp = a;     a = b;     b = tmp;   }   long long lowbit(long long &x) { return x & (-x); }   void read(long long &x) {     x = 0;     char ch = getchar(), c = ch;     while (ch <  0  || ch >  9 ) c = ch, ch = getchar();     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch -  0 , ch = getchar();     if (c ==  - ) x = -x;   }   const long long INF = 0x3f3f3f3f3f3f3f3f;   const long long MAXN = 300000 + 10;   const long long MAXM = 10;   long long dp[MAXN][MAXM + 10], n, m, k, a[MAXN];   int main() {     read(n), read(m), read(k);     long long ans = 0;     for (long long i = 1; i <= n; ++i) read(a[i]);     for (int i = 0; i <= n; ++i)       for (int j = 0; j < m; ++j) dp[i][j] = -INF;     dp[0][m - 1] = 0;     for (long long i = 1; i <= n; ++i)       for (long long j = 0; j < m; ++j) {         if (j == 0)           dp[i][j] = max(dp[i - 1][m - 1] + a[i], a[i]) - k;         else           dp[i][j] = dp[i - 1][j - 1] + a[i];         ans = max(ans, dp[i][j]);       }     printf( %I64d , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool getmin(T *a, const T &b) {     if (b < *a) {       *a = b;       return true;     }     return false;   }   template <class T>   inline bool getmax(T *a, const T &b) {     if (b > *a) {       *a = b;       return true;     }     return false;   }   template <class T>   inline void read(T *a) {     char c;     while (isspace(c = getchar())) {     }     bool flag = 0;     if (c ==  - )       flag = 1, *a = 0;     else       *a = c - 48;     while (isdigit(c = getchar())) *a = *a * 10 + c - 48;     if (flag) *a = -*a;   }   const int mo = 1000000007;   template <class T>   T pow(T a, T b, int c = mo) {     T res = 1;     for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c)       if (b & i) res = 1LL * res * a % c;     return res;   }   const int inf = 1000000000;   const int N = 210000;   struct node {     int p, nextt, w;   } edge[N];   int cnt;   int head[N];   void ae(int a, int b, int c) {     edge[++cnt].p = b;     edge[cnt].nextt = head[a];     edge[cnt].w = c;     head[a] = cnt;   }   queue<int> q;   int d[N], tmp[N];   int n, m;   int bfs(int u) {     static vector<int> v;     v.clear();     d[u] = 0;     while (!q.empty()) q.pop();     q.push(u);     int ans = 0, num = 0;     while (!q.empty()) {       int u = q.front();       q.pop();       ans += d[u];       v.push_back(u);       ++num;       for (int k = head[(u)]; k; k = edge[k].nextt) {         int v = edge[k].p;         if (d[v] != -1 && (d[u] ^ d[v]) != edge[k].w)           return inf;         else if (d[v] == -1) {           d[v] = (d[u] ^ edge[k].w);           q.push(v);         }       }     }     for (int i = (0); i <= (num - 1); ++i)       if (num - ans < ans) d[v[i]] ^= 1;     return min(ans, num - ans);   }   int solve() {     for (int i = (1); i <= (n); ++i) d[i] = -1;     int ans = 0;     for (int i = (1); i <= (n); ++i)       if (d[i] == -1) {         int x = bfs(i);         if (x == inf)           return inf;         else           ans += x;       }     return ans;   }   int main() {     cin >> n >> m;     for (int i = (1); i <= (m); ++i) {       int x, y;       string s;       cin >> x >> y >> s;       int z = 0;       if (s ==  R ) z = 1;       ae(x, y, z);       ae(y, x, z);     }     int ans = solve();     for (int i = (1); i <= (n); ++i) tmp[i] = d[i];     for (int i = (1); i <= (n); ++i)       for (int k = head[(i)]; k; k = edge[k].nextt) edge[k].w ^= 1;     int x = solve();     if (x < ans) {       ans = x;       for (int i = (1); i <= (n); ++i) tmp[i] = d[i];     }     if (ans == inf) {       cout << -1 << endl;     } else {       cout << ans << endl;       for (int i = (1); i <= (n); ++i)         if (tmp[i]) printf( %d  , i);       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int a[100], n, m, x, h, ans, l, r;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       a[x]++;     }     for (int i = 1; i <= 50; i++) {       if (a[i] == 0) continue;       if (a[i] > n / 2) {         cout <<  Bob ;         return 0;       }       break;     }     cout <<  Alice ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const int maxn = 2e5 + 10;   int N, K;   int L[105], R[105];   struct min_segtree {     int tree[maxn * 3];     void init() {       for (int i = 0; i <= 2 * 2 * N + 2048; ++i) tree[i] = INF;     }     void update(int l, int r, int pos, int id, int val) {       if (l > r || pos < l || pos > r) return;       if (l == pos && pos == r) {         tree[id] = val;         return;       }       int mid = (l + r) >> 1;       if (pos <= mid)         update(l, mid, pos, id << 1, val);       else         update(mid + 1, r, pos, id << 1 | 1, val);       tree[id] = min(tree[id << 1], tree[id << 1 | 1]);     }     int query(int l, int r, int x, int y, int id) {       if (l > r || x > y || r < x || l > y) return INF;       if (l <= x && y <= r) return tree[id];       int mid = (x + y) >> 1;       if (r <= mid) return query(l, r, x, mid, id << 1);       if (l > mid) return query(l, r, mid + 1, y, id << 1 | 1);       return min(query(l, r, x, mid, id << 1),                  query(l, r, mid + 1, y, id << 1 | 1));     }   } DP[105];   int main() {     scanf( %d %d , &N, &K);     int i, j, lim = 2 * N;     for (i = 1; i <= K; ++i) scanf( %d %d , &L[i], &R[i]);     for (i = 0; i <= K; ++i) {       DP[i].init();     }     DP[0].update(0, lim, 0, 1, 0);     for (i = 1; i <= K; ++i) {       for (j = 0; j <= lim && j <= R[i]; ++j) {         int zero = (j - R[i] + R[i - 1] >= 0)                        ? DP[i - 1].query(j - R[i] + R[i - 1], j - R[i] + R[i - 1],                                          0, lim, 1)                        : INF;         int one =             1 + DP[i - 1].query(max(0, R[i - 1] - j),                                 min(lim, R[i - 1] - j + R[i] - L[i]), 0, lim, 1);         int two = 2 + DP[i - 1].query(max(0, j - R[i] + R[i - 1]),                                       min(lim, j - R[i] + R[i - 1] + R[i] - L[i]),                                       0, lim, 1);         DP[i].update(0, lim, j, 1, min(zero, min(one, two)));       }     }     if (R[K] - N < 0 || DP[K].query(R[K] - N, R[K] - N, 0, lim, 1) >= INF) {       printf( Hungry n );     } else {       printf( Full n%d n , DP[K].query(R[K] - N, R[K] - N, 0, lim, 1));     }   }


#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   const int N = 2e5;   long long gi() {     long long w = 0;     bool q = 1;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) q = 0, c = getchar();     while (c >=  0  && c <=  9 ) w = w * 10 + c -  0 , c = getchar();     return q ? w : -w;   }   int main() {     long long n = gi(), m = gi(), a = gi(), d = gi(), last = 0, k, x, y, ans = 0,               u = d / a + 1;     while (m--) {       k = gi();       x = max(last / a + 1, 1LL);       y = min(k / a, n);       if (x <= y) {         ans += (y - x) / u + 1;         last = (x + (y - x) / u * u) * a + d;       }       if (last < k) last = k + d, ans++;     }     x = max(last / a + 1, 1LL);     if (x <= n) ans += (n - x) / u + 1;     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class P, class Q>   inline bool mmin(P &a, Q b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class P, class Q>   inline bool mmax(P &a, Q b) {     if (a < b) {       a = b;       return true;     }     return false;   }   const int MAXn = 400 + 5, INF = 1000;   int n;   vector<pair<int, int> > adj[MAXn];   vector<int> son[MAXn];   int par[MAXn], siz[MAXn];   int dp[MAXn][MAXn];   int cur[MAXn][MAXn], upd[MAXn][MAXn];   bool mark[MAXn];   int nxt[MAXn];   inline void calcDP(int x) {     int m = ((int)son[x].size());     cur[m][0] = 0;     for (int j = 1; j < siz[x]; ++j) cur[m][j] = INF;     int s = 0;     for (int i = m - 1; i >= 0; --i) {       s += siz[son[x][i]];       for (int j = 0; j <= s; ++j) {         cur[i][j] = INF;         for (int k = 0; k <= j && k <= siz[son[x][i]]; ++k)           if (j - k <= s - siz[son[x][i]] &&               mmin(cur[i][j], cur[i + 1][j - k] + dp[son[x][i]][k]))             upd[i][j] = k;       }     }   }   void DFS(int x) {     siz[x] = 1;     for (int i = 0; i < ((int)adj[x].size()); ++i) {       int y = adj[x][i].first;       if (y != par[x]) {         son[x].push_back(y);         par[y] = x;         DFS(y);         siz[x] += siz[y];       }     }     calcDP(x);     dp[x][0] = 1;     for (int j = 1; j <= siz[x]; ++j) dp[x][j] = cur[0][j - 1];   }   void DFS2(int x, int k) {     if (!k) return;     mark[x] = 1;     if (k == 1) return;     calcDP(x);     int y = k - 1;     for (int i = 0; i < ((int)son[x].size()); ++i) {       nxt[son[x][i]] = upd[i][y];       y -= upd[i][y];     }     y = k - 1;     for (int i = 0; i < ((int)son[x].size()); ++i) {       DFS2(son[x][i], nxt[son[x][i]]);       y -= nxt[son[x][i]];     }   }   int main() {     ios_base::sync_with_stdio(false);     int k;     cin >> n >> k;     for (int i = 0; i < n - 1; ++i) {       int x, y;       cin >> x >> y;       --x;       --y;       adj[x].push_back(pair<int, int>(y, i + 1));       adj[y].push_back(pair<int, int>(x, i + 1));     }     fill(dp[0], dp[n], INF);     DFS(0);     int mn = dp[0][k], ind = 0;     for (int i = 1; i < n; ++i)       if (mmin(mn, dp[i][k] + 1)) ind = i;     DFS2(ind, k);     vector<int> v;     for (int i = 0; i < n; ++i)       for (int j = 0; j < ((int)adj[i].size()); ++j)         if (adj[i][j].first > i && (mark[i] ^ mark[adj[i][j].first]))           v.push_back(adj[i][j].second);     cout << ((int)v.size()) << endl;     for (int i = 0; i < ((int)v.size()); ++i) cout << v[i] <<    ;     cout << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z, q, w, e;     cin >> x >> y >> z >> q >> w >> e;     int leg = 0;     int el = 0;     leg = abs(x - y) * q;     el = 3 * e + abs(x - z) * w + abs(y - x) * w;     if (el <= leg) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }


#include <bits/stdc++.h>   using namespace std;   string solve(string s, int t) {     while (t--) {       for (int i = s.size() - 1; i >= 1; i--) {         if (s[i] ==  G  && s[i - 1] ==  B ) {           swap(s[i], s[i - 1]);           i--;         }       }     }     return s;   }   int main() {     int n, t;     cin >> n >> t;     string s;     cin >> s;     cout << solve(s, t);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long linf = 0x3f3f3f3fLL;   int main() {     int n;     scanf( %d , &n);     if (n < 10)       puts( 1 );     else {       int aux = n;       while (aux >= 10) {         aux /= 10;       }       int num = aux + 1;       aux = n;       while (aux >= 10) {         aux /= 10;         num *= 10;       }       printf( %d n , num - n);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   void checkmax(T &t, T x) {     if (x > t) t = x;   }   template <class T>   void checkmin(T &t, T x) {     if (x < t) t = x;   }   template <class T>   void _checkmax(T &t, T x) {     if (t == -1 || x > t) t = x;   }   template <class T>   void _checkmin(T &t, T x) {     if (t == -1 || x < t) t = x;   }   int main() {     int n, num, flag;     double dou, sum, sub;     while (cin >> n) {       sum = num = flag = 0;       for (int i = 0; i < (2 * n); ++i) {         scanf( %lf , &dou);         sub = ceil(dou) - dou;         sum += sub;         if (sub < 10e-4 && sub > -10e-4) num++;       }       sum -= n - num;       if (num == 0)         printf( %.3lf n , fabs(sum));       else {         for (int i = 0; i < (num); ++i) {           if (fabs(sum) > fabs(sum - 1))             sum = sum - 1;           else {             printf( %.3lf n , fabs(sum));             flag = 1;             break;           }         }         if (!flag) printf( %.3lf n , fabs(sum));       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long a[200005], b[200005], c[200005], mod = 998244353, ans = 0;   int main() {     long long n;     cin >> n;     c[1] = c[n] = (long long)n;     for (long long i = 2; i <= n / 2; i++) {       c[i] = (n - i + 1) * i;       c[n - i + 1] = c[i];     }     if (n % 2 == 1) {       c[n / 2 + 1] = (n - n / 2) * (n / 2 + 1);     }     for (int i = 1; i <= n; i++) {       cin >> a[i];       a[i] *= (long long)c[i];     }     for (int i = 1; i <= n; i++) {       cin >> b[i];     }     sort(a + 1, a + n + 1);     sort(b + 1, b + n + 1, [](long long x, long long y) { return x > y; });     for (int i = 1; i <= n; i++) {       long long tmp = (a[i] % mod * b[i] % mod) % mod;       ans = (ans + tmp) % mod;     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     double n, k, m, l, a, b, f, d;     cin >> n >> k;     long long kek = n;     double cnt1 = 0, cnt2 = 0;     while (kek % 2 == 0) {       kek /= 2;       cnt1++;     }     kek = n;     while (kek % 5 == 0) {       kek /= 5;       cnt2++;     }     cout.precision(0);     cout << fixed;     cnt1 = max(0.0, k - cnt1);     cnt2 = max(0.0, k - cnt2);     cout << n * pow(2, cnt1) * pow(5, cnt2);     return 0;   }


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