#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200005;   set<int> ab[MAXN][2];   int N, M, Q;   struct segTree {     int f, t, mini, maxi;     bool ans;     segTree *L, *R;     segTree(int _f, int _t) : f(_f), t(_t) {       ans = false;       mini = INT_MAX;       maxi = INT_MIN;       if (f != t) {         L = new segTree(f, (f + t) / 2);         R = new segTree((f + t) / 2 + 1, t);       }     }     void update(int x, int v, bool flag) {       if (f == t && t == x) {         if (flag)           maxi = v;         else           mini = v;         ans = maxi >= mini;         return;       }       if (x < R->f)         L->update(x, v, flag);       else         R->update(x, v, flag);       mini = min(R->mini, L->mini);       maxi = max(R->maxi, L->maxi);       ans = R->ans | L->ans | (R->maxi >= L->mini);     }   };   int main() {     scanf( %d %d %d , &N, &M, &Q);     segTree *tree = new segTree(0, N + 1);     for (int i = 0; i < Q; i++) {       int x, y;       scanf( %d %d , &x, &y);       x--, y--;       bool flag = (x & 1);       int mult = (flag ? -1 : 1);       if (ab[x / 2][flag].count((y / 2) * mult))         ab[x / 2][flag].erase((y / 2) * mult);       else         ab[x / 2][flag].insert((y / 2) * mult);       int val = INT_MAX;       if (flag) val = INT_MIN;       if (ab[x / 2][flag].size() > 0) val = abs(*ab[x / 2][flag].begin());       tree->update(x / 2, val, flag);       puts((!tree->ans ?  YES  :  NO ));     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, sum, m[17], r[17];   double ans;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> m[i];     for (int i = 1; i <= n; i++) cin >> r[i];     for (int i = 1; i <= 999999; i++)       for (int j = 1; j <= n; j++)         if (i % m[j] == r[j]) {           sum++;           break;         }     ans = 1.0 * sum / 999999;     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int o;     long long w, s, t;     cin >> o;     for (int i = 0; i < o; i++) {       cin >> w >> s >> t;       long long minnn = min(s, t);       cout << (w - minnn) + 1 <<   n ;     }   }


#include<bits/stdc++.h>   using namespace std;      #define ll long long   #define mtv(kit) cout<<#kit<<  -  <<kit<<  n ;   #define ff first   #define ss second   #define pb push_back   #define rep(i,a,b) for(ll i=a;i<b;i++)   #define pii pair<ll , ll>   #define all(x) x.begin(),x.end()   #define nl   n    #define ump unordered_map         void doit(){    ll b, g, k; cin >> b >> g >> k;    vector<pii>p(k);    vector<ll>B(b + 2), G(g + 2);    for(ll i = 0; i < k; i++){     cin >> p[i].ff;     B[p[i].ff]++;    }    for(ll i = 0; i < k; i++){     cin >> p[i].ss;     G[p[i].ss]++;    }    ll ans = 0;    for(ll i = 0; i < k ; i++){     ans += (k - i - 1) - (B[p[i].ff] + G[p[i].ss] - 2);     B[p[i].ff]--;     G[p[i].ss]--;    }    cout << ans << nl;   }      int main(){       ios_base::sync_with_stdio(false);       cin.tie(NULL);       ll t = 1;    cin >> t;       for(ll i = 1; i <= t; i++){           doit();       }   }


#include <bits/stdc++.h>   using namespace std;   int m, n, t, k;   int main() {     while (scanf( %d%d , &n, &k) == 2) {       if (k > n || (n >= 2 && k == 1))         printf( -1 n );       else if (k == 1)         printf( %c n ,  a );       else {         int m = n - (k - 2);         for (int i = 0; i < m; i++) printf( %c , i % 2 == 0 ?  a  :  b );         for (int i = 0; i < k - 2; i++) printf( %c ,  a  + 2 + i);         printf(  n );       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   long long dx[4] = {0, 0, -1, 1};   long long dy[4] = {1, -1, 0, 0};   int n, m, q;   char s[11];   long long bz[100010 << 1][52];   int pos[100010 << 1][52];   int head[100010 << 1], nex[100010 << 1], val[100010 << 1], op[100010 << 1], tot;   int T[100010 << 2];   void pushdown(int rt) {     if (T[rt]) {       T[rt << 1] = T[rt << 1 | 1] = T[rt];       T[rt] = 0;     }   }   void insert(int l, int r, int rt, int x, int y, int v) {     if (x <= l && r <= y) {       T[rt] = v;       return;     }     int mid = l + r >> 1;     pushdown(rt);     if (mid >= x) insert(l, mid, rt << 1, x, y, v);     if (mid < y) insert(mid + 1, r, rt << 1 | 1, x, y, v);   }   int query(int l, int r, int rt, int v) {     if (l == r) return T[rt];     int mid = l + r >> 1;     pushdown(rt);     if (mid >= v)       return query(l, mid, rt << 1, v);     else       return query(mid + 1, r, rt << 1 | 1, v);   }   void add(long long x, long long y, int tp) {     tot++;     nex[tot] = head[x];     head[x] = tot;     val[tot] = y;     op[tot] = tp;   }   struct vec {     long long x1, x2, y1, y2;     int op;     void read() {       scanf( %I64d%I64d%I64d%I64d , &x1, &y1, &x2, &y2);       if (y1 < y2) op = 0;       if (y1 > y2) op = 1;       if (x1 > x2) op = 2;       if (x1 < x2) op = 3;     }   } a[100010];   struct node {     int op;     long long len, x, y;     void read() {       scanf( %I64d%I64d%s%I64d , &x, &y, s, &len);       if (s[0] ==  U ) op = 0;       if (s[0] ==  D ) op = 1;       if (s[0] ==  L ) op = 2;       if (s[0] ==  R ) op = 3;     }   } b[100010];   pair<long long, long long> cal(long long x, long long y, int p) {     if (a[p].x1 == a[p].x2) {       if (a[p].x1 == x) {         if (min(a[p].y1, a[p].y2) <= y && y <= max(a[p].y1, a[p].y2))           return make_pair(x, y);         if (y < min(a[p].y1, a[p].y2))           return make_pair(x, min(a[p].y1, a[p].y2));         else           return make_pair(x, max(a[p].y1, a[p].y2));       } else         return make_pair(a[p].x1, y);     } else {       if (a[p].y1 == y) {         if (min(a[p].x1, a[p].x2) <= x && x <= max(a[p].x1, a[p].x2))           return make_pair(x, y);         if (x < min(a[p].x1, a[p].x2))           return make_pair(min(a[p].x1, a[p].x2), y);         else           return make_pair(max(a[p].x1, a[p].x2), y);       } else         return make_pair(x, a[p].y1);     }   }   int dis(long long x1, long long y1, long long x2, long long y2) {     return abs(x1 - x2) + abs(y1 - y2);   }   pair<long long, long long> find(long long x, long long y, int tp,                                   long long step) {     return make_pair(x + step * dx[tp], y + step * dy[tp]);   }   void print(pair<long long, long long> p) {     long long x = p.first, y = p.second;     x = max(x, 0ll);     x = min(x, (long long)m);     y = max(y, 0ll);     y = min(y, (long long)m);     printf( %I64d %I64d n , x, y);   }   int main() {     n = read();     m = read();     for (int i = 1; i <= n; i++) a[i].read();     q = read();     for (int i = 1; i <= q; i++) b[i].read();     for (int i = 0; i <= 3; i++) {       tot = 0;       memset(head, 0, sizeof(head));       memset(T, 0, sizeof(T));       for (int j = 1; j <= q; j++)         if (b[j].op == i) {           if (i < 2)             add(b[j].y, j + n, 1);           else             add(b[j].x, j + n, 1);         }       for (int j = 1; j <= n; j++) {         if (i == 0) add(max(a[j].y1, a[j].y2), j, 0);         if (i == 1) add(min(a[j].y1, a[j].y2), j, 0);         if (i == 2) add(min(a[j].x1, a[j].x2), j, 0);         if (i == 3) add(max(a[j].x1, a[j].x2), j, 0);       }       for (int j = 1; j <= n; j++)         if (a[j].op == i) {           if (i < 2)             add(a[j].y2, j, 1);           else             add(a[j].x2, j, 1);         }       int now = (i == 0 || i == 3) ? m : 0;       while (now != -1 && now != m + 1) {         for (int j = head[now]; j; j = nex[j]) {           if (!op[j]) {             if (i < 2)               insert(0, m, 1, min(a[val[j]].x1, a[val[j]].x2),                      max(a[val[j]].x1, a[val[j]].x2), val[j]);             else               insert(0, m, 1, min(a[val[j]].y1, a[val[j]].y2),                      max(a[val[j]].y1, a[val[j]].y2), val[j]);           } else {             int tmp;             if (val[j] <= n) {               if (i < 2)                 tmp = query(0, m, 1, a[val[j]].x1);               else                 tmp = query(0, m, 1, a[val[j]].y1);             } else {               if (i < 2)                 tmp = query(0, m, 1, b[val[j] - n].x);               else                 tmp = query(0, m, 1, b[val[j] - n].y);             }             pos[val[j]][0] = tmp;             if (tmp) {               if (val[j] <= n)                 bz[val[j]][0] =                     abs(a[tmp].x2 - a[val[j]].x2) + abs(a[tmp].y2 - a[val[j]].y2);               else                 bz[val[j]][0] = abs(a[tmp].x2 - b[val[j] - n].x) +                                 abs(a[tmp].y2 - b[val[j] - n].y);             } else               bz[val[j]][0] = 1ll << 50;           }         }         if (i == 0 || i == 3)           now--;         else           now++;       }     }     for (int i = 1; i <= 50; i++) bz[0][i] = 1ll << 50;     for (int i = 1; i <= 50; i++)       for (int j = 1; j <= n + q; j++) {         pos[j][i] = pos[pos[j][i - 1]][i - 1];         bz[j][i] = bz[j][i - 1] + bz[pos[j][i - 1]][i - 1];         bz[j][i] = min(bz[j][i], 1ll << 50);       }     for (int i = 1; i <= q; i++) {       int tmp = i + n;       long long t = b[i].len;       for (int j = 50; j >= 0; j--)         if (bz[tmp][j] <= t) {           t -= bz[tmp][j];           tmp = pos[tmp][j];         }       if (tmp == i + n) {         if (pos[tmp][0]) {           pair<long long, long long> tq = cal(b[i].x, b[i].y, pos[tmp][0]);           int tw = dis(tq.first, tq.second, b[i].x, b[i].y);           if (tw >= t)             print(find(b[i].x, b[i].y, b[i].op, t));           else             print(find(tq.first, tq.second, a[pos[tmp][0]].op, t - tw));         } else           print(find(b[i].x, b[i].y, b[i].op, t));       } else {         if (!pos[tmp][0])           print(find(a[tmp].x2, a[tmp].y2, a[tmp].op, t));         else {           pair<long long, long long> tq = cal(a[tmp].x2, a[tmp].y2, pos[tmp][0]);           int tw = dis(tq.first, tq.second, a[tmp].x2, a[tmp].y2);           if (tw >= t)             print(find(a[tmp].x2, a[tmp].y2, a[tmp].op, t));           else             print(find(tq.first, tq.second, a[pos[tmp][0]].op, t - tw));         }       }     }     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const long long INF = (long long)1e18 + 100;   long long safe_sum(long long a, long long b) {     long long s = (a + b);     s = min(s, INF);     return s;   }   long long safe_mult(long long a, long long b) {     if (a == 0 || b == 0) return 0;     if (a >= ((INF + b - 1) / b)) return INF;     return (a * b);   }   const int maxN = 1005;   long long c[maxN][maxN];   long long gcd(long long x, long long y) {     while (x > 0 && y > 0) {       if (x < y) swap(x, y);       x %= y;     }     return (x + y);   }   long long cnk(long long x, int a) {     vector<long long> cur;     for (int i = 0; i < a; i++) {       cur.push_back(x - i);     }     for (int j = 1; j <= a; j++) {       int now = j;       for (auto& it : cur) {         if (now == 1) break;         int d = (int)(gcd(it, now));         it /= d;         now /= d;       }     }     long long ans = 1;     for (auto& it : cur) ans = safe_mult(ans, it);     return ans;   }   int n;   long long k;   const int maxT = 2 * (int)1e5 + 100;   const int BUBEN = 10;   long long a[maxT];   long long get_cnk(long long x, long long y) {     if (x - y < y) return get_cnk(x, x - y);     if (x < y) return 0;     if (x < maxN) {       return c[x][y];     }     if (y >= BUBEN)       return INF;     else       return cnk(x, (int)y);   }   bool ok(long long who) {     long long f = 0;     for (int i = 0; i < n; i++) {       f = safe_sum(f, safe_mult(a[i], get_cnk(n - i - 1 + who - 1, who - 1)));       if (f >= k) return true;     }     return (f >= k);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     c[0][0] = 1;     for (int i = 1; i < maxN; i++) {       c[i][0] = 1;       for (int j = 1; j <= i; j++) {         c[i][j] = safe_sum(c[i - 1][j], c[i - 1][j - 1]);       }     }     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] >= k) {         cout << 0;         return 0;       }     }     long long l = 0;     long long r = (long long)(1e18) + 100;     while (r - l > 1) {       long long mid = (l + r) / 2;       if (ok(mid))         r = mid;       else         l = mid;     }     cout << r;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct pvec {     long long int x, y;     pvec(long long int x = 0, long long int y = 0) : x(x), y(y) {}     pvec operator-(pvec p) { return pvec(x - p.x, y - p.y); }     bool operator==(pvec p) { return x == p.x and y == p.y; }     long long int dot(pvec p) { return x * p.x + y * p.y; }     long long int abs2() { return x * x + y * y; }   };   pvec v[12], Q[12], R[12];   long long int Qi[12], Ri[12];   long long int perm[][3] = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3},                              {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};   inline bool quadrado() {     for (long long int i = 0; i < 6; i++) {       pvec p0 = Q[0];       pvec p1 = Q[perm[i][0]];       pvec p2 = Q[perm[i][1]];       pvec p3 = Q[perm[i][2]];       pvec v1 = p1 - p0, v2 = p2 - p1, v3 = (p2 - p3), v4 = (p3 - p0);       if (!(v1 == v3 and v2 == v4)) continue;       if (v1.abs2() != v2.abs2()) continue;       if (v1.dot(v2) != 0) continue;       return true;     }     return false;   }   inline bool retangulo() {     for (long long int i = 0; i < 6; i++) {       pvec p0 = R[0];       pvec p1 = R[perm[i][0]];       pvec p2 = R[perm[i][1]];       pvec p3 = R[perm[i][2]];       pvec v1 = p1 - p0, v2 = p2 - p1, v3 = (p2 - p3), v4 = (p3 - p0);       if (!(v1 == v3 and v2 == v4)) continue;       if (v1.dot(v2) != 0) continue;       return true;     }     return false;   }   bool da(long long int u, long long int quad, long long int ret) {     if (quad > 4 or ret > 4) return false;     if (u == 8) {       if (quadrado() and retangulo()) return true;       return false;     }     Q[quad] = v[u];     Qi[quad] = u;     if (da(u + 1, quad + 1, ret)) return true;     R[ret] = v[u];     Ri[ret] = u;     if (da(u + 1, quad, ret + 1)) return true;     return false;   }   int main() {     for (long long int i = 0; i < 8; i++) {       long long int x, y;       cin >> x >> y;       v[i] = pvec(x, y);     }     if (!da(0, 0, 0)) {       cout <<  NO  << endl;     } else {       cout <<  YES  << endl;       for (long long int i = 0; i < 4; i++) {         if (i) printf(   );         cout << Qi[i] + 1;       }       cout << endl;       for (long long int i = 0; i < 4; i++) {         if (i) printf(   );         cout << Ri[i] + 1;       }       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     long long a = 1, n;     cin >> n;     for (int i = 0; i < n; i++) {       a *= i + 1;     }     cout << a * 2 / n / n;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long l, r, b, c, a;       long long m;       cin >> l >> r >> m;       for (long long i = l; i <= r; i++) {         a = i;         long long n = m / a, temp = a * n, diff = m - temp;         if (n > 0 && abs(m - temp) <= r - l) {           if (diff >= 0) {             b = r;             c = r - m + temp;           } else {             b = l;             c = l + temp - m;           }           cout << a <<     << b <<     << c <<   n ;           break;         }         n = m / a + 1, temp = a * n, diff = m - temp;         if (abs(m - temp) <= r - l) {           if (diff >= 0) {             b = r;             c = r - m + temp;           } else {             b = l;             c = l + temp - m;           }           cout << a <<     << b <<     << c <<   n ;           break;         }       }     }   }


#include <bits/stdc++.h>   using namespace std;   double a, v, d, w, l, ans, mid, t2, t;   bool check(double maxv) {     return d - ((maxv + w) / 2) * (((maxv - w) * 2) / a) > 1e-8;   }   int main() {     scanf( %lf %lf %lf %lf %lf , &a, &v, &l, &d, &w);     w = min(min(w, v), sqrt(2 * a * d));     if (2 * a * d + w * w > 2 * v * v) {       t = (d - v * v / a + w * w / a / 2) / v + (2 * v - w) / a;     } else {       t = (2 * sqrt(a * d + w * w / 2) - w) / a;     }     l = l - d;     t2 = (v - w) / a;     if (l - w * t2 - 0.5 * a * t2 * t2 > 0) {       t2 = t2 + (l - w * t2 - 0.5 * a * t2 * t2) / v;     } else {       t2 = (-w + sqrt(w * w + 2.0 * a * l)) / a;     }     printf( %.10f n , t + t2);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int Maxn = 200020;   int n, a[Maxn];   long long sum[Maxn];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 0; i < n - 1; i++) {       int cur;       for (cur = 1; cur <= i;) {         int val = i / cur;         int ncur = i / val + 1;         if (a[i + 2] < a[val + 1]) {           sum[cur]++;           sum[ncur]--;         }         cur = ncur;       }       if (a[i + 2] < a[1]) sum[cur]++, sum[n]--;     }     for (int i = 1; i < n; i++) sum[i] += sum[i - 1], printf( %I64d n , sum[i]);     ;   }


#include <bits/stdc++.h>   int main() {     int n, i;     int maximum, maxIndex, target;     int A[1000];     scanf( %d , &n);     maximum = -1;     for (i = 0; i < n; ++i) {       scanf( %d , &A[i]);       if (A[i] > maximum) {         maximum = A[i];         maxIndex = i;       }     }     A[maxIndex] = -2;     target = -1;     for (i = 0; i < n; ++i) {       if (A[i] > target) {         target = A[i];       }     }     printf( %d %d , maxIndex + 1, target);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i]--;     }     vector<int> v(n), d(n);     queue<int> q;     q.push(0);     v[0] = 1;     int l = 0;     while (!q.empty()) {       int nn = q.size();       while (nn-- > 0) {         int t = q.front();         q.pop();         d[t] = l;         if (t > 0 && v[t - 1] == 0) {           q.push(t - 1);           v[t - 1] = 1;         }         if (t < n - 1 && v[t + 1] == 0) {           q.push(t + 1);           v[t + 1] = 1;         }         if (v[a[t]] == 0) {           q.push(a[t]);           v[a[t]] = 1;         }       }       l++;     }     for (int i : d) cout << i <<    ;     cout << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   int n, k;   int a[2011];   long long pre[1 << 11 + 1];   long long cur[1 << 11 + 1];   void solve() {     memset(pre, 0, sizeof(pre));     pre[0] = 1;     for (int i = 0; i < n; i++) {       memset(cur, 0, sizeof(cur));       for (int j = 0; j < (1 << k) + 1; j++) {         if (a[i] == 2 || a[i] == 0) {           int nj = min(j + 2, 1 << k);           cur[nj] = (cur[nj] + pre[j]) % mod;         }         if (a[i] == 4 || a[i] == 0) {           int nj = min(j + 4, 1 << k);           if ((j & 2) != 0) {             nj = 4;           }           cur[nj] = (cur[nj] + pre[j]) % mod;         }       }       memcpy(pre, cur, sizeof(cur));     }     cout << pre[1 << k] << endl;   }   void coding() {     while (cin >> n >> k) {       for (int i = 0; i < n; i++) cin >> a[i];       solve();     }   }   int main() { coding(); }


#include <bits/stdc++.h>   using namespace std;   const long long dp = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, a;     cin >> n >> a;     vector<int> vec(n);     int cnt = 0;     for (int i = 0; i < n; i++) {       cin >> vec[i];       if (vec[i]) cnt++;     }     for (int i = 0; i < a; i++) {       if (vec[a - 1 - i] + vec[a - 1 + i] == 1) cnt--;       if (i >= n - a) break;     }     cout << cnt <<   n ;     return 0;   }


#include <bits/stdc++.h>   const int maxn = 2005;   const int inf = 1e9;   using namespace std;   vector<pair<int, int>> G[maxn];   vector<int> C[maxn], v;   bool critical[maxn * maxn];   vector<int> seen, sum, col, depth, up;   void dfs(int node, int ind) {     seen[node] = 1;     int minFromSons = inf;     up[node] = depth[node];     for (auto tmp : G[node]) {       if (seen[tmp.first] && tmp.second != ind)         up[node] = min(up[node], depth[tmp.first]);       else if (!seen[tmp.first]) {         depth[tmp.first] = depth[node] + 1;         dfs(tmp.first, tmp.second);         minFromSons = min(minFromSons, up[tmp.first]);       }     }     up[node] = min(up[node], minFromSons);     if (minFromSons >= depth[node] && ind != -1) {       critical[ind] = 1;     }   }   void dfsColor(int node, int color) {     col[node] = color;     v[color]++;     for (auto tmp : G[node]) {       if (critical[tmp.second] == 1 && col[tmp.first] == 0) continue;       if (critical[tmp.second] == 1 && col[tmp.first]) {         C[col[tmp.first]].push_back(color);         C[color].push_back(col[tmp.first]);         continue;       } else if (col[tmp.first] == 0)         dfsColor(tmp.first, color);     }   }   void dfsSub(int node) {     seen[node] = 1;     sum[node] = v[node];     for (auto tmp : C[node])       if (!seen[tmp]) {         dfsSub(tmp);         sum[node] += sum[tmp];       }   }   int main() {     ios_base ::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int a, b;       cin >> a >> b;       G[a].push_back(make_pair(b, i));       G[b].push_back(make_pair(a, i));     }     seen = vector<int>(n + 1, 0);     depth = vector<int>(n + 1, 0);     up = vector<int>(n + 1, 0);     dfs(1, -1);     int c = 0;     col = vector<int>(n + 1, 0);     v = vector<int>(n + 1, 0);     int all = 0;     for (int i = 1; i <= n; ++i)       if (col[i] == 0) {         ++c;         dfsColor(i, c);         all += v[c] * v[c];       }     int ans = 0;     for (int i = 1; i <= c; ++i) {       seen = vector<int>(c + 1, 0);       sum = vector<int>(c + 1, 0);       dfsSub(i);       int tmp = 0;       for (int j = 1; j <= c; ++j) tmp += sum[j] * v[j];       vector<int> can(n + 1, 0);       can[0] = 1;       for (auto tmp : C[i]) {         for (int j = n; j >= 0; --j)           if (can[j] && j + sum[tmp] <= n) can[j + sum[tmp]] = 1;       }       int res = -1;       for (int j = (n - v[i]) / 2; j >= 0; --j)         if (can[j]) {           res = j;           break;         }       tmp += res * (n - v[i] - res);       ans = max(ans, tmp);     }     cerr << all <<   n ;     cout << ans <<   n ;   }


#include <bits/stdc++.h>   int main() {     int x, count = 0, i;     char ar[50];     for (i = 0; i < 9; i++) scanf(  %c , &ar[i]);     for (i = 0; i < 9; i++) {       if (ar[i] == ar[8 - i]) count++;     }     if (count == 9)       printf( YES );     else       printf( NO );   }


#include <bits/stdc++.h>   using namespace std;   const int shape[4][4][2] = {{{1, 0}, {2, 0}, {1, 1}, {1, 2}},                               {{1, 0}, {2, 0}, {2, -1}, {2, 1}},                               {{0, 1}, {0, 2}, {-1, 2}, {1, 2}},                               {{0, 1}, {0, 2}, {1, 1}, {2, 1}}};   int x, y;   struct node {     char g[9][9];     int num;     int sx, sy;     int layer;     node() {       layer = 0;       sx = sy = 0;       memset(g, 0, sizeof(g));       num = 0;     }     void printNode() {       for (int i = 0; i < y; i++) {         for (int j = 0; j < x; j++) printf( %c , g[i][j] ? g[i][j] :  . );         cout <<    << endl;       }     }   };   stack<node> q;   int ans;   node ansNode;   int maxG[9][9][4];   void bfs() {     while (!q.empty()) {       node now = q.top();       q.pop();       if (now.num > ans) {         ans = now.num;         ansNode = now;       }       now.num++;       char ch =  A  + now.num - 1;       for (int i = now.sy; i < y; i++) {         for (int j = 0; j < x; j++) {           if (!now.g[i][j]) {             for (int k = 0; k < 4; k++) {               if (maxG[i][j][k] > now.num + 1) continue;               bool flag = true;               for (int l = 0; l < 4 && flag; l++) {                 int tx = j + shape[k][l][1];                 int ty = i + shape[k][l][0];                 if (tx < 0 || tx >= x || ty < 0 || ty >= y || now.g[ty][tx]) {                   flag = false;                 }               }               if (flag) {                 node tNode = now;                 tNode.g[i][j] = ch;                 for (int l = 0; l < 4; l++) {                   int tx = j + shape[k][l][1];                   int ty = i + shape[k][l][0];                   tNode.g[ty][tx] = ch;                 }                 tNode.sx = j + 1;                 tNode.sy = i;                 tNode.layer++;                 q.push(tNode);                 maxG[i][j][k] = max(maxG[i][j][k], now.num);               }             }           }         }       }     }   }   int main() {     ans = -1;     cin >> y >> x;     while (!q.empty()) q.pop();     q.push(node());     bfs();     cout << ans << endl;     ansNode.printNode();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100009;   int sol, qs[N], qe[N], sorted[N], ans[N], a[N], s, e;   unordered_map<int, int> freq;   void add(int el) {     sol -= !(freq[el] ^ el);     freq[el]++;     sol += !(freq[el] ^ el);   }   void remove(int el) {     sol -= !(freq[el] ^ el);     freq[el]--;     sol += !(freq[el] ^ el);   }   void mo(int idx) {     while (s > qs[idx]) add(a[--s]);     while (e <= qe[idx]) add(a[e++]);     while (s < qs[idx]) remove(a[s++]);     while (e > qe[idx] + 1) remove(a[--e]);     ans[idx] = sol;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) {       cin >> qs[i] >> qe[i];       qs[i]--, qe[i]--;       sorted[i] = i;     }     int sq = sqrt(n);     sort(sorted, sorted + m, [sq](int i, int j) {       return make_pair(qs[i] / sq, qe[i]) < make_pair(qs[j] / sq, qe[j]);     });     for (int i = 0; i < m; i++) mo(sorted[i]);     for (int i = 0; i < m; i++) cout << ans[i] <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   using min_pq = priority_queue<T, vector<T>, greater<T>>;   const int MAXN = 1e5 + 10, MAXQ = 3e5 + 10, MAXL = 20, ALP = 26, MOD = 1e9 + 7,             MAXK = 17, INF = 1e9 + 10, MAXA = 30, MAXB = 24, MAXBB = (1 << MAXB);   const string no =  NO n , yes =  YES n ;   const int hA[4] = {1, 0, -1, 0}, kA[4] = {0, 1, 0, -1};   void solve() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int a;         cin >> a;         if ((a & 1) != ((i + j) & 1)) a++;         cout << a <<    ;       }       cout <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t = 1;     cin >> t;     while (t--) solve();   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, sum1 = 0, res1 = 0, last = 0;     bool flag = true;     cin >> n;     unordered_map<long long int, long long int> m;     vector<pair<long long int, long long int>> v;     for (long long int i = 0; i < n; i++) {       long long int element;       cin >> element;       m[element]++;       v.emplace_back(make_pair(element, i));     }     if (n == 1) {       cout << 1 <<   n ;       cout << v[0].first <<                <<  0 n ;       return 0;     }     sort(v.begin(), v.end());     vector<pair<long long int, long long int>> v1;     for (long long int i = 0; i < v.size() - 1; i++) {       flag = true;       if (i < v.size() - 1 && v[i].first == v[i + 1].first)         sum1 = v[i + 1].second - v[i].second;       else if (i < v.size() - 1)         sum1 = 0;       while (i < v.size() - 1 && v[i].first == v[i + 1].first) {         res1 = v[i + 1].second - v[i].second;         if (res1 != sum1) {           flag = false;           break;         }         i++;       }       if (flag == true) {         v1.push_back(make_pair(v[i].first, sum1));       }       while (i < v.size() - 1 && v[i].first == v[i + 1].first) {         i++;       }     }     if (v[v.size() - 1].first != v[v.size() - 2].first) {       v1.emplace_back(make_pair(v[v.size() - 1].first, 0));     }     cout << v1.size() <<   n ;     for (long long int i = 0; i < v1.size(); i++) {       cout << v1[i].first <<     << v1[i].second <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     long long int t, temp, i, ans = 0, n, m, index, j;     cin >> n >> m;     vector<pair<long long int, long long int> > pa;     vector<long long int> v(n), finger(m);     for (i = 0; i < n; i++) {       cin >> v[i];     }     for (i = 0; i < m; i++) {       cin >> finger[i];       for (j = 0; j < n; j++) {         if (v[j] == finger[i]) {           pa.push_back(make_pair(j, finger[i]));         }       }     }     sort(pa.begin(), pa.end());     if (pa.size() == 0)       cout <<   n ;     else {       for (auto it = pa.begin(); it != pa.end(); it++) {         cout << it->second <<    ;       }     }   }


#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long inf2 = 0x3f3f3f3f3f3f3f3f;   const double eps = 1e-6;   const int mod = 1000000007;   namespace fastio {   char in[100000];   int itr = 0, llen = 0;   char get() {     if (itr == llen) llen = fread(in, 1, 100000, stdin), itr = 0;     if (llen == 0) return EOF;     return in[itr++];   }   char out[100000];   int itr2 = 0;   void put(char c) {     out[itr2++] = c;     if (itr2 == 100000) {       fwrite(out, 1, 100000, stdout);       itr2 = 0;     }   }   int clear() {     fwrite(out, 1, itr2, stdout);     itr2 = 0;     return 0;   }   int getint() {     int r = 0;     bool ng = 0;     char c;     c = get();     while (c !=  -  && (c <  0  || c >  9 )) c = get();     if (c ==  - ) ng = 1, c = get();     while (c >=  0  && c <=  9 ) r = r * 10 + c -  0 , c = get();     return ng ? -r : r;   }   string getstr() {     string ret =   ;     char ch = get();     while (ch ==     || ch ==   n ) ch = get();     while (ch !=     && ch !=   n ) ret.push_back(ch), ch = get();     return ret;   }   void putstr(string s) {     for (int i = 0; i < s.size(); i++) put(s[i]);   }   void putint(int x) {     if (x < 0) {       put( - );       x = -x;     }     if (x == 0) {       put( 0 );       return;     }     char c[20];     int pos = 0;     while (x) {       c[pos++] =  0  + x % 10;       x /= 10;     }     for (int i = pos - 1; i >= 0; i--) put(c[i]);   }   void getarr(int arrname[], int size) {     for (int i = 0; i < size; i++) arrname[i] = getint();   }   }  // namespace fastio   using namespace fastio;   int number[1000005], BITN = 1e6;   void modify(int x, int y) {     while (x <= BITN) {       number[x] += y;       x += x & -x;     }   }   int sum(int x) {     int ret = 0;     while (x) {       ret += number[x];       x &= x - 1;     }     return ret;   }   void add(int l, int r, int v) {     modify(l, v);     modify(r, -v);   }   int qry(int x) { return sum(x); }   int n, k;   vector<int> g[1000005];   vector<int> ord;   int pos[1000005];   bool used[1000005];   int par[1000005];   int sz[1000005], depth[1000005];   void dfs(int x, int pr) {     depth[x] = x == n ? 0 : depth[pr] + 1;     pos[x] = ord.size() + 1;     ord.push_back(x);     sz[x] = 1;     for (auto to : g[x])       if (to != pr) par[to] = x, dfs(to, x), sz[x] += sz[to];   }   int main() {     n = getint();     k = getint();     for (int i = 1; i < n; i++) {       int a = getint(), b = getint();       g[a].push_back(b);       g[b].push_back(a);     }     dfs(n, 0);     for (int i = 0; i < ord.size(); i++) {       modify(i + 1, depth[ord[i]] - (i == 0 ? 0 : depth[ord[i - 1]]));     }     used[n] = true;     int rest = n - k - 1;     for (int v = n - 1; v > 0 && rest; v--) {       if (used[v]) continue;       int len = qry(pos[v]);       if (len <= rest) {         int cur = v;         while (!used[cur]) {           used[cur] = true;           add(pos[cur], pos[cur] + sz[cur], -1);           cur = par[cur];           rest--;         }       }     }     vector<int> ans;     for (int i = 1; i <= n; i++)       if (!used[i]) ans.push_back(i);     for (int i = 0; i < ans.size(); i++) putint(ans[i]), put(   );     clear();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 5555;   int hackable[N];   int sols[N];   int pts[N][13];   int score[N];   int z[N];   int bound[N];   int cnt_hack[N];   int rgt[N];   int task[N][13];   int guys[N];   int main() {     int n;     scanf( %d , &n);     for (int j = 0; j < 3; j++) {       hackable[j] = 0;       sols[j] = 0;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < 3; j++) {         scanf( %d , task[i] + j);         if (task[i][j] < 0) {           hackable[j]++;         }         if (task[i][j] > 0) {           sols[j]++;         }       }     }     int cost[3];     int ans = n;     for (cost[0] = 500; cost[0] <= 3000; cost[0] += 500) {       for (cost[1] = 500; cost[1] <= 3000; cost[1] += 500) {         for (cost[2] = 500; cost[2] <= 3000; cost[2] += 500) {           bool err = false;           for (int j = 0; j < 3; j++) {             cnt_hack[j] = -1;             for (int u = hackable[j]; u >= 0; u--) {               int k = sols[j] + (hackable[j] - u);               int real_cost = 500;               int coeff = 2;               while (coeff * k <= n && real_cost < 3000) {                 coeff *= 2;                 real_cost += 500;               }               if (real_cost == cost[j]) {                 cnt_hack[j] = u;                 break;               }             }             if (cnt_hack[j] == -1) {               err = true;               break;             }           }           if (err) {             continue;           }           for (int i = 0; i < n; i++) {             score[i] = 0;             for (int j = 0; j < 3; j++) {               int a = abs(task[i][j]);               pts[i][j] = (a > 0 ? (cost[j] * (250 - a) / 250) : 0);               score[i] += pts[i][j];             }           }           score[0] += 100 * (cnt_hack[0] + cnt_hack[1] + cnt_hack[2]);           int cnt = 0;           for (int type = 0; type < 128; type++) {             guys[type] = 0;           }           for (int i = 1; i < n; i++) {             if (score[i] > score[0]) {               int type = 0;               for (int t = 1; t < 8; t++) {                 int dec = 0;                 for (int j = 0; j < 3; j++) {                   if (t & (1 << j)) {                     if (task[i][j] < 0) {                       dec += pts[i][j];                     }                   }                 }                 if (score[i] - dec <= score[0]) {                   type |= (1 << (t - 1));                 }               }               guys[type]++;               cnt++;             }           }           for (int mask = 1; mask < (1 << 7); mask++) {             rgt[mask] = 0;             for (int type = 0; type < 128; type++) {               if (type & mask) {                 rgt[mask] += guys[type];               }             }           }           for (int j = 0; j < 3; j++) {             cnt_hack[j] = min(cnt_hack[j], cnt);           }           for (int AB = 0; AB <= cnt_hack[0]; AB++) {             for (int AC = 0; AB + AC <= cnt_hack[0]; AC++) {               for (int BC = 0; AB + BC <= cnt_hack[1] && AC + BC <= cnt_hack[2];                    BC++) {                 for (int ABC = 0;                      AB + AC + ABC <= cnt_hack[0] &&                      AB + BC + ABC <= cnt_hack[1] && AC + BC + ABC <= cnt_hack[2];                      ABC++) {                   int A = cnt_hack[0] - AB - AC - ABC;                   int B = cnt_hack[1] - AB - BC - ABC;                   int C = cnt_hack[2] - AC - BC - ABC;                   z[1] = 0;                   z[2] = 0;                   z[3] = AB;                   z[4] = 0;                   z[5] = AC;                   z[6] = BC;                   z[7] = ABC;                   bound[0] = 0;                   bound[1] = A;                   bound[2] = B;                   bound[3] = A + B;                   bound[4] = C;                   bound[5] = A + C;                   bound[6] = B + C;                   bound[7] = A + B + C;                   for (int mask = 1; mask < (1 << 7); mask++) {                     int lft = 0;                     for (int t = 1; t < 8; t++) {                       if (mask & (1 << (t - 1))) {                         lft += z[t];                       }                     }                     bound[mask & 7] = min(bound[mask & 7], rgt[mask] - lft);                   }                   if (bound[0] < 0) {                     continue;                   }                   for (int realA = 0; realA <= bound[1]; realA++) {                     int boundB = min(bound[2], bound[3] - realA);                     int boundC = min(bound[4], bound[5] - realA);                     int boundBC = min(bound[6], bound[7] - realA);                     if (boundB >= 0 && boundC >= 0 && boundBC >= 0) {                       int realBplusC = min(boundB + boundC, boundBC);                       ans = min(ans, 1 + (cnt - realA - realBplusC - AB - AC -                                           BC - ABC));                     }                   }                 }               }             }           }         }       }     }     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long m, l, r, k;   struct Matrix {     long long W[2][2];   };   Matrix operator*(const Matrix& A, const Matrix& B) {     Matrix S;     memset(S.W, 0, sizeof(S.W));     for (int i = 0; i < 2; ++i)       for (int j = 0; j < 2; ++j)         for (int l = 0; l < 2; ++l)           S.W[i][j] = (S.W[i][j] + A.W[i][l] * B.W[l][j]) % m;     return S;   }   Matrix operator^(Matrix A, long long e) {     Matrix S;     S.W[0][0] = S.W[1][1] = 1;     S.W[0][1] = S.W[1][0] = 0;     while (e) {       if (e & 1) S = S * A;       A = A * A;       e >>= 1;     }     return S;   }   long long gcd() {     long long s = 1;     for (long long i = 1; i * i <= r; ++i) {       if (r / i - (l - 1) / i >= k && i > s) s = i;       long long e = r / i;       if (i - (l - 1) / e >= k && e > s) s = e;     }     return s;   }   int main() {     cin >> m >> l >> r >> k;     long long n = gcd();     if (n <= 2)       cout << 1 % m << endl;     else {       Matrix D, S;       D.W[0][0] = 0;       D.W[0][1] = D.W[1][0] = D.W[1][1] = 1;       S = D ^ (n - 2);       cout << (S.W[0][1] + S.W[1][1]) % m << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int N;   vector<int> a, b, c;   multiset<int> m;   int main(void) {     ios::sync_with_stdio(false);     cin.tie(NULL), cout.tie(NULL);     cin >> N;     a.resize(N);     b.resize(N);     c.resize(N);     for (int i = 0; i < N; i++) {       cin >> a[i];     }     for (int i = 0; i < N; i++) {       cin >> b[i];       m.insert(b[i]);     }     for (int i = 0; i < N; i++) {       int cur = N - a[i];       multiset<int>::iterator iter = m.lower_bound(cur);       if (iter == m.end()) {         iter = m.begin();       }       c[i] = (a[i] + (*iter)) % N;       m.erase(iter);     }     for (int i = 0; i < N; i++) {       cout << c[i] <<    ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct node {     int h, w, r;   } edge[110];   bool vis[11];   int x[5000000];   int n, k, t;   void init() {     cin >> n >> k >> t;     for (int i = 1; i <= k; i++) cin >> edge[i].h >> edge[i].w >> edge[i].r;   }   void solve() {     int l = 0;     for (int j = 1; j <= (1 << k) - 1; j++) {       int t = 0;       for (int i = 1; i <= k; i++)         if ((j & (1 << (i - 1))) != 0) t++;       if (t > n) continue;       memset(vis, 0, sizeof(vis));       int s = 0;       bool flag = true;       for (int i = 1; i <= k; i++)         if ((j & (1 << (i - 1))) != 0) {           if (vis[edge[i].h] || vis[edge[i].w + n]) {             flag = false;             break;           }           vis[edge[i].h] = vis[edge[i].w + n] = true;           s += edge[i].r;         }       if (flag) x[++l] = s;     }     sort(x, x + l + 1);     cout << x[t - 1] << endl;   }   int main() {     ios::sync_with_stdio(false);     init();     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int TAM = 100000 + 15;   const long long MOD = 1000000007LL;   const double PI = 3.14159265359;   long long add(long long x, long long y) { return (x + y + 2 * MOD) % MOD; }   long long mult(long long x, long long y) {     return (add(x, 0) * add(y, 0)) % MOD;   }   long long fast_expo(long long x, long long y) {     if (x == 0) return 0;     if (y == 0) return 1;     long long res = 1;     long long mid = fast_expo(x, y / 2);     if (y % 2 != 0) res = x;     return mult(mult(mid, mid), res);   }   long long inver(long long x) { return fast_expo(x, MOD - 2); }   long long gcd(long long e1, long long e2) {     if (e2 == 0) return e1;     return gcd(e2, e1 % e2);   }   int n;   map<int, int> mapa[TAM];   int color[TAM];   vector<int> G[TAM];   long long dom[TAM];   int tam[TAM];   int cant[TAM];   void dfs_tam(int u, int pd = -1) {     tam[u] = 1;     for (int v : G[u]) {       if (v != pd) {         dfs_tam(v, u);         tam[u] += tam[v];       }     }   }   void dfs(int u, int pd = -1) {     int m = -1, val = -1;     for (int v : G[u]) {       if (v != pd) {         if (tam[v] > val) {           m = v;           val = tam[v];         }       }     }     if (m == -1) {       mapa[u][color[u]]++;       dom[u] = color[u];       cant[u] = 1;       return;     }     for (int v : G[u]) {       if (v != pd) {         dfs(v, u);       }     }     swap(mapa[u], mapa[m]);     dom[u] = dom[m];     cant[u] = cant[m];     mapa[u][color[u]]++;     if (mapa[u][color[u]] > cant[u]) {       cant[u] = mapa[u][color[u]];       dom[u] = 1LL * color[u];     } else if (mapa[u][color[u]] == cant[u]) {       dom[u] += 1LL * color[u];     }     for (int v : G[u]) {       if (v != pd && v != m) {         int k, t;         for (map<int, int>::iterator it = mapa[v].begin(); it != mapa[v].end();              it++) {           k = it->first;           t = it->second;           mapa[u][k] += t;           if (mapa[u][k] > cant[u]) {             cant[u] = mapa[u][k];             dom[u] = 1LL * k;           } else if (mapa[u][k] == cant[u]) {             dom[u] += 1LL * k;           }         }       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &color[i]);     int u, v;     for (int i = 0; i < n - 1; i++) {       scanf( %d%d , &u, &v);       G[u - 1].push_back(v - 1);       G[v - 1].push_back(u - 1);     }     dfs_tam(0);     dfs(0);     for (int i = 0; i < n; i++) cout << 1LL * dom[i] <<    ;     cout << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool compare(pair<int, int> p1, pair<int, int> p2) {     return p1.first > p2.first;   }   long long int power(int a, int b) {     if (b == 0) return 1;     return a * power(a, b - 1);   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     int n, m;     cin >> n >> m;     int a[n + 1], b[m + 1];     for (int i = 0; i < n + 1; i++) {       cin >> a[i];     }     for (int i = 0; i < m + 1; i++) {       cin >> b[i];     }     if (n > m) {       if (a[0] * b[0] > 0)         cout <<  Infinity ;       else         cout <<  -Infinity ;     } else if (n < m) {       cout <<  0/1 ;     } else {       if (a[0] * b[0] < 0) {         cout <<  - ;       }       cout << abs(a[0]) / gcd(abs(a[0]), abs(b[0])) <<  /             << abs(b[0]) / gcd(abs(a[0]), abs(b[0]));     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 2 * 1e5 + 10;   long long t[2][4 * N], a, b;   void update(int l, int r, int j, int pos, int val) {     if (r < pos || pos < l) return;     if (pos <= l && r <= pos) {       t[0][j] = min(a, t[0][j] + val);       t[1][j] = min(b, t[1][j] + val);       return;     }     int mid = (l + r) >> 1;     update(l, mid, 2 * j, pos, val);     update(mid + 1, r, 2 * j + 1, pos, val);     if (l != r) {       t[0][j] = t[0][2 * j] + t[0][2 * j + 1];       t[1][j] = t[1][2 * j] + t[1][2 * j + 1];     }   }   long long getSum(int l, int r, int j, int x, int y, int wh) {     if (r < x || y < l) return 0LL;     if (x <= l && r <= y) {       return t[wh][j];     }     int mid = (l + r) >> 1;     long long X = getSum(l, mid, (j << 1), x, y, wh);     long long Y = getSum(mid + 1, r, ((j << 1) | 1), x, y, wh);     return X + Y;   }   int n, k, q;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> k >> a >> b >> q;     for (int i = 0; i < q; i++) {       int type;       cin >> type;       if (type == 1) {         int di, ai;         cin >> di >> ai;         update(1, n, 1, di, ai);       } else {         int p;         cin >> p;         long long res = getSum(1, n, 1, 1, p - 1, 1);         res += getSum(1, n, 1, p + k, n, 0);         cout << res <<   n ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int a[N], b[N];   bool p[N];   vector<int> P;   pair<bool, int> c[N];   int num(string s) {     int x = 0;     for (int i = 1; i < s.size(); i++) x = x * 10 + (s[i] -  0 );     return x;   }   int main() {     int n, m, t = 0, T = 0;     string s;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> s;       if (s[0] ==  + ) {         a[num(s)]++;         c[i + 1] = {0, num(s)};       } else {         b[num(s)]++;         t++;         c[i + 1] = {1, num(s)};       }     }     for (int i = 1; i <= n; i++) {       if (a[i] + t - b[i] == m) {         p[i] = 1;         P.push_back(i);         T++;       }     }     if (T == 1) {       for (int i = 1; i <= n; i++) {         if (c[i].first == 0) {           if (c[i].second == P[0]) {             cout <<  Truth n ;           } else {             cout <<  Lie n ;           }         } else {           if (c[i].second == P[0]) {             cout <<  Lie n ;           } else {             cout <<  Truth n ;           }         }       }       return 0;     }     for (int i = 1; i <= n; i++) {       if (c[i].first == 0) {         if (p[c[i].second]) {           cout <<  Not defined n ;         } else {           cout <<  Lie n ;         }       } else {         if (p[c[i].second]) {           cout <<  Not defined n ;         } else {           cout <<  Truth n ;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, w, m;   double a[100];   int kol[100];   vector<pair<int, double> > v[100];   int main() {     cin >> n >> w >> m;     double q = n * w * 1.0 / m;     memset(kol, 0, sizeof(kol));     for (int i = 0; i < 100; ++i) a[i] = w;     for (int i = 0; i < m; ++i) {       double p = q;       int z = 0;       for (int j = 0; j < n; ++j) {         if (a[j] > 1e-9) {           double temp = min(p, a[j]);           v[i].push_back(make_pair(j + 1, temp));           p -= temp;           a[j] -= temp;           ++z;           ++kol[j];           if (kol[j] > 2) {             cout <<  NO n ;             return 0;           }           if (p < 1e-9) break;         }       }       if (z == 0 || p > 1e-9) {         cout <<  NO n ;         return 0;       }     }     cout <<  YES n ;     for (int i = 0; i < m; ++i) {       for (int j = 0; j < v[i].size(); ++j) {         if (j) cout <<    ;         cout << v[i][j].first <<     << fixed << setprecision(10)              << v[i][j].second;       }       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct Antenna {     int iniLeft, iniRight;   };   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int nbAntennas, totLen;     cin >> nbAntennas >> totLen;     vector<Antenna> ants(nbAntennas);     for (int iAnt = 0; iAnt < nbAntennas; ++iAnt) {       int center, iniScope;       cin >> center >> iniScope;       ants[iAnt].iniLeft = max(0, center - iniScope);       ants[iAnt].iniRight = min(totLen, center + iniScope);     }     vector<int> minCost(totLen + 1);     minCost[totLen] = 0;     for (int pos = totLen - 1; pos >= 0; --pos) {       minCost[pos] = (totLen - pos);       for (int iAnt = 0; iAnt < nbAntennas; ++iAnt) {         int left = ants[iAnt].iniLeft, right = ants[iAnt].iniRight;         if (left <= pos + 1 && pos + 1 <= right) {           minCost[pos] = minCost[pos + 1];           break;         }         if (pos < left) {           int accessCost = (left - pos - 1);           int nextPos = min(totLen, right + accessCost);           minCost[pos] = min(minCost[pos], accessCost + minCost[nextPos]);         }       }     }     cout << minCost[0] <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     ll n, m, k;     cin >> n >> m >> k;     vector<ll> vec(m);     for (ll &v : vec) cin >> v;     ll ans = 0, i = 0;     while (i < m) {       ll t = (vec[i] - i - 1) / k, j = i + 1;       while (j < m && (vec[j] - i - 1) / k == t) j++;       ans++, i = j;     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int p[2222], n;   int D[2222];   int Find(int x) {     if (D[x] != 0) return D[x];     if (p[x] == -1)       return D[x] = 1;     else       return D[x] = Find(p[x]) + 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &p[i]);     int ans = 0, tmp;     for (int i = 1; i <= n; i++) {       tmp = Find(i);       if (tmp > ans) ans = tmp;     }     printf( %d n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int64_t INF = 4e18, MOD = 998244353;   template <int64_t maxn>   struct NTT {     constexpr static int lg2(int n) { return 32 - __builtin_clz(n - 1); }     const static int MAXN = 1 << lg2(maxn), MOD = 998244353, root = 3;     int rev[MAXN], rt[MAXN];     int mul(int a, int b) { return (long long)a * b % MOD; }     int sub(int a, int b) { return b > a ? a - b + MOD : a - b; }     int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }     int binExp(int base, long long exp) {       if (exp == 0) return 1;       return mul(binExp(mul(base, base), exp / 2), exp & 1 ? base : 1);     }     NTT() {       rt[1] = 1;       for (int k = 1; k < lg2(MAXN); k++) {         int z[] = {1, binExp(root, (MOD - 1) >> (k + 1))};         for (int i = (1 << k); i < 2 << k; i++) rt[i] = mul(rt[i / 2], z[i & 1]);       }     }     void ntt(int *a, int n) {       for (int i = 0; i < n; i++) rev[i] = (rev[i / 2] | (i & 1) << lg2(n)) / 2;       for (int i = 0; i < n; i++)         if (i < rev[i]) swap(a[i], a[rev[i]]);       for (int k = 1; k < n; k *= 2)         for (int i = 0; i < n; i += 2 * k)           for (int j = 0; j < k; j++) {             int z = mul(rt[j + k], a[i + j + k]);             a[i + j + k] = sub(a[i + j], z);             a[i + j] = add(a[i + j], z);           }     }     int in[2][MAXN];     vector<int> multiply(const vector<int> &a, const vector<int> &b) {       if (a.empty() || b.empty()) return {};       int sz = a.size() + b.size() - 1, n = 1 << lg2(sz);       fill(in[0], in[0] + n, 0), fill(in[1], in[1] + n, 0);       copy(a.begin(), a.end(), in[0]), copy(b.begin(), b.end(), in[1]);       ntt(in[0], n), ntt(in[1], n);       int invN = binExp(n, MOD - 2);       for (int i = 0; i < n; i++) in[0][i] = mul(mul(in[0][i], in[1][i]), invN);       reverse(in[0] + 1, in[0] + n);       ntt(in[0], n);       return vector<int>(in[0], in[0] + sz);     }   };   struct DSU {     int64_t n;     vector<int64_t> p, sz, cnt;     vector<bool> good;     vector<vector<int64_t>> g;     DSU(int64_t n) : n(n), p(n, -1), sz(n, 1), cnt(n, 0), good(n, 1), g(n) {}     int64_t find(int64_t c) {       if (p[c] == -1) return c;       return p[c] = find(p[c]);     }     void check(int64_t a) {       good.resize(p.size());       good[a] = (cnt[a] == (sz[a] * (sz[a] - 1)) / 2);     }     void uni(int64_t a, int64_t b) {       a = find(a), b = find(b);       if (a == b) {         cnt[a]++;         check(a);         return;       }       p[a] = p[b] = p.size();       p.push_back(-1);       sz.push_back(sz[a] + sz[b]);       cnt.push_back(cnt[a] + cnt[b] + 1);       g.resize(p.size());       g.back() = {a, b};       check(p.size() - 1);     }   };   void add(int32_t &a, int64_t b) { a = (a + b) % MOD; }   int64_t n, k;   vector<vector<int64_t>> g;   vector<vector<int32_t>> ans;   vector<int64_t> sz;   vector<bool> good;   NTT<2 * 1505> ntt;   void dfs(int64_t cur) {     for (auto nei : g[cur]) {       dfs(nei);     }     if (g[cur].size()) {       int64_t a = g[cur][0], b = g[cur][1];       ans[cur] = ntt.multiply(ans[a], ans[b]);     }     if (good[cur]) add(ans[cur][1], 1);     ans[cur].resize(sz[cur] + 1);   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin >> n;     vector<vector<int64_t>> mat(n, vector<int64_t>(n));     vector<pair<int64_t, pair<int64_t, int64_t>>> edges;     for (int64_t i = 0; i < n; i++) {       for (int64_t j = 0; j < n; j++) {         cin >> mat[i][j];         if (j < i) edges.push_back({mat[i][j], {j, i}});       }     }     sort(edges.begin(), edges.end());     DSU dsu(n);     for (auto e : edges) {       dsu.uni(e.second.first, e.second.second);     }     g = dsu.g, good = dsu.good, sz = dsu.sz;     good.resize(g.size());     int64_t root = dsu.find(0);     k = n, n = g.size();     ans.resize(n, vector<int32_t>(k + 1));     dfs(root);     for (int64_t i = 1; i < k + 1; i++) cout << ans[root][i] <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   #define f(i,q,n) for(int i=(int)q;i<n;i++)   #define pb push_back   #define debug(x) cout<<#x<<   <<x<<endl;   int main()   {       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);       int t=1;       cin>>t;       while(t--){           int n,m;           cin>>n>>m;           string s;           cin>>s;           while(m--){           string ans=s;           f(i,0,n){               if(i==0 and ans[i]== 0  and ans[i+1]== 1 ){s[i]= 1 ;}               else if(i==n-1 and ans[i]== 0  and ans[i-1]== 1 ){s[i]= 1 ;}               else{                   if(i<n-1 and i>0 and ans[i]== 0  and ans[i+1]!=ans[i-1]){                       s[i]= 1 ;                   }               }           }           if(s==ans){               break;           }                 }                  cout<<s<<endl;          }       return 0;   }   //check constraints, testcases, ll vs int


#include <bits/stdc++.h>   using namespace std;   using namespace std;   long long a[200005];   struct poi {     long long val;     int pos;   } tp;   bool operator<(const poi &a, const poi &b) {     return (a.val > b.val) || (a.val == b.val and a.pos > b.pos);   }   priority_queue<poi> q;   int main() {     int n;     int cnt = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %lld , &a[i]);       tp.val = a[i];       tp.pos = i;       q.push(tp);     }     while (!q.empty()) {       poi a1 = q.top();       q.pop();       poi b1 = q.top();       q.pop();       while (!q.empty() && a1.val != b1.val) {         a1 = b1;         b1 = q.top();         q.pop();       }       if (a1.val == b1.val and a1.pos != b1.pos) {         a[b1.pos] = b1.val * 2;         b1.val = b1.val * 2;         a[a1.pos] = -1;         cnt++;         if (q.empty()) break;         q.push(b1);       }     }     printf( %d n , n - cnt);     for (int i = 0; i < n; i++) {       if (a[i] != -1) printf( %lld  , a[i]);     }     printf(  n );   }


#include <bits/stdc++.h>   using namespace std;   string str;   const long long MOD = 1e9 + 7;   template <class T>   inline void amin(T &x, const T &y) {     if (y < x) x = y;   }   template <class T>   inline void amax(T &x, const T &y) {     if (x < y) x = y;   }   int read() {     long long s = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       s = s * 10 + c -  0 ;       c = getchar();     }     return s * f;   }   long long Pow(long long a, long long b) {     if (a == 1 || b == 1) return a;     if (b % 2 == 1) return (a * Pow(a, b - 1)) % MOD;     return (Pow(a, b / 2) * Pow(a, b / 2)) % MOD;   }   long long factorial(long long n) {     long long ans = 1;     while (--n) ans = (ans * (n + 1)) % MOD;     return ans;   }   vector<bool> b(12, 0);   bool binod(int k) {     bool arr[13][13];     memset(arr, 0, sizeof(arr));     int a = 0;     for (int i = 0; i < k; i++)       for (int j = 0; j < 12 / k; j++) {         arr[i][j] = b[a];         a++;       }     a = 0;     bool d;     for (int j = 0; j < 12 / k; j++) {       d = 1;       for (int i = 0; i < k; i++) {         if (!arr[i][j]) d = 0;       }       if (d) return 1;     }     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       for (int i = 0; i < 12; i++) {         char sign;         cin >> sign;         if (sign ==  X )           b[i] = 1;         else           b[i] = 0;       }       vector<int> v;       if (binod(1)) v.push_back(1);       if (binod(2)) v.push_back(2);       if (binod(3)) v.push_back(3);       if (binod(4)) v.push_back(4);       if (binod(6)) v.push_back(6);       if (binod(12)) v.push_back(12);       cout << v.size() <<    ;       for (int i = 0; i < v.size(); i++) {         cout << v[i] <<  x  << 12 / v[i] <<    ;       }       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   string str;   int make(int star, int en) {     if (en - star >= 7) return -1e7;     if (en - star >= 1 && str[star] ==  0 ) return -1e7;     if (str[star] ==  0  && str[en] !=  0 ) return -1e7;     int sum = 0;     for (int i = star; i <= en; i++) {       sum = sum * 10 + (str[i] -  0 );     }     if (sum > 1e6) return -1e7;     return sum;   }   int main() {     int m = -1, i, j, len, a, b, c;     cin >> str;     len = str.length();     for (i = 0; i < len - 2; i++) {       for (j = i + 1; j < len - 1; j++) {         a = make(0, i);         b = make(i + 1, j);         c = make(j + 1, len - 1);         m = max(m, a + b + c);       }     }     if (m < 0)       printf( -1 );     else       printf( %d , m);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   static const double EPS = 1e-9;   static const double PI = acos(-1.0);   char ans[4][110];   int main() {     int n;     while (scanf( %d , &n) > 0) {       if (n == 1) {         printf( a na nb nb n );         continue;       }       ans[0][0] =  a ;       ans[1][0] =  a ;       ans[2][0] =  b ;       ans[3][0] =  c ;       int ud = 2;       char p =  b ;       for (int i = 1; i < n; i++) {         ans[ud][i] = p;         ans[ud + 1][i] = p + 1;         p += 2;         if (p >=  x ) {           p =  a ;         }         ud ^= 2;         if (i == n - 1) {           ans[ud][i] = p;           ans[ud + 1][i] = p;         } else {           ans[ud][i] = p;           ans[ud + 1][i] = p + 1;         }       }       for (int y = 0; y < (int)(4); y++) {         for (int x = 0; x < (int)(n); x++) {           putchar(ans[y][x]);         }         puts(  );       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, a;     vector<pair<int, int> > v;     cin >> n;     for (i = 0; i < n; ++i) {       cin >> a;       v.push_back(make_pair(a, i + 1));     }     for (i = 0; i < n; ++i) {       cin >> a;       v.push_back(make_pair(a, i + 1));     }     long long m;     cin >> m;     m *= 2;     sort(v.begin(), v.end());     long long r = 1;     int c = 0, c1 = 0;     for (i = 1; i < n + n; ++i) {       if (v[i].first == v[i - 1].first) {         ++c;         if (v[i].second == v[i - 1].second) {           ++c1;         } else           c1 = 0;       } else {         c1 = c = 0;       }       r = (r * (c + 1) / (c1 + 1)) % m;       c1 = 0;     }     cout << r % (m / 2);     return 0;   }   int cpp4cf_main() {     freopen( B.cpp ,  r , stdin);     char s[99];     bool f;     while (true) {       cin >> s;       if (cin.eof()) break;       if (strstr(s,  /* )) {         cin >> s;         if (strstr(s,  Test )) {           cin >> s;           if (strstr(s,  on )) {             cout <<  Output:  ;             cpp4cf_main();             cout <<   nAnswer:  ;             f = false;             while (true) {               cin >> s;               if (strstr(s,  */ )) break;               if (strstr(s,  // )) {                 if (f)                   cout << endl;                 else                   f = true;               } else                 cout << s <<    ;             }             cout <<   n n ;           }         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long a[n];     for (long long i = 0; i < n; i++) cin >> a[i];     map<long long, long long> mp;     long long ans = 0;     long long prev = 0;     long long sum = 0;     for (long long i = 0; i < n; i++) {       sum += a[i];       if (sum == 0)         prev = max(prev, mp[0] + 1);       else if (mp.find(sum) != mp.end())         prev = max(prev, mp[sum] + 1);       ans += i + 1 - prev;       mp[sum] = i + 1;     }     cout << ans <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const bool debug = 0;   struct mout {     int i, j;     long long first;     mout(){};     mout(int i, int j, long long first) : i(i), j(j), first(first) {}   };   int main() {     if (!debug) {       cin.tie(0);       cout.tie(0);       ios::sync_with_stdio(0);     }     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<long long> a(n);       vector<mout> out;       for (int i = 0; i < n; i++) cin >> a[i];       long long s = 0;       for (int i = 0; i < n; i++) s += a[i];       if (s != (s / n) * n) {         cout <<  -1 n ;         continue;       }       s /= n;       for (int i = 1; i < n; i++) {         if (a[i] % (i + 1) != 0) {           out.push_back({1, i + 1, i + 1 - a[i] % (i + 1)});           a[1] -= i + 1 - a[i] % (i + 1);           a[i] += i + 1 - a[i] % (i + 1);         }         out.push_back({i + 1, 1, a[i] / (i + 1)});         a[1] += a[i];         a[i] = 0;       }       for (int i = 1; i < n; i++) {         out.push_back({1, i + 1, s});       }       cout << out.size() <<   n ;       for (int i = 0; i < out.size(); i++)         cout << out[i].i <<     << out[i].j <<     << out[i].first <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e14;   const long long TE3 = 1005;   const long long TE5 = 300005;   const string YN[2] = { NO ,  YES };   using namespace std;   long long f(long long n, vector<long long>& q1, vector<long long>& q2) {     unordered_map<long long, long long> e;     long long c = 0;     e[0] = -1;     long long i = 0, j = 0;     long long ans = 0;     while (i < q1.size() || j < q2.size()) {       long long g;       long long q1t = (i >= q1.size()) ? INF : q1[i];       long long q2t = (j >= q2.size()) ? INF : q2[j];       if (q1t < q2t) {         g = q1t;         ++c;         ++i;       } else {         g = q2t;         --c;         ++j;       }       if (e.find(c) == e.end()) {         e[c] = g;       } else {         q2t = (j >= q2.size()) ? INF : q2[j];         q1t = (i >= q1.size()) ? INF : q1[i];         long long tmp = min(q1t, q2t);         long long cur = (tmp == INF ? n : tmp) - e[c] - 1;         ans = max(ans, cur);       }     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     long long n;     cin >> n;     long long x;     unordered_map<long long, vector<long long> > mpq;     for (long long i = (0); i < (n); ++i) {       cin >> x;       mpq[x].push_back(i);     }     if (mpq.size() == 1) {       cout << 0 << endl;       return 0;     }     unordered_map<long long, long long> rev;     long long ma = -INF, mo = 0;     for (auto it : mpq) {       rev[it.second.size()]++;       if (it.second.size() > mo) {         ma = it.first;         mo = it.second.size();       }     }     if (rev[mo] >= 2) {       cout << n << endl;       return 0;     }     long long ans = 0;     for (auto it : mpq) {       if (it.first == ma) continue;       ans = max(ans, f(n, mpq[ma], it.second));     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long oo = 1e18;   struct dta {     int u, id;     dta(int _u = 0, int _id = 0) {       u = _u;       id = _id;     }   };   struct TDij {     long long val;     int x;     TDij(long long _val = 0, int _x = 0) {       x = _x;       val = _val;     }   };   inline bool operator<(const TDij &a, const TDij &b) { return (a.val > b.val); }   int n, m, k, cost[300010], trace[300010], delneed;   bool flag[300010];   long long F[300010];   vector<dta> A[300010];   priority_queue<TDij> Q;   void dijks() {     memset(flag, true, sizeof(flag));     memset(trace, 0, sizeof(trace));     for (int i = 2; i <= n; ++i) F[i] = oo;     F[1] = 0;     Q.push(TDij(0, 1));     while (!Q.empty()) {       TDij topx = Q.top();       Q.pop();       if (topx.val != F[topx.x]) continue;       int u = topx.x;       for (int i = 0; i <= A[u].size() - 1; ++i) {         if (F[A[u][i].u] > F[u] + cost[A[u][i].id]) {           F[A[u][i].u] = F[u] + cost[A[u][i].id];           flag[trace[A[u][i].u]] = true;           trace[A[u][i].u] = A[u][i].id;           flag[A[u][i].id] = false;           Q.push(TDij(F[A[u][i].u], A[u][i].u));         }       }     }   }   void dfs(int x, int par, int pared) {     for (int i = 0; i <= A[x].size() - 1; ++i)       if (A[x][i].u != par && !flag[A[x][i].id]) {         dfs(A[x][i].u, x, A[x][i].id);         if (delneed == 0) return;       }     if (delneed > 0) {       (--delneed);       flag[pared] = true;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (int i = 1; i <= m; ++i) {       int u, v;       cin >> u >> v >> cost[i];       A[u].push_back(dta(v, i));       A[v].push_back(dta(u, i));     }     dijks();     delneed = m - k;     if (!delneed) {       for (int i = 1; i <= m; ++i) delneed += (!flag[i]);       cout << delneed <<   n ;       for (int i = 1; i <= m; ++i)         if (!flag[i]) cout << i <<    ;       return 0;     }     for (int i = 1; i <= m; ++i)       if (flag[i]) {         if ((--delneed) == 0) {           cout << k <<   n ;           for (int j = 1; j <= i; ++j)             if (!flag[j]) cout << j <<    ;           for (int j = i + 1; j <= m; ++j) cout << j <<    ;           return 0;         }       }     dfs(1, 0, 0);     cout << k <<   n ;     for (int i = 1; i <= m; ++i)       if (!flag[i]) cout << i <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   vector<string> solve(int k) {     vector<string> s;     if (k == 0) {       s.push_back( + );       return s;     }     vector<string> prev = solve(k - 1), rev;     for (int i = 0; i < prev.size(); i++) {       string temp;       for (int j = 0; j < prev.size(); j++) {         if (prev[i][j] ==  + )           temp +=  * ;         else           temp +=  + ;       }       rev.push_back(temp);     }     for (int i = 0; i < prev.size(); i++) {       s.push_back(prev[i] + prev[i]);       s.push_back(prev[i] + rev[i]);     }     return s;   }   int main() {     int k;     cin >> k;     vector<string> s;     s = solve(k);     for (int i = 0; i < s.size(); i++) {       cout << s[i] << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   inline int read() {     int s = 0;     char c;     while ((c = getchar()) <  0  || c >  9 )       ;     do {       s = s * 10 + c -  0 ;     } while ((c = getchar()) >=  0  && c <=  9 );     return s;   }   const int N = 3010, M = 310;   int n, m, rp[M];   double f[M][2][N], tp[N][M];   priority_queue<pair<double, int> > h;   double nxdp(int i) {     int p = (++rp[i]) & 1;     if (rp[i] > n) return -1e9;     f[i][p][0] = 0;     for (int k = 1; k <= n; k++)       f[i][p][k] =           tp[k][i] * f[i][p ^ 1][k - 1] + (1 - tp[k][i]) * f[i][p][k - 1];     return f[i][p][n];   }   double work() {     int i, k;     double ans = 0;     for (i = 1; i <= m; i++)       for (k = 0; k <= n; k++) f[i][0][k] = 1;     for (i = 1; i <= m; i++) h.push(make_pair(nxdp(i), i));     for (i = 1; i <= n; i++) {       pair<double, int> t = h.top();       h.pop();       ans += t.first;       h.push(make_pair(nxdp(t.second), t.second));     }     return ans;   }   int main() {     int i, j;     n = read(), m = read();     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) tp[i][j] = read() * 0.001;     printf( %.11lf n , work());     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int siz = 1e5 + 10;   const long long modu = 1e9 + 7;   int pre[13] = {1, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341};   int main() {     int n;     scanf( %d , &n);     if (n < 13) {       cout << pre[n] << endl;       return 0;     }     long long n1 = n;     long long ans = pre[12];     ans += (n1 - 12ll) * 49ll;     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int main() {     int n, num, flag = 1, f;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &num);       ++mp[num];     }     map<int, int>::iterator it = mp.begin();     int ln = it->first;     int lm = it->second;     int l = ln, r = ln;     ++it;     for (; it != mp.end(); ++it) {       if (it->first > r + 1) {         flag = 0;         break;       } else {         if (lm == it->second) {           lm = 1;           r = it->first;         } else if (lm > it->second) {           lm -= it->second;           if (lm > 1) {             flag = 0;             break;           }         } else if (lm < it->second) {           if (l + 1 != it->first) {             lm = it->second - lm + 1;             r = it->first;             continue;           }           l = it->first;           r = it->first;           lm = it->second - lm;         }       }     }     if (l + 1 != r) flag = 0;     if (flag && lm < 2) {       printf( YES );     } else       printf( NO );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int ct[2][6] = {0};     for (int i = 0; i < n; i++) {       int tmp;       scanf( %d , &tmp);       ct[0][tmp]++;     }     for (int i = 0; i < n; i++) {       int tmp;       scanf( %d , &tmp);       ct[1][tmp]++;     }     int diff = 0;     int flag = 0;     for (int i = 1; i <= 5; i++) {       if (ct[0][i] != ct[1][i]) {         int tmp = abs(ct[0][i] - ct[1][i]);         if (tmp % 2 != 0) flag = 1;         diff += tmp / 2;       }     }     if (flag == 0)       cout << diff / 2;     else       cout << -1;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long j, k, s, l, m, n, t, d;   long long e[111][33333], a, b, i, p, c;   map<string, long long> y;   string q, r, w;   int main() {     cin >> n >> a >> b >> c;     n *= 2;     for (i = 0; i <= a; i++) {       for (j = 0; j <= b; j++) {         k = n - i - 2 * j;         if (k % 4 == 0 && k / 4 <= c && k >= 0) s++;       }     }     cout << s;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t, k, d, t1, t2, kol;     bool f;     f = false;     cin >> n;     cin >> t;     cin >> k;     cin >> d;     t1 = 0;     t2 = 0;     kol = 0;     while (kol < n) {       t1++;       if (t1 % t == 0) {         kol = kol + k;       }     }     kol = 0;     while (kol < n) {       t2++;       if (f == true) {         if ((t2 - d) % t == 0) {           kol = kol + k;         }       }       if (t2 % t == 0) {         kol = kol + k;       }       if (t2 % d == 0) {         f = true;       }     }     if (t1 > t2) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int y, w;     cin >> y >> w;     int ans;     ans;     if (y >= w) {       ans = 6 - y + 1;     } else if (w >= y) {       ans = 6 - w + 1;     }     if (ans == 6) {       cout << 1 <<  /  << 1 << endl;     }     if (ans == 1) {       cout << 1 <<  /  << 6 << endl;     }     if (ans == 2) {       cout << 1 <<  /  << 3 << endl;     }     if (ans == 3) {       cout << 1 <<  /  << 2 << endl;     }     if (ans == 4) {       cout << 2 <<  /  << 3 << endl;     }     if (ans == 5) {       cout << 5 <<  /  << 6 << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m, a[111], ans = 1e9;   set<int> s[111];   int main() {     ios_base ::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     for (int i = 0, x, y; i < m; ++i) {       cin >> x >> y;       s[x].insert(y);       s[y].insert(x);     }     for (int i = 1; i < n - 1; ++i) {       for (int j = i + 1; j < n; ++j) {         if (s[i].count(j)) {           for (int k = j + 1; k <= n; ++k) {             if (s[i].count(k) && s[j].count(k)) {               ans = min(a[i] + a[j] + a[k], ans);             }           }         }       }     }     if (ans == 1e9) {       cout << -1;     } else {       cout << ans;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int temp = 0;     int n = 0;     cin >> n;     vector<int> city(n);     for (int i = 0; i < n; ++i) {       cin >> city[i];     }     int max = 0;     int min = 0;     for (int j = 0; j < n; ++j) {       if (j == n - 1) {         min = abs(city[j] - city[j - 1]);         max = abs(city[j] - city[0]);       } else if (j == 0) {         min = abs(city[0] - city[1]);         max = abs(city[0] - city[n - 1]);       } else {         if (abs(city[j] - city[j + 1]) < abs(city[j] - city[j - 1]))           min = abs(city[j] - city[j + 1]);         else if (abs(city[j] - city[j + 1]) >= abs(city[j] - city[j - 1]))           min = abs(city[j] - city[j - 1]);         if (abs(city[j] - city[0]) < abs(city[j] - city[n - 1]))           max = abs(city[j] - city[n - 1]);         else if (abs(city[j] - city[0]) >= abs(city[j] - city[n - 1]))           max = abs(city[j] - city[0]);       }       cout << min <<     << max << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     return (b == 0) ? a : gcd(b, a % b);   }   template <typename T>   T lcm(T a, T b) {     return a * (b / gcd(a, b));   }   template <typename T>   T mod_exp(T b, T p, T m) {     T x = 1;     while (p) {       if (p & 1) x = (x * b) % m;       b = (b * b) % m;       p = p >> 1;     }     return x;   }   template <typename T>   T invFermat(T a, T p) {     return mod_exp(a, p - 2, p);   }   template <typename T>   T exp(T b, T p) {     T x = 1;     while (p) {       if (p & 1) x = (x * b);       b = (b * b);       p = p >> 1;     }     return x;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int a, b;     cin >> a >> b;     if (a == 0 && b == 0) {       cout <<  NO  <<   n ;     } else if (abs(a - b) <= 1)       cout <<  YES  <<   n ;     else       cout <<  NO  <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int A[105][105];   int main() {     int n;     int ans = 0;     cin >> n;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < n; j++) {         if (s[j] ==  C ) {           A[i][j] = 1;         } else {           A[i][j] = 0;         }       }     }     for (int i = 0; i < n; i++) {       int cnt = 0;       for (int j = 0; j < n; j++) {         if (A[i][j] == 1) {           cnt++;         }       }       ans += (cnt * (cnt - 1)) / 2;     }     for (int i = 0; i < n; i++) {       int cnt = 0;       for (int j = 0; j < n; j++) {         if (A[j][i] == 1) {           cnt++;         }       }       ans += (cnt * (cnt - 1)) / 2;     }     cout << ans;   }


#include <bits/stdc++.h>   using namespace std;   char name[110][3000], text[110][3000];   int name_len[110], text_len[110];   bool found[110][110], dp[110][110];   int pre[110][110];   int chosen[110];   void variable_init() {     memset(found, 0, sizeof found);     memset(dp, 0, sizeof dp);   }   int main() {     int tcase, n, m;     scanf( %d , &tcase);     while (tcase--) {       variable_init();       scanf( %d , &n);       for (int i = 1; i <= n; i++) {         scanf( %s , name[i]);         name_len[i] = strlen(name[i]);       }       scanf( %d , &m);       gets(text[0]);       for (int i = 1; i <= m; i++) {         gets(text[i]);         text_len[i] = strlen(text[i]);         if (text[i][0] !=  ? ) {           for (int k = 1; k <= n; k++) {             bool ok = true;             if (text_len[i] < name_len[k]) ok = false;             for (int l = 0; l < name_len[k] && ok; l++) {               if (text[i][l] != name[k][l]) ok = false;             }             ok &=                 (name_len[k] == text_len[i] || (!isalpha(text[i][name_len[k]]) &&                                                 !isdigit(text[i][name_len[k]])));             if (ok) {               bool found_others = false;               int pre_choose;               if (i == 1) {                 found_others = true;                 pre_choose = -1;               }               for (int j = 1; j <= n; j++)                 if (j != k && dp[i - 1][j]) {                   found_others = true;                   pre_choose = j;                   break;                 }               dp[i][k] = found_others;               pre[i][k] = pre_choose;               break;             }           }           continue;         }         for (int j = 0; j < text_len[i]; j++) {           if (!isalpha(text[i][j]) && !isdigit(text[i][j])) {             for (int k = 1; k <= n; k++) {               bool ok = true;               if (text_len[i] - 1 - j < name_len[k]) ok = false;               for (int l = j + 1; l <= j + name_len[k] && ok; l++) {                 if (text[i][l] != name[k][l - (j + 1)]) ok = false;               }               ok &= (j + name_len[k] + 1 == text_len[i] ||                      (!isalpha(text[i][j + name_len[k] + 1]) &&                       !isdigit(text[i][j + name_len[k] + 1])));               if (ok) found[i][k] = true;             }           }         }         for (int j = 1; j <= n; j++) {           for (int k = 1; k <= n; k++) {             if (i == 1) {               if (!found[i][k]) {                 dp[i][k] = true;                 pre[i][k] = -1;               }             } else {               if (j != k && dp[i - 1][j] && !found[i][k]) {                 dp[i][k] = true;                 pre[i][k] = j;               }             }           }         }       }       bool least_one = false;       int last;       for (int i = 1; i <= n; i++) {         if (dp[m][i]) {           least_one = true;           last = i;         }       }       if (!least_one)         puts( Impossible );       else {         for (int i = m; i >= 1; i--) {           chosen[i] = last;           last = pre[i][last];         }         for (int i = 1; i <= m; i++) {           if (text[i][0] ==  ? ) {             printf( %s , name[chosen[i]]);             int pos;             for (int j = 1; j < text_len[i]; j++)               if (text[i][j] ==  : ) {                 pos = j;                 break;               }             puts(text[i] + pos);           } else {             puts(text[i]);           }         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void readi(int &x) {     int v = 0, f = 1;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = v * 10 + c -  0 ;     while (isdigit(c = getchar())) v = v * 10 + c -  0 ;     x = v * f;   }   void readll(long long &x) {     long long v = 0ll, f = 1ll;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = v * 10 + c -  0 ;     while (isdigit(c = getchar())) v = v * 10 + c -  0 ;     x = v * f;   }   void readc(char &x) {     char c;     while ((c = getchar()) ==    )       ;     x = c;   }   void writes(string s) { puts(s.c_str()); }   void writeln() { writes(  ); }   void writei(int x) {     if (!x) putchar( 0 );     char a[25];     int top = 0;     while (x) {       a[++top] = (x % 10) +  0 ;       x /= 10;     }     while (top) {       putchar(a[top]);       top--;     }   }   void writell(long long x) {     if (!x) putchar( 0 );     char a[25];     int top = 0;     while (x) {       a[++top] = (x % 10) +  0 ;       x /= 10;     }     while (top) {       putchar(a[top]);       top--;     }   }   inline long long inc(int &x) { return ++x; }   inline long long inc(long long &x) { return ++x; }   inline long long inc(int &x, long long y) { return x += y; }   inline long long inc(long long &x, long long y) { return x += y; }   inline double inc(double &x, double y) { return x += y; }   inline long long dec(int &x) { return --x; }   inline long long dec(long long &x) { return --x; }   inline long long dec(int &x, long long y) { return x -= y; }   inline long long dec(long long &x, long long y) { return x -= y; }   inline double dec(double &x, double y) { return x -= y; }   inline long long mul(int &x) { return x = ((long long)x) * x; }   inline long long mul(long long &x) { return x = x * x; }   inline long long mul(int &x, long long y) { return x *= y; }   inline long long mul(long long &x, long long y) { return x *= y; }   inline double mul(double &x, double y) { return x *= y; }   inline long long divi(int &x) { return x = sqrt(x); }   inline long long divi(long long &x) { return x = sqrt(x); }   inline long long divi(int &x, long long y) { return x /= y; }   inline long long divi(long long &x, long long y) { return x /= y; }   inline double divi(double &x, double y) { return x /= y; }   inline long long mod(int &x, long long y) { return x %= y; }   inline long long mod(long long &x, long long y) { return x %= y; }   long long n, m, i, j, cnt, cas;   long long ans;   vector<long long> all;   struct Scanning_line {     long long l, r, h, ad;   } s[200005];   struct seg {     long long l, r, add;     long long sum;   } tr[800005];   void build(long long x, long long l, long long r) {     if (l == r) {       tr[x].l = l;       tr[x].r = r;       tr[x].add = tr[x].sum = 0;       return;     }     tr[x].l = l;     tr[x].r = r;     tr[x].add = tr[x].sum = 0;     build(x * 2, l, (l + r) / 2);     build(x * 2 + 1, (l + r) / 2 + 1, r);   }   void pushup(long long x) {     if (tr[x].add)       tr[x].sum = all[tr[x].r] - all[tr[x].l - 1];     else if (tr[x].l == tr[x].r)       tr[x].sum = 0;     else       tr[x].sum = tr[x * 2].sum + tr[x * 2 + 1].sum;   }   void update(long long x, long long l, long long r, long long c) {     if (tr[x].l > r || tr[x].r < l) return;     if (l <= tr[x].l && tr[x].r <= r) {       tr[x].add += c;       pushup(x);       return;     }     update(x * 2, l, r, c);     update(x * 2 + 1, l, r, c);     pushup(x);   }   bool cmp(Scanning_line x, Scanning_line y) { return x.h < y.h; }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     cnt = 0;     for (i = 1; i <= n; i++) {       long long w, x, y, z;       cin >> w >> x >> y >> z;       if (w > y) swap(w, y);       if (x > z) swap(x, z);       w--;       x--;       all.push_back(w);       all.push_back(y);       s[++cnt] = {w, y, x, 1};       s[++cnt] = {w, y, z, -1};     }     stable_sort(all.begin(), all.end());     stable_sort(s + 1, s + cnt + 1, cmp);     all.resize(unique(all.begin(), all.end()) - all.begin());     ans = 0;     build(1, 0, all.size());     for (i = 1; i <= cnt; i++) {       if (i != 1 && s[i].h != s[i - 1].h) {         ans += abs(s[i].h - s[i - 1].h) * tr[1].sum;       }       long long l = upper_bound(all.begin(), all.end(), s[i].l) - all.begin();       long long r = upper_bound(all.begin(), all.end(), s[i].r) - all.begin();       update(1, l, r - 1, s[i].ad);     }     cout << ans << endl;     return 0;   }


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


#include <bits/stdc++.h>   using namespace std;   int n, d;   string s, t;   map<pair<char, char>, vector<int> > M;   map<char, vector<int> > N;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> s >> t;     d = 0;     for (int i = 0; i < n; ++i) {       if (s[i] != t[i]) {         M[make_pair(s[i], t[i])].push_back(i + 1);         N[s[i]].push_back(i + 1);         ++d;       }     }     for (int i = 0; i < n; ++i) {       if (s[i] != t[i]) {         map<pair<char, char>, vector<int> >::iterator it =             M.find(make_pair(t[i], s[i]));         if (it != M.end()) {           cout << d - 2 << endl;           cout << i + 1 <<     << it->second.back() << endl;           return 0;         }       }     }     for (int i = 0; i < n; ++i) {       if (s[i] != t[i]) {         if (N.find(t[i]) != N.end()) {           cout << d - 1 << endl;           cout << i + 1 <<     << N[t[i]].back() << endl;           return 0;         }       }     }     cout << d << endl;     cout <<  -1 -1  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   set<int> s;   int ans[300005];   int main() {     int n, m, l, r, x;     cin >> n >> m;     for (int i = 1; i < n + 1; i++) {       s.insert(i);       ans[i] = 0;     }     for (int i = 0; i < m; i++) {       cin >> l >> r >> x;       set<int>::iterator lb = s.lower_bound(l), ub = s.upper_bound(r);       for (set<int>::iterator it = lb; it != ub; it++)         if (*it != x) ans[*it] = x;       s.erase(lb, ub);       s.insert(x);     }     for (int i = 1; i < n + 1; i++) cout << ans[i] <<    ;     cout <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 5;   char s[N];   int n, f[N], mk[N], cnt[N];   vector<int> p;   void init() {     for (int i = 2; i < N; i++)       if (!mk[i]) {         p.push_back(i);         for (int j = i + i; j < N; j += i) mk[j] = true;       }   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     init();     memset(mk, 0, sizeof(mk));     for (int i = 0; i < p.size(); i++) {       if (p[i] * 2 > n) break;       for (int j = 1; j * p[i] <= n; j++) mk[p[i] * j] = true;     }     int tot = 0, mx = 0, pos;     for (int i = 1; i <= n; i++) {       cnt[s[i] -  a ]++;       if (mk[i]) tot++;     }     for (int i = 0; i < 26; i++)       if (mx < cnt[i]) mx = cnt[i], pos = i;     if (mx < tot) {       cout <<  NO  <<   n ;       return 0;     }     puts( YES );     for (int i = 1; i <= n; i++) {       if (mk[i])         printf( %c ,  a  + pos), cnt[pos]--, tot--;       else         for (int j = 0; j < 26; j++)           if (j == pos && cnt[j] > tot || (j != pos && cnt[j])) {             printf( %c ,  a  + j);             cnt[j]--;             break;           }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   vector<vector<long long int> > edge(100010);   long long int vis[100010];   vector<long long int> color[2];   bool dfs(long long int a, long long int c = 2) {     vis[a] = c;     color[c - 1].push_back(a);     for (auto x : edge[a]) {       if (!vis[x] && dfs(x, 3ll - c)) {         return 1;       }       if (vis[x] != 3ll - c) {         return 1;       }     }     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, m, x, y;     cin >> n >> m;     for (long long int i = 1; i <= m; i++) {       cin >> x >> y;       edge[x].push_back(y);       edge[y].push_back(x);     }     for (long long int i = 1; i <= n; i++) {       if (!vis[i]) {         if (edge[i].size() == 0) {           continue;         }         if (dfs(i)) {           cout << -1 << endl;           return 0;         }       }     }     for (long long int i = 0; i < 2; i++) {       cout << color[i].size() << endl;       for (auto x : color[i]) {         cout << x <<    ;       }       cout << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int p[110];   int find(int v) {     if (p[v] == v) return v;     return p[v] = find(p[v]);   }   bool merge(int u, int v) {     int x = find(u);     int y = find(v);     if (x != y) {       p[x] = y;       return true;     }     return false;   }   int main() {     int n, m;     cin >> n >> m;     vector<pair<int, int> > edges;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       edges.push_back({a, b});       p[a] = a;       p[b] = b;     }     int flag = 0, count = 1;     for (pair<int, int> e : edges) {       int a = e.first, b = e.second;       if (!merge(a, b)) {         flag++;         if (flag > 1) break;       } else         count++;     }     if (flag == 1 && count == n)       cout <<  FHTAGN!             <<   n ;     else       cout <<  NO             <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   char local =  O ;   template <typename T>   void read(T &p) {     cin >> p;   }   template <typename T, typename T1>   void read(pair<T, T1> &p) {     read(p.first);     read(p.second);   }   template <typename T>   void read(T arr[], long long n) {     for (long long i = 0; i < n; i++) {       read(arr[i]);     }   }   template <typename T>   void read(vector<T> &arr) {     for (long long i = 0; i < arr.size(); i++) {       read(arr[i]);     }   }   template <typename T>   void out(T &n) {     cout << n;   }   template <typename T, typename T1>   void out(pair<T, T1> &p) {     cout <<  ( ;     out(p.first);     cout <<  , ;     out(p.second);     cout <<  ) ;   }   template <typename T>   void out(T arr[], long long n) {     for (long long i = 0; i < n; i++) {       out(arr[i]);       cout <<    ;     }   }   template <typename T>   void out(vector<T> &arr) {     for (long long i = 0; i < arr.size(); i++) {       out(arr[i]);       cout <<    ;     }   }   template <typename T>   void out(set<T> &arr) {     for (auto i : arr) {       out(i);       cout <<    ;     }   }   template <typename T>   void out(multiset<T> &arr) {     for (auto i : arr) {       out(i);       cout <<    ;     }   }   template <typename T, typename T1>   void out(map<T, T1> &m) {     for (auto i : m) {       out(i.first);       cout <<   ->  ;       out(i.second);       cout <<  ,  ;     }   }   template <typename Arg1>   void __f(const char *name, Arg1 &&arg1) {     cout << name <<   :  ;     out(arg1);   }   template <typename Arg1, typename... Args>   void __f(const char *names, Arg1 &&arg1, Args &&...args) {     const char *comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :  ;     out(arg1);     cout <<   |  ;     __f(comma + 1, args...);   }   template <class T>   void debug(T n, string a) {     cout << a <<  =  << n <<   n ;   }   void cal() {}   void solve() {     int n, h;     cin >> n >> h;     for (int i = 1; i < n; i++) {       cout << fixed << setprecision(15) << (sqrt(i / (n * 1.0)) * h) <<    ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t1;     t1 = 1;     cal();     while (t1--) {       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   bool match(string s1, string s2) {     long long cnt = 0;     for (long long i = 0; s1[i]; ++i) {       if (s1[i] != s2[i]) ++cnt;       if (cnt > 1) return 0;     }     return 1;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       vector<string> v(n);       for (long long i = 0; i < n; ++i) cin >> v[i];       bool ans = 0;       string str;       for (long long i = 0; i < m; ++i) {         string s = v[0];         for (long long j = 1; j < n; ++j) {           s[i] = v[j][i];           bool all_match = 1;           for (long long k = 1; k < n; ++k) {             if (!match(s, v[k])) {               all_match = 0;               break;             }           }           if (all_match) {             ans = 1;             str = s;             break;           }         }         if (ans) break;       }       if (ans)         cout << str <<   n ;       else {         bool all_match = 1;         for (long long i = 1; i < n; ++i) {           if (!match(v[0], v[i])) {             all_match = 0;             break;           }         }         if (all_match)           cout << v[0] <<   n ;         else           cout << -1 <<   n ;       }     }   }


#include <bits/stdc++.h>   using namespace std;   long long min(long long a, long long b) {     if (a < b)       return a;     else       return b;   }   static long long gcd(long long a, long long b) {     long long r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   long long lcm(long long a, long long b) {     long long temp = gcd(a, b);     return temp ? (a / temp * b) : 0;   }   unsigned long long PowMod(unsigned long long x, unsigned long long e,                             unsigned long long mod) {     unsigned long long res;     if (e == 0) {       res = 1;     } else if (e == 1) {       res = x;     } else {       res = PowMod(x, e / 2, mod);       res = res * res % mod;       if (e % 2) res = res * x % mod;     }     return res;   }   int solve() {     int n, m;     cin >> n >> m;     long long a[n], b[m];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int j = 0; j < m; j++) {       cin >> b[j];     }     vector<pair<long long, int> > v;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         v.push_back(make_pair(a[i] * b[j], i));       }     }     sort((v).begin(), (v).end());     int I = v[(n * m) - 1].second;     long long ans = (1000000000LL) * (1000000000LL) * (-1LL);     ans--;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (i != I) {           ans = max(ans, a[i] * b[j]);         }       }     }     cout << ans;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int static_init = []() {     ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;     return 0;   }();   constexpr int N = 3e5;   int32_t n, x[2], c[N + 1], p[N + 1];   int64_t t[N + 2];   bool run(bool sw) {     for (int k1 = 1; k1 <= n; k1++) {       int i1 =           lower_bound(p + 1, p + n + 2 - k1, x[sw],                       [k1](int i, int x) { return (int64_t)c[i] * k1 < x; }) -           p;       int j = i1 + k1;       if (j <= n && t[j] >= x[!sw]) {         int i2;         for (i2 = n; i2 >= j; i2--) {           if (t[i2] == t[j]) break;         }         int k2 = n - i2 + 1;         if (sw) swap(k1, k2), swap(i1, i2);         cout <<  Yes n  << k1 <<     << k2 << endl;         for (int i = i1; i < i1 + k1; i++)           cout << p[i] << (i == i1 + k1 - 1 ?   n  :    );         for (int i = i2; i < i2 + k2; i++)           cout << p[i] << (i == i2 + k2 - 1 ?   n  :    );         return true;       }     }     return false;   }   int main() {     cin >> n >> x[0] >> x[1];     for (int i = 1; i <= n; i++) cin >> c[i];     iota(p + 1, p + n + 1, 1);     sort(p + 1, p + n + 1, [](int i, int j) { return c[i] < c[j]; });     for (int i = n; i >= 1; i--) {       t[i] = max(t[i + 1], (int64_t)c[p[i]] * (n - i + 1));     }     if (!run(false) && !run(true)) cout <<  No  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9 + 7;   const int N = 1e3 + 10;   const int M = 1e4;   int a[N][N];   int main() {     int n, k, d;     cin >> n >> k >> d;     int flag = 1;     memset((a), (0), sizeof(a));     if (n == 1) {       while (d--) cout << 1 << endl;       return 0;     }     for (int i = 1; i <= d; i++) a[1][i] = 1;     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= d; j++) a[i][j] = a[i - 1][j];       a[i][d]++;       for (int j = d; j > 0; j--) {         if (a[i][j] > k)           a[i][j] = 1, a[i][j - 1]++;         else           break;       }       if (a[i][0] == 1) {         flag = 0;         break;       }     }     if (!flag) {       cout << -1 << endl;       return 0;     }     for (int j = 1; j <= d; j++) {       for (int i = 1; i <= n; i++) {         if (i > 1) cout <<    ;         cout << a[i][j];       }       cout <<   n ;     }     return 0;   }